Closed BvB93 closed 4 years ago
Proposed syntax for forcefield parameters as inspired by those in Auto-FOX:
>>> from qmflows import Settings
>>> s = Settings()
>>> s.specific.cp2k.sigma = Settings({
... 'key_path': ('specific', 'cp2k', 'force_eval', 'mm', 'forcefield', 'nonbonded', 'lennard-jones')
... 'unit': 'angstrom'
... 'Cd': '3.0'
... 'Se': 2.5
... 'O': 2
... })
>>> s.specific.cp2k.epsilon = Settings({
... 'key_path': ('specific', 'cp2k', 'force_eval', 'mm', 'forcefield', 'nonbonded', 'lennard-jones')
... 'Cd': '12.0'
... 'Se': 3.5
... 'O': 8
... })
In the proposed syntax each parameter block consists of three different type of keys:
"key_path"
: A path of nested keys leading to the setting of interest. The "key_path"
provided in the example above corresponds to the CP2K FORCE_EVAL/MM/FORCEFIELD/NONBONDED/LENNARD-JONES section. This keyword is mandatory and a value must be assigned by the user. Alternatively, a user can provide a string ("lennard-jones"
in this case) serving as one of the in qmflows-defined aliases for the actual key path; for a comprehensive overview of available aliases see: https://github.com/SCM-NV/qmflows/blob/666f326a76de0f88f35b0f75071e1db2aa1d1508/src/qmflows/packages/cp2k_mm.py#L207-L238 "unit"
: The unit that will be assigned to all parameters within a particular parameter block; see https://manual.cp2k.org/trunk/units.html for a comprehensive overview of all available units.
Supplying this value will, for example, internally transform "O": 2
into "O": "[angstrom] 2"
. This is an optional keyword."Cd"
, "Se"
, "O"
, etc.: The values of the actual parameters of interest. The name of the block (in combination with "key_path"
) will finally determine in where block these values will be assigned, e.g. under SIGMA and EPSILON.Open question: what would be best name for the
Solved as of https://github.com/SCM-NV/qmflows/issues/148#issuecomment-596585344."key_path"
keyword (tentative name) as described above?
Updated the parameter syntax in https://github.com/SCM-NV/qmflows/commit/4f086061d9454f834f208913bf8bdc00356739a3:
Moved "key_path"
to the main key and moved the specific CP2K keys to "param"
.
Dictionary values can now be supplied as a either scalars or sequences but cannot be freely mixed.
>>> lennard_jones = { # Example 1
... 'param': ('epsilon', 'sigma'),
... 'unit': ('kcalmol', 'angstrom'), # An optional key
... 'Cs': (1, 1),
... 'Cd': (2, 2),
... 'O': (3, 3),
... 'H': (4, 4)
... }
>>> lennard_jones = [ # Example 2
... {'param': 'epsilon',
... 'unit': 'kcalmol', # An optional key
... 'Cs': 1,
... 'Cd': 2,
... 'O': 3,
... 'H': 4},
... {'param': 'sigma',
... 'unit': 'angstrom', # An optional key
... 'Cs': 1,
... 'Cd': 2,
... 'O': 3,
... 'H': 4}
... ]
Note that both examples result in equivalent settings.
Introduced in https://github.com/SCM-NV/qmflows/pull/150. See https://github.com/SCM-NV/qmflows/issues/159 for further updates and new features.
CP2K
class is heavily tailored towards density functional theory-calculations (DFT).CP2K
class or create a separatePackage
subclass for handling classical molecular mechanics (MM) calculations (something along the line ofCP2K_MM
?).Example input