ppqm 0.1.0__py3-none-any.whl
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.
- env/bin/activate_this.py +59 -0
- ppqm/__init__.py +7 -0
- ppqm/calculator.py +110 -0
- ppqm/chembridge.py +1211 -0
- ppqm/constants.py +25 -0
- ppqm/gamess.py +790 -0
- ppqm/gaussian.py +373 -0
- ppqm/jupyter.py +60 -0
- ppqm/mndo.py +510 -0
- ppqm/mopac.py +475 -0
- ppqm/orca.py +523 -0
- ppqm/tasks.py +100 -0
- ppqm/units.py +17 -0
- ppqm/utils/__init__.py +2 -0
- ppqm/utils/env.py +0 -0
- ppqm/utils/files.py +117 -0
- ppqm/utils/functools.py +125 -0
- ppqm/utils/linesio.py +185 -0
- ppqm/utils/shell.py +198 -0
- ppqm/version.py +1 -0
- ppqm/xtb.py +862 -0
- ppqm-0.1.0.dist-info/METADATA +115 -0
- ppqm-0.1.0.dist-info/RECORD +36 -0
- ppqm-0.1.0.dist-info/WHEEL +5 -0
- ppqm-0.1.0.dist-info/licenses/LICENSE +21 -0
- ppqm-0.1.0.dist-info/top_level.txt +3 -0
- tests/conftest.py +3 -0
- tests/test_chembridge.py +437 -0
- tests/test_gamess.py +432 -0
- tests/test_gaussian.py +120 -0
- tests/test_linesio.py +42 -0
- tests/test_mndo.py +41 -0
- tests/test_mopac.py +178 -0
- tests/test_orca.py +462 -0
- tests/test_shell.py +10 -0
- tests/test_xtb.py +427 -0
env/bin/activate_this.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Copyright (c) 2020-202x The virtualenv developers
|
|
2
|
+
#
|
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
# a copy of this software and associated documentation files (the
|
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
# the following conditions:
|
|
10
|
+
#
|
|
11
|
+
# The above copyright notice and this permission notice shall be
|
|
12
|
+
# included in all copies or substantial portions of the Software.
|
|
13
|
+
#
|
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
"""
|
|
23
|
+
Activate virtualenv for current interpreter:
|
|
24
|
+
|
|
25
|
+
import runpy
|
|
26
|
+
runpy.run_path(this_file)
|
|
27
|
+
|
|
28
|
+
This can be used when you must use an existing Python interpreter, not the virtualenv bin/python.
|
|
29
|
+
""" # noqa: D415
|
|
30
|
+
|
|
31
|
+
from __future__ import annotations
|
|
32
|
+
|
|
33
|
+
import os
|
|
34
|
+
import site
|
|
35
|
+
import sys
|
|
36
|
+
|
|
37
|
+
try:
|
|
38
|
+
abs_file = os.path.abspath(__file__)
|
|
39
|
+
except NameError as exc:
|
|
40
|
+
msg = "You must use import runpy; runpy.run_path(this_file)"
|
|
41
|
+
raise AssertionError(msg) from exc
|
|
42
|
+
|
|
43
|
+
bin_dir = os.path.dirname(abs_file)
|
|
44
|
+
base = bin_dir[: -len("bin") - 1] # strip away the bin part from the __file__, plus the path separator
|
|
45
|
+
|
|
46
|
+
# prepend bin to PATH (this file is inside the bin directory)
|
|
47
|
+
os.environ["PATH"] = os.pathsep.join([bin_dir, *os.environ.get("PATH", "").split(os.pathsep)])
|
|
48
|
+
os.environ["VIRTUAL_ENV"] = base # virtual env is right above bin directory
|
|
49
|
+
os.environ["VIRTUAL_ENV_PROMPT"] = "" or os.path.basename(base) # noqa: SIM222
|
|
50
|
+
|
|
51
|
+
# add the virtual environments libraries to the host python import mechanism
|
|
52
|
+
prev_length = len(sys.path)
|
|
53
|
+
for lib in "../lib/python3.12/site-packages".split(os.pathsep):
|
|
54
|
+
path = os.path.realpath(os.path.join(bin_dir, lib))
|
|
55
|
+
site.addsitedir(path)
|
|
56
|
+
sys.path[:] = sys.path[prev_length:] + sys.path[0:prev_length]
|
|
57
|
+
|
|
58
|
+
sys.real_prefix = sys.prefix
|
|
59
|
+
sys.prefix = base
|
ppqm/__init__.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
from ppqm import chembridge
|
|
2
|
+
from ppqm.gamess import GamessCalculator
|
|
3
|
+
from ppqm.gaussian import GaussianCalculator
|
|
4
|
+
from ppqm.mopac import MopacCalculator
|
|
5
|
+
from ppqm.orca import OrcaCalculator
|
|
6
|
+
from ppqm.utils.files import WorkDir
|
|
7
|
+
from ppqm.xtb import XtbCalculator
|
ppqm/calculator.py
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import abc
|
|
2
|
+
import copy
|
|
3
|
+
import logging
|
|
4
|
+
from collections import ChainMap
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from ppqm import chembridge, constants
|
|
9
|
+
from ppqm.chembridge import Mol
|
|
10
|
+
|
|
11
|
+
_logger = logging.getLogger(__name__)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class BaseCalculator(abc.ABC):
|
|
15
|
+
"""Base class for quantum calculators
|
|
16
|
+
|
|
17
|
+
This class should not be used directly, use a class appropriate for your
|
|
18
|
+
quantum calculations (e.g. MopacCalculator or GamessCalculator) instead.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(self, scr: Path = constants.SCR) -> None:
|
|
22
|
+
self.scr = Path(scr)
|
|
23
|
+
# Ensure scrdir
|
|
24
|
+
self.set_scratch_directory()
|
|
25
|
+
|
|
26
|
+
def _health_check(self) -> None:
|
|
27
|
+
raise NotImplementedError
|
|
28
|
+
|
|
29
|
+
def _generate_options(self, **kwargs: Any) -> dict:
|
|
30
|
+
"""to be implemented by individual programs"""
|
|
31
|
+
raise NotImplementedError
|
|
32
|
+
|
|
33
|
+
def calculate(self, molobj: Mol, options: dict) -> list[dict | None]:
|
|
34
|
+
raise NotImplementedError
|
|
35
|
+
|
|
36
|
+
def optimize(self, molobj: Mol, options: dict | None = None, return_copy: bool = True) -> Mol:
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
Parameters
|
|
40
|
+
----------
|
|
41
|
+
molobj: Mol
|
|
42
|
+
A RDkit Molobj
|
|
43
|
+
|
|
44
|
+
return_copy: Bool
|
|
45
|
+
Return a new copy of molobj, instead of overwriting it
|
|
46
|
+
|
|
47
|
+
return_properties: Bool
|
|
48
|
+
Return list of properties for molobj conformers
|
|
49
|
+
|
|
50
|
+
Examples
|
|
51
|
+
--------
|
|
52
|
+
>>> molobj_prime = calc.optimize(molobj)
|
|
53
|
+
|
|
54
|
+
Returns
|
|
55
|
+
-------
|
|
56
|
+
molobj: Mol
|
|
57
|
+
RDKit molobj with updated conformer coordinates
|
|
58
|
+
|
|
59
|
+
properties: List(Dict(Str, Any))
|
|
60
|
+
Properties associated with each conformer
|
|
61
|
+
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
# TODO Embed properties into conformres
|
|
65
|
+
|
|
66
|
+
# Merge options
|
|
67
|
+
if options is None:
|
|
68
|
+
options = {}
|
|
69
|
+
options_ = self._generate_options(optimize=True)
|
|
70
|
+
options_prime = dict(ChainMap(options, options_))
|
|
71
|
+
|
|
72
|
+
if return_copy:
|
|
73
|
+
molobj = copy.deepcopy(molobj)
|
|
74
|
+
|
|
75
|
+
result_properties: list[dict] = self.calculate(molobj, options_prime) # type: ignore
|
|
76
|
+
|
|
77
|
+
for i, properties in enumerate(result_properties):
|
|
78
|
+
# TODO Check if unconverged
|
|
79
|
+
# TODO Check number of steps?
|
|
80
|
+
|
|
81
|
+
if constants.COLUMN_COORDINATES not in properties:
|
|
82
|
+
# TODO Unable to set coordinates, skip for now
|
|
83
|
+
_logger.error(f"Unable to optimize, conformer {i} skipped")
|
|
84
|
+
continue
|
|
85
|
+
|
|
86
|
+
coord = properties[constants.COLUMN_COORDINATES]
|
|
87
|
+
|
|
88
|
+
# Set coord on conformer
|
|
89
|
+
chembridge.molobj_set_coordinates(molobj, coord, confid=i)
|
|
90
|
+
|
|
91
|
+
return molobj
|
|
92
|
+
|
|
93
|
+
def get_gradient(self, molobj: Mol) -> None:
|
|
94
|
+
raise NotImplementedError
|
|
95
|
+
|
|
96
|
+
def get_hessian(self, molobj: Mol) -> None:
|
|
97
|
+
raise NotImplementedError
|
|
98
|
+
|
|
99
|
+
def set_energy_unit(self, unit: Mol) -> None:
|
|
100
|
+
raise NotImplementedError
|
|
101
|
+
# TODO set unit.convert(value, X, to)
|
|
102
|
+
|
|
103
|
+
def set_scratch_directory(self) -> None:
|
|
104
|
+
self.scr.mkdir(parents=True, exist_ok=True)
|
|
105
|
+
|
|
106
|
+
def health_check(self) -> None:
|
|
107
|
+
raise NotImplementedError
|
|
108
|
+
|
|
109
|
+
def __repr__(self) -> str:
|
|
110
|
+
return "CalculatorSkeleton()"
|