stjames 0.0.44__py3-none-any.whl → 0.0.45__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.
Potentially problematic release.
This version of stjames might be problematic. Click here for more details.
- stjames/constraint.py +38 -4
- stjames/correction.py +3 -0
- stjames/method.py +20 -31
- stjames/molecule.py +5 -7
- stjames/types.py +2 -0
- stjames/workflows/__init__.py +1 -0
- stjames/workflows/bde.py +5 -1
- stjames/workflows/conformer_search.py +345 -0
- stjames/workflows/electronic_properties.py +86 -0
- stjames/workflows/molecular_dynamics.py +10 -3
- stjames/workflows/multistage_opt.py +83 -12
- stjames/workflows/redox_potential.py +68 -4
- stjames/workflows/spin_states.py +1 -1
- {stjames-0.0.44.dist-info → stjames-0.0.45.dist-info}/METADATA +1 -1
- {stjames-0.0.44.dist-info → stjames-0.0.45.dist-info}/RECORD +18 -16
- {stjames-0.0.44.dist-info → stjames-0.0.45.dist-info}/WHEEL +1 -1
- {stjames-0.0.44.dist-info → stjames-0.0.45.dist-info}/LICENSE +0 -0
- {stjames-0.0.44.dist-info → stjames-0.0.45.dist-info}/top_level.txt +0 -0
stjames/constraint.py
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
from
|
|
1
|
+
from typing import Optional, Self
|
|
2
|
+
|
|
3
|
+
from pydantic import PositiveFloat, PositiveInt, model_validator
|
|
2
4
|
|
|
3
5
|
from .base import Base, LowercaseStrEnum
|
|
4
6
|
|
|
@@ -12,25 +14,57 @@ class ConstraintType(LowercaseStrEnum):
|
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
class Constraint(Base):
|
|
15
|
-
"""
|
|
17
|
+
"""
|
|
18
|
+
Represents a single (absolute) constraint.
|
|
19
|
+
|
|
20
|
+
:param constraint_type: which type
|
|
21
|
+
:param atoms: the atoms in question
|
|
22
|
+
:param value: the value to constrain this to, leaving this blank sets the current value
|
|
23
|
+
"""
|
|
16
24
|
|
|
17
25
|
constraint_type: ConstraintType
|
|
18
26
|
atoms: list[PositiveInt] # 1-indexed
|
|
27
|
+
value: Optional[float] = None
|
|
28
|
+
|
|
29
|
+
@model_validator(mode="after")
|
|
30
|
+
def check_atom_list_length(self) -> Self:
|
|
31
|
+
match self.constraint_type:
|
|
32
|
+
case ConstraintType.BOND:
|
|
33
|
+
if len(self.atoms) != 2:
|
|
34
|
+
raise ValueError("Bond constraint needs two atom indices!")
|
|
35
|
+
case ConstraintType.ANGLE:
|
|
36
|
+
if len(self.atoms) != 3:
|
|
37
|
+
raise ValueError("Angle constraint needs three atom indices!")
|
|
38
|
+
case ConstraintType.DIHEDRAL:
|
|
39
|
+
if len(self.atoms) != 4:
|
|
40
|
+
raise ValueError("Dihedral constraint needs four atom indices!")
|
|
41
|
+
case _:
|
|
42
|
+
raise ValueError("Unknown constraint_type!")
|
|
43
|
+
|
|
44
|
+
return self
|
|
19
45
|
|
|
20
46
|
|
|
21
47
|
class PairwiseHarmonicConstraint(Base):
|
|
22
48
|
"""
|
|
23
49
|
Represents a harmonic constraint, with a characteristic spring constant.
|
|
50
|
+
|
|
51
|
+
:param atoms: whch atoms to apply to
|
|
52
|
+
:param force_constant: the strength of the attraction, in kcal/mol/Å
|
|
53
|
+
:param equilibrium: the distance at which force is zero
|
|
24
54
|
"""
|
|
25
55
|
|
|
26
56
|
atoms: tuple[PositiveInt, PositiveInt] # 1-indexed
|
|
27
|
-
|
|
57
|
+
force_constant: PositiveFloat # kcal/mol / Å**2
|
|
58
|
+
equilibrium: PositiveFloat # Å
|
|
28
59
|
|
|
29
60
|
|
|
30
61
|
class SphericalHarmonicConstraint(Base):
|
|
31
62
|
"""
|
|
32
63
|
Represents a spherical harmonic constraint to keep a system near the origin.
|
|
64
|
+
|
|
65
|
+
:param confining radius: the confining radius, in Å
|
|
66
|
+
:param force_constant: the strength of the confinement, in kcal/mol/Å
|
|
33
67
|
"""
|
|
34
68
|
|
|
35
69
|
confining_radius: PositiveFloat
|
|
36
|
-
|
|
70
|
+
force_constant: PositiveFloat = 10 # kcal/mol / Å**2
|
stjames/correction.py
CHANGED
stjames/method.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from typing import Literal
|
|
2
|
+
|
|
1
3
|
from .base import LowercaseStrEnum
|
|
2
4
|
|
|
3
5
|
|
|
@@ -7,6 +9,7 @@ class Method(LowercaseStrEnum):
|
|
|
7
9
|
|
|
8
10
|
PBE = "pbe"
|
|
9
11
|
B973C = "b97_3c"
|
|
12
|
+
B97D3BJ = "b97_d3bj"
|
|
10
13
|
R2SCAN = "r2scan"
|
|
11
14
|
R2SCAN3C = "r2scan_3c"
|
|
12
15
|
TPSS = "tpss"
|
|
@@ -28,6 +31,9 @@ class Method(LowercaseStrEnum):
|
|
|
28
31
|
DSDBLYPD3BJ = "dsd_blyp_d3bj"
|
|
29
32
|
|
|
30
33
|
AIMNET2_WB97MD3 = "aimnet2_wb97md3"
|
|
34
|
+
MACE_MP_0 = "mace_mp_0"
|
|
35
|
+
OCP24_S = "ocp24_s"
|
|
36
|
+
OCP24_L = "ocp24_l"
|
|
31
37
|
|
|
32
38
|
GFN_FF = "gfn_ff"
|
|
33
39
|
GFN0_XTB = "gfn0_xtb"
|
|
@@ -38,34 +44,17 @@ class Method(LowercaseStrEnum):
|
|
|
38
44
|
BP86 = "bp86"
|
|
39
45
|
|
|
40
46
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
XTB_METHODS = [
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
Method.R2SCAN3C,
|
|
56
|
-
Method.WB97X3C,
|
|
57
|
-
]
|
|
58
|
-
|
|
59
|
-
PREPACKAGED_METHODS = [
|
|
60
|
-
*MLFF,
|
|
61
|
-
*XTB_METHODS,
|
|
62
|
-
*COMPOSITE_METHODS,
|
|
63
|
-
]
|
|
64
|
-
|
|
65
|
-
METHODS_WITH_CORRECTION = [
|
|
66
|
-
Method.WB97XD3,
|
|
67
|
-
Method.WB97XV,
|
|
68
|
-
Method.WB97MV,
|
|
69
|
-
Method.WB97MD3BJ,
|
|
70
|
-
Method.DSDBLYPD3BJ,
|
|
71
|
-
]
|
|
47
|
+
NNPMethod = Literal[Method.AIMNET2_WB97MD3]
|
|
48
|
+
NNP_METHODS = [Method.AIMNET2_WB97MD3]
|
|
49
|
+
|
|
50
|
+
XTBMethod = Literal[Method.GFN_FF, Method.GFN0_XTB, Method.GFN1_XTB, Method.GFN2_XTB]
|
|
51
|
+
XTB_METHODS = [Method.GFN_FF, Method.GFN0_XTB, Method.GFN1_XTB, Method.GFN2_XTB]
|
|
52
|
+
|
|
53
|
+
CompositeMethod = Literal[Method.HF3C, Method.B973C, Method.R2SCAN3C, Method.WB97X3C]
|
|
54
|
+
COMPOSITE_METHODS = [Method.HF3C, Method.B973C, Method.R2SCAN3C, Method.WB97X3C]
|
|
55
|
+
|
|
56
|
+
PrepackagedMethod = XTBMethod | CompositeMethod | NNPMethod
|
|
57
|
+
PREPACKAGED_METHODS = [*XTB_METHODS, *COMPOSITE_METHODS]
|
|
58
|
+
|
|
59
|
+
MethodWithCorrection = Literal[Method.WB97XD3, Method.WB97XV, Method.WB97MV, Method.WB97MD3BJ, Method.DSDBLYPD3BJ]
|
|
60
|
+
METHODS_WITH_CORRECTION = [Method.WB97XD3, Method.WB97XV, Method.WB97MV, Method.WB97MD3BJ, Method.DSDBLYPD3BJ, Method.B97D3BJ]
|
stjames/molecule.py
CHANGED
|
@@ -8,7 +8,7 @@ from pydantic import NonNegativeInt, PositiveInt, ValidationError
|
|
|
8
8
|
from .atom import Atom
|
|
9
9
|
from .base import Base
|
|
10
10
|
from .periodic_cell import PeriodicCell
|
|
11
|
-
from .types import Matrix3x3, Vector3D, Vector3DPerAtom
|
|
11
|
+
from .types import FloatPerAtom, Matrix3x3, Vector3D, Vector3DPerAtom
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class MoleculeReadError(RuntimeError):
|
|
@@ -18,10 +18,8 @@ class MoleculeReadError(RuntimeError):
|
|
|
18
18
|
class VibrationalMode(Base):
|
|
19
19
|
frequency: float # in cm-1
|
|
20
20
|
reduced_mass: float # amu
|
|
21
|
-
|
|
22
|
-
#
|
|
23
|
-
force_constant: float
|
|
24
|
-
displacements: Vector3DPerAtom
|
|
21
|
+
force_constant: float # mDyne/Å
|
|
22
|
+
displacements: Vector3DPerAtom # Å
|
|
25
23
|
|
|
26
24
|
|
|
27
25
|
class Molecule(Base):
|
|
@@ -44,8 +42,8 @@ class Molecule(Base):
|
|
|
44
42
|
|
|
45
43
|
velocities: Optional[Vector3DPerAtom] = None # Å/fs
|
|
46
44
|
|
|
47
|
-
mulliken_charges:
|
|
48
|
-
mulliken_spin_densities:
|
|
45
|
+
mulliken_charges: FloatPerAtom | None = None
|
|
46
|
+
mulliken_spin_densities: FloatPerAtom | None = None
|
|
49
47
|
dipole: Optional[Vector3D] = None # in Debye
|
|
50
48
|
|
|
51
49
|
vibrational_modes: Optional[list[VibrationalMode]] = None
|
stjames/types.py
CHANGED
stjames/workflows/__init__.py
CHANGED
stjames/workflows/bde.py
CHANGED
|
@@ -58,7 +58,7 @@ class BDEWorkflow(Workflow, MultiStageOptMixin):
|
|
|
58
58
|
:param initial_molecule: Molecule of interest
|
|
59
59
|
:param mode: Mode for workflow
|
|
60
60
|
:param multistage_opt_settings: set by mode unless mode=MANUAL (ignores additional settings if set)
|
|
61
|
-
:param solvent: solvent to use
|
|
61
|
+
:param solvent: solvent to use for singlepoint
|
|
62
62
|
:param xtb_preopt: pre-optimize with xtb (sets based on mode when None)
|
|
63
63
|
|
|
64
64
|
Overridden:
|
|
@@ -106,6 +106,10 @@ class BDEWorkflow(Workflow, MultiStageOptMixin):
|
|
|
106
106
|
"""
|
|
107
107
|
return f"{type(self).__name__} {self.mode.name}\n" + "\n".join(map(str, self.fragment_indices))
|
|
108
108
|
|
|
109
|
+
@property
|
|
110
|
+
def level_of_theory(self) -> str:
|
|
111
|
+
return self.multistage_opt_settings.level_of_theory
|
|
112
|
+
|
|
109
113
|
@property
|
|
110
114
|
def energies(self) -> tuple[float | None, ...]:
|
|
111
115
|
return tuple(bde.energy for bde in self.bdes)
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
"""Conformer Search Workflow."""
|
|
2
|
+
|
|
3
|
+
from abc import ABC
|
|
4
|
+
from typing import Self, Sequence, TypeVar
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, Field, field_validator, model_validator
|
|
7
|
+
|
|
8
|
+
from ..base import LowercaseStrEnum
|
|
9
|
+
from ..constraint import Constraint
|
|
10
|
+
from ..method import Method, XTBMethod
|
|
11
|
+
from ..mode import Mode
|
|
12
|
+
from ..types import UUID
|
|
13
|
+
from .multistage_opt import MultiStageOptMixin
|
|
14
|
+
from .workflow import Workflow
|
|
15
|
+
|
|
16
|
+
_sentinel = object()
|
|
17
|
+
|
|
18
|
+
_T = TypeVar("_T")
|
|
19
|
+
_U = TypeVar("_U")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def check_sentinel(value: _T, default: _U) -> _T | _U:
|
|
23
|
+
"""Return value unless _sentinel, then return default."""
|
|
24
|
+
return default if value is _sentinel else value
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ScreeningSettings(BaseModel):
|
|
28
|
+
"""
|
|
29
|
+
Settings for determing unique and useful conformers.
|
|
30
|
+
|
|
31
|
+
:param energy_threshhold: maximum relative energy for screening
|
|
32
|
+
:param rotational_constants_threshhold: maximum difference in rotational constants for screening
|
|
33
|
+
:param rmsd: cartesian RMSD for screening
|
|
34
|
+
:param max_confs: maximum number of conformers to keep
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
energy_threshhold: float | None = None # kcal/mol
|
|
38
|
+
rotational_constants_threshhold: float | None = 0.02
|
|
39
|
+
rmsd: float | None = 0.25
|
|
40
|
+
max_confs: int | None = None
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class ConformerGenSettings(BaseModel):
|
|
44
|
+
"""
|
|
45
|
+
Conformer generation settings.
|
|
46
|
+
|
|
47
|
+
Conformers are generated and an initial screening is performed to remove duplicates and high-energy conformers.
|
|
48
|
+
|
|
49
|
+
:param mode: Mode for calculations
|
|
50
|
+
:param conf_opt_method: method for the optimization
|
|
51
|
+
:param screening: post-generation screening settings
|
|
52
|
+
:param constraints: constraints for conformer generation
|
|
53
|
+
:param nci: add a constraining potential for non-covalent interactions
|
|
54
|
+
:param max_confs: maximum number of conformers to keep
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
mode: Mode = Mode.RAPID
|
|
58
|
+
conf_opt_method: XTBMethod = Method.GFN_FF
|
|
59
|
+
screening: ScreeningSettings | None = None
|
|
60
|
+
constraints: Sequence[Constraint] = tuple()
|
|
61
|
+
nci: bool = False
|
|
62
|
+
max_confs: int | None = None
|
|
63
|
+
|
|
64
|
+
def __str__(self) -> str:
|
|
65
|
+
"""Return a string representation of the ConformerGenSettings."""
|
|
66
|
+
return repr(self)
|
|
67
|
+
|
|
68
|
+
def __repr__(self) -> str:
|
|
69
|
+
"""Return a string representation of the ConformerGenSettings."""
|
|
70
|
+
return f"<{type(self).__name__} {self.mode.name}>"
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class ETKDGSettings(ConformerGenSettings):
|
|
74
|
+
"""
|
|
75
|
+
Settings for ETKDG conformer generation.
|
|
76
|
+
|
|
77
|
+
Inherited:
|
|
78
|
+
:param mode: Mode for calculations
|
|
79
|
+
:param screening: post-generation screening settings
|
|
80
|
+
:param constraints: constraints for conformer generation
|
|
81
|
+
:param nci: add a constraining potential for non-covalent interactions (not supported in ETKDG)
|
|
82
|
+
:param conf_opt_method: method for the optimization
|
|
83
|
+
|
|
84
|
+
New:
|
|
85
|
+
:param num_initial_confs: number of initial conformers to generate
|
|
86
|
+
:param num_confs_considered: number of conformers to consider for optimization
|
|
87
|
+
:param num_confs_taken: number of final conformers to take
|
|
88
|
+
:param max_mmff_energy: MMFF energy cutoff
|
|
89
|
+
:param max_mmff_iterations: MMFF optimization iterations
|
|
90
|
+
:param max_confs: maximum number of conformers to keep
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
num_initial_confs: int = 300
|
|
94
|
+
num_confs_considered: int = 100
|
|
95
|
+
max_mmff_iterations: int = 500
|
|
96
|
+
max_mmff_energy: float | None = 30
|
|
97
|
+
|
|
98
|
+
@field_validator("constraints")
|
|
99
|
+
def check_constraints(cls, constraints: Sequence[Constraint]) -> Sequence[Constraint]:
|
|
100
|
+
if constraints:
|
|
101
|
+
raise ValueError("ETKDG does not support constraints")
|
|
102
|
+
|
|
103
|
+
return tuple(constraints)
|
|
104
|
+
|
|
105
|
+
@field_validator("nci")
|
|
106
|
+
def check_nci(cls, nci: bool) -> bool:
|
|
107
|
+
if nci:
|
|
108
|
+
raise ValueError("ETKDG does not support NCI")
|
|
109
|
+
|
|
110
|
+
return nci
|
|
111
|
+
|
|
112
|
+
@model_validator(mode="after")
|
|
113
|
+
def validate_and_build(self) -> Self:
|
|
114
|
+
match self.mode:
|
|
115
|
+
case Mode.MANUAL:
|
|
116
|
+
pass
|
|
117
|
+
case Mode.RECKLESS:
|
|
118
|
+
self.num_initial_confs = 200
|
|
119
|
+
self.num_confs_considered = 50
|
|
120
|
+
self.max_confs = 20 if self.max_confs is _sentinel else self.max_confs
|
|
121
|
+
self.max_mmff_energy = 20
|
|
122
|
+
case Mode.RAPID:
|
|
123
|
+
self.max_confs = 50 if self.max_confs is _sentinel else self.max_confs
|
|
124
|
+
self.conf_opt_method = Method.GFN0_XTB
|
|
125
|
+
case _:
|
|
126
|
+
raise NotImplementedError(f"Unsupported mode: {self.mode}")
|
|
127
|
+
|
|
128
|
+
return self
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class iMTDSpeeds(LowercaseStrEnum):
|
|
132
|
+
MEGAQUICK = "megaquick"
|
|
133
|
+
SUPERQUICK = "superquick"
|
|
134
|
+
QUICK = "quick"
|
|
135
|
+
NORMAL = "normal"
|
|
136
|
+
EXTENSIVE = "extensive"
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
class iMTDSettings(ConformerGenSettings, ABC):
|
|
140
|
+
"""
|
|
141
|
+
Settings for iMTD style conformer generation.
|
|
142
|
+
|
|
143
|
+
RECKLESS:
|
|
144
|
+
- GFN-FF//MTD(GFN-FF)
|
|
145
|
+
- Megaquick
|
|
146
|
+
- No GC
|
|
147
|
+
- No rotamer metadynamics
|
|
148
|
+
- Energy window = 5.0
|
|
149
|
+
- Run scaling factor = 0.5
|
|
150
|
+
- 6 MTD runs
|
|
151
|
+
RAPID:
|
|
152
|
+
- GFN0//MTD(GFN-FF)
|
|
153
|
+
- Superquick
|
|
154
|
+
- No GC
|
|
155
|
+
- No rotamer metadynamics
|
|
156
|
+
- Energy window = 5.0
|
|
157
|
+
- Run scaling factor = 0.5
|
|
158
|
+
- 6 MTD runs
|
|
159
|
+
CAREFUL:
|
|
160
|
+
- GFN2//MTD(GFN-FF)
|
|
161
|
+
- Quick
|
|
162
|
+
- GC (for iMTD-GC)
|
|
163
|
+
- Rotamer metadynamics (for iMTD-GC)
|
|
164
|
+
- Energy window = 5.0
|
|
165
|
+
- Run scaling factor = 0.5
|
|
166
|
+
- 6 MTD runs
|
|
167
|
+
METICULOUS:
|
|
168
|
+
- GFN2//MTD(GFN2)
|
|
169
|
+
- "Normal"
|
|
170
|
+
- GC (for iMTD-GC)
|
|
171
|
+
- Rotamer metadynamics (for iMTD-GC)
|
|
172
|
+
- Energy window = 6.0
|
|
173
|
+
- Run scaling factor = 1
|
|
174
|
+
- 14 MTD runs (2 with extreme values)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
See https://github.com/crest-lab/crest/blob/5ca82feb2ec4df30a0129db957163c934f085952/src/choose_settings.f90#L202
|
|
178
|
+
and https://github.com/crest-lab/crest/blob/5ca82feb2ec4df30a0129db957163c934f085952/src/confparse.f90#L825
|
|
179
|
+
for how quick, superquick, and megaquick are defined.
|
|
180
|
+
|
|
181
|
+
Additional notes:
|
|
182
|
+
Extensive mode
|
|
183
|
+
- GC
|
|
184
|
+
- Rotamer metadynamics
|
|
185
|
+
- Energy window = 8.0
|
|
186
|
+
- Run scaling factor = 2
|
|
187
|
+
- 14 MTD runs (2 with extreme values)
|
|
188
|
+
|
|
189
|
+
--NCI may switch things to QUICK?
|
|
190
|
+
|
|
191
|
+
Inherited:
|
|
192
|
+
:param mode: Mode for calculations
|
|
193
|
+
:param conf_opt_method: method for the optimization
|
|
194
|
+
:param screening: post-generation screening settings (not used)
|
|
195
|
+
:param constraints: constraints to add
|
|
196
|
+
:param nci: add an ellipsoide potential around the input structure
|
|
197
|
+
|
|
198
|
+
New:
|
|
199
|
+
:param mtd_method: method for the metadynamics
|
|
200
|
+
:param speed: speed of the calculations (CREST specific setting)
|
|
201
|
+
:param reopt: re-optimize conformers (corrects for the lack of rotamer metadynamics and GC)
|
|
202
|
+
:param free_energy_weights: calculate frequencies and re-weight based on free energies
|
|
203
|
+
"""
|
|
204
|
+
|
|
205
|
+
mtd_method: XTBMethod = Method.GFN_FF
|
|
206
|
+
mtd_runtype: str = "imtd-gc"
|
|
207
|
+
|
|
208
|
+
speed: iMTDSpeeds = iMTDSpeeds.QUICK
|
|
209
|
+
reopt: bool = _sentinel # type: ignore [assignment]
|
|
210
|
+
free_energy_weights: bool = False
|
|
211
|
+
|
|
212
|
+
@model_validator(mode="after")
|
|
213
|
+
def validate_and_build_imtdgc_settings(self) -> Self:
|
|
214
|
+
match self.mode:
|
|
215
|
+
case Mode.MANUAL:
|
|
216
|
+
if self.reopt is _sentinel:
|
|
217
|
+
raise ValueError("Must specify reopt with MANUAL mode")
|
|
218
|
+
case Mode.RECKLESS: # GFN-FF//MTD(GFN-FF)
|
|
219
|
+
self.max_confs = 20 if self.max_confs is _sentinel else self.max_confs
|
|
220
|
+
self.speed = iMTDSpeeds.MEGAQUICK
|
|
221
|
+
self.reopt = check_sentinel(self.reopt, True)
|
|
222
|
+
case Mode.RAPID: # GFN0//MTD(GFN-FF)
|
|
223
|
+
self.max_confs = 50 if self.max_confs is _sentinel else self.max_confs
|
|
224
|
+
self.speed = iMTDSpeeds.SUPERQUICK
|
|
225
|
+
self.conf_opt_method = Method.GFN0_XTB
|
|
226
|
+
self.reopt = check_sentinel(self.reopt, True)
|
|
227
|
+
case Mode.CAREFUL: # GFN2//MTD(GFN-FF)
|
|
228
|
+
self.speed = iMTDSpeeds.QUICK
|
|
229
|
+
self.conf_opt_method = Method.GFN2_XTB
|
|
230
|
+
self.reopt = check_sentinel(self.reopt, False)
|
|
231
|
+
case Mode.METICULOUS: # GFN2//MTD(GFN2)
|
|
232
|
+
self.speed = iMTDSpeeds.NORMAL
|
|
233
|
+
self.mtd_method = Method.GFN2_XTB
|
|
234
|
+
self.conf_opt_method = Method.GFN2_XTB
|
|
235
|
+
self.reopt = check_sentinel(self.reopt, False)
|
|
236
|
+
# case Mode.EXTREME: # GFN2//MTD(GFN2)
|
|
237
|
+
# self.mtd_method = Method.GFN2_XTB
|
|
238
|
+
# self.conf_opt_method = Method.GFN2_XTB
|
|
239
|
+
# self.speed = iMTDSpeeds.EXTENSIVE
|
|
240
|
+
# self.reopt = check_sentinel(self.reopt, False)
|
|
241
|
+
case _:
|
|
242
|
+
raise NotImplementedError(f"Unsupported mode: {self.mode}")
|
|
243
|
+
|
|
244
|
+
return self
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
class iMTDGCSettings(iMTDSettings):
|
|
248
|
+
run_type: str = "imtdgc"
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
class iMTDsMTDSettings(iMTDSettings):
|
|
252
|
+
run_type: str = "imtd-smtd"
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
class ConformerGenMixin(BaseModel):
|
|
256
|
+
"""
|
|
257
|
+
Mixin for workflows that need conformer generation.
|
|
258
|
+
|
|
259
|
+
:param conf_gen_mode: Mode for calculations
|
|
260
|
+
:param conf_gen_settings: settings for conformer generation
|
|
261
|
+
"""
|
|
262
|
+
|
|
263
|
+
conf_gen_mode: Mode = Mode.RAPID
|
|
264
|
+
conf_gen_settings: ConformerGenSettings = _sentinel # type: ignore [assignment]
|
|
265
|
+
constraints: Sequence[Constraint] = tuple()
|
|
266
|
+
|
|
267
|
+
@model_validator(mode="after")
|
|
268
|
+
def validate_and_build_conf_gen_settings(self) -> Self:
|
|
269
|
+
"""Validate and build the ConformerGenSettings."""
|
|
270
|
+
if self.conf_gen_settings is not _sentinel and self.conf_gen_mode != Mode.MANUAL:
|
|
271
|
+
raise ValueError("Cannot specify conf_gen_settings with non-MANUAL mode")
|
|
272
|
+
|
|
273
|
+
match self.conf_gen_mode:
|
|
274
|
+
case Mode.MANUAL:
|
|
275
|
+
if self.conf_gen_settings is _sentinel:
|
|
276
|
+
raise ValueError("Must specify conf_gen_settings with MANUAL mode")
|
|
277
|
+
|
|
278
|
+
case Mode.RECKLESS | Mode.RAPID:
|
|
279
|
+
# ETKDGSettings will error if constraints added
|
|
280
|
+
self.conf_gen_settings = ETKDGSettings(mode=self.conf_gen_mode, constraints=self.constraints)
|
|
281
|
+
case Mode.CAREFUL | Mode.METICULOUS:
|
|
282
|
+
self.conf_gen_settings = iMTDSettings(mode=self.conf_gen_mode, constraints=self.constraints)
|
|
283
|
+
|
|
284
|
+
case _:
|
|
285
|
+
raise NotImplementedError(f"Unsupported mode: {self.conf_gen_mode}")
|
|
286
|
+
|
|
287
|
+
return self
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
class ConformerSearchMixin(ConformerGenMixin, MultiStageOptMixin):
|
|
291
|
+
"""
|
|
292
|
+
Mixin for workflows that need conformer search—a combination of conformer generation and optimization.
|
|
293
|
+
|
|
294
|
+
Inherited:
|
|
295
|
+
:param conf_gen_mode: Mode for conformer generation
|
|
296
|
+
:param mso_mode: Mode for MultiStageOptSettings
|
|
297
|
+
:param conf_gen_settings: settings for conformer generation
|
|
298
|
+
:param multistage_opt_settings: set by mso_mode unless mode=MANUAL (ignores additional settings if set)
|
|
299
|
+
:param solvent: solvent to use
|
|
300
|
+
:param xtb_preopt: pre-optimize with xtb (sets based on mode when None)
|
|
301
|
+
:param constraints: constraints to add (diamond inheritance, works as expected)
|
|
302
|
+
:param transition_state: whether this is a transition state
|
|
303
|
+
|
|
304
|
+
Overridden:
|
|
305
|
+
:param frequencies: whether to calculate frequencies (turned off)
|
|
306
|
+
"""
|
|
307
|
+
|
|
308
|
+
frequencies: bool = False
|
|
309
|
+
|
|
310
|
+
def __str__(self) -> str:
|
|
311
|
+
"""Return a string representation of the ConformerSearch workflow."""
|
|
312
|
+
return repr(self)
|
|
313
|
+
|
|
314
|
+
def __repr__(self) -> str:
|
|
315
|
+
"""Return a string representation of the ConformerSearch workflow."""
|
|
316
|
+
return f"<{type(self).__name__} {self.conf_gen_mode.name} {self.mso_mode.name}>"
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
class ConformerSearchWorkflow(ConformerSearchMixin, Workflow):
|
|
320
|
+
"""
|
|
321
|
+
ConformerSearch Workflow.
|
|
322
|
+
|
|
323
|
+
Inherited:
|
|
324
|
+
:param initial_molecule: Molecule of interest
|
|
325
|
+
:param conf_gen_mode: Mode for calculations
|
|
326
|
+
:param conf_gen_settings: settings for conformer generation
|
|
327
|
+
:param mso_mode: Mode for MultiStageOptSettings
|
|
328
|
+
:param multistage_opt_settings: set by mode unless mode=MANUAL (ignores additional settings if set)
|
|
329
|
+
:param solvent: solvent to use
|
|
330
|
+
:param xtb_preopt: pre-optimize with xtb (sets based on mode when None)
|
|
331
|
+
:param constraints: constraints to add
|
|
332
|
+
:param transition_state: whether this is a transition state
|
|
333
|
+
:param frequencies: whether to calculate frequencies (turned off)
|
|
334
|
+
|
|
335
|
+
Ignored:
|
|
336
|
+
:param mode: Mode to use (not used)
|
|
337
|
+
|
|
338
|
+
New:
|
|
339
|
+
:param conformer_uuids: list of UUIDs of the Molecules generated
|
|
340
|
+
:param energies: energies of the molecules
|
|
341
|
+
"""
|
|
342
|
+
|
|
343
|
+
# Results
|
|
344
|
+
conformer_uuids: list[list[UUID | None]] = Field(default_factory=list)
|
|
345
|
+
energies: list[float] = Field(default_factory=list)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
from pydantic import NonNegativeFloat, NonNegativeInt
|
|
2
|
+
|
|
3
|
+
from ..base import Base
|
|
4
|
+
from ..settings import Settings
|
|
5
|
+
from ..types import UUID, FloatPerAtom, Matrix3x3, Vector3D
|
|
6
|
+
from .workflow import Workflow
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PropertyCubePoint(Base):
|
|
10
|
+
x: float
|
|
11
|
+
y: float
|
|
12
|
+
z: float
|
|
13
|
+
val: float
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class PropertyCube(Base):
|
|
17
|
+
"""
|
|
18
|
+
Represents a "cubefile" of some property.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
cube_data: list[PropertyCubePoint]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class MolecularOrbitalCube(PropertyCube):
|
|
25
|
+
"""
|
|
26
|
+
Inherits `cube_data`.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
occupation: NonNegativeInt
|
|
30
|
+
energy: float
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class ElectronicPropertiesWorkflow(Workflow):
|
|
34
|
+
"""
|
|
35
|
+
Workflow for computing electronic properties!
|
|
36
|
+
|
|
37
|
+
Inherited
|
|
38
|
+
:param initial_molecule: molecule of interest
|
|
39
|
+
|
|
40
|
+
Config settings:
|
|
41
|
+
:param settings: the level of theory to use
|
|
42
|
+
:param compute_density_cube: whether or not to compute the density on a cube
|
|
43
|
+
:param compute_electrostatic_potential_cube: whether or not to compute the electrostatic potential on a cube
|
|
44
|
+
:param compute_num_occupied_orbitals: how many occupied orbitals to save
|
|
45
|
+
:param compute_num_virtual_orbitals: how many virtual orbitals to save
|
|
46
|
+
|
|
47
|
+
Populated while running:
|
|
48
|
+
:param calculation: the UUID of the calculation
|
|
49
|
+
:param dipole: the dipole moment
|
|
50
|
+
:param quadrupole: the quadrupole moment
|
|
51
|
+
:param mulliken_charges: the Mulliken charges
|
|
52
|
+
:param lowdin_charges: the Lowdin charges
|
|
53
|
+
:param wiberg_bond_orders: the Wiberg bond orders (`atom1`, `atom2`, `order`)
|
|
54
|
+
:param mayer_bond_orders: the Mayer bond orders (`atom1`, `atom2`, `order`)
|
|
55
|
+
:param density_cube: the electron density, as a cube
|
|
56
|
+
:param electrostatic_potential_cube: the electrostatic potential, as a cube
|
|
57
|
+
:param molecular_orbitals_alpha: for open-shell species (UHF/ROHF), a dict containing the alpha MOs
|
|
58
|
+
(The key is the absolute orbital index.)
|
|
59
|
+
:param molecular_orbitals_beta: for open-shell species (UHF/ROHF), a dict containing the beta MOs
|
|
60
|
+
(The key is the absolute orbital index.)
|
|
61
|
+
:param molecular_orbitals: for closed-shell species (RHF), a dict containing the MOs
|
|
62
|
+
(The key is the absolute orbital index.)
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
settings: Settings
|
|
66
|
+
compute_density_cube: bool = True
|
|
67
|
+
compute_electrostatic_potential_cube: bool = True
|
|
68
|
+
compute_num_occupied_orbitals: NonNegativeInt = 1
|
|
69
|
+
compute_num_virtual_orbitals: NonNegativeInt = 1
|
|
70
|
+
|
|
71
|
+
calculation: UUID | None = None
|
|
72
|
+
|
|
73
|
+
dipole: Vector3D | None = None
|
|
74
|
+
quadrupole: Matrix3x3 | None = None
|
|
75
|
+
|
|
76
|
+
mulliken_charges: FloatPerAtom | None = None
|
|
77
|
+
lowdin_charges: FloatPerAtom | None = None
|
|
78
|
+
|
|
79
|
+
wiberg_bond_orders: list[tuple[NonNegativeInt, NonNegativeInt, NonNegativeFloat]] = []
|
|
80
|
+
mayer_bond_orders: list[tuple[NonNegativeInt, NonNegativeInt, NonNegativeFloat]] = []
|
|
81
|
+
|
|
82
|
+
density_cube: PropertyCube | None = None
|
|
83
|
+
electrostatic_potential_cube: PropertyCube | None = None
|
|
84
|
+
molecular_orbitals_alpha: dict[NonNegativeInt, MolecularOrbitalCube] = {}
|
|
85
|
+
molecular_orbitals_beta: dict[NonNegativeInt, MolecularOrbitalCube] = {}
|
|
86
|
+
molecular_orbitals: dict[NonNegativeInt, MolecularOrbitalCube] = {}
|
|
@@ -9,6 +9,11 @@ from ..types import UUID
|
|
|
9
9
|
from .workflow import Workflow
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
class MolecularDynamicsInitialization(LowercaseStrEnum):
|
|
13
|
+
RANDOM = "random"
|
|
14
|
+
QUASICLASSICAL = "quasiclassical"
|
|
15
|
+
|
|
16
|
+
|
|
12
17
|
class ThermodynamicEnsemble(LowercaseStrEnum):
|
|
13
18
|
NPT = "npt"
|
|
14
19
|
NVT = "nvt"
|
|
@@ -18,22 +23,24 @@ class ThermodynamicEnsemble(LowercaseStrEnum):
|
|
|
18
23
|
class Frame(Base):
|
|
19
24
|
index: int # what number frame this is within the MD simulation
|
|
20
25
|
|
|
21
|
-
|
|
26
|
+
calculation_uuid: UUID | None = None # UUID of calculation
|
|
22
27
|
|
|
23
28
|
pressure: float
|
|
24
29
|
temperature: float
|
|
30
|
+
volume: float
|
|
25
31
|
energy: float
|
|
26
32
|
|
|
27
33
|
|
|
28
34
|
class MolecularDynamicsSettings(Base):
|
|
29
35
|
ensemble: ThermodynamicEnsemble = ThermodynamicEnsemble.NVT
|
|
36
|
+
initialization: MolecularDynamicsInitialization = MolecularDynamicsInitialization.RANDOM
|
|
30
37
|
|
|
31
38
|
timestep: PositiveFloat = 1.0 # fs
|
|
32
39
|
num_steps: PositiveInt = 500
|
|
33
40
|
|
|
34
41
|
confining_constraint: SphericalHarmonicConstraint | None = None
|
|
35
42
|
|
|
36
|
-
temperature: PositiveFloat
|
|
43
|
+
temperature: PositiveFloat = 300 # K
|
|
37
44
|
pressure: PositiveFloat | None = None # atm
|
|
38
45
|
|
|
39
46
|
langevin_thermostat_timescale: PositiveFloat = 100 # fs
|
|
@@ -46,7 +53,7 @@ class MolecularDynamicsSettings(Base):
|
|
|
46
53
|
"""Check that NVT ensemble always has temperature defined, and that NPT has temp and pressure defined."""
|
|
47
54
|
if self.ensemble == ThermodynamicEnsemble.NVT and self.temperature is None:
|
|
48
55
|
raise ValueError("NVT ensemble must have a temperature defined")
|
|
49
|
-
|
|
56
|
+
elif self.ensemble == ThermodynamicEnsemble.NPT and (self.temperature is None or self.pressure is None):
|
|
50
57
|
raise ValueError("NPT ensemble must have both temperature and pressure defined")
|
|
51
58
|
return self
|
|
52
59
|
|
|
@@ -27,14 +27,14 @@ class MultiStageOptSettings(BaseModel):
|
|
|
27
27
|
wB97M-D3BJ/def2-TZVPPD//wB97X-3c//r²SCAN-3c with GFN2-xTB pre-opt
|
|
28
28
|
|
|
29
29
|
Notes:
|
|
30
|
-
- No solvent in
|
|
30
|
+
- No solvent in any optimizations when using Modes
|
|
31
31
|
- If solvent: xTB singlepoints use CPCMX, xTB optimizations use ALBP, all else use CPCM
|
|
32
32
|
- Allows a single point to be called with no optimization
|
|
33
33
|
|
|
34
34
|
:param mode: Mode for settings
|
|
35
35
|
:param optimization_settings: list of opt settings to apply successively
|
|
36
36
|
:param singlepoint_settings: final single point settings
|
|
37
|
-
:param solvent: solvent to use
|
|
37
|
+
:param solvent: solvent to use for singlepoint
|
|
38
38
|
:param xtb_preopt: pre-optimize with xtb (sets based on mode when None)
|
|
39
39
|
:param constraints: constraints for optimization
|
|
40
40
|
:param transition_state: whether this is a transition state
|
|
@@ -44,7 +44,7 @@ class MultiStageOptSettings(BaseModel):
|
|
|
44
44
|
>>> msos
|
|
45
45
|
<MultiStageOptSettings RAPID>
|
|
46
46
|
>>> msos.level_of_theory
|
|
47
|
-
'r2scan_3c/cpcm(water)//gfn2_xtb
|
|
47
|
+
'r2scan_3c/cpcm(water)//gfn2_xtb'
|
|
48
48
|
"""
|
|
49
49
|
|
|
50
50
|
mode: Mode
|
|
@@ -78,7 +78,7 @@ class MultiStageOptSettings(BaseModel):
|
|
|
78
78
|
|
|
79
79
|
>>> msos = MultiStageOptSettings(mode=Mode.RAPID, solvent="hexane")
|
|
80
80
|
>>> msos.level_of_theory
|
|
81
|
-
'r2scan_3c/cpcm(hexane)//gfn2_xtb
|
|
81
|
+
'r2scan_3c/cpcm(hexane)//gfn2_xtb'
|
|
82
82
|
"""
|
|
83
83
|
methods = [self.singlepoint_settings] if self.singlepoint_settings else []
|
|
84
84
|
methods += reversed(self.optimization_settings)
|
|
@@ -148,14 +148,14 @@ class MultiStageOptSettings(BaseModel):
|
|
|
148
148
|
match mode:
|
|
149
149
|
case Mode.RECKLESS:
|
|
150
150
|
self.xtb_preopt = False
|
|
151
|
-
self.optimization_settings = [opt(Method.GFN_FF,
|
|
151
|
+
self.optimization_settings = [opt(Method.GFN_FF, freq=self.frequencies)]
|
|
152
152
|
self.singlepoint_settings = sp(Method.GFN2_XTB, solvent=self.solvent)
|
|
153
153
|
|
|
154
154
|
case Mode.RAPID:
|
|
155
155
|
self.xtb_preopt = bool(self.xtb_preopt)
|
|
156
156
|
self.optimization_settings = [
|
|
157
157
|
*gfn0_pre_opt * self.xtb_preopt,
|
|
158
|
-
opt(Method.GFN2_XTB,
|
|
158
|
+
opt(Method.GFN2_XTB, freq=self.frequencies),
|
|
159
159
|
]
|
|
160
160
|
self.singlepoint_settings = sp(Method.R2SCAN3C, solvent=self.solvent)
|
|
161
161
|
|
|
@@ -163,7 +163,7 @@ class MultiStageOptSettings(BaseModel):
|
|
|
163
163
|
self.xtb_preopt = (self.xtb_preopt is None) or self.xtb_preopt
|
|
164
164
|
self.optimization_settings = [
|
|
165
165
|
*gfn2_pre_opt * self.xtb_preopt,
|
|
166
|
-
opt(Method.R2SCAN3C,
|
|
166
|
+
opt(Method.R2SCAN3C, freq=self.frequencies),
|
|
167
167
|
]
|
|
168
168
|
self.singlepoint_settings = sp(Method.WB97X3C, solvent=self.solvent)
|
|
169
169
|
|
|
@@ -171,8 +171,8 @@ class MultiStageOptSettings(BaseModel):
|
|
|
171
171
|
self.xtb_preopt = (self.xtb_preopt is None) or self.xtb_preopt
|
|
172
172
|
self.optimization_settings = [
|
|
173
173
|
*gfn2_pre_opt * self.xtb_preopt,
|
|
174
|
-
opt(Method.R2SCAN3C
|
|
175
|
-
opt(Method.WB97X3C,
|
|
174
|
+
opt(Method.R2SCAN3C),
|
|
175
|
+
opt(Method.WB97X3C, freq=self.frequencies),
|
|
176
176
|
]
|
|
177
177
|
self.singlepoint_settings = sp(Method.WB97MD3BJ, "def2-TZVPPD", solvent=self.solvent)
|
|
178
178
|
|
|
@@ -191,7 +191,7 @@ class MultiStageOptWorkflow(Workflow, MultiStageOptSettings):
|
|
|
191
191
|
:param mode: Mode for workflow
|
|
192
192
|
:param optimization_settings: list of opt settings to apply successively
|
|
193
193
|
:param singlepoint_settings: final single point settings
|
|
194
|
-
:param solvent: solvent to use
|
|
194
|
+
:param solvent: solvent to use for singlepoint
|
|
195
195
|
:param xtb_preopt: pre-optimize with xtb (sets based on mode when None)
|
|
196
196
|
:param constraints: constraints for optimization
|
|
197
197
|
:param transition_state: whether this is a transition state
|
|
@@ -206,7 +206,7 @@ class MultiStageOptWorkflow(Workflow, MultiStageOptSettings):
|
|
|
206
206
|
>>> msow
|
|
207
207
|
<MultiStageOptWorkflow RAPID>
|
|
208
208
|
>>> msow.level_of_theory
|
|
209
|
-
'r2scan_3c/cpcm(water)//gfn2_xtb
|
|
209
|
+
'r2scan_3c/cpcm(water)//gfn2_xtb'
|
|
210
210
|
"""
|
|
211
211
|
|
|
212
212
|
# Populated while running the workflow
|
|
@@ -228,7 +228,7 @@ class MultiStageOptMixin(BaseModel):
|
|
|
228
228
|
Mixin for workflows that use MultiStageOptSettings.
|
|
229
229
|
"""
|
|
230
230
|
|
|
231
|
-
mso_mode: Mode
|
|
231
|
+
mso_mode: Mode = Mode.AUTO
|
|
232
232
|
# Need to use a sentinel object to make both mypy and pydantic happy
|
|
233
233
|
multistage_opt_settings: MultiStageOptSettings = _sentinel_msos # type: ignore [assignment]
|
|
234
234
|
solvent: Solvent | None = None
|
|
@@ -265,3 +265,74 @@ class MultiStageOptMixin(BaseModel):
|
|
|
265
265
|
)
|
|
266
266
|
|
|
267
267
|
return self
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
def build_mso_settings(
|
|
271
|
+
sp_method: Method,
|
|
272
|
+
sp_basis_set: str | None,
|
|
273
|
+
opt_methods: list[Method],
|
|
274
|
+
opt_basis_sets: list[str | None],
|
|
275
|
+
mode: Mode = Mode.MANUAL,
|
|
276
|
+
solvent: Solvent | None = None,
|
|
277
|
+
use_solvent_for_opt: bool = False,
|
|
278
|
+
constraints: list[Constraint] | None = None,
|
|
279
|
+
transition_state: bool = False,
|
|
280
|
+
frequencies: bool = True,
|
|
281
|
+
) -> MultiStageOptSettings:
|
|
282
|
+
"""
|
|
283
|
+
Helper function to construct multi-stage opt settings objects manually.
|
|
284
|
+
|
|
285
|
+
There's no xTB pre-optimization here - add that yourself!
|
|
286
|
+
|
|
287
|
+
:param optimization_settings: list of opt settings to apply successively
|
|
288
|
+
:param singlepoint_settings: final single point settings
|
|
289
|
+
:param mode: Mode for settings, defaults to `MANUAL`
|
|
290
|
+
:param solvent: solvent to use
|
|
291
|
+
:param use_solvent_for_opt: whether to conduct opts with solvent
|
|
292
|
+
:param constraints: constraints for optimization
|
|
293
|
+
:param transition_state: whether this is a transition state
|
|
294
|
+
:param frequencies: whether to calculate frequencies
|
|
295
|
+
:returns: the final multistage opt settings
|
|
296
|
+
"""
|
|
297
|
+
if constraints is None:
|
|
298
|
+
constraints = []
|
|
299
|
+
|
|
300
|
+
opt_settings = OptimizationSettings(constraints=constraints, transition_state=transition_state)
|
|
301
|
+
|
|
302
|
+
OPT = [Task.OPTIMIZE if not transition_state else Task.OPTIMIZE_TS]
|
|
303
|
+
|
|
304
|
+
def opt(method: Method, basis_set: str | None = None, solvent: Solvent | None = None, freq: bool = False) -> Settings:
|
|
305
|
+
"""Generates optimization settings."""
|
|
306
|
+
model = "alpb" if method in XTB_METHODS else "cpcm"
|
|
307
|
+
|
|
308
|
+
return Settings(
|
|
309
|
+
method=method,
|
|
310
|
+
basis_set=basis_set,
|
|
311
|
+
tasks=OPT + [Task.FREQUENCIES] * freq,
|
|
312
|
+
solvent_settings=SolventSettings(solvent=solvent, model=model) if (solvent and use_solvent_for_opt) else None,
|
|
313
|
+
opt_settings=opt_settings,
|
|
314
|
+
)
|
|
315
|
+
|
|
316
|
+
def sp(method: Method, basis_set: str | None = None, solvent: Solvent | None = None) -> Settings:
|
|
317
|
+
"""Generate singlepoint settings."""
|
|
318
|
+
model = "cpcmx" if method in XTB_METHODS else "cpcm"
|
|
319
|
+
|
|
320
|
+
return Settings(
|
|
321
|
+
method=method,
|
|
322
|
+
basis_set=basis_set,
|
|
323
|
+
tasks=[Task.ENERGY],
|
|
324
|
+
solvent_settings=SolventSettings(solvent=solvent, model=model) if solvent else None,
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
return MultiStageOptSettings(
|
|
328
|
+
mode=mode,
|
|
329
|
+
optimization_settings=[
|
|
330
|
+
opt(method=method, basis_set=basis_set, solvent=solvent, freq=frequencies) for method, basis_set in zip(opt_methods, opt_basis_sets, strict=True)
|
|
331
|
+
],
|
|
332
|
+
singlepoint_settings=sp(method=sp_method, basis_set=sp_basis_set, solvent=solvent),
|
|
333
|
+
solvent=solvent,
|
|
334
|
+
xtb_preopt=False,
|
|
335
|
+
constraints=constraints,
|
|
336
|
+
transition_state=transition_state,
|
|
337
|
+
frequencies=frequencies,
|
|
338
|
+
)
|
|
@@ -1,19 +1,56 @@
|
|
|
1
|
-
from typing import Any
|
|
1
|
+
from typing import Any, TypeVar
|
|
2
|
+
|
|
3
|
+
from pydantic import ValidationInfo, field_validator, model_validator
|
|
2
4
|
|
|
3
5
|
from ..mode import Mode
|
|
4
6
|
from ..solvent import Solvent
|
|
5
7
|
from ..types import UUID
|
|
8
|
+
from .multistage_opt import MultiStageOptMixin
|
|
6
9
|
from .workflow import Workflow
|
|
7
10
|
|
|
11
|
+
_T = TypeVar("_T")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class RedoxPotentialWorkflow(Workflow, MultiStageOptMixin):
|
|
15
|
+
"""
|
|
16
|
+
Workflow for computing spin states of molecules.
|
|
17
|
+
|
|
18
|
+
Uses the modes from MultiStageOptSettings.
|
|
19
|
+
|
|
20
|
+
Inherited
|
|
21
|
+
:param initial_molecule: Molecule of interest
|
|
22
|
+
:param mode: Mode for workflow
|
|
23
|
+
:param multistage_opt_settings: set by mode unless mode=MANUAL (ignores additional settings if set)
|
|
24
|
+
:param xtb_preopt: pre-optimize with xtb (sets based on mode when None)
|
|
25
|
+
:param constraints: constraints to add
|
|
26
|
+
:param transition_state: whether this is a transition state
|
|
27
|
+
:param frequencies: whether to calculate frequencies
|
|
28
|
+
|
|
29
|
+
Overridden:
|
|
30
|
+
:param mso_mode: Mode for MultiStageOptSettings
|
|
31
|
+
:param solvent: solvent to use for optimization
|
|
32
|
+
|
|
33
|
+
New:
|
|
34
|
+
:param reduction: whether or not to calculate the reduction half-reaction
|
|
35
|
+
:param oxidation: whether or not to calculate the oxidation half-reaction
|
|
36
|
+
:param neutral_molecule: UUID of the calculation for the neutral molecule
|
|
37
|
+
:param anion_molecule: UUID of the calculation for the anion molecule
|
|
38
|
+
:param cation_molecule: UUID of the calculation for the cation molecule
|
|
39
|
+
:param reduction_potential: the final potential, in V
|
|
40
|
+
:param oxidation_potential: the final potential, in V
|
|
41
|
+
|
|
42
|
+
Legacy:
|
|
43
|
+
:param redox_type: one of "reduction" or "oxidation"
|
|
44
|
+
:param redox_potential: the corresponding potential, in V
|
|
45
|
+
"""
|
|
8
46
|
|
|
9
|
-
class RedoxPotentialWorkflow(Workflow):
|
|
10
|
-
mode: Mode = Mode.RAPID
|
|
11
47
|
solvent: Solvent = Solvent.ACETONITRILE
|
|
48
|
+
|
|
12
49
|
reduction: bool = True
|
|
13
50
|
oxidation: bool = True
|
|
14
51
|
|
|
15
52
|
# legacy values - remove in future release!
|
|
16
|
-
redox_type:
|
|
53
|
+
redox_type: str | None = None
|
|
17
54
|
redox_potential: float | None = None
|
|
18
55
|
|
|
19
56
|
# uuids
|
|
@@ -24,6 +61,33 @@ class RedoxPotentialWorkflow(Workflow):
|
|
|
24
61
|
reduction_potential: float | None = None
|
|
25
62
|
oxidation_potential: float | None = None
|
|
26
63
|
|
|
64
|
+
@field_validator("solvent", mode="before")
|
|
65
|
+
@classmethod
|
|
66
|
+
def only_mecn_please(cls, val: Solvent | None) -> Solvent:
|
|
67
|
+
"""Only MeCN please!"""
|
|
68
|
+
if val != Solvent.ACETONITRILE:
|
|
69
|
+
raise ValueError("Only acetonitrile permitted!")
|
|
70
|
+
|
|
71
|
+
return val
|
|
72
|
+
|
|
73
|
+
@field_validator("constraints", "transition_state")
|
|
74
|
+
@classmethod
|
|
75
|
+
def turned_off(cls, value: _T, info: ValidationInfo) -> _T:
|
|
76
|
+
if value:
|
|
77
|
+
raise ValueError(f"{info.field_name} not supported in redox potential workflows.")
|
|
78
|
+
|
|
79
|
+
return value
|
|
80
|
+
|
|
81
|
+
@model_validator(mode="before")
|
|
82
|
+
@classmethod
|
|
83
|
+
def set_mode_and_mso_mode(cls, values: dict[str, Any]) -> dict[str, Any]:
|
|
84
|
+
"""Set the MultiStageOptSettings mode to match current redox potential mode, and select mode if `Auto`."""
|
|
85
|
+
if ("mode" not in values) or (values["mode"] == Mode.AUTO):
|
|
86
|
+
values["mode"] = Mode.RAPID
|
|
87
|
+
|
|
88
|
+
values["mso_mode"] = values["mode"]
|
|
89
|
+
return values
|
|
90
|
+
|
|
27
91
|
def model_post_init(self, __context: Any) -> None:
|
|
28
92
|
"""Keep back-compatible with old schema."""
|
|
29
93
|
if self.redox_type == "oxidation":
|
stjames/workflows/spin_states.py
CHANGED
|
@@ -51,7 +51,7 @@ class SpinStatesWorkflow(Workflow, MultiStageOptMixin):
|
|
|
51
51
|
:param initial_molecule: Molecule of interest
|
|
52
52
|
:param mode: Mode for workflow
|
|
53
53
|
:param multistage_opt_settings: set by mode unless mode=MANUAL (ignores additional settings if set)
|
|
54
|
-
:param solvent: solvent to use
|
|
54
|
+
:param solvent: solvent to use for optimization
|
|
55
55
|
:param xtb_preopt: pre-optimize with xtb (sets based on mode when None)
|
|
56
56
|
:param constraints: constraints to add
|
|
57
57
|
:param transition_state: whether this is a transition state
|
|
@@ -4,15 +4,15 @@ stjames/atom.py,sha256=w7q-x9xpBw4sJ1WGrWt65WAaStxhz-m7dugXCYEOpq4,2064
|
|
|
4
4
|
stjames/base.py,sha256=9PvUjBeVSkmA3TaruaB0uvjFMbWYTGKXECISNGAj_AU,1201
|
|
5
5
|
stjames/basis_set.py,sha256=wI3M2q9uPf9jhKpAi4E2DrsyKzloDGLRjAlk7krdYgc,949
|
|
6
6
|
stjames/calculation.py,sha256=O2LwwQ_cOLmDOGXTHA9J71YbUZXigUSbvbLA-fSVm3w,915
|
|
7
|
-
stjames/constraint.py,sha256=
|
|
8
|
-
stjames/correction.py,sha256=
|
|
7
|
+
stjames/constraint.py,sha256=aD4JkNIyya5uh016R68WLYLd0AK6msgki7Q1kAKGzRs,2203
|
|
8
|
+
stjames/correction.py,sha256=ZVErCcj4TPyZeKrdvXVjHa0tFynsCaoy96QZUVxWFM8,413
|
|
9
9
|
stjames/diis_settings.py,sha256=QHc7L-hktkbOWBYr29byTdqL8lWJzKJiY9XW8ha4Qzo,552
|
|
10
10
|
stjames/grid_settings.py,sha256=WrSNGc-8_f87YBZYt9Hh7RbhM4MweADoVzwBMcSqcsE,640
|
|
11
11
|
stjames/int_settings.py,sha256=5HXp8opt5ZyY1UpmfaK7NVloWVLM5jkG0elEEqpVLUo,896
|
|
12
12
|
stjames/message.py,sha256=Rq6QqmHZKecWxYH8fVyXmuoCCPZv8YinvgykSeorXSU,216
|
|
13
|
-
stjames/method.py,sha256=
|
|
13
|
+
stjames/method.py,sha256=a6QQff-0YsutkOTuOcGrdDW76x9ZexiNLdKzzoE1Vcw,1698
|
|
14
14
|
stjames/mode.py,sha256=xw46Cc7f3eTS8i35qECi-8DocAlANhayK3w4akD4HBU,496
|
|
15
|
-
stjames/molecule.py,sha256=
|
|
15
|
+
stjames/molecule.py,sha256=v8NikFHfwOahXSo4VKGSqeHKI2HIoRdNjGE0GkZgNS4,10554
|
|
16
16
|
stjames/opt_settings.py,sha256=gxXGtjy9l-Q5Wen9eO6T6HHRCuS8rfOofdVQIJj0JcI,550
|
|
17
17
|
stjames/periodic_cell.py,sha256=JDCyynpamggTNi_HnTnnotRbeSMBfYc-srhD-IwUnrg,996
|
|
18
18
|
stjames/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -22,7 +22,7 @@ stjames/solvent.py,sha256=u037tmu-9oa21s-WEDZ7VC7nuNVjkqR2ML4JWjWSME4,1158
|
|
|
22
22
|
stjames/status.py,sha256=wTKNcNxStoEHrxxgr_zTyN90NITa3rxMQZzOgrCifEw,332
|
|
23
23
|
stjames/task.py,sha256=OLINRqe66o7t8arffilwmggrF_7TH0L79u6DhGruxV8,329
|
|
24
24
|
stjames/thermochem_settings.py,sha256=ZTLz31v8Ltutde5Nfm0vH5YahWjcfFWfr_R856KffxE,517
|
|
25
|
-
stjames/types.py,sha256=
|
|
25
|
+
stjames/types.py,sha256=CPKR0g_kdFejMjGdKBjtuJRQqfmAZ-uIaSuGR1vBzCQ,245
|
|
26
26
|
stjames/data/__init__.py,sha256=O59Ksp7AIqwOELCWymfCx7YeBzwNOGCMlGQi7tNLqiE,24
|
|
27
27
|
stjames/data/bragg_radii.json,sha256=hhbn-xyZNSdmnULIjN2Cvq-_BGIZIqG243Ls_mey61w,1350
|
|
28
28
|
stjames/data/elements.py,sha256=9BW01LZlyJ0H5s7Q26vUmjZIST41fwOYYrGvmPd7q0w,858
|
|
@@ -30,23 +30,25 @@ stjames/data/isotopes.json,sha256=5ba8QnLrHD_Ypv2xekv2cIRwYrX3MQ19-1FOFtt0RuU,83
|
|
|
30
30
|
stjames/data/nist_isotopes.json,sha256=d5DNk1dX0iB1waEYIRR6JMHuA7AuYwSBEgBvb4EKyhM,14300
|
|
31
31
|
stjames/data/read_nist_isotopes.py,sha256=y10FNjW43QpC45qib7VHsIghEwT7GG5rsNwHdc9osRI,3309
|
|
32
32
|
stjames/data/symbol_element.json,sha256=vl_buFusTqBd-muYQtMLtTDLy2OtBI6KkBeqkaWRQrg,1186
|
|
33
|
-
stjames/workflows/__init__.py,sha256=
|
|
33
|
+
stjames/workflows/__init__.py,sha256=JwcKWrXtrYKJfe6tPbVy6JKSwYxeEaiJWFDL3cVDXf8,363
|
|
34
34
|
stjames/workflows/admet.py,sha256=V8noO0Eb7h2bDFSnj6Pxv4ILm0lGxyVRCi13hE0zmEQ,149
|
|
35
35
|
stjames/workflows/basic_calculation.py,sha256=q48bpab7ZqmRTR4PsGC6bWkuxqkVdJRM8gysevTYXP0,212
|
|
36
|
-
stjames/workflows/bde.py,sha256=
|
|
36
|
+
stjames/workflows/bde.py,sha256=QAcG-ifw_BSyPspOH4EsLNqc3M3b2Xeu4-I2cj-SqoE,9697
|
|
37
37
|
stjames/workflows/conformer.py,sha256=YYwL3l7OaVeea4N9-ihghwa_ieKY6hia9LNbiTraMb0,2732
|
|
38
|
+
stjames/workflows/conformer_search.py,sha256=PjFvotJ3BEMQqsirRxwH7wOIsnV12VuyXQCIyC2NSKE,12485
|
|
38
39
|
stjames/workflows/descriptors.py,sha256=jQ3RuMi7xk799JZ_AL1ARL3yQfWLG03L_VVsK4KIMeY,281
|
|
40
|
+
stjames/workflows/electronic_properties.py,sha256=y4tQl1r6K-Wt_sTjrVyQkq0zukeFQ4KlBrSZgIBZp6Y,3100
|
|
39
41
|
stjames/workflows/fukui.py,sha256=F5tw5jTqBimo_GiXuThhRpoxauZE5YadZjObLFDCba8,348
|
|
40
|
-
stjames/workflows/molecular_dynamics.py,sha256=
|
|
41
|
-
stjames/workflows/multistage_opt.py,sha256=
|
|
42
|
+
stjames/workflows/molecular_dynamics.py,sha256=Y3xUJaCO0A4VHvhEHlqJWu2IrEfruCRTqfnC6SdJu18,2194
|
|
43
|
+
stjames/workflows/multistage_opt.py,sha256=gUHtsl3DRvtaZ13_L8CCzAKwridVRnY-0QBNAN0Fq4g,12964
|
|
42
44
|
stjames/workflows/pka.py,sha256=zpR90Yv2L-D56o2mGArM8027DWpnFFnay31UR9Xh5Nc,774
|
|
43
|
-
stjames/workflows/redox_potential.py,sha256=
|
|
45
|
+
stjames/workflows/redox_potential.py,sha256=Jteftsi9SLu2Z4Cq5XpKn9kwn0z3Hkbyfx4Y1p8rCsw,3651
|
|
44
46
|
stjames/workflows/scan.py,sha256=hL4Hco3Ns0dntjh2G2HhhWmED1mbt0gA_hsglPQ5Vjg,814
|
|
45
|
-
stjames/workflows/spin_states.py,sha256=
|
|
47
|
+
stjames/workflows/spin_states.py,sha256=VcCRr7dV-zpazHTkVWb9qds7_4QpTe-Hz_ECdUG9S_Y,4623
|
|
46
48
|
stjames/workflows/tautomer.py,sha256=kZSCHo2Q7LzqtQjF_WyyxjECkndG49T9QOM12hsUkx8,421
|
|
47
49
|
stjames/workflows/workflow.py,sha256=tIu5naADYgYS7kdW8quvGEWHWosBcrIdcD7L86v-uMQ,976
|
|
48
|
-
stjames-0.0.
|
|
49
|
-
stjames-0.0.
|
|
50
|
-
stjames-0.0.
|
|
51
|
-
stjames-0.0.
|
|
52
|
-
stjames-0.0.
|
|
50
|
+
stjames-0.0.45.dist-info/LICENSE,sha256=i7ehYBS-6gGmbTcgU4mgk28pyOx2kScJ0kcx8n7bWLM,1084
|
|
51
|
+
stjames-0.0.45.dist-info/METADATA,sha256=cXN2IrU7jfMFtL93PeemKYzPCGNGZgV7MlQQSOnJL2A,1628
|
|
52
|
+
stjames-0.0.45.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
|
53
|
+
stjames-0.0.45.dist-info/top_level.txt,sha256=FYCwxl6quhYOAgG-mnPQcCK8vsVM7B8rIUrO-WrQ_PI,8
|
|
54
|
+
stjames-0.0.45.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|