easyxtb 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,167 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
110
+ .pdm.toml
111
+ .pdm-python
112
+ .pdm-build/
113
+
114
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115
+ __pypackages__/
116
+
117
+ # Celery stuff
118
+ celerybeat-schedule
119
+ celerybeat.pid
120
+
121
+ # SageMath parsed files
122
+ *.sage.py
123
+
124
+ # Environments
125
+ .env
126
+ .venv
127
+ env/
128
+ venv/
129
+ ENV/
130
+ env.bak/
131
+ venv.bak/
132
+
133
+ # Spyder project settings
134
+ .spyderproject
135
+ .spyproject
136
+
137
+ # Rope project settings
138
+ .ropeproject
139
+
140
+ # mkdocs documentation
141
+ /site
142
+
143
+ # mypy
144
+ .mypy_cache/
145
+ .dmypy.json
146
+ dmypy.json
147
+
148
+ # Pyre type checker
149
+ .pyre/
150
+
151
+ # pytype static type analyzer
152
+ .pytype/
153
+
154
+ # Cython debug symbols
155
+ cython_debug/
156
+
157
+ # PyCharm
158
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
161
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
162
+ #.idea/
163
+
164
+ # avo_xtb
165
+ last/
166
+ xtb/
167
+ config.json
easyxtb-0.5.0/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2023-2024, Matthew J. Milner
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
easyxtb-0.5.0/PKG-INFO ADDED
@@ -0,0 +1,157 @@
1
+ Metadata-Version: 2.3
2
+ Name: easyxtb
3
+ Version: 0.5.0
4
+ Summary: A Python API for xtb (and CREST).
5
+ Project-URL: Homepage, https://github.com/matterhorn103/avo_xtb
6
+ Project-URL: Issues, https://github.com/matterhorn103/avo_xtb/issues
7
+ License-File: LICENSE
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: License :: OSI Approved :: BSD License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+
15
+ # easyxtb
16
+
17
+ `easyxtb` is an unofficial API for the xtb and CREST semi-empirical quantum chemistry programs with an emphasis on intuitive and straightforward usage.
18
+
19
+ It forms the basis for `avo_xtb`, a plugin for the 3D chemical visualization software [Avogadro 2](https://two.avogadro.cc) that provides an in-app interface to the xtb program for quick and accurate calculations, as well as the CREST program for extended functionality.
20
+
21
+ The Python package `easyxtb` can be used independently of `avo_xtb` as an interface to launch calculations and process their results from Python.
22
+
23
+ [`xtb`](https://github.com/grimme-lab/xtb) is developed by the Grimme group in Bonn and carries out semi-empirical quantum mechanical calculations using the group's e**x**tended **T**ight-**B**inding methods, referred to as "GFNn-xTB".
24
+
25
+ These methods provide fast and reasonably accurate calculation of **G**eometries, **F**requencies, and **N**on-covalent interactions for molecular systems with up to roughly 1000 atoms, with broad coverage of the periodic table up to *Z* = 86 (radon).
26
+
27
+ [`crest`](https://github.com/crest-lab/crest) (Conformer–Rotamer Ensemble Sampling Tool) adds a variety of sampling procedures for several interesting applications including conformer searches, thermochemistry, and solvation.
28
+
29
+ ## Usage
30
+
31
+ Full documentation is a work in progress, but to demonstrate basic usage:
32
+
33
+ To load a geometry (XYZ and CJSON files are supported currently):
34
+
35
+ ```python
36
+ >>> from pathlib import Path
37
+ >>> import py_xtb
38
+ >>> py_xtb.XTB_BIN = Path.home() / ".local/bin/xtb"
39
+ >>> input_geom = py_xtb.Geometry.from_file(Path.home() / "calcs/benzoic_acid.xyz")
40
+ >>> input_geom
41
+ <py_xtb.geometry.Geometry object at 0x7ff91fdb15d0>
42
+ >>> input_geom.atoms
43
+ [Atom(element='C', x=-3.61652, y=0.64945, z=-0.0), Atom(element='C', x=-3.59105, y=-1.15881, z=-0.0), Atom(element='C', x=-0.43296, y=-1.32436, z=-1e-05), ..., Atom(element='O', x=1.54084, y=3.42551, z=-1e-05), Atom(element='O', x=2.9034, y=0.39476, z=1e-05), Atom(element='H', x=2.60455, y=-0.50701, z=2e-05)]
44
+ >>> for atom in input_geom:
45
+ ... print(atom)
46
+ ...
47
+ Atom(element='C', x=-3.61652, y=0.64945, z=-0.0)
48
+ Atom(element='C', x=-3.59105, y=-1.15881, z=-0.0)
49
+ ... # Truncated for brevity
50
+ Atom(element='O', x=2.9034, y=0.39476, z=1e-05)
51
+ Atom(element='H', x=2.60455, y=-0.50701, z=2e-05)
52
+ ```
53
+
54
+ The package provides a function API for basic xtb calculation types (`energy`, `optimize`, `frequencies`, `opt_freq`, `orbitals`):
55
+
56
+ ```python
57
+ >>> optimized = py_xtb.calc.optimize(input_geom, charge=0, multiplicity=1, solvation="water", method=2, level="normal")
58
+ >>> for atom in optimized:
59
+ ... print(atom)
60
+ ...
61
+ Atom(element='C', x=-2.94841377173243, y=0.53595421697827, z=-0.00205114575446)
62
+ Atom(element='C', x=-2.96353116164446, y=-0.85021326429608, z=-0.00028605784754)
63
+ ... # Truncated for brevity
64
+ Atom(element='O', x=1.83119245847571, y=0.4663499792285, z=-0.00384872174663)
65
+ Atom(element='H', x=1.55896002888703, y=-0.46876579604809, z=-0.00948378184114)
66
+ ```
67
+
68
+ For greater control and for runtypes or command line options that don't yet have support in the API the `Calculation` object can be used:
69
+
70
+ ```python
71
+ >>> freq_calc = py_xtb.Calculation(program="xtb", runtype="hess", options={"charge": 0, "multiplicity": 1, "solvation": "water"})
72
+ >>> freq_calc.input_geometry = input_geom
73
+ >>> freq_calc.run()
74
+ >>> freq_calc.energy
75
+ -24.418716794336
76
+ >>> freq_calc.output_geometry
77
+ <py_xtb.geometry.Geometry object at 0x7ff91fdb15d0>
78
+ >>> freq_calc.frequencies
79
+ [{'mode': 1, 'symmetry': 'a', 'frequency': -816.7902, 'reduced_mass': 12.1428, 'ir_intensity': 7.2604, 'raman_scattering_activity': 0.0, 'eigenvectors': [[-0.26, -0.46, 0.0], [-0.24, 0.43, -0.0], [-0.05, -0.05, 0.0], [0.08, 0.3, -0.0], [0.42, 0.02, -0.0], [-0.02, 0.03, -0.0], [0.24, -0.09, -0.0], [0.0, -0.02, 0.0], [-0.26, 0.1, 0.0], [0.05, 0.01, -0.0], [-0.02, -0.03, 0.0], [0.0, -0.21, 0.0], [0.05, 0.0, -0.0], [-0.02, 0.01, -0.0]]}, {'mode': 2, 'symmetry': 'a', 'frequency': -759.3794, 'reduced_mass': 12.9124, 'ir_intensity': 17.3638, 'raman_scattering_activity': 0.0, 'eigenvectors': [[0.12, 0.19, -0.0], [0.15, -0.32, 0.0], [0.07, 0.18, -0.0], [0.12, 0.58, -0.0], [0.01, -0.11, 0.0], [0.01, -0.03, 0.0], [-0.29, 0.05, 0.0], [-0.02, 0.01, 0.0], [-0.32, -0.02, -0.0], [0.02, -0.03, -0.0], [0.01, 0.01, -0.0], [-0.01, -0.47, 0.0], [0.13, -0.0, -0.0], [-0.03, 0.02, 0.0]]}, ..., {'mode': 36, 'symmetry': 'a', 'frequency': 3752.5636, 'reduced_mass': 1.893, 'ir_intensity': 79.5584, 'raman_scattering_activity': 0.0, 'eigenvectors': [[-0.0, -0.0, 0.0], [0.0, -0.0, 0.0], [0.0, 0.0, -0.0], [-0.0, 0.0, 0.0], [-0.0, 0.0, -0.0], [-0.0, 0.0, -0.0], [0.0, 0.0, 0.0], [-0.0, 0.0, 0.0], [0.0, 0.0, -0.0], [0.0, 0.0, -0.0], [-0.0, 0.0, -0.0], [-0.0, -0.0, 0.0], [0.08, 0.23, -0.0], [-0.31, -0.92, 0.0]]}]
80
+ ```
81
+
82
+ We were returned some negative frequencies!
83
+ The xtb team recommend generally using the `ohess` (optimization followed by a frequency calculation) as, in the case of negative frequencies, xtb will produce a distorted geometry along the imaginary mode.
84
+ The `opt_freq()` calculation function takes advantage of this and will continue reoptimizing using these distorted geometries until a minimum is reached, so is more reliable in getting what we want:
85
+
86
+ ```python
87
+ >>> output_geom, output_freqs, calc = py_xtb.calc.opt_freq(input_geom, solvation="water", return_calc=True)
88
+ >>> output_freqs[0]
89
+ {'mode': 1, 'symmetry': 'a', 'frequency': 70.0622, 'reduced_mass': 13.4154, 'ir_intensity': 6.422, 'raman_scattering_activity': 0.0, 'eigenvectors': [[0.0, 0.0, -0.28], [-0.0, 0.0, -0.0], [-0.0, -0.0, 0.25], [0.0, -0.0, 0.04], [0.0, -0.0, -0.24], [-0.0, 0.0, -0.0], [-0.0, 0.0, 0.29], [-0.0, 0.0, 0.15], [0.0, -0.0, 0.02], [0.0, -0.0, -0.12], [0.0, 0.0, -0.15], [0.0, -0.0, 0.55], [0.0, 0.01, -0.56], [0.0, 0.0, -0.19]]}
90
+ ```
91
+
92
+ The geometries can be converted back to XYZ or CJSON formats, or saved to file:
93
+
94
+ ```python
95
+ >>> output_geom.to_xyz()
96
+ ['14', ' energy: -25.558538770724 gnorm: 0.000926226194 xtb: 6.7.1 (edcfbbe)', 'C -2.94841 0.53597 -0.00204', 'C -2.96354 -0.85020 -0.00027', 'C -0.61077 -0.84138 0.00148', 'C 0.75088 1.26262 0.00405', 'C -1.75577 1.23036 -0.00190', 'H -3.89917 -1.39047 0.00050', 'C -1.76452 -1.56433 0.00117', 'H -1.76882 -2.64357 0.00283', 'C -0.54492 0.52708 0.00053', 'H -1.70901 2.30959 -0.00318', 'H -3.88278 1.07775 -0.00326', 'O 0.84510 2.45868 0.01349', 'O 1.83119 0.46634 -0.00386', 'H 1.55896 -0.46877 -0.00949']
97
+ >>> output_geom.to_cjson()
98
+ {'atoms': {'coords': {'3d': [-2.94841097258746, 0.53596965124863, -0.00204178926542, -2.96353561428538, -0.85019774776951, -0.0002742292702, -0.61076575425764, -0.84137850926872, 0.00147639902781, 0.75088171422694, 1.2626220330939, 0.00405051293617, -1.75577241044775, 1.23035899741552, -0.00189846159875, -3.89916811270068, -1.39047034080804, 0.00049537269594, -1.76451828574256, -1.56433051119015, 0.00116984833688, -1.76882023929805, -2.64357304665774, 0.00283010066276, -0.54491722564374, 0.52708246765258, 0.00052577760818, -1.70901066150243, 2.30958748867245, -0.00317692528336, -3.88277644809706, 1.07774511697242, -0.00326302099431, 0.84510262816245, 2.45867627843098, 0.01348592446867, 1.83119488680479, 0.46634038440289, -0.00385592774839, 1.55895754130232, -0.46877397528872, -0.00948840548749]}, 'elements': {'number': [6, 6, 6, 6, 6, 1, 6, 1, 6, 1, 1, 8, 8, 1]}}}
99
+ >>> output_geom.to_file(Path.home() / "calcs/optimized_benzoic_acid.xyz")
100
+ ```
101
+
102
+ ## Requirements
103
+
104
+ ### xtb
105
+
106
+ Only tested for `xtb >= 6.7`.
107
+
108
+ The `xtb` binary is not bundled with the package.
109
+ Instead, it must be obtained separately.
110
+
111
+ The location of `xtb` can be set from Python code simply by setting `easyxtb.XTB_BIN` to an appropriate `pathlib.Path` object.
112
+
113
+ An `xtb` binary will also be picked up automatically by `easyxtb` if located in one of the following locations:
114
+ 1. The system or user PATH
115
+ 2. Within the `easyxtb` binary directory at `<user data>/easyxtb/bin/xtb` (see below for more information on where this is on your system)
116
+ 3. Within the folder it is distributed in under the `easyxtb` binary directory, which would thus currently be at `<user data>/easyxtb/bin/xtb-dist/bin/xtb`
117
+ 4. Any other location but with a link to it from `<user data>/easyxtb/bin/xtb`
118
+
119
+ ### CREST
120
+
121
+ Only tested for `crest >= 3.0`.
122
+
123
+ While `xtb` is cross-platform, `crest` is currently distributed only for Linux/UNIX systems.
124
+
125
+ `crest` can be made visible to the plugin in the same ways as for `xtb` listed above.
126
+ If it is not in `$PATH`, the `crest` binary, or link to it, should be located at `<user data>/easyxtb/bin/crest`.
127
+
128
+ ## Data location
129
+
130
+ `easyxtb` uses a central location to run its calculations, store its configuration, and save its log file.
131
+ This location is `<user data>/easyxtb`, where `<user data>` is OS-dependent:
132
+
133
+ - Windows: `$USER_HOME\AppData\Local\easyxtb`
134
+ - macOS: `~/Library/Application Support/easyxtb`
135
+ - Linux: `~/.local/share/easyxtb`
136
+
137
+ Additionally, if the environment variable `XDG_DATA_HOME` is set its value will be respected and takes precedence over the above paths (on all OSes).
138
+
139
+ ## Disclaimer
140
+
141
+ `xtb` and `crest` are distributed by the Grimme group under the LGPL license v3. The authors of `easyxtb`, `avo_xtb`, and Avogadro bear no responsibility for xtb or CREST or the contents of the respective repositories. Source code for the programs is available at the repositories linked above.
142
+
143
+ ## Cite
144
+
145
+ General reference to `xtb` and the implemented GFN methods:
146
+ * C. Bannwarth, E. Caldeweyher, S. Ehlert, A. Hansen, P. Pracht, J. Seibert, S. Spicher, S. Grimme
147
+ *WIREs Comput. Mol. Sci.*, **2020**, 11, e01493.
148
+ DOI: [10.1002/wcms.1493](https://doi.org/10.1002/wcms.1493)
149
+
150
+ For GFN2-xTB (default method):
151
+ * C. Bannwarth, S. Ehlert and S. Grimme., *J. Chem. Theory Comput.*, **2019**, 15, 1652-1671. DOI: [10.1021/acs.jctc.8b01176](https://dx.doi.org/10.1021/acs.jctc.8b01176)
152
+
153
+ For CREST:
154
+ * P. Pracht, S. Grimme, C. Bannwarth, F. Bohle, S. Ehlert, G. Feldmann, J. Gorges, M. Müller, T. Neudecker, C. Plett, S. Spicher, P. Steinbach, P. Wesołowski, F. Zeller, *J. Chem. Phys.*, **2024**, *160*, 114110. DOI: [10.1063/5.0197592](https://doi.org/10.1063/5.0197592)
155
+ * P. Pracht, F. Bohle, S. Grimme, *Phys. Chem. Chem. Phys.*, **2020**, 22, 7169-7192. DOI: [10.1039/C9CP06869D](https://dx.doi.org/10.1039/C9CP06869D)
156
+
157
+ See the xtb and CREST GitHub repositories for other citations.
@@ -0,0 +1,143 @@
1
+ # easyxtb
2
+
3
+ `easyxtb` is an unofficial API for the xtb and CREST semi-empirical quantum chemistry programs with an emphasis on intuitive and straightforward usage.
4
+
5
+ It forms the basis for `avo_xtb`, a plugin for the 3D chemical visualization software [Avogadro 2](https://two.avogadro.cc) that provides an in-app interface to the xtb program for quick and accurate calculations, as well as the CREST program for extended functionality.
6
+
7
+ The Python package `easyxtb` can be used independently of `avo_xtb` as an interface to launch calculations and process their results from Python.
8
+
9
+ [`xtb`](https://github.com/grimme-lab/xtb) is developed by the Grimme group in Bonn and carries out semi-empirical quantum mechanical calculations using the group's e**x**tended **T**ight-**B**inding methods, referred to as "GFNn-xTB".
10
+
11
+ These methods provide fast and reasonably accurate calculation of **G**eometries, **F**requencies, and **N**on-covalent interactions for molecular systems with up to roughly 1000 atoms, with broad coverage of the periodic table up to *Z* = 86 (radon).
12
+
13
+ [`crest`](https://github.com/crest-lab/crest) (Conformer–Rotamer Ensemble Sampling Tool) adds a variety of sampling procedures for several interesting applications including conformer searches, thermochemistry, and solvation.
14
+
15
+ ## Usage
16
+
17
+ Full documentation is a work in progress, but to demonstrate basic usage:
18
+
19
+ To load a geometry (XYZ and CJSON files are supported currently):
20
+
21
+ ```python
22
+ >>> from pathlib import Path
23
+ >>> import py_xtb
24
+ >>> py_xtb.XTB_BIN = Path.home() / ".local/bin/xtb"
25
+ >>> input_geom = py_xtb.Geometry.from_file(Path.home() / "calcs/benzoic_acid.xyz")
26
+ >>> input_geom
27
+ <py_xtb.geometry.Geometry object at 0x7ff91fdb15d0>
28
+ >>> input_geom.atoms
29
+ [Atom(element='C', x=-3.61652, y=0.64945, z=-0.0), Atom(element='C', x=-3.59105, y=-1.15881, z=-0.0), Atom(element='C', x=-0.43296, y=-1.32436, z=-1e-05), ..., Atom(element='O', x=1.54084, y=3.42551, z=-1e-05), Atom(element='O', x=2.9034, y=0.39476, z=1e-05), Atom(element='H', x=2.60455, y=-0.50701, z=2e-05)]
30
+ >>> for atom in input_geom:
31
+ ... print(atom)
32
+ ...
33
+ Atom(element='C', x=-3.61652, y=0.64945, z=-0.0)
34
+ Atom(element='C', x=-3.59105, y=-1.15881, z=-0.0)
35
+ ... # Truncated for brevity
36
+ Atom(element='O', x=2.9034, y=0.39476, z=1e-05)
37
+ Atom(element='H', x=2.60455, y=-0.50701, z=2e-05)
38
+ ```
39
+
40
+ The package provides a function API for basic xtb calculation types (`energy`, `optimize`, `frequencies`, `opt_freq`, `orbitals`):
41
+
42
+ ```python
43
+ >>> optimized = py_xtb.calc.optimize(input_geom, charge=0, multiplicity=1, solvation="water", method=2, level="normal")
44
+ >>> for atom in optimized:
45
+ ... print(atom)
46
+ ...
47
+ Atom(element='C', x=-2.94841377173243, y=0.53595421697827, z=-0.00205114575446)
48
+ Atom(element='C', x=-2.96353116164446, y=-0.85021326429608, z=-0.00028605784754)
49
+ ... # Truncated for brevity
50
+ Atom(element='O', x=1.83119245847571, y=0.4663499792285, z=-0.00384872174663)
51
+ Atom(element='H', x=1.55896002888703, y=-0.46876579604809, z=-0.00948378184114)
52
+ ```
53
+
54
+ For greater control and for runtypes or command line options that don't yet have support in the API the `Calculation` object can be used:
55
+
56
+ ```python
57
+ >>> freq_calc = py_xtb.Calculation(program="xtb", runtype="hess", options={"charge": 0, "multiplicity": 1, "solvation": "water"})
58
+ >>> freq_calc.input_geometry = input_geom
59
+ >>> freq_calc.run()
60
+ >>> freq_calc.energy
61
+ -24.418716794336
62
+ >>> freq_calc.output_geometry
63
+ <py_xtb.geometry.Geometry object at 0x7ff91fdb15d0>
64
+ >>> freq_calc.frequencies
65
+ [{'mode': 1, 'symmetry': 'a', 'frequency': -816.7902, 'reduced_mass': 12.1428, 'ir_intensity': 7.2604, 'raman_scattering_activity': 0.0, 'eigenvectors': [[-0.26, -0.46, 0.0], [-0.24, 0.43, -0.0], [-0.05, -0.05, 0.0], [0.08, 0.3, -0.0], [0.42, 0.02, -0.0], [-0.02, 0.03, -0.0], [0.24, -0.09, -0.0], [0.0, -0.02, 0.0], [-0.26, 0.1, 0.0], [0.05, 0.01, -0.0], [-0.02, -0.03, 0.0], [0.0, -0.21, 0.0], [0.05, 0.0, -0.0], [-0.02, 0.01, -0.0]]}, {'mode': 2, 'symmetry': 'a', 'frequency': -759.3794, 'reduced_mass': 12.9124, 'ir_intensity': 17.3638, 'raman_scattering_activity': 0.0, 'eigenvectors': [[0.12, 0.19, -0.0], [0.15, -0.32, 0.0], [0.07, 0.18, -0.0], [0.12, 0.58, -0.0], [0.01, -0.11, 0.0], [0.01, -0.03, 0.0], [-0.29, 0.05, 0.0], [-0.02, 0.01, 0.0], [-0.32, -0.02, -0.0], [0.02, -0.03, -0.0], [0.01, 0.01, -0.0], [-0.01, -0.47, 0.0], [0.13, -0.0, -0.0], [-0.03, 0.02, 0.0]]}, ..., {'mode': 36, 'symmetry': 'a', 'frequency': 3752.5636, 'reduced_mass': 1.893, 'ir_intensity': 79.5584, 'raman_scattering_activity': 0.0, 'eigenvectors': [[-0.0, -0.0, 0.0], [0.0, -0.0, 0.0], [0.0, 0.0, -0.0], [-0.0, 0.0, 0.0], [-0.0, 0.0, -0.0], [-0.0, 0.0, -0.0], [0.0, 0.0, 0.0], [-0.0, 0.0, 0.0], [0.0, 0.0, -0.0], [0.0, 0.0, -0.0], [-0.0, 0.0, -0.0], [-0.0, -0.0, 0.0], [0.08, 0.23, -0.0], [-0.31, -0.92, 0.0]]}]
66
+ ```
67
+
68
+ We were returned some negative frequencies!
69
+ The xtb team recommend generally using the `ohess` (optimization followed by a frequency calculation) as, in the case of negative frequencies, xtb will produce a distorted geometry along the imaginary mode.
70
+ The `opt_freq()` calculation function takes advantage of this and will continue reoptimizing using these distorted geometries until a minimum is reached, so is more reliable in getting what we want:
71
+
72
+ ```python
73
+ >>> output_geom, output_freqs, calc = py_xtb.calc.opt_freq(input_geom, solvation="water", return_calc=True)
74
+ >>> output_freqs[0]
75
+ {'mode': 1, 'symmetry': 'a', 'frequency': 70.0622, 'reduced_mass': 13.4154, 'ir_intensity': 6.422, 'raman_scattering_activity': 0.0, 'eigenvectors': [[0.0, 0.0, -0.28], [-0.0, 0.0, -0.0], [-0.0, -0.0, 0.25], [0.0, -0.0, 0.04], [0.0, -0.0, -0.24], [-0.0, 0.0, -0.0], [-0.0, 0.0, 0.29], [-0.0, 0.0, 0.15], [0.0, -0.0, 0.02], [0.0, -0.0, -0.12], [0.0, 0.0, -0.15], [0.0, -0.0, 0.55], [0.0, 0.01, -0.56], [0.0, 0.0, -0.19]]}
76
+ ```
77
+
78
+ The geometries can be converted back to XYZ or CJSON formats, or saved to file:
79
+
80
+ ```python
81
+ >>> output_geom.to_xyz()
82
+ ['14', ' energy: -25.558538770724 gnorm: 0.000926226194 xtb: 6.7.1 (edcfbbe)', 'C -2.94841 0.53597 -0.00204', 'C -2.96354 -0.85020 -0.00027', 'C -0.61077 -0.84138 0.00148', 'C 0.75088 1.26262 0.00405', 'C -1.75577 1.23036 -0.00190', 'H -3.89917 -1.39047 0.00050', 'C -1.76452 -1.56433 0.00117', 'H -1.76882 -2.64357 0.00283', 'C -0.54492 0.52708 0.00053', 'H -1.70901 2.30959 -0.00318', 'H -3.88278 1.07775 -0.00326', 'O 0.84510 2.45868 0.01349', 'O 1.83119 0.46634 -0.00386', 'H 1.55896 -0.46877 -0.00949']
83
+ >>> output_geom.to_cjson()
84
+ {'atoms': {'coords': {'3d': [-2.94841097258746, 0.53596965124863, -0.00204178926542, -2.96353561428538, -0.85019774776951, -0.0002742292702, -0.61076575425764, -0.84137850926872, 0.00147639902781, 0.75088171422694, 1.2626220330939, 0.00405051293617, -1.75577241044775, 1.23035899741552, -0.00189846159875, -3.89916811270068, -1.39047034080804, 0.00049537269594, -1.76451828574256, -1.56433051119015, 0.00116984833688, -1.76882023929805, -2.64357304665774, 0.00283010066276, -0.54491722564374, 0.52708246765258, 0.00052577760818, -1.70901066150243, 2.30958748867245, -0.00317692528336, -3.88277644809706, 1.07774511697242, -0.00326302099431, 0.84510262816245, 2.45867627843098, 0.01348592446867, 1.83119488680479, 0.46634038440289, -0.00385592774839, 1.55895754130232, -0.46877397528872, -0.00948840548749]}, 'elements': {'number': [6, 6, 6, 6, 6, 1, 6, 1, 6, 1, 1, 8, 8, 1]}}}
85
+ >>> output_geom.to_file(Path.home() / "calcs/optimized_benzoic_acid.xyz")
86
+ ```
87
+
88
+ ## Requirements
89
+
90
+ ### xtb
91
+
92
+ Only tested for `xtb >= 6.7`.
93
+
94
+ The `xtb` binary is not bundled with the package.
95
+ Instead, it must be obtained separately.
96
+
97
+ The location of `xtb` can be set from Python code simply by setting `easyxtb.XTB_BIN` to an appropriate `pathlib.Path` object.
98
+
99
+ An `xtb` binary will also be picked up automatically by `easyxtb` if located in one of the following locations:
100
+ 1. The system or user PATH
101
+ 2. Within the `easyxtb` binary directory at `<user data>/easyxtb/bin/xtb` (see below for more information on where this is on your system)
102
+ 3. Within the folder it is distributed in under the `easyxtb` binary directory, which would thus currently be at `<user data>/easyxtb/bin/xtb-dist/bin/xtb`
103
+ 4. Any other location but with a link to it from `<user data>/easyxtb/bin/xtb`
104
+
105
+ ### CREST
106
+
107
+ Only tested for `crest >= 3.0`.
108
+
109
+ While `xtb` is cross-platform, `crest` is currently distributed only for Linux/UNIX systems.
110
+
111
+ `crest` can be made visible to the plugin in the same ways as for `xtb` listed above.
112
+ If it is not in `$PATH`, the `crest` binary, or link to it, should be located at `<user data>/easyxtb/bin/crest`.
113
+
114
+ ## Data location
115
+
116
+ `easyxtb` uses a central location to run its calculations, store its configuration, and save its log file.
117
+ This location is `<user data>/easyxtb`, where `<user data>` is OS-dependent:
118
+
119
+ - Windows: `$USER_HOME\AppData\Local\easyxtb`
120
+ - macOS: `~/Library/Application Support/easyxtb`
121
+ - Linux: `~/.local/share/easyxtb`
122
+
123
+ Additionally, if the environment variable `XDG_DATA_HOME` is set its value will be respected and takes precedence over the above paths (on all OSes).
124
+
125
+ ## Disclaimer
126
+
127
+ `xtb` and `crest` are distributed by the Grimme group under the LGPL license v3. The authors of `easyxtb`, `avo_xtb`, and Avogadro bear no responsibility for xtb or CREST or the contents of the respective repositories. Source code for the programs is available at the repositories linked above.
128
+
129
+ ## Cite
130
+
131
+ General reference to `xtb` and the implemented GFN methods:
132
+ * C. Bannwarth, E. Caldeweyher, S. Ehlert, A. Hansen, P. Pracht, J. Seibert, S. Spicher, S. Grimme
133
+ *WIREs Comput. Mol. Sci.*, **2020**, 11, e01493.
134
+ DOI: [10.1002/wcms.1493](https://doi.org/10.1002/wcms.1493)
135
+
136
+ For GFN2-xTB (default method):
137
+ * C. Bannwarth, S. Ehlert and S. Grimme., *J. Chem. Theory Comput.*, **2019**, 15, 1652-1671. DOI: [10.1021/acs.jctc.8b01176](https://dx.doi.org/10.1021/acs.jctc.8b01176)
138
+
139
+ For CREST:
140
+ * P. Pracht, S. Grimme, C. Bannwarth, F. Bohle, S. Ehlert, G. Feldmann, J. Gorges, M. Müller, T. Neudecker, C. Plett, S. Spicher, P. Steinbach, P. Wesołowski, F. Zeller, *J. Chem. Phys.*, **2024**, *160*, 114110. DOI: [10.1063/5.0197592](https://doi.org/10.1063/5.0197592)
141
+ * P. Pracht, F. Bohle, S. Grimme, *Phys. Chem. Chem. Phys.*, **2020**, 22, 7169-7192. DOI: [10.1039/C9CP06869D](https://dx.doi.org/10.1039/C9CP06869D)
142
+
143
+ See the xtb and CREST GitHub repositories for other citations.
@@ -0,0 +1,29 @@
1
+ [project]
2
+ name = "easyxtb"
3
+ version = "0.5.0"
4
+ description = "A Python API for xtb (and CREST)."
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ dependencies = []
8
+ classifiers = [
9
+ "Programming Language :: Python :: 3",
10
+ "License :: OSI Approved :: BSD License",
11
+ "Development Status :: 4 - Beta",
12
+ "Topic :: Scientific/Engineering :: Chemistry",
13
+ ]
14
+
15
+ [project.urls]
16
+ Homepage = "https://github.com/matterhorn103/avo_xtb"
17
+ Issues = "https://github.com/matterhorn103/avo_xtb/issues"
18
+
19
+ [build-system]
20
+ requires = ["hatchling"]
21
+ build-backend = "hatchling.build"
22
+
23
+ [tool.ruff]
24
+ line-length = 100
25
+ indent-width = 4
26
+
27
+ [tool.ruff.format]
28
+ quote-style = "double"
29
+ indent-style = "space"
@@ -0,0 +1,17 @@
1
+ import logging
2
+
3
+ from .conf import config, config_file
4
+ from .conf import PLUGIN_DIR, CALC_DIR, TEMP_DIR, BIN_DIR, XTB_BIN, CREST_BIN
5
+ from .geometry import Atom, Geometry
6
+ from .calc import Calculation
7
+ from . import calc, conf, convert
8
+
9
+
10
+ logger = logging.getLogger(__name__)
11
+ logging.basicConfig(
12
+ filename=PLUGIN_DIR / "log.log",
13
+ filemode="w",
14
+ format="%(name)s:%(lineno)s: %(message)s",
15
+ encoding="utf-8",
16
+ level=logging.DEBUG,
17
+ )