InputParams¶
The InputParams
class is meant to represent the input
parameters of a BigDFT calculation in a yaml format.
It also comes with two functions:
check()
to check that a dictionary is only made of valid BigDFT input parameters.clean()
to clean a dictionary of input parameters so that only non-default values are kept in memory.
-
class
mybigdft.iofiles.inputparams.
InputParams
(params=None)[source]¶ Bases:
collections.abc.MutableMapping
Class allowing to initialize, read, write and interact with the input parameters of a BigDFT calculation.
Input parameters are initialized from a yaml dictionary.
- Parameters
data (dict) – yaml dictionary of the input parameters.
>>> InputParams({'dft': {'hgrids': [0.35]*3}}) {'dft': {'hgrids': [0.35, 0.35, 0.35]}}
Default values are cleaned from the input parameters:
>>> InputParams({'dft': {'hgrids': [0.45]*3}}) {}
The input parameters can be empty:
>>> InputParams() {}
Initializing with unknown parameters raises a
KeyError
:>>> InputParams({'dfpt': {'hgrids': [0.35]*3}}) Traceback (most recent call last): ... KeyError: "Unknown key 'dfpt'" >>> InputParams({'dft': {'hgrid': [0.35]*3}}) Traceback (most recent call last): ... KeyError: "Unknown key 'hgrid' in 'dft'"
-
classmethod
from_file
(filename)[source]¶ Initialize an InputParams instance from a BigDFT input file.
- Parameters
filename (str) – Name of the file to read.
- Returns
InputParams instance initialized from the file.
- Return type
-
classmethod
from_string
(string)[source]¶ Initialize an InputParams instance from a string.
- Parameters
string (str) – Input parameters dictionary as a string.
- Returns
InputParams instance initialized from the string.
- Return type
>>> InputParams.from_string("{'dft': {'rmult': [6, 8]}}") {'dft': {'rmult': [6, 8]}}
-
property
params
¶ - Returns
Input parameters.
- Return type
dict
-
property
posinp
¶ - Returns
Initial positions contained in the input parameters
- Return type
Posinp or None
-
mybigdft.iofiles.inputparams.
clean
(params, keyword=None)[source]¶ - Parameters
params (dict) – Trial BigDFT input parameters.
keyword (NoneType or str) – Main key of input parameters key to be checked (used to check CheSS input parameters).
- Returns
Input parameters whose values are not their default, after checking that all the keys in params correspond to actual BigDFT parameters.
- Return type
dict
-
mybigdft.iofiles.inputparams.
check
(params, keyword=None)[source]¶ Check that the keys of params correspond to BigDFT parameters.
- Parameters
params (dict) – Trial input parameters.
- Raises
KeyError – If a key or a sub-key is not a BigDFT parameter.
ValueError – If a value is invalid (not in the correct range, not in the possible values, the value of the master key does not allow for the key to be defined)