stjames 0.0.44__tar.gz → 0.0.46__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.

Potentially problematic release.


This version of stjames might be problematic. Click here for more details.

Files changed (67) hide show
  1. {stjames-0.0.44/stjames.egg-info → stjames-0.0.46}/PKG-INFO +1 -1
  2. {stjames-0.0.44 → stjames-0.0.46}/pyproject.toml +1 -1
  3. stjames-0.0.46/stjames/constraint.py +74 -0
  4. {stjames-0.0.44 → stjames-0.0.46}/stjames/correction.py +3 -0
  5. {stjames-0.0.44 → stjames-0.0.46}/stjames/diis_settings.py +1 -1
  6. stjames-0.0.46/stjames/method.py +60 -0
  7. {stjames-0.0.44 → stjames-0.0.46}/stjames/molecule.py +5 -7
  8. {stjames-0.0.44 → stjames-0.0.46}/stjames/scf_settings.py +1 -1
  9. {stjames-0.0.44 → stjames-0.0.46}/stjames/types.py +2 -0
  10. stjames-0.0.46/stjames/workflows/__init__.py +55 -0
  11. {stjames-0.0.44 → stjames-0.0.46}/stjames/workflows/bde.py +6 -3
  12. stjames-0.0.46/stjames/workflows/conformer_search.py +352 -0
  13. {stjames-0.0.44 → stjames-0.0.46}/stjames/workflows/descriptors.py +1 -1
  14. stjames-0.0.46/stjames/workflows/electronic_properties.py +96 -0
  15. {stjames-0.0.44 → stjames-0.0.46}/stjames/workflows/fukui.py +1 -1
  16. {stjames-0.0.44 → stjames-0.0.46}/stjames/workflows/molecular_dynamics.py +13 -6
  17. {stjames-0.0.44 → stjames-0.0.46}/stjames/workflows/multistage_opt.py +87 -21
  18. stjames-0.0.46/stjames/workflows/redox_potential.py +102 -0
  19. {stjames-0.0.44 → stjames-0.0.46}/stjames/workflows/scan.py +1 -1
  20. {stjames-0.0.44 → stjames-0.0.46}/stjames/workflows/spin_states.py +2 -2
  21. {stjames-0.0.44 → stjames-0.0.46}/stjames/workflows/tautomer.py +1 -1
  22. {stjames-0.0.44 → stjames-0.0.46/stjames.egg-info}/PKG-INFO +1 -1
  23. {stjames-0.0.44 → stjames-0.0.46}/stjames.egg-info/SOURCES.txt +3 -0
  24. stjames-0.0.46/tests/test_constraints.py +29 -0
  25. stjames-0.0.44/stjames/constraint.py +0 -36
  26. stjames-0.0.44/stjames/method.py +0 -71
  27. stjames-0.0.44/stjames/workflows/__init__.py +0 -13
  28. stjames-0.0.44/stjames/workflows/redox_potential.py +0 -38
  29. {stjames-0.0.44 → stjames-0.0.46}/LICENSE +0 -0
  30. {stjames-0.0.44 → stjames-0.0.46}/README.md +0 -0
  31. {stjames-0.0.44 → stjames-0.0.46}/setup.cfg +0 -0
  32. {stjames-0.0.44 → stjames-0.0.46}/stjames/__init__.py +0 -0
  33. {stjames-0.0.44 → stjames-0.0.46}/stjames/_deprecated_solvent_settings.py +0 -0
  34. {stjames-0.0.44 → stjames-0.0.46}/stjames/atom.py +0 -0
  35. {stjames-0.0.44 → stjames-0.0.46}/stjames/base.py +0 -0
  36. {stjames-0.0.44 → stjames-0.0.46}/stjames/basis_set.py +0 -0
  37. {stjames-0.0.44 → stjames-0.0.46}/stjames/calculation.py +0 -0
  38. {stjames-0.0.44 → stjames-0.0.46}/stjames/data/__init__.py +0 -0
  39. {stjames-0.0.44 → stjames-0.0.46}/stjames/data/bragg_radii.json +0 -0
  40. {stjames-0.0.44 → stjames-0.0.46}/stjames/data/elements.py +0 -0
  41. {stjames-0.0.44 → stjames-0.0.46}/stjames/data/isotopes.json +0 -0
  42. {stjames-0.0.44 → stjames-0.0.46}/stjames/data/nist_isotopes.json +0 -0
  43. {stjames-0.0.44 → stjames-0.0.46}/stjames/data/read_nist_isotopes.py +0 -0
  44. {stjames-0.0.44 → stjames-0.0.46}/stjames/data/symbol_element.json +0 -0
  45. {stjames-0.0.44 → stjames-0.0.46}/stjames/grid_settings.py +0 -0
  46. {stjames-0.0.44 → stjames-0.0.46}/stjames/int_settings.py +0 -0
  47. {stjames-0.0.44 → stjames-0.0.46}/stjames/message.py +0 -0
  48. {stjames-0.0.44 → stjames-0.0.46}/stjames/mode.py +0 -0
  49. {stjames-0.0.44 → stjames-0.0.46}/stjames/opt_settings.py +0 -0
  50. {stjames-0.0.44 → stjames-0.0.46}/stjames/periodic_cell.py +0 -0
  51. {stjames-0.0.44 → stjames-0.0.46}/stjames/py.typed +0 -0
  52. {stjames-0.0.44 → stjames-0.0.46}/stjames/settings.py +0 -0
  53. {stjames-0.0.44 → stjames-0.0.46}/stjames/solvent.py +0 -0
  54. {stjames-0.0.44 → stjames-0.0.46}/stjames/status.py +0 -0
  55. {stjames-0.0.44 → stjames-0.0.46}/stjames/task.py +0 -0
  56. {stjames-0.0.44 → stjames-0.0.46}/stjames/thermochem_settings.py +0 -0
  57. {stjames-0.0.44 → stjames-0.0.46}/stjames/workflows/admet.py +0 -0
  58. {stjames-0.0.44 → stjames-0.0.46}/stjames/workflows/basic_calculation.py +0 -0
  59. {stjames-0.0.44 → stjames-0.0.46}/stjames/workflows/conformer.py +0 -0
  60. {stjames-0.0.44 → stjames-0.0.46}/stjames/workflows/pka.py +0 -0
  61. {stjames-0.0.44 → stjames-0.0.46}/stjames/workflows/workflow.py +0 -0
  62. {stjames-0.0.44 → stjames-0.0.46}/stjames.egg-info/dependency_links.txt +0 -0
  63. {stjames-0.0.44 → stjames-0.0.46}/stjames.egg-info/requires.txt +0 -0
  64. {stjames-0.0.44 → stjames-0.0.46}/stjames.egg-info/top_level.txt +0 -0
  65. {stjames-0.0.44 → stjames-0.0.46}/tests/test_from_extxyz.py +0 -0
  66. {stjames-0.0.44 → stjames-0.0.46}/tests/test_molecule.py +0 -0
  67. {stjames-0.0.44 → stjames-0.0.46}/tests/test_settings.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: stjames
3
- Version: 0.0.44
3
+ Version: 0.0.46
4
4
  Summary: standardized JSON atom/molecule encoding scheme
5
5
  Author-email: Corin Wagen <corin@rowansci.com>
6
6
  Project-URL: Homepage, https://github.com/rowansci/stjames
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "stjames"
3
- version = "0.0.44"
3
+ version = "0.0.46"
4
4
  description = "standardized JSON atom/molecule encoding scheme"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -0,0 +1,74 @@
1
+ from typing import Optional, Self
2
+
3
+ from pydantic import PositiveFloat, PositiveInt, model_validator
4
+
5
+ from .base import Base, LowercaseStrEnum
6
+
7
+
8
+ class ConstraintType(LowercaseStrEnum):
9
+ """Different sorts of constraints."""
10
+
11
+ BOND = "bond"
12
+ ANGLE = "angle"
13
+ DIHEDRAL = "dihedral"
14
+ FREEZE_ATOMS = "freeze_atoms"
15
+
16
+
17
+ class Constraint(Base):
18
+ """
19
+ Represents a single (absolute) constraint.
20
+
21
+ :param constraint_type: which type
22
+ :param atoms: the atoms in question. n.b. - these are 1-indexed!
23
+ :param value: the value to constrain this to, leaving this blank sets the current value
24
+ """
25
+
26
+ constraint_type: ConstraintType
27
+ atoms: list[PositiveInt] # 1-indexed
28
+ value: Optional[float] = None
29
+
30
+ @model_validator(mode="after")
31
+ def check_atom_list_length(self) -> Self:
32
+ match self.constraint_type:
33
+ case ConstraintType.BOND:
34
+ if len(self.atoms) != 2:
35
+ raise ValueError("Bond constraint needs two atom indices!")
36
+ case ConstraintType.ANGLE:
37
+ if len(self.atoms) != 3:
38
+ raise ValueError("Angle constraint needs three atom indices!")
39
+ case ConstraintType.DIHEDRAL:
40
+ if len(self.atoms) != 4:
41
+ raise ValueError("Dihedral constraint needs four atom indices!")
42
+ case ConstraintType.FREEZE_ATOMS:
43
+ if len(self.atoms) == 0:
44
+ raise ValueError("Can't freeze atoms without any atoms to freeze!")
45
+ case _:
46
+ raise ValueError("Unknown constraint_type!")
47
+
48
+ return self
49
+
50
+
51
+ class PairwiseHarmonicConstraint(Base):
52
+ """
53
+ Represents a harmonic constraint, with a characteristic spring constant.
54
+
55
+ :param atoms: which atoms to apply to
56
+ :param force_constant: the strength of the attraction, in kcal/mol/Å
57
+ :param equilibrium: the distance at which force is zero
58
+ """
59
+
60
+ atoms: tuple[PositiveInt, PositiveInt] # 1-indexed
61
+ force_constant: PositiveFloat # kcal/mol / Å**2
62
+ equilibrium: PositiveFloat # Å
63
+
64
+
65
+ class SphericalHarmonicConstraint(Base):
66
+ """
67
+ Represents a spherical harmonic constraint to keep a system near the origin.
68
+
69
+ :param confining radius: the confining radius, in Å
70
+ :param force_constant: the strength of the confinement, in kcal/mol/Å
71
+ """
72
+
73
+ confining_radius: PositiveFloat
74
+ force_constant: PositiveFloat = 10 # kcal/mol / Å**2
@@ -10,5 +10,8 @@ class Correction(LowercaseStrEnum):
10
10
  # Grimme's D3 dispersion correction, *without* Becke–Johnson damping
11
11
  D3 = "d3"
12
12
 
13
+ # Grimme's D4 dispersion correction
14
+ D4 = "d4"
15
+
13
16
  # Grimme's geometric counterpoise correction
14
17
  GCP = "gcp"
@@ -4,7 +4,7 @@ from .base import Base, LowercaseStrEnum
4
4
 
5
5
 
6
6
  class DIISStrategy(LowercaseStrEnum):
7
- # regular pulay DIIS
7
+ # regular Pulay DIIS
8
8
  DIIS = "diis"
9
9
 
10
10
  # Hu/Yang JCP 2010 - ADIIS
@@ -0,0 +1,60 @@
1
+ from typing import Literal
2
+
3
+ from .base import LowercaseStrEnum
4
+
5
+
6
+ class Method(LowercaseStrEnum):
7
+ HARTREE_FOCK = "hf"
8
+ HF3C = "hf_3c"
9
+
10
+ PBE = "pbe"
11
+ B973C = "b97_3c"
12
+ B97D3BJ = "b97_d3bj"
13
+ R2SCAN = "r2scan"
14
+ R2SCAN3C = "r2scan_3c"
15
+ TPSS = "tpss"
16
+ M06L = "m06l"
17
+
18
+ PBE0 = "pbe0"
19
+ B3LYP = "b3lyp"
20
+ TPSSH = "tpssh"
21
+ M06 = "m06"
22
+ M062X = "m062x"
23
+
24
+ CAMB3LYP = "camb3lyp"
25
+ WB97XD3 = "wb97x_d3"
26
+ WB97XV = "wb97x_v"
27
+ WB97MV = "wb97m_v"
28
+ WB97MD3BJ = "wb97m_d3bj"
29
+ WB97X3C = "wb97x_3c"
30
+
31
+ DSDBLYPD3BJ = "dsd_blyp_d3bj"
32
+
33
+ AIMNET2_WB97MD3 = "aimnet2_wb97md3"
34
+ MACE_MP_0 = "mace_mp_0"
35
+ OCP24_S = "ocp24_s"
36
+ OCP24_L = "ocp24_l"
37
+
38
+ GFN_FF = "gfn_ff"
39
+ GFN0_XTB = "gfn0_xtb"
40
+ GFN1_XTB = "gfn1_xtb"
41
+ GFN2_XTB = "gfn2_xtb"
42
+
43
+ # this was going to be removed, but Jonathon wrote such a nice basis set test... it's off the front end.
44
+ BP86 = "bp86"
45
+
46
+
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]
@@ -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
- # todo - check units here?
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: Optional[list[float]] = None
48
- mulliken_spin_densities: Optional[list[float]] = None
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
@@ -20,7 +20,7 @@ class SCFInitMethod(LowercaseStrEnum):
20
20
  class OrthonormalizationMethod(LowercaseStrEnum):
21
21
  SYMMETRIC = "symmetric"
22
22
  CANONICAL = "canonical"
23
- # cholesky, in future?
23
+ # Cholesky, in future?
24
24
 
25
25
 
26
26
  class SCFSettings(Base):
@@ -5,4 +5,6 @@ UUID: TypeAlias = str
5
5
  Vector3D: TypeAlias = tuple[float, float, float]
6
6
  Vector3DPerAtom: TypeAlias = list[Vector3D]
7
7
 
8
+ FloatPerAtom: TypeAlias = list[float]
9
+
8
10
  Matrix3x3: TypeAlias = tuple[Vector3D, Vector3D, Vector3D]
@@ -0,0 +1,55 @@
1
+ # ruff: noqa: F405
2
+ from typing import Literal
3
+
4
+ from .admet import *
5
+ from .basic_calculation import *
6
+ from .bde import *
7
+ from .conformer import *
8
+ from .conformer_search import *
9
+ from .descriptors import *
10
+ from .electronic_properties import *
11
+ from .fukui import *
12
+ from .molecular_dynamics import *
13
+ from .multistage_opt import *
14
+ from .pka import *
15
+ from .redox_potential import *
16
+ from .scan import *
17
+ from .spin_states import *
18
+ from .tautomer import *
19
+ from .workflow import Workflow
20
+
21
+ WORKFLOW_NAME = Literal[
22
+ "admet",
23
+ "basic_calculation",
24
+ "bde",
25
+ "conformers",
26
+ "conformer_search",
27
+ "descriptors",
28
+ "electronic_properties",
29
+ "fukui",
30
+ "molecular_dynamics",
31
+ "multistage_opt",
32
+ "pka",
33
+ "redox_potential",
34
+ "scan",
35
+ "spin_states",
36
+ "tautomers",
37
+ ]
38
+
39
+ WORKFLOW_MAPPING: dict[str, Workflow] = {
40
+ "admet": ADMETWorkflow, # type: ignore [dict-item]
41
+ "basic_calculation": BasicCalculationWorkflow, # type: ignore [dict-item]
42
+ "bde": BDEWorkflow, # type: ignore [dict-item]
43
+ "conformers": ConformerWorkflow, # type: ignore [dict-item]
44
+ "conformer_search": ConformerSearchWorkflow, # type: ignore [dict-item]
45
+ "descriptors": DescriptorsWorkflow, # type: ignore [dict-item]
46
+ "electronic_properties": ElectronicPropertiesWorkflow, # type: ignore [dict-item]
47
+ "fukui": FukuiIndexWorkflow, # type: ignore [dict-item]
48
+ "molecular_dynamics": MolecularDynamicsWorkflow, # type: ignore [dict-item]
49
+ "multistage_opt": MultiStageOptWorkflow, # type: ignore [dict-item]
50
+ "pka": pKaWorkflow, # type: ignore [dict-item]
51
+ "redox_potential": RedoxPotentialWorkflow, # type: ignore [dict-item]
52
+ "scan": ScanWorkflow, # type: ignore [dict-item]
53
+ "spin_states": SpinStatesWorkflow, # type: ignore [dict-item]
54
+ "tautomers": TautomerWorkflow, # type: ignore [dict-item]
55
+ }
@@ -58,12 +58,12 @@ 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
+ :param frequencies: whether to calculate frequencies
63
64
 
64
65
  Overridden:
65
66
  :param mso_mode: Mode for MultiStageOptSettings
66
- :param frequencies: whether to calculate frequencies
67
67
 
68
68
  Turned off:
69
69
  :param constraints: constraints to add (not supported)
@@ -81,7 +81,6 @@ class BDEWorkflow(Workflow, MultiStageOptMixin):
81
81
  """
82
82
 
83
83
  mso_mode: Mode = _sentinel_mso_mode # type: ignore [assignment]
84
- frequencies: bool = False
85
84
  optimize_fragments: bool = None # type: ignore [assignment]
86
85
 
87
86
  atoms: tuple[PositiveInt, ...] = Field(default_factory=tuple)
@@ -106,6 +105,10 @@ class BDEWorkflow(Workflow, MultiStageOptMixin):
106
105
  """
107
106
  return f"{type(self).__name__} {self.mode.name}\n" + "\n".join(map(str, self.fragment_indices))
108
107
 
108
+ @property
109
+ def level_of_theory(self) -> str:
110
+ return self.multistage_opt_settings.level_of_theory
111
+
109
112
  @property
110
113
  def energies(self) -> tuple[float | None, ...]:
111
114
  return tuple(bde.energy for bde in self.bdes)
@@ -0,0 +1,352 @@
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 determining unique and useful conformers.
30
+
31
+ :param energy_threshold: maximum relative energy for screening
32
+ :param rotational_constants_threshold: 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_threshold: float | None = None # kcal/mol
38
+ rotational_constants_threshold: 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 conf_opt_method: method for the optimization
80
+ :param screening: post-generation screening settings
81
+ :param constraints: constraints for conformer generation
82
+ :param nci: add a constraining potential for non-covalent interactions (not supported in ETKDG)
83
+ :param max_confs: maximum number of conformers to keep
84
+
85
+ New:
86
+ :param num_initial_confs: number of initial conformers to generate
87
+ :param num_confs_considered: number of conformers to consider for optimization
88
+ :param num_confs_taken: number of final conformers to take
89
+ :param max_mmff_energy: MMFF energy cutoff
90
+ :param max_mmff_iterations: MMFF optimization iterations
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 None else self.max_confs
121
+ self.max_mmff_energy = 20
122
+ case Mode.RAPID:
123
+ self.max_confs = 50 if self.max_confs is None 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
+ :param max_confs: maximum number of conformers to keep
198
+
199
+ New:
200
+ :param mtd_method: method for the metadynamics
201
+ :param speed: speed of the calculations (CREST specific setting)
202
+ :param reopt: re-optimize conformers (corrects for the lack of rotamer metadynamics and GC)
203
+ :param free_energy_weights: calculate frequencies and re-weight based on free energies
204
+ """
205
+
206
+ mtd_method: XTBMethod = Method.GFN_FF
207
+ mtd_runtype: str = "imtd-gc"
208
+
209
+ speed: iMTDSpeeds = iMTDSpeeds.QUICK
210
+ reopt: bool = _sentinel # type: ignore [assignment]
211
+ free_energy_weights: bool = False
212
+
213
+ @model_validator(mode="after")
214
+ def validate_and_build_imtdgc_settings(self) -> Self:
215
+ match self.mode:
216
+ case Mode.MANUAL:
217
+ if self.reopt is _sentinel:
218
+ raise ValueError("Must specify reopt with MANUAL mode")
219
+ case Mode.RECKLESS: # GFN-FF//MTD(GFN-FF)
220
+ self.max_confs = 20 if self.max_confs is None else self.max_confs
221
+ self.speed = iMTDSpeeds.MEGAQUICK
222
+ self.reopt = check_sentinel(self.reopt, True)
223
+ case Mode.RAPID: # GFN0//MTD(GFN-FF)
224
+ self.max_confs = 50 if self.max_confs is None else self.max_confs
225
+ self.speed = iMTDSpeeds.SUPERQUICK
226
+ self.conf_opt_method = Method.GFN0_XTB
227
+ self.reopt = check_sentinel(self.reopt, True)
228
+ case Mode.CAREFUL: # GFN2//MTD(GFN-FF)
229
+ self.speed = iMTDSpeeds.QUICK
230
+ self.conf_opt_method = Method.GFN2_XTB
231
+ self.reopt = check_sentinel(self.reopt, False)
232
+ case Mode.METICULOUS: # GFN2//MTD(GFN2)
233
+ self.speed = iMTDSpeeds.NORMAL
234
+ self.mtd_method = Method.GFN2_XTB
235
+ self.conf_opt_method = Method.GFN2_XTB
236
+ self.reopt = check_sentinel(self.reopt, False)
237
+ # case Mode.EXTREME: # GFN2//MTD(GFN2)
238
+ # self.mtd_method = Method.GFN2_XTB
239
+ # self.conf_opt_method = Method.GFN2_XTB
240
+ # self.speed = iMTDSpeeds.EXTENSIVE
241
+ # self.reopt = check_sentinel(self.reopt, False)
242
+ case _:
243
+ raise NotImplementedError(f"Unsupported mode: {self.mode}")
244
+
245
+ return self
246
+
247
+
248
+ class iMTDGCSettings(iMTDSettings):
249
+ run_type: str = "imtdgc"
250
+
251
+
252
+ class iMTDsMTDSettings(iMTDSettings):
253
+ run_type: str = "imtd-smtd"
254
+
255
+
256
+ class ConformerGenMixin(BaseModel):
257
+ """
258
+ Mixin for workflows that need conformer generation.
259
+
260
+ :param conf_gen_mode: Mode for calculations
261
+ :param conf_gen_settings: settings for conformer generation
262
+ :param constraints: constraints to add
263
+ :param nci: add a constraining potential for non-covalent interactions
264
+ :param max_confs: maximum number of conformers to keep
265
+ """
266
+
267
+ conf_gen_mode: Mode = Mode.RAPID
268
+ conf_gen_settings: ConformerGenSettings = _sentinel # type: ignore [assignment]
269
+ constraints: Sequence[Constraint] = tuple()
270
+ nci: bool = False
271
+ max_confs: int | None = None
272
+
273
+ @model_validator(mode="after")
274
+ def validate_and_build_conf_gen_settings(self) -> Self:
275
+ """Validate and build the ConformerGenSettings."""
276
+ if self.conf_gen_settings is not _sentinel and self.conf_gen_mode != Mode.MANUAL:
277
+ raise ValueError("Cannot specify conf_gen_settings with non-MANUAL mode")
278
+
279
+ match self.conf_gen_mode:
280
+ case Mode.MANUAL:
281
+ if self.conf_gen_settings is _sentinel:
282
+ raise ValueError("Must specify conf_gen_settings with MANUAL mode")
283
+
284
+ case Mode.RECKLESS | Mode.RAPID:
285
+ # ETKDGSettings will error if constraints or nci are set
286
+ self.conf_gen_settings = ETKDGSettings(mode=self.conf_gen_mode, constraints=self.constraints, nci=self.nci, max_confs=self.max_confs)
287
+ case Mode.CAREFUL | Mode.METICULOUS:
288
+ self.conf_gen_settings = iMTDSettings(mode=self.conf_gen_mode, constraints=self.constraints, nci=self.nci, max_confs=self.max_confs)
289
+
290
+ case _:
291
+ raise NotImplementedError(f"Unsupported mode: {self.conf_gen_mode}")
292
+
293
+ return self
294
+
295
+
296
+ class ConformerSearchMixin(ConformerGenMixin, MultiStageOptMixin):
297
+ """
298
+ Mixin for workflows that need conformer search—a combination of conformer generation and optimization.
299
+
300
+ Inherited (ConformerGenMixin):
301
+ :param conf_gen_mode: Mode for conformer generation
302
+ :param mso_mode: Mode for MultiStageOptSettings
303
+ :param conf_gen_settings: settings for conformer generation
304
+ :param nci: add a constraining potential for non-covalent interactions
305
+
306
+ Inherited (MultiStageOptMixin):
307
+ :param multistage_opt_settings: set by mso_mode unless mode=MANUAL (ignores additional settings if set)
308
+ :param solvent: solvent to use
309
+ :param xtb_preopt: pre-optimize with xtb (sets based on mode when None)
310
+ :param transition_state: whether this is a transition state
311
+ :param frequencies: whether to calculate frequencies
312
+
313
+ Inherited (Both):
314
+ :param constraints: constraints to add (diamond inheritance, works as expected)
315
+ """
316
+
317
+ def __str__(self) -> str:
318
+ """Return a string representation of the ConformerSearch workflow."""
319
+ return repr(self)
320
+
321
+ def __repr__(self) -> str:
322
+ """Return a string representation of the ConformerSearch workflow."""
323
+ return f"<{type(self).__name__} {self.conf_gen_mode.name} {self.mso_mode.name}>"
324
+
325
+
326
+ class ConformerSearchWorkflow(ConformerSearchMixin, Workflow):
327
+ """
328
+ ConformerSearch Workflow.
329
+
330
+ Inherited:
331
+ :param initial_molecule: Molecule of interest
332
+ :param conf_gen_mode: Mode for calculations
333
+ :param conf_gen_settings: settings for conformer generation
334
+ :param mso_mode: Mode for MultiStageOptSettings
335
+ :param multistage_opt_settings: set by mode unless mode=MANUAL (ignores additional settings if set)
336
+ :param solvent: solvent to use
337
+ :param xtb_preopt: pre-optimize with xtb (sets based on mode when None)
338
+ :param constraints: constraints to add
339
+ :param transition_state: whether this is a transition state
340
+ :param frequencies: whether to calculate frequencies
341
+
342
+ Ignored:
343
+ :param mode: Mode to use (not used)
344
+
345
+ New:
346
+ :param conformer_uuids: list of UUIDs of the Molecules generated
347
+ :param energies: energies of the molecules
348
+ """
349
+
350
+ # Results
351
+ conformer_uuids: list[list[UUID | None]] = Field(default_factory=list)
352
+ energies: list[float] = Field(default_factory=list)
@@ -5,7 +5,7 @@ Descriptors = dict[str, dict[str, float] | tuple[float | None, ...] | float]
5
5
 
6
6
 
7
7
  class DescriptorsWorkflow(Workflow):
8
- # uuid of optimization
8
+ # UUID of optimization
9
9
  optimization: UUID | None = None
10
10
 
11
11
  descriptors: Descriptors | None = None