PRMContainer¶
FOX.io.read_prm¶
A class for reading and generating .prm parameter files.
Index¶
PRMContainer ([filename, atoms, bonds, …]) |
A container for managing prm files. |
PRMContainer.read (filename[, encoding]) |
Construct a new instance from this object’s class by reading the content of filename. |
PRMContainer.write ([filename, encoding]) |
Write the content of this instance to filename. |
PRMContainer.overlay_mapping (prm_name, param_df) |
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.io.read_prm.
PRMContainer
(filename=None, atoms=None, bonds=None, angles=None, dihedrals=None, improper=None, impropers=None, nonbonded=None, nonbonded_header=None, nbfix=None, hbond=None)[source]¶ A container for managing prm files.
-
pd_printoptions
¶ A dictionary with Pandas print options. See Options and settings.
Type: dict
[str
,object
], private
-
CP2K_TO_PRM
¶ A mapping providing tools for converting CP2K settings to .prm-compatible values. See
CP2K_TO_PRM
.Type: Mapping
[str
,PRMMapping
]
-
-
classmethod
PRMContainer.
read
(filename, encoding=None, **kwargs)[source]¶ Construct a new instance from this object’s class by reading the content of filename.
Parameters: - filename (
str
,bytes
,os.PathLike
or a file object) – The path+filename or a file object of the to-be read .psf file. In practice, any iterable can substitute the role of file object as long iteration returns either strings or bytes (see encoding). - encoding (
str
, optional) – Encoding used to decode the input (e.g."utf-8"
). Only relevant when a file object is supplied to filename and the datastream is not in text mode. - **kwargs (
Any
) – Optional keyword arguments that will be passed to bothPRMContainer._read_iterate()
andPRMContainer._read_postprocess()
.
See also
PRMContainer._read_iterate()
- An abstract method for parsing the opened file in
PRMContainer.read()
. PRMContainer._read_postprocess()
- Post processing the class instance created by
PRMContainer.read()
.
Return type: PRMContainer
- filename (
-
PRMContainer.
write
(filename=None, encoding=None, **kwargs)[source]¶ Write the content of this instance to filename.
Parameters: - filename (
str
,bytes
,os.PathLike
or a file object) – The path+filename or a file object of the to-be read .psf file. Contrary to_read_postprocess()
, file objects can not be substituted for generic iterables. - encoding (
str
, optional) – Encoding used to decode the input (e.g."utf-8"
). Only relevant when a file object is supplied to filename and the datastream is not in text mode. - **kwargs (
Any
) – Optional keyword arguments that will be passed to_write_iterate()
.
See also
PRMContainer._write_iterate()
- Write the content of this instance to an opened datastream.
PRMContainer._get_writer()
- Take a
write()
method and ensure its first argument is properly encoded.
Return type: None
- filename (
-
PRMContainer.
overlay_mapping
(prm_name, param_df, 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_df (
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"]
.
Return type: - 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.See also
PRMMapping
PRMMapping
A mapping providing tools for converting CP2K settings to .prm-compatible values.
Return type: None