Code documentation

Documentation for the different part of the “core” nachos package

Core (nachos.core)

nachos.core.compute_numerical_derivative_of_tensor(recipe, basis, derivative_repr, tensor_func, frequency=None, dry_run=False, force_choice=None, **kwargs)
Parameters:
  • recipe (nachos.core.files.Recipe) – recipe

  • basis (qcip_tools.derivatives.Derivative) – basis of differentiation (representation for the base tensors)

  • derivative_repr (qcip_tools.derivatives.Derivative) – representation of the further derivatives of the tensor

  • tensor_func – function to access to the tensor

  • frequency (float|str) – frequency if electrical derivative

  • dry_run (bool) – do not fill the tensor or perform Romberg analysis

  • kwargs (dict) – args passed to tensor_func

  • force_choice (tuple) – force the choice in the Romberg triangle

Returns:

tensor

Return type:

qcip_tools.derivatives.Tensor, dict

nachos.core.fancy_output_component_of_derivative(derivative, component, geometry=None)

Get the representation of the component of a given tensor

Parameters:
  • derivative (qcip_tools.derivatives.Derivative) – derivative

  • component (list|tuple) – component of the tensor

  • geometry (qcip_tools.molecule.Molecule) – the geometry

Return type:

str

nachos.core.fancy_output_derivative(derivative, frequency=None)
Parameters:
  • derivative (qcip_tools.derivatives.Derivative) – derivative to output

  • frequency (str|float) – eventual frequency

Return type:

str

Files (nachos.core.files)

exception nachos.core.files.BadRecipe
exception nachos.core.files.BadResult
class nachos.core.files.ComputationalResults(recipe, directory='.')

A class to store all the results obtained from the cooking process

Parameters:

recipe (nachos.core.files.Recipe) – a recipe

add_result(fields, derivative, value, allow_replace=False)

Add result for a given derivative in given fields

Parameters:
  • fields (tuple|list) – fields

  • derivative (str) – derivative

  • value (dict|qcip_tools.derivatives.Tensor) – value of the derivative

  • allow_replace (bool) – allow the value to be replaced

check()

Check that, according to the recipe, everything is present

Return type:

tuple

read(path)

Read in h5 file

Parameters:

path (str) – path to the file, relative to directory

write(path)

Write in h5 file

Parameters:

path (str) – path to the file, relative to directory

exception nachos.core.files.DerivativeAlreadyDefined(fields, derivative)
exception nachos.core.files.FieldsNotNeeded
class nachos.core.files.Recipe(directory='.', **kwargs)

Class that handle the parameters to perform numerical differentiation

bases(level_min=-1)

Get basis in the form of Derivatives objects, plus the level of differentiation

Parameters:

level_min (int) – minimum level required

Return type:

list of tuple

check_data()

check if data are coherent

Raises:

BadRecipe – if there is something wrong ;)

maximum_derivatives()

Get the different derivatives performed by the recipe

Return type:

list

read(fp)

Load a given YAML file and fill the Recipe with it.

Parameters:

fp (file) – valid file descriptor (in read mode)

Raises:

BadRecipe – if parameters are not allowed

write(fp)

Dump the Recipe into a YAML file

Parameters:

fp (file) – valid file descriptor (in write mode)

Making (nachos.core.making)

exception nachos.core.making.BadMaking
class nachos.core.making.BasisCompleter(bases)
get_completions(document, complete_event)

This should be a generator that yields Completion instances.

If the generation of completions is something expensive (that takes a lot of time), consider wrapping this Completer class in a ThreadedCompleter. In that case, the completer algorithm runs in a background thread and completions will be displayed as soon as they arrive.

Parameters:
  • documentDocument instance.

  • complete_eventCompleteEvent instance.

class nachos.core.making.BasisValidator(bases, max_diff, method)
validate(document)

Validate the input. If invalid, this should raise a ValidationError.

Parameters:

documentDocument instance.

class nachos.core.making.ChemistryFileValidator
validate(document)

Validate the input. If invalid, this should raise a ValidationError.

Parameters:

documentDocument instance.

class nachos.core.making.ChoicesValidator(choices=None, default=None, **kwargs)
validate(document)

Validate the input. If invalid, this should raise a ValidationError.

Parameters:

documentDocument instance.

class nachos.core.making.ExtraFlavorCompleter(allowed_keywords)
get_completions(document, complete_event)

This should be a generator that yields Completion instances.

If the generation of completions is something expensive (that takes a lot of time), consider wrapping this Completer class in a ThreadedCompleter. In that case, the completer algorithm runs in a background thread and completions will be displayed as soon as they arrive.

Parameters:
  • documentDocument instance.

  • complete_eventCompleteEvent instance.

class nachos.core.making.ExtraFlavorValidator(allowed_keywords)
validate(document)

Validate the input. If invalid, this should raise a ValidationError.

Parameters:

documentDocument instance.

class nachos.core.making.FrequenciesValidator
validate(document)

Validate the input. If invalid, this should raise a ValidationError.

Parameters:

documentDocument instance.

class nachos.core.making.GenBasisValidator(geometry)
validate(document)

Validate the input. If invalid, this should raise a ValidationError.

Parameters:

documentDocument instance.

class nachos.core.making.Maker(use_fallback_prompt=False, raise_when_arg_wrong=False)

Make a recipe out of prompting question or arguments

make(args)

make the recipe

Parameters:

args (dict) – input arguments

Return type:

nachos.core.files.Recipe

class nachos.core.making.TypeFloatValidator(default=None)
class nachos.core.making.TypeIntValidator(default=None)
class nachos.core.making.TypeValidator(default=None)
validate(document)

Validate the input. If invalid, this should raise a ValidationError.

Parameters:

documentDocument instance.

Preparing (nachos.core.preparing)

exception nachos.core.preparing.BadPreparation
class nachos.core.preparing.Preparer(recipe, directory='.')

Prepare the input files

Parameters:

recipe (nachos.core.files.Recipe) – a recipe

static deform_geometry(geometry, real_fields, geometry_in_angstrom=True)

Create an input for gaussian

Parameters:
  • real_fields (list) – Real differentiation field

  • geometry (qcip_tools.molecule.Molecule) – geometry do deform

  • geometry_in_angstrom (bool) – indicate wheter the geometry is given in Angstrom or not (because the field is obviously given in atomic units)

Return type:

qcip_tools.molecule.Molecule

prepare(dry_run=False)

Create the different input files in the directory

Parameters:

dry_run (bool) – do not create the files

Return type:

list

prepare_dalton_inputs(dry_run=False)

Create inputs for dalton. Note that it assume geometrical derivatives for the moment

Parameters:

dry_run (bool) – do not create the files

Return type:

list

prepare_gaussian_inputs(dry_run=False)

Create inputs for gaussian

Parameters:

dry_run (bool) – do not create the files

Return type:

list

prepare_qchem_inputs(dry_run=False)
Parameters:

dry_run (bool) – do not create the files

Return type:

list

nachos.core.preparing.fields_needed_by_recipe(recipe)
Parameters:

recipe (nachos.core.files.Recipe) – recipe

Return type:

list

Cooking (nachos.core.cooking)

exception nachos.core.cooking.BadCooking
class nachos.core.cooking.Cooker(recipe, directory='.')

Cooker class to retrieve the information out of the calculation results

Parameters:
cook(directories, out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, verbosity_level=0, use_gaussian_logs=False)

Cook files in directories, all together in a storage file

Parameters:
  • directories (list of str) – directories where QM results should be looked for

  • out (file) – output of eventual information

  • verbosity_level (bool) – wetter to write information or not

  • use_gaussian_logs (bool) – use Gaussian LOGs instead of FCHKs. But don’t ;)

Return type:

nachos.core.files.ComputationalResults

cook_from_file(f, name, storage)
Parameters:
Returns:

what was obtained

Return type:

list

Baking (nachos.core.baking)

exception nachos.core.baking.BadBaking
class nachos.core.baking.Baker(recipe, storage, directory='.', original_cf=None)

Baker class to finally perform the numerical differentiation

Parameters:
bake(only=None, out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, verbosity_level=0, copy_zero_field_basis=False, force_choice=None)

Perform the numerical differentiation

Parameters:
  • only (list) – list of derivatives to perform (None = all of them)

  • out (file) – output if information is needed to be outputed

  • verbosity_level (int) – how far should we print information

  • copy_zero_field_basis (bool) – copy the basis found in zero field

  • force_choice (tuple) – force the choice in the Romberg triangle

Return type:

qcip_tools.chemistry_files.chemistry_datafile.ChemistryDataFile

static make_uncertainty_tensor(romberg_triangles, initial_derivative, diff_derivative, frequency)
Parameters:
  • romberg_triangles (collections.OrderedDict) – the different Romberg triangles

  • initial_derivative (qcip_tools.derivatives.Derivative) – starting point

  • diff_derivative (qcip_tools.derivatives.Derivative) – differentialtion

  • frequency (str|float) – the frequency

Return type:

qcip_tools.derivatives.Tensor

static output_information(recipe, initial_derivative, diff_derivative, final_result, romberg_triangles, tensor_access, out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, verbosity_level=0)

Output information about what was computed

Note

If verbosity level is:

  • <=0: nothing happen ;

  • >0: output final tensor ;

  • >1: output Romberg triangle and best value ;

  • >2: output decision process to find best value in Romberg triangle.

Therefore, it triggers once again the computation of the best value in Romberg triangle if verbosity_level is > 2.

Parameters:
  • recipe (nachos.core.files.Recipe) – the corresponding recipe

  • initial_derivative (qcip_tools.derivatives.Derivative) – starting point

  • final_result (qcip_tools.derivatives.Tensor) – what was computed

  • romberg_triangles (collections.OrderedDict) – the different Romberg triangles

  • out (file) – output

  • verbosity_level (int) – how far should we print information

nachos.core.baking.project_geometrical_derivatives(recipe, datafile, mass_weighted_hessian, out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, verbosity_level=0)

Project geometrical derivatives, if any

Parameters:
  • recipe (nachos.core.files.Recipe) – the recipe

  • datafile (qcip_tools.chemistry_files.chemistry_datafile.ChemistryDataFile) – the data file with derivatives

  • mass_weighted_hessian (qcip_tools.derivatives_g.MassWeightedHessian) – the mass weighted hessian

  • out (file) – output

  • verbosity_level (int) – how far should we print information

Shaking (nachos.core.shaking)

Note

\[\newcommand{\tdiff}[2]{\left(\frac{\partial #1}{ \partial #2}\right)} \newcommand{\lb}[2]{\lambda^{\pm #1}_{#2}}\]

The (pv) contributions are written listing the properties, then the anharmonicity orders, so \([\mu^2]^{2,0}\) is written F_F___2_0. The ZPVA contributions are written the same way, except that it is only XDD__0_1 for \(\Delta\beta^{0,1}\).

Here is the list of contributions and corresponding functions:

Property

pv

Function

Polarizability

\([\mu^2]^{0,0}\)

_compute_F_F__0_0_component

\([\mu^2]^{1,1}\)

_compute_F_F__1_1_component

\([\mu^2]^{2,0}\)

_compute_F_F__2_0_component

\([\mu^2]^{0,2}\)

_compute_F_F__0_2_component

First hyperpolarizability

\([\mu\alpha]^{0,0}\)

_compute_F_FF__0_0_component

\([\mu\alpha]^{1,1}\)

_compute_F_FF__1_1_component

\([\mu\alpha]^{2,0}\)

_compute_F_FF__2_0_component

\([\mu\alpha]^{0,2}\)

_compute_F_FF__0_2_component

\([\mu^3]^{1,0}\)

_compute_F_F_F__1_0_component

\([\mu^3]^{0,1}\)

_compute_F_F_F__0_1_component

Second hyperpolarizability

\([\alpha^2]^{0,0}\)

_compute_FF_FF__0_0_component

\([\alpha^2]^{1,1}\)

_compute_FF_FF__1_1_component

\([\alpha^2]^{2,0}\)

_compute_FF_FF__2_0_component

\([\alpha^2]^{0,2}\)

_compute_FF_FF__0_2_component

\([\mu\beta]^{0,0}\)

_compute_F_FFF__0_0_component

\([\mu\beta]^{1,1}\)

_compute_F_FFF__1_1_component

\([\mu\beta]^{2,0}\)

_compute_F_FFF__2_0_component

\([\mu\beta]^{0,2}\)

_compute_F_FFF__0_2_component

\([\mu^4]^{1,1}\)

_compute_F_F_F_F__1_1_component

\([\mu^4]^{2,0}\)

_compute_F_F_F_F__2_0_component

\([\mu^4]^{0,2}\)

_compute_F_F_F_F__0_2_component

\([\mu^2\alpha]^{1,0}\)

_compute_F_F_FF__1_0_component

\([\mu^2\alpha]^{0,1}\)

_compute_F_F_FF__0_1_component

The formulas are detailed in this document.

exception nachos.core.shaking.BadShaking
exception nachos.core.shaking.DerivativeNotAvailable(representation, frequency='static')
class nachos.core.shaking.Shaker(datafile)

Shaker class to compute vibrational contributions (to electrical derivatives)

Parameters:

datafile (qcip_tools.chemistry_files.chemistry_datafile.ChemistryDataFile) – input for derivatives

__make_availability()

make the availability table, and the frequency list

_compute_FF_FF__0_0_component(coo, input_fields, frequencies, t_nff)

Compute a component of the \([\alpha^2]^{0,0}\) contribution

\[[\alpha^2]^{0,0} = \frac{1}{8}\,\sum_{\mathcal{P}_{ijkl}} \sum_a \tdiff{\alpha_{ij}}{Q_a}\,\tdiff{\alpha_{kl}}{Q_a}\,\lb{23}{a}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nff (numpy.ndarray) – NFF components

Return type:

list of float

_compute_FF_FF__0_2_component(coo, input_fields, frequencies, t_nff, t_nnn)

Compute a component of the \([\alpha^2]^{0,2}\) contribution

\[\begin{align} [\alpha^2]^{0,2} &= \frac{1}{32}\,\sum_{\mathcal{P}_{ijkl}} \sum_{abcd} \tdiff{\alpha_{ij}}{Q_c}\tdiff{\alpha_{kl}}{Q_d}\, \left[F_{aab}\,F_{bcd}\,\lb{23}{c}\lb{\sigma}{d}\,\omega_b^{-2} +2\,F_{abc}\,F_{abd}\,\lb{23}{ab}\,\lb{23}{c}\,\lb{\sigma}{d}\right] \end{align}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nff (numpy.ndarray) – NFF components

  • t_nnn (numpy.ndarray) – NNN components

Return type:

list of float

_compute_FF_FF__1_1_component(coo, input_fields, frequencies, t_nff, t_nnff, t_nnn)

Compute a component of the \([\alpha^2]^{1,1}\) contribution

\[\begin{split}\begin{align} [\alpha^2]^{1,1} &= -\frac{1}{16}\,\sum_{\mathcal{P}_{ijkl}} \sum_{abc} F_{abc}\, \tdiff{^2\alpha_{ij}}{Q_a\partial Q_b}\,\tdiff{\alpha_{kl}}{Q_c}\, \lb{23}{ab}\,\lb{23}{c}\,(\omega_a^{-1}+\omega_b^{-1})\\ &+ F_{bcc}\,\tdiff{^2\alpha_{ij}}{Q_a\partial Q_b}\,\tdiff{\alpha_{kl}}{Q_a}\, \lb{23}{a}\,\omega_b^{-2}\,\omega_c^{-1} \end{align}\end{split}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nff (numpy.ndarray) – NFF components

  • t_nnff (numpy.ndarray) – NNFF components

  • t_nnn (numpy.ndarray) – NNN components

Return type:

list of float

_compute_FF_FF__2_0_component(coo, input_fields, frequencies, t_nnff)

Compute a component of the \([\alpha^2]^{2,0}\) contribution

\[\begin{align} [\alpha^2]^{2,0} &= \frac{1}{16}\,\sum_{\mathcal{P}_{ijkl}} \sum_{ab} \tdiff{^2\alpha_{ij}}{Q_a\partial Q_b}\tdiff{^2\alpha_{kl}}{Q_a\partial Q_b} \,\lb{23}{ab}\,\omega_a^{-1} \end{align}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nnff (numpy.ndarray) – NNFF components

Return type:

list of float

_compute_F_FFF__0_0_component(coo, input_fields, frequencies, t_nf, t_nfff)

Compute a component of the \([\mu\beta]^{0,0}\) contribution

\[[\mu\beta]^{0,0} = \frac{1}{6}\,\sum_{\mathcal{P}_{ijkl}} \sum_a \tdiff{\mu_i}{Q_a}\,\tdiff{\beta_{jkl}}{Q_a}\,\lb{\sigma}{a}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nf (numpy.ndarray) – NF components

  • t_nfff (numpy.ndarray) – NFFF components

Return type:

list of float

_compute_F_FFF__0_2_component(coo, input_fields, frequencies, t_nf, t_nfff, t_nnn)

Compute a component of the \([\mu\beta]^{0,2}\) contribution

\[\begin{split}\begin{align} [\mu\beta]^{0,2} &= \frac{1}{24}\,\sum_{\mathcal{P}_{ijkl}} \sum_{abcd} \tdiff{\mu_i}{Q_c}\tdiff{\beta_{jkl}}{Q_d}\times\\ &\left[F_{aab}\,F_{bcd}\,\lb{\sigma}{c}\lb{\sigma}{d}\,\omega_b^{-2} +2\,F_{abc}\,F_{abd}\,\lb{\sigma}{ab}\,\lb{\sigma}{c}\,\lb{\sigma}{d}\right] \end{align}\end{split}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nf (numpy.ndarray) – NF components

  • t_nfff (numpy.ndarray) – NFFF components

  • t_nnn (numpy.ndarray) – NNN components

Return type:

list of float

_compute_F_FFF__1_1_component(coo, input_fields, frequencies, t_nf, t_nnf, t_nfff, t_nnfff, t_nnn)

Compute a component of the \([\mu\beta]^{1,1}\) contribution

\[\begin{split}\begin{align} [\mu\beta]^{1,1} &= -\frac{1}{24}\,\sum_{\mathcal{P}_{ijkl}} \sum_{abc} \left\{ F_{abc}\,\left[\tdiff{^2\mu_i}{Q_a\partial Q_b}\,\tdiff{\beta_{jkl}}{Q_c} +\tdiff{^2\beta_{jkl}}{Q_a\partial Q_b}\,\tdiff{\mu_i}{Q_c}\right] \,\lb{\sigma}{ab}\,\lb{\sigma}{c}\,(\omega_a^{-1}+\omega_b^{-1})\right.\\ &\left.+ F_{bcc}\,\left[\tdiff{^2\mu_i}{Q_a\partial Q_b}\,\tdiff{\beta_{jkl}}{Q_a} +\tdiff{^2\beta_{jkl}}{Q_a\partial Q_b}\,\tdiff{\mu_i}{Q_a}\right] \,\lb{\sigma}{a}\,\omega_b^{-2}\,\omega_c^{-1}\right\} \end{align}\end{split}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nnf (numpy.ndarray) – NNF components

  • t_nnfff (numpy.ndarray) – NNFFF components

  • t_nf (numpy.ndarray) – NF components

  • t_nfff (numpy.ndarray) – NFFF components

  • t_nnn (numpy.ndarray) – NNN components

Return type:

list of float

_compute_F_FFF__2_0_component(coo, input_fields, frequencies, t_nnf, t_nnfff)

Compute a component of the \([\mu\beta]^{2,0}\) contribution

\[\begin{align} [\mu\beta]^{2,0} &= \frac{1}{12}\,\sum_{\mathcal{P}_{ijkl}} \sum_{ab} \tdiff{^2\mu_i}{Q_a\partial Q_b}\tdiff{^2\beta_{jkl}}{Q_a\partial Q_b}\, \lb{\sigma}{ab}\,\omega_a^{-1} \end{align}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nnf (numpy.ndarray) – NNF components

  • t_nnfff (numpy.ndarray) – NNFFF components

Return type:

list of float

_compute_F_FF__0_0_component(coo, input_fields, frequencies, t_nf, t_nff)

Compute a component of the \([\mu\alpha]^{0,0}\) contribution

\[\begin{align} [\mu\alpha]^{0,0} &= \frac{1}{2}\,\sum_{\mathcal{P}_{ijk}} \sum_a \tdiff{\mu_i}{Q_a}\,\tdiff{\alpha_{jk}}{Q_a}\,\lb{\sigma}{a} \end{align}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nf (numpy.ndarray) – NF components

  • t_nff (numpy.ndarray) – NFF components

Return type:

list of float

_compute_F_FF__0_2_component(coo, input_fields, frequencies, t_nf, t_nff, t_nnn)

Compute a component of the \([\mu\alpha]^{0,2}\) contribution

\[\begin{split}\begin{align} [\mu\alpha]^{0,2} &= \frac{1}{8}\,\sum_{\mathcal{P}_{ijk}} \sum_{abcd} \tdiff{\mu_i}{Q_c}\tdiff{\alpha_{jk}}{Q_d}\times\\ &\left[ F_{aab}\,F_{bcd}\,\lb{\sigma}{c}\,\lb{\sigma}{d}\,\omega_b^{-2} +2\,F_{abc}\,F_{abd}\,\lb{\sigma}{ab}\,\lb{\sigma}{c}\,\lb{\sigma}{d}\right] \end{align}\end{split}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nf (numpy.ndarray) – NF components

  • t_nff (numpy.ndarray) – NFF components

  • t_nnn (numpy.ndarray) – NNN components

Return type:

list of float

_compute_F_FF__1_1_component(coo, input_fields, frequencies, t_nf, t_nnf, t_nff, t_nnff, t_nnn)

Compute a component of the \([\mu\alpha]^{1,1}\) contribution

\[\begin{split}\begin{align} [\mu\alpha]^{1,1} &= -\frac{1}{8}\,\sum_{\mathcal{P}_{ij}} \sum_{abc} F_{abc}\times\\ &\left[\tdiff{^2\mu_i}{Q_a\partial Q_b}\,\tdiff{\alpha_{jk}}{Q_c}+ \tdiff{^2\alpha_{jk}}{Q_a\partial Q_b}\,\tdiff{\mu_i}{Q_c}\right]\times\\ &\lb{\sigma}{ab}\,\lb{\sigma}{c}\,(\omega_a^{-1}+\omega_b^{-1}) \\ &+ F_{bcc}\,\left[\tdiff{^2\mu_i}{Q_a\partial Q_b}\,\tdiff{\alpha_{jk}}{Q_a} +\tdiff{^2\alpha_{jk}}{Q_a\partial Q_b}\,\tdiff{\mu_i}{Q_a}\right]\times\\ &\lb{\sigma}{a}\,\omega_b^{-2}\,\omega_c^{-1} \end{align}\end{split}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nnf (numpy.ndarray) – NNF components

  • t_nnff (numpy.ndarray) – NNFF components

  • t_nf (numpy.ndarray) – NF components

  • t_nff (numpy.ndarray) – NFF components

  • t_nnn (numpy.ndarray) – NNN components

Return type:

list of float

_compute_F_FF__2_0_component(coo, input_fields, frequencies, t_nnf, t_nnff)

Compute a component of the \([\mu\alpha]^{2,0}\) contribution

\[\begin{align} [\mu\alpha]^{2,0} &= \frac{1}{4}\,\sum_{\mathcal{P}_{ijk}} \sum_{ab} \tdiff{^2\mu_i}{Q_a\partial Q_b}\tdiff{^2\alpha_{jk}}{Q_a\partial Q_b}\, \lb{\sigma}{ab}\,\omega_a^{-1} \end{align}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nnf (numpy.ndarray) – NNF components

  • t_nnff (numpy.ndarray) – NNFF components

Return type:

list of float

_compute_F_F_FF__0_1_component(coo, input_fields, frequencies, t_nf, t_nff, t_nnn)

Compute a component of the \([\mu^2\alpha]^{0,1}\) contribution

\[[\mu^2\alpha]^{0,1} = -\frac{1}{4}\,\sum_{\mathcal{P}_{ijkl}} \sum_{abc} F_{abc}\, \tdiff{\mu_j}{Q_b}\,\tdiff{\mu_i}{Q_a}\,\tdiff{\alpha_{jk}}{Q_c}\,\lb{\sigma}{a}\, \lb{1}{b}\,\lb{23}{c}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nff (numpy.ndarray) – NFF components

  • t_nfff (numpy.ndarray) – NFFF components

  • t_nnn (numpy.ndarray) – NNN components

Return type:

list of float

_compute_F_F_FF__1_0_component(coo, input_fields, frequencies, t_nf, t_nff, t_nnf, t_nnff)

Compute a component of the \([\mu^2\alpha]^{1,0}\) contribution

\[\begin{split}\begin{align} [\mu^2\alpha]^{1,0} &= \frac{1}{4}\,\sum_{\mathcal{P}_{ijkl}} \sum_{ab} \left\{\tdiff{\mu_i}{Q_a}\,\tdiff{^2\alpha_{jk}}{Q_a\partial Q_b}\tdiff{\mu_l}{Q_b} \lb{\sigma}{a}\,\lb{3}{b}\right.\nonumber\\ &+\left.2\,\tdiff{\mu_i}{Q_a}\,\tdiff{^2\mu_j}{Q_a\partial Q_b}\,\tdiff{\alpha_{kl}}{Q_b} \lb{\sigma}{a}\,\lb{23}{b}\right\} \end{align}\end{split}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nff (numpy.ndarray) – NFF components

  • t_nfff (numpy.ndarray) – NFFF components

  • t_nnf (numpy.ndarray) – NNF components

  • t_nnff (numpy.ndarray) – NNFF components

Return type:

list of float

_compute_F_F_F_F__0_2_component(coo, input_fields, frequencies, t_nf, t_nnn)

Compute a component of the \([\mu^4]^{0,2}\) contribution

\[\begin{align} [\mu^4]^{0,2} &= \frac{1}{8}\,\sum_{\mathcal{P}_{ijkl}} \sum_{abcde} \,F_{abc}\,F_{cde}\,\tdiff{\mu_i}{Q_a}\, \tdiff{\mu_j}{Q_b}\, \tdiff{\mu_k}{Q_d}\,\tdiff{\mu_l}{Q_e} \,\lb{\sigma}{a}\,\lb{1}{b}\,\lb{23}{c}\,\lb{2}{d}\,\lb{3}{e} \end{align}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nf (numpy.ndarray) – NF components

  • t_nnn (numpy.ndarray) – NNN components

Return type:

list of float

_compute_F_F_F_F__1_1_component(coo, input_fields, frequencies, t_nf, t_nnf, t_nnn)

Compute a component of the \([\mu^4]^{1,1}\) contribution

\[\begin{split}[\mu^4]^{1,1} = -\frac{1}{2}\,\sum_{\mathcal{P}_{ijkl}} \sum_{abcd}\,F_{abc} \tdiff{\mu_i}{Q_a}\,\tdiff{\mu_j}{Q_b}\,\tdiff{^2\mu_k}{Q_c\partial Q_d}\,\tdiff{\mu_l}{Q_d} \times\\\lb{\sigma}{a}\,\lb{1}{b}\,\lb{23}{c}\,\lb{3}{d}\end{split}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nf (numpy.ndarray) – NF components

  • t_nnf (numpy.ndarray) – NNF components

  • t_nnn (numpy.ndarray) – NNN components

Return type:

list of float

_compute_F_F_F_F__2_0_component(coo, input_fields, frequencies, t_nf, t_nnf)

Compute a component of the \([\mu^4]^{2,0}\) contribution

\[\begin{align} [\mu^4]^{2,0} &= \frac{1}{2}\,\sum_{\mathcal{P}_{ijkl}} \sum_{abc} \,F_{abc}\,\tdiff{\mu_i}{Q_a}\, \tdiff{^2\mu_j}{Q_a\partial Q_b}\, \tdiff{^2\mu_k}{Q_b\partial Q_c}\,\tdiff{\mu_l}{Q_c} \,\lb{\sigma}{a}\,\lb{23}{b}\,\lb{\sigma}{3} \end{align}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nf (numpy.ndarray) – NNF components

  • t_nnf (numpy.ndarray) – NNF components

Return type:

list of float

_compute_F_F_F__0_1_component(coo, input_fields, frequencies, t_nf, t_nnn)

Compute a component of the \([\mu^3]^{0,1}\) contribution

\[\begin{align} [\mu^3]^{0,1} &= -\frac{1}{6}\,\sum_{\mathcal{P}_{ijk}} \sum_{abc} F_{abc} \tdiff{\mu_i}{Q_a}\,\tdiff{\mu_j}{Q_b}\,\tdiff{\mu_k}{Q_c}\, \lb{\sigma}{a}\,\lb{1}{b}\,\lb{2}{c} \end{align}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nf (numpy.ndarray) – NF components

  • t_nnn (numpy.ndarray) – NNN components

Return type:

list of float

_compute_F_F_F__1_0_component(coo, input_fields, frequencies, t_nf, t_nnf)

Compute a component of the \([\mu^3]^{1,0}\) contribution

\[\begin{align} [\mu^3]^{1,0} &= \frac{1}{2}\,\sum_{\mathcal{P}_{ijk}} \sum_{ab} \tdiff{\mu_i}{Q_a}\,\tdiff{^2\mu_j}{Q_a\partial Q_b}\, \tdiff{\mu_k}{Q_b}\,\lb{\sigma}{a}\,\lb{2}{b} \end{align}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nnf (numpy.ndarray) – NNF components

  • t_nf (numpy.ndarray) – NF components

Return type:

list of float

_compute_F_F__0_0_component(coo, input_fields, frequencies, t_nf)

Compute a component of the \([\mu^2]^{0,0}\) contribution

\[[\mu^2]^{0,0} = \frac{1}{2}\,\sum_{\mathcal{P}_{ij}} \sum_a \tdiff{\mu_i}{Q_a}\,\tdiff{\mu_j}{Q_a}\,\lb{\sigma}{a}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nf (numpy.ndarray) – NF components

Return type:

list of float

_compute_F_F__0_2_component(coo, input_fields, frequencies, t_nf, t_nnn)

Compute a component of the \([\mu^2]^{0,2}\) contribution

\[\begin{split}\begin{align} [\mu^2]^{0,2} &= -\frac{1}{8}\,\sum_{\mathcal{P}_{ij}} \sum_{abcd} \tdiff{\mu_i}{Q_c}\tdiff{\mu_j}{Q_d}\times\\ &\left[F_{aab}\,F_{bcd}\,\lb{\sigma}{c}\lb{\sigma}{d}\,\omega_b^{-2} +2\,F_{abc}\,F_{abd}\,\lb{\sigma}{ab}\,\lb{\sigma}{c}\,\lb{\sigma}{d}\right] \end{align}\end{split}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nf (numpy.ndarray) – NF components

  • t_nnn (numpy.ndarray) – NNN components

Return type:

list of float

_compute_F_F__1_1_component(coo, input_fields, frequencies, t_nf, t_nnf, t_nnn)

Compute a component of the \([\mu^2]^{1,1}\) contribution

\[\begin{split}\begin{align} [\mu^2]^{1,1} &= -\frac{1}{4}\,\sum_{\mathcal{P}_{ij}} \sum_{abc} F_{abc}\, \tdiff{^2\mu_i}{Q_a\partial Q_b}\,\tdiff{\mu_j}{Q_c}\, \lb{\sigma}{ab}\,\lb{\sigma}{c}\,(\omega_a^{-1}+\omega_b^{-1})\\ &+ F_{bcc}\,\tdiff{^2\mu_i}{Q_a\partial Q_b}\,\tdiff{\mu_j}{Q_a}\, \lb{\sigma}{a}\,\omega_b^{-2}\,\omega_c^{-1} \end{align}\end{split}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nf (numpy.ndarray) – NF components

  • t_nnf (numpy.ndarray) – NNF components

  • t_nnn (numpy.ndarray) – NNN components

Return type:

list of float

_compute_F_F__2_0_component(coo, input_fields, frequencies, t_nnf)

Compute a component of the \([\mu^2]^{2,0}\) contribution

\[\begin{align} [\mu^2]^{2,0} &= \frac{1}{4}\,\sum_{\mathcal{P}_{ij}} \sum_{ab} \tdiff{^2\mu_i}{Q_a\partial Q_b}\tdiff{^2\mu_j}{Q_a\partial Q_b}\, \lb{\sigma}{ab}\,\omega_a^{-1} \end{align}\]
Parameters:
  • coo (tuple|list) – coordinates

  • input_fields (tuple|list) – input fields

  • frequencies (list of float|str) – the frequencies

  • t_nnf (numpy.ndarray) – NNF components

Return type:

list of float

_compute_zpva_01(derivative, frequencies)

Compute the ZPVA contribution from mechanical anharmonicity:

\[[p]^{0,1} = -\frac{1}{4}\,\sum_{ab} F_{abb}\,\tdiff{p}{Q_a}\,\omega_a^{-2}\,\omega_b^{-1}\]
Parameters:
  • derivative (qcip_tools.derivatives.Derivative) – the derivative

  • frequencies (list of float|str) – the frequencies

Return type:

qcip_tools.derivatives.Tensor

_compute_zpva_10(derivative, frequencies)

Compute the ZPVA contribution from electrical anharmonicity:

\[[p]^{1,0} = \frac{1}{4}\,\sum_a \tdiff{^2p}{Q_a^2}\,\omega_a^{-1}\]
Parameters:
  • derivative (qcip_tools.derivatives.Derivative) – the derivative

  • frequencies (list of float|str) – the frequencies

Return type:

qcip_tools.derivatives.Tensor

_create_tensors(derivative, frequencies, callback, **kwargs)

Create a list of tensor, by taking advantage of the fact that it may (?) be easier to compute the same contribution for many frequencies.

The callback function must be a function of this class, and receive:

  • input_fields` as first argument,

  • then frequencies` (as a list of float, sorted),

  • and finally **kwargs.

Note

  • It is more efficient to compute the static version separately (because of permutations)

  • Permutation of the full tensor is not used: the first coordinate is separated from the rest.

Parameters:
  • derivative (qcip_tools.derivatives.Derivative) – the derivative of the tensor for which the contribution should be computed

  • frequencies (list) – the frequencies

  • callback (str) – callback func

  • kwargs (dict) – kwargs

Return type:

dict

check_availability(vc, limit_anharmonicity_usage=True)

Check what is available for the computation

Parameters:
  • vc (VibrationalContribution) – vibrational contribution

  • limit_anharmonicity_usage (bool) – limit the usage of anharmonicity to first order (so it accepts m>1, n>1 even if the corresponding derivative is not available)

Return type:

bool

compute_pv(vc, derivative, frequencies, limit_anharmonicity_usage=True)

Compute a pure vibrational contribution.

Note

Expect the callback function to be '_compute_' + what + '_component', and kwargs to looks like 't_' + repr.

Parameters:
  • vc (VibrationalContribution) – what to compute

  • derivative (qcip_tools.derivatives.Derivative) – representation

  • frequencies (list) – list of frequencies

  • limit_anharmonicity_usage (bool) – limit the usage of anharmonicity to first order

Return type:

dict

compute_zpva(vc, derivative, frequencies)

Compute a ZPVA contribution to a given derivative. It does not uses _create_tensors() since it is possible to go along without permutations (and therefore, work with the all tensor as one).

Parameters:
  • vc (VibrationalContribution) – what to compute

  • derivative (qcip_tools.derivatives.Derivative) – representation

  • frequencies (list) – list of frequencies

Return type:

dict

static display_message(message, out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, verbosity_level=0)

Output a message, if requested

Parameters:
  • message (str) – the message

  • out (file) – output if information is needed to be outputed

  • verbosity_level (int) – how far should we print information

static get_iterator(coordinates, input_fields)

Get the iteration over all possible permutations

Parameters:
  • coordinates (tuple) – coordinates

  • input_fields (tuple) – the input fields

Return type:

(int, list)

static lambda_(up, down)

Compute the lambda quantity found in the papers of Kirtman and Bishop

\[\begin{split}\begin{align} \lambda^{\pm ij\ldots}_{xy\ldots}= [(\omega_x+\omega_y+\ldots)& +(\omega_i+\omega_j+\ldots)]^{-1} \times\\ &[(\omega_x+\omega_y+\ldots)-(\omega_i+\omega_j+\ldots)]^{-1} \end{align}\end{split}\]
Parameters:
  • up (float|list|tuple) – upper argument (optical frequencies: \(\omega_{i}\), …)

  • down (float|list|tuple) – down argument (vibrational frequencies: \(\omega_{x}\), …)

Return type:

float

static output_tensors(base, vc, tensors, frequencies, out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, verbosity_level=0, what='')

Output a bit of information if requested

Parameters:
  • base (qcip_tools.derivatives.Derivative) – base electrical derivative for which the vibrational contribution is computed

  • vc (VibrationalContribution|None) – vibrational contribution

  • tensors (dict) – list of tensors

  • frequencies (list) – frequencies

  • out (file) – output if information is needed to be outputed

  • verbosity_level (int) – how far should we print information

  • what (str) – used when no vc is given

shake(only=None, frequencies=None, out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, verbosity_level=0, limit_anharmonicity_usage=True)

Compute the vibrational contributions

Parameters:
  • only (list|tuple of qcip_tools.derivatives.Derivative, int) – restrict to the vibrational contribution to certain derivatives

  • frequencies (list) – frequencies (if not available, ZPVA will not be computed for those ones)

  • out (file) – output if information is needed to be outputed

  • verbosity_level (int) – how far should we print information

  • limit_anharmonicity_usage (bool) – limit the usage of anharmonicity to first order

Return type:

dict

class nachos.core.shaking.VibrationalContribution(derivatives_, m=0, n=0, dof=3)

Represent a vibrational contribution

Parameters:
  • derivatives (list|tuple) – list of derivatives_

  • m (int) – m (electrical anharmonicity)

  • n (int) – n (mechanical anharmonicity)

derivatives_needed(limit_anharmonicity_usage=True, dof=None)

Get the list of the derivatives needed to compute this contribution

Parameters:

limit_anharmonicity_usage (bool) – limit the usage to first order of mechanical and electrical anharmonicity

Return type:

list

static from_representation(representation, dof=3)

Convert the not fancy representation back into class

Parameters:
  • representation (str) – reprentation of the vibrational contribution (X_Y_Z__m_n)

  • dof (int) – dof

Return type:

VibrationalContribution

class nachos.core.shaking.VibrationalContributionsData(derivative, spacial_dof)

Store the different vibrational contributions for a given derivative

Parameters:

derivative (qcip_tools.derivatives.Derivative) – the derivative

add_contribution(vc, values)

add a contribution

Parameters:
sort_per_type_and_order()

Group vibrational contributions together.

Type:

dict

write_in_group(group)

Write in an h5py group

Parameters:

group (h5py.Group) – the group

nachos.core.shaking._merge_dict_of_tensors(b, a)

Merge two dicts of tensors. Please keep that function internal.

nachos.core.shaking.load_vibrational_contributions(path, spacial_dof)

Save the contributions in an h5file

Parameters:
  • path (str) – path to the h5 file

  • spacial_dof (int) – dof

Return type:

dict

nachos.core.shaking.save_vibrational_contributions(path, contributions)

Save the contributions in an h5file

Parameters:
  • path (str) – path to the h5 file

  • contributions (dict) – the vibrational contributions

Analyzing (nachos.core.analyzing)

class nachos.core.analyzing.Analyzer(datafile, vibrational_contributions=None)

Analyzer class that outputs property for different tensors contained in data file

Parameters:
analyze(properties, out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, only=None, frequencies_to_show=None, inverse_vibs=None, group_vibs=False)

Display the different values, as requested

Parameters:
  • properties (dict) – different properties

  • out (file) – output

  • only (list of qcip_tools.derivatives.Derivative) – derivatives for which properties must be shown

  • frequencies_to_show (list) – only show given frequencies

  • inverse_vibs (bool) – for vibrational, show value(total - current) rather than value(current)

  • group_vibs (bool) – for vibrational, group by perturbation order rather than detailed

exception nachos.core.analyzing.BadAnalysis
class nachos.core.analyzing.GetPropertyOfTensor(accessor, converter=<function GetPropertyOfTensor.<lambda>>, explain=None, **kwargs)

Get a property for a given object (with an eventual conversion)

Parameters:
  • what (callback) – function

  • convert (callback) – convert Tensor to a more specialized tensor

  • explain (str) – explanation of the property

execute(obj, total=None)

Execute callback on obj, after conversion

Parameters:
  • obj (qcip_tools.derivatives.Tensor) – the obj

  • total – use callback on total - obj rather than obj

Returns:

nachos.core.analyzing.component_access(obj, **kwargs)

Access to a coordinate of the tensor

Parameters:

obj (qcip_tools.derivatives.Tensor) – tensor

Return type:

float

nachos.core.analyzing.get_tensor_converter(type_)

Get a converter from qcip_tools.derivatives.Tensor to a more specialized type

nachos.core.analyzing.get_vibrational_contributions(order)

Get the different vibrational contribution to a given order

Parameters:

order (int) – order (1=dipole, 2=polarizability, …)

Return type:

list

nachos.core.analyzing.property_access(obj, **kwargs)

Access to a property of the tensor

Parameters:

obj (qcip_tools.derivatives.Tensor) – tensor