PRMContainer¶
A class for reading and generating .prm parameter files.
Index¶
PRMContainer ([atoms, bonds, angles, …]) |
A class for managing prm files. |
PRMContainer.read (file[, bytes_decoding]) |
Construct a new instance from this object’s class by reading the content of file. |
PRMContainer.write ([file, bytes_encoding]) |
Write the content of this instance to file. |
PRMContainer.overlay_mapping (prm_name, param) |
Update a set of parameters, prm_name, with those provided in param_df. |
PRMContainer.overlay_cp2k_settings (cp2k_settings) |
Extract forcefield information from PLAMS-style CP2K settings. |
API¶
-
class
FOX.
PRMContainer
(atoms=None, bonds=None, angles=None, dihedrals=None, impropers=None, nbfix=None, hbond=None, nonbonded_header=None, nonbonded=None, improper=None)[source] A class for managing prm files.
Examples
>>> from FOX import PRMContainer >>> input_file = str(...) >>> output_file = str(...) >>> prm = PRMContainer.read(input_file) >>> prm.write(output_file)
-
impropers
A dataframe holding improper diehdral-related parameters.
-
atoms
A dataframe holding atomic parameters.
-
bonds
A dataframe holding bond-related parameters.
-
angles
A dataframe holding angle-related parameters.
-
dihedrals
A dataframe holding proper dihedral-related parameters.
-
nonbonded
A dataframe holding non-bonded atomic parameters.
-
nbfix
A dataframe holding non-bonded pair-wise atomic parameters.
-
-
classmethod
PRMContainer.
read
(file, bytes_decoding=None, **kwargs)¶ Construct a new instance from this object’s class by reading the content of file.
Parameters: - file (
str
,bytes
,os.PathLike
orIO
) – A path- or file-like object. - bytes_decoding (
str
, optional) – The type of encoding to use when reading from file when it will be/is be opened inbytes
mode. This value should be left empty otherwise. - **kwargs (
Any
) – Further keyword arguments foropen()
. Only relevant if file is a path-like object.
Returns: A new instance constructed from file.
Return type: nanoutils.AbstractFileContainer
- file (
-
PRMContainer.
write
(file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, bytes_encoding=None, **kwargs)¶ Write the content of this instance to file.
Parameters: - file (
str
,bytes
,os.PathLike
orIO
) –A path- or file-like object. Defaults to
sys.stdout
if not specified. - bytes_encoding (
str
, optional) – The type of encoding to use when writing to file when it will be/is be opened inbytes
mode. This value should be left empty otherwise. - **kwargs (
Any
) – Further keyword arguments foropen()
. Only relevant if file is a path-like object.
Return type: - file (
-
PRMContainer.
overlay_mapping
(prm_name, param, units=None)[source]¶ Update a set of parameters, prm_name, with those provided in param_df.
Examples
>>> from FOX import PRMContainer >>> prm = PRMContainer(...) >>> param_dict = {} >>> param_dict['epsilon'] = {'Cd Cd': ..., 'Cd Se': ..., 'Se Se': ...} # epsilon >>> param_dict['sigma'] = {'Cd Cd': ..., 'Cd Se': ..., 'Se Se': ...} # sigma >>> units = ('kcal/mol', 'angstrom') # input units for epsilon and sigma >>> prm.overlay_mapping('nonbonded', param_dict, units=units)
Parameters: - prm_name (
str
) – The name of the parameter of interest. See the keys ofPRMContainer.CP2K_TO_PRM
for accepted values. - param (
pandas.DataFrame
or nestedMapping
) – A DataFrame or nested mapping with the to-be added parameters. The keys should be a subset ofPRMContainer.CP2K_TO_PRM[prm_name]["columns"]
. If the index/nested sub-keys consist of strings then they’ll be split and turned into apandas.MultiIndex
. Note that the resulting values are not sorted. - units (
Iterable[str]
, optional) – An iterable with the input units of each column in param_df. IfNone
, default to the defaults specified inPRMContainer.CP2K_TO_PRM[prm_name]["unit"]
.
- prm_name (
-
PRMContainer.
overlay_cp2k_settings
(cp2k_settings)[source]¶ Extract forcefield information from PLAMS-style CP2K settings.
Performs an inplace update of this instance.
Examples
Example input value for cp2k_settings. In the provided example the cp2k_settings are directly extracted from a CP2K .inp file.
>>> import cp2kparser # https://github.com/nlesc-nano/CP2K-Parser >>> filename = str(...) >>> cp2k_settings: dict = cp2kparser.read_input(filename) >>> print(cp2k_settings) {'force_eval': {'mm': {'forcefield': {'nonbonded': {'lennard-jones': [...]}}}}}
Parameters: cp2k_settings ( Mapping
) – A Mapping with PLAMS-style CP2K settings.