Skip to main content

COMPLAX Python package PyPI License: MIT PyPI Downloads

COMPLAX is an automated Python workflow designed to position solvent molecules (provided as .xyz files) around a user-specified atom of another molecule, also supplied in .xyz format.
It was primarily developed for the microsolvation of small organic molecules, but it can also be applied to other molecular systems, serving as a robust starting point for high-level quantum mechanical modeling (e.g., DFT).

Following an unbiased stochastic solvent placement, the program performs two-stage geometry optimization using the semiempirical xTB methods. [1]

A constrained pre-relaxation prevents unphysical solvent detachment, which is then automatically followed by a full structural equilibration.

Optionally, the user can perform a stochastic sampling to explore the conformational space and request an on-the-fly evaluation of the solvation effect in terms of potential energy differences.

Installation

Install via PyPI

You can install COMPLAX directly from PyPI using pip:

pip install complax

Installation from GitHub:

Manually clone the repository and install it via pip:

git clone [https://github.com/Fedelau/complax.git](https://github.com/Fedelau/complax.git)
cd complax
pip install .

Requirements

  • Python 3.8 or higher
  • External dependencies (automatically installed via pip):
    • numpy
    • ase
    • colorama
    • tqdm
    • tabulate

Tested with Python 3.11.2

External Software

COMPLAX interfaces with the external program xTB, which must be installed and accessible from your system’s PATH. See https://github.com/grimme-lab/xtb for installation instructions. Since this version of COMPLAX utilizes the recent g-xTB semi-empirical electronic structure method, to run a calculation with this level of theory, the modified xTB binaries are required, available at this link https://github.com/grimme-lab/g-xtb. [2]

xTB is developed by the Grimme group and distributed under the Creative Commons Attribution-ShareAlike 4.0 International License (CC BY-SA 4.0).

Quick Start

Example input files are provided in the examples/ folder. (If you installed complax via pip, you can access these files by cloning the repository or downloading them directly from the GitHub examples directory).

This example shows how to position 3 tetrahydrofuran molecules (thf.xyz) around a lithium atom in methyllithium (meli.xyz).

  1. First, identify the indices of the atoms to be used:

    • Lithium atom in meli.xyz: 5
    • Oxygen atom in thf.xyz: 2
  2. Then run the command:

complax meli.xyz thf.xyz -a 5 2 -c 3
  1. What happens next?
    • The program places the molecules avoiding steric clashes.
    • Then, a robust two-stage geometry optimization is performed using xTB for each incremental number of solvent molecules. During the entire process, the solute coordinates and the internal geometries of the solvent molecules (intramolecular distances) are kept completely frozen.
      • Stage 1 (Pre-relaxation): The intermolecular target distance (e.g., Li-O) is harmonically constrained for 50 cycles. This crucial step dissipates initial spatial clashes and prevents the solvent molecules from artificially detaching or flying away.
      • Stage 2 (Full equilibration): The intermolecular distance constraint is released. The rigid solvent molecules are now completely free to translate and reorient around the fixed solute core to find their global thermodynamic minimum.
    • After optimization, the final geometry is saved in the outplax/ directory named complax_struct_{n}solvent_{s}.xtbopt.xyz, where {n} is the number of solvent molecules and {s} is the structure index.

Conformational Sampling and Energy Evaluation Example

To get the most out of COMPLAX, you can combine multiple flags to run a fully automated conformational search and thermodynamic analysis in a single line.

This command generates 40 different starting configurations (--nstruct 40), retains only the top 3 most stable geometries for each solvation state (--keep-best 3), and computes the stabilization energies (--solvfx):

complax meli.xyz thf.xyz -a 5 2 -c 3 --nstruct 40 --keep-best 3 --solvfx

What happens here?

  • COMPLAX explores the coordination space by optimizing 40 random clusters.
  • It automatically ranks them by total energy, discarding the highest-energy structures to save disk space and keeping only the top 3 conformers per state.
  • Finally, it prints a clean summary report on the terminal (and saves it in complax_summary.txt), displaying both the energy ranking and the stepwise solvation effect:
[...]
--- 3 solvent molecule(s) ---
complax_struct_3solvent_7.xtbopt.xyz          -103.573414 Eh
complax_struct_3solvent_23.xtbopt.xyz         -103.573345 Eh
complax_struct_3solvent_39.xtbopt.xyz         -103.573296 Eh
[...]

                     ***************************
                     * Effect of the Solvation *
                     ***************************

+--------------------------------+------------+------------+------------+
|                                |          1 |          2 |          3 |
+================================+============+============+============+
| Sum of reag + solv (Hartree)   | -20.609217 | -37.322501 | -54.035785 |
+--------------------------------+------------+------------+------------+
| Tot Energy (Complex) (Hartree) | -20.631873 | -37.364828 | -54.095412 |
+--------------------------------+------------+------------+------------+
| ΔE (kcal/mol)                  |     -14.22 |     -26.56 |     -37.42 |
+--------------------------------+------------+------------+------------+

Commandline Usage

complax molecule.xyz solvent.xyz [options]

Mandatory arguments:

Argument Description Default
-a (MOL) (SOLV) Atom numbers of molecule and solvent. Format: (MOLECULE ATOM) (SOLVENT ATOM) using 1-based indexing. Required
-c INT Number of solvent copies (solvent.xyz) to be placed around the selected atom of the solute. 1

Optional arguments:

Argument Description Default
-t FLOAT Target distance from the selected molecule atom, in Ångstrom. 2.0
--alpb SOLVENT Analytical linearized Poisson-Boltzman (ALPB) model. Available solvents on xTB are acetone, acetonitrile, aniline, benzaldehyde, benzene, ch2cl2, chcl3, cs2, dioxane, dmf, dmso, ether, ethylacetate, furane, hexandecane, hexane, methanol, nitromethane, octanol, woctanol, phenol, toluene, thf, water. [3] None
--gbsa SOLVENT Generalized Born solvation model (GBSA) is a simplified version of ALPB. Available solvents are acetone, acetonitrile, benzene (only GFN1-xTB), CH2Cl2, CHCl3, CS2, DMF (only GFN2-xTB), DMSO, ether, H2O, methanol, n-hexane (only GFN2-xTB), THF and toluene. [3] None
--gbe SOLVENT Generalized Born model with finite epsilon for solvation. Requires --lev gxtb. None
-p INT Number of parallel processes. During the initial optimization, the program uses the specified number of processes. For subsequent optimizations, it automatically launches as many parallel calculations as the number of solvent molecules selected. 1
--lev LEVEL Level of theory for the optimization. Options include gfn0, gfn1, gfn2, gfnff, gxtb. gfn2
--chrg INT Molecular charge. 0
-u, --uhf INT Number of unpaired electrons. 0
--res INT Number of points in the Fibonacci spherical grid. 10000
--nstruct INT Number of stochastic, non-overlapping starting structures to generate and optimize. Ideal for exploring the conformational space of the solvated complex. 400
--keep-best INT Filters the output to keep only the N lowest-energy optimized structures for each solvent configuration, automatically deleting the less stable ones. None
--solvfx Evaluates the effect of solvation in terms of potential energy differences among systems with an increasing number of solvent molecules. False
--cutoff FLOAT Steric overlap distance threshold in Ångstrom. 1.6
--seed INT Seed for the pseudo-random number generator to ensure reproducibility. Set to -1 for pure stochasticity. 42

Tips and Troubleshooting

  • Stochastic Sampling: For complex solvent environments, use --nstruct 1000 --keep-best 3. COMPLAX will generate 1000 different random orientations of the solvent cluster, optimize all of them, and retain only the 3 most thermodynamically stable configurations, saving you a massive amount of manual sorting. (Note: The number of generated structures is equal to --nstruct multiplied by the number of solvent molecules, -c).

  • Pre-optimized geometries: The ideal workflow uses pre-optimized input geometries from prior DFT calculations. COMPLAX keeps the internal geometry of both solute and solvent rigidly constrained during the entire xTB optimization process. This maintains their original intramolecular distances while exclusively allowing the exploration of the best intermolecular solvent coordination.

  • Visual Check: COMPLAX stochastically positions solvent molecules around the selected atom, avoiding steric overlaps based on the chosen target distance. Due to the unbiased nature of the sampling, especially in highly congested spatial environments, it is always recommended to visually inspect the final optimized geometries to ensure the resulting coordination aligns with your chemical intuition.

  • Important: COMPLAX writes output files in the outplax/ folder. If you want to keep multiple results, move the files out of outplax before running a new calculation or run complax in another folder, otherwise the previous files will be overwritten and lost.

Authors

Federica Lauria, Department of Chemistry, University of Turin, Torino, Italy

Andrea Maranzana, Deparment of Chemistry, University of Turin, Torino, Italy

References

[1] C. Bannwarth, E. Caldeweyher, S. Ehlert, A. Hansen, P. Pracht, J. Seibert, S. Spicher, S. Grimme WIREs Comput. Mol. Sci., 2020, 11, e01493. DOI: 10.1002/wcms.1493

[2] T. Froitzheim, M. Müller, A. Hansen, et al., ChemRxiv. 23 June 2025. DOI: 10.26434/chemrxiv-2025-bjxvt

[3] S. Ehlert, M. Stahn, S. Spicher, S. Grimme, J. Chem. Theory Comput., 2021, 17, 4250-4261 DOI: 10.1021/acs.jctc.1c00471

License

Complax is licensed under the MIT License.

See the LICENSE file for the full text.

Citation

If you use COMPLAX in your research, please cite our paper:

COMPLAX: A Python Tool Package for Automated Microsolvation of Organic Molecules
Federica Lauria and Andrea Maranzana.
Journal of Chemical Information and Modeling, 2026.
DOI: 10.1021/acs.jcim.6c02105

Metadata

Release files for complax 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for complax 1.1.2
File Size Uploaded Provenance
complax-1.1.2.tar.gz 86.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for complax 1.1.2
File Interpreter ABI Platform
complax-1.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 101.2 kB

Release files / complax-1.1.2.tar.gz

Download URL complax-1.1.2.tar.gz
Size 86.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4adb1684f8ec7c5c13bcd6629ac9015599eddbf850984e08e7df7d6117170138
BLAKE2b-256 checksum
How to use checksums
9c609fd8bdd1dd7a05ba42502fdc1b4726657f98ac288a3cb1dbd2488d8238a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.2

Release files / complax-1.1.2-py3-none-any.whl

Download URL complax-1.1.2-py3-none-any.whl
Size 15.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a84d96c6c3ceabf46625f6568c5805dee985a47d2963175f6731b81034cdf3b8
BLAKE2b-256 checksum
How to use checksums
65ffc1fc5457c77b2db06517dc74b79eed745d1604c9f84675ef81b6830ef5db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.2

Security for complax 1.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page