vibrav.core.config module

class vibrav.core.config.Config(*args, **kwargs)[source]

Bases: Series

Base class to read the configuration file given at the start of the different Vibrational Averaging modules.

Global default values.

Attribute

Description

Default Value

delta_file

Filepath of the delta displacement parameters used to generate the different displaced structures.

delta.dat

reduced_mass_file

Filepath to the reduced masses of the vibrational modes.

redmass.dat

frequency_file

Filepath of the energies of the normal modes.

freq.dat

smatrix_file

Filepath of the frequency normal mode displacements as a column vector of normalized cartesian coordinates in atomic units.

smatrix.dat

eqcoord_file

Filepath of the equilibrium coordinates of the molecule. This is given as a column vector of the coordinates in Angstrom units.

eqcoord.dat

atom_order_file

Filepath of the atomic symbols in the correct order as it appears on the XYZ coordinate file.

atom_order.dat

delta_disp

Constant displacement parameter to generate the displaced structures. Only matters for the delta_type parameter for vibrav.util.gen_displaced.gen_delta() is 3.

0.0

delta_algorithm

Delta algorithm used to generate the displaced structures. This is passed as the delta_type parameter in vibrav.util.gen_displaced.gen_delta()

2

delta_value

Normalization parameter used to generate the displaced structures. This is passed as the norm parameter in vibrav.util.gen_displaced.gen_delta()

0.04

freqdx

Set which frequency indices to calculate. This is a zero based index and can be set with a ‘-’ for a range of indices and a ‘,’ or ‘ ‘ for specific indices.

-1

classmethod open_config(fp, required=None, defaults=None, skip_defaults=None)[source]

Open and read the config file that is given.

Parameters:
  • fp (str) – Filepath to the config file.

  • required (list) – Required arguments that must be present in the config file.

  • defaults (list, optional) – Default arguments for the config file that are not necessary. Defaults to None.

  • skip_defaults (list, optional) – Skip the given default arguments. This is helpful for unit testing as all of the default files may not be available. Defaults to None.

Returns:

config (dict) – Dictionary with all of the elements in the config as keys

Raises:
  • AttributeError – When there is more than one value for a default argument, having more than one value when the input dictionaries say it should be one value, or when there is a missing required parameter.

  • Exception – Default catch when the required parameter is not interpreted correctly and does not fall within any of the coded parameters.

  • ValueError – When it cannot set the type that has been given as an input. I.e. converting string character into a number.

Examples

The usage of this module can be as follows.

>>> from vibrav.base import resource
>>> config = Config.open_config(resource('molcas-ucl6-2minus-vibronic-config'), required={})
>>> print(config.to_sring())
config_elem
freq_data_file              [ADF_FREQ_FILE]
number_of_multiplicity                  [2]
spin_multiplicity                    [3, 1]
number_of_states                   [42, 49]
number_of_nuclei                        [7]
number_of_modes                        [15]
delta_algorithm                           0
delta_value                            0.04
oscillator_spin_states                 [91]
delta_file                        delta.dat
reduced_mass_file               redmass.dat
frequency_file                     freq.dat
sf_energies_file          [energies-SF.txt]
so_energies_file             [energies.txt]
zero_order_file             [ucl-rassi.out]
delta_disp                                0
>>> print(type(config.number_of_nuclei), type(config.number_of_nuclei[0]))
<class 'list'> <class 'str'>
>>> print(type(config.spin_multiplicity), type(config.spin_multiplicity[0]))
<class 'list'> <class 'str'>

Any of the items that are not passed as default or required in the defaults or required parameters respectively will be shown as a list entry as shown in the number_of_multiplicity entry in the result from the example above.

Now if we pass some required arguments for number_of_multiplicity, spin_multiplicity, number_of_states and number_of_modes, as is required in the vibronic coupling calculations from vibrav.vibronic.Vibronic, the input is now as follows.

>>> from vibrav.base import resource
>>> required = {'number_of_multiplicity': int, 'spin_multiplicity': (tuple, int),
...             'number_of_states': (tuple, int), 'number_of_nuclei': int}
>>> config = Config.open_config(resource('molcas-ucl6-2minus-vibronic-config'), required=required)
>>> print(config.to_sring())
config_elem
freq_data_file              [ADF_FREQ_FILE]
number_of_multiplicity                    2
spin_multiplicity                    (3, 1)
number_of_states                   (42, 49)
number_of_nuclei                          7
number_of_modes                        [15]
delta_algorithm                           0
delta_value                            0.04
oscillator_spin_states                 [91]
delta_file                        delta.dat
reduced_mass_file               redmass.dat
frequency_file                     freq.dat
sf_energies_file          [energies-SF.txt]
so_energies_file             [energies.txt]
zero_order_file             [ucl-rassi.out]
delta_disp                                0
>>> print(type(config.number_of_nuclei))
<class 'int'>
>>> print(type(config.spin_multiplicity), type(config.spin_multiplicity[0]))
<class 'tuple'> <class 'int'>

Now the required inputs that we gave the function are of the specified types. The required parameter has to take a dictionary where single values in the input file will have a single data type defined in the required dictionary. Parameters in the input file with more than one input, such as the ‘spin_multiplicity’ input, will have a list or tuple of data types where the first one defined what type of list-like object it will be and the second parameter is the data type of the individual entries.

If additional default values are to be passed, the defaults parameter must be used. We will create a new dummy argument, test, that will default to ‘Hi I am a string’ as a str.

>>> from vibrav.base import resource
>>> required = {'number_of_multiplicity': int, 'spin_multiplicity': (tuple, int),
...             'number_of_states': (tuple, int), 'number_of_nuclei': int}
>>> new_default = {'test': ('', str)}
>>> config = Config.open_config(resource('molcas-ucl6-2minus-vibronic-config'), required=required, defaults=new_default)
>>> print(config.to_sring())
config_elem
freq_data_file              [ADF_FREQ_FILE]
number_of_multiplicity                    2
spin_multiplicity                    (3, 1)
number_of_states                   (42, 49)
number_of_nuclei                          7
number_of_modes                        [15]
delta_algorithm                           0
delta_value                            0.04
oscillator_spin_states                 [91]
delta_file                        delta.dat
reduced_mass_file               redmass.dat
frequency_file                     freq.dat
sf_energies_file          [energies-SF.txt]
so_energies_file             [energies.txt]
zero_order_file             [ucl-rassi.out]
test                       Hi I am a string
delta_disp                                0
>>> print(type(config.test))
<class 'str'>

We can see that we have added a default argument to the input file that is called test with a str value of ‘Hi I am a string’. The format of the default parameter that must be given is a dictionary where every value is a tuple of 2 objects. The first one defines the default value, the second one defines the data type of the default value.

Any other input that is not defined as a default or required argument is saved in the config object as a :obj;`list` of string/s. An example if the freq_data_file input in the above examples. These are saved in case they are needed later on rather than being deleted as a whole.

exception vibrav.core.config.MissingRequiredInput[source]

Bases: Exception