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: Recipe, directory='.')

Store computational results from the cooking process.

This class manages derivative results computed during numerical differentiation.

Parameters:

recipe – Recipe object defining differentiation parameters.

add_result(fields: list | tuple, derivative: str, value: dict | object, allow_replace: bool = False)

Store a derivative result for specified field points.

Parameters:
  • fields – Field strength points.

  • derivative – String representation of the derivative.

  • value – Computed derivative value.

  • allow_replace – If True, allow overwriting existing results.

Raises:
check() tuple[list, list]

Verify all required derivatives are present.

Validates that all fields and derivatives specified by the recipe have been computed and stored.

Returns:

Tuple of (missing_fields, missing_derivatives) lists.

static get_recipe_check_data(recipe: Recipe) list

Extract recipe verification data for consistency checks.

Parameters:

recipe – Recipe object to extract data from.

Returns:

List containing [min_field, ratio, k_max, type_flag, num_atoms, weighted_atomic_sum].

read(path: str) None

Load results from an HDF5 file.

Parameters:

path – Relative path to the HDF5 file to read.

Raises:

BadResult – If file format is invalid or incompatible with current recipe.

tensor_element_access(fields: list | tuple, min_field: float, basis: Derivative, component: tuple, frequency: float, recipe: Recipe) float

Access a specific tensor component value.

Parameters:
  • fields – Field strength points.

  • min_field – Minimum field value used in calculations.

  • basis – Derivative basis object.

  • component – Tuple specifying tensor component indices.

  • frequency – Frequency value (for frequency-dependent properties).

  • recipe – Recipe object.

Returns:

The tensor component value.

Raises:

BadResult – If fields, derivatives, or components are not available.

write(path: str) None

Serialize results to an HDF5 file.

Parameters:

path – Relative path to the output HDF5 file.

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

Handle parameters for numerical differentiation.

This class manages recipe configuration for numerical differentiation calculations.

bases(level_min: int = -1) list[tuple[Derivative, int]]

Retrieve derivative bases with their differentiation levels.

Parameters:

level_min – Minimum differentiation level required.

Returns:

List of tuples containing (Derivative object, level).

check_data()

Validate recipe data coherence.

Raises:

BadRecipe – If recipe parameters are invalid or inconsistent.

maximum_derivatives() list[Derivative]

Retrieve all derivative objects up to maximum differentiation level.

Returns:

List of Derivative objects for differentiation orders 1 to max_differentiation.

read(fp: TextIO) None

Load recipe configuration from a YAML file.

Parameters:

fp – File descriptor opened in read mode.

Raises:

BadRecipe – If recipe parameters are invalid or disallowed.

write(fp: TextIO) None

Write recipe configuration to a YAML file.

Parameters:

fp – File descriptor opened 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)

Build a recipe through interactive prompts or command-line arguments.

Guides users through creating a numerical differentiation recipe by prompting for configuration parameters or accepting them from arguments.

make(args: dict) Recipe

Create a recipe from user input or arguments.

Interactively prompts for or accepts recipe configuration parameters and returns a validated Recipe object.

Parameters:

args – Dictionary of command-line arguments (attribute access compatible).

Returns:

Configured Recipe object ready for numerical differentiation.

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 computation input files for supported quantum chemistry packages.

This class generates input files for various quantum chemistry software based on a numerical differentiation recipe.

Parameters:

recipe – Recipe object defining the differentiation parameters.

static deform_geometry(geometry: object, real_fields: list, geometry_in_angstrom: bool = True) object

Apply field-induced deformation to molecular geometry.

Displaces atomic positions according to field-dependent deformations, accounting for unit conversions if needed.

Parameters:
  • geometry – Molecular geometry to deform.

  • real_fields – Field-dependent displacements in atomic units.

  • geometry_in_angstrom – If True, geometry is in Angstrom; field is in atomic units.

Returns:

Deformed molecule with updated atomic positions.

static nonzero_fields(fields: list, geometry: object, t: str) list

Generate labels for non-zero field components.

Parameters:
  • fields – List of field values.

  • geometry – Molecular geometry object.

  • t – Type of derivatives (‘G’ for geometrical, ‘F’ for field-dependent).

Returns:

List of formatted field component labels.

prepare(dry_run: bool = False) list

Generate input files for all required field configurations.

Parameters:

dry_run – If True, simulate file creation without writing files.

Returns:

List of (fields, basis_types, file_path) tuples for created files.

prepare_dalton_inputs(dry_run: bool = False) list

Generate Dalton input files for geometrical derivatives.

Note: Currently only supports geometrical derivatives (type=’G’).

Parameters:

dry_run – If True, simulate file creation without writing files.

Returns:

List of (fields, basis_types, file_path) tuples for created files.

prepare_gaussian_inputs(dry_run: bool = False) list

Generate Gaussian input files for all required field configurations.

Parameters:

dry_run – If True, simulate file creation without writing files.

Returns:

List of (fields, basis_types, file_path) tuples for created files.

prepare_qchem_inputs(dry_run: bool = False) list

Generate Q-Chem input files for all required field configurations.

Parameters:

dry_run – If True, simulate file creation without writing files.

Returns:

List of (fields, basis_types, file_path) tuples for created files.

nachos.core.preparing.fields_needed_by_recipe(recipe: Any) list

Determine field points needed according to recipe.

Identifies all unique field configurations required for numerical differentiation based on the recipe specification.

Parameters:

recipe – Recipe object specifying differentiation parameters.

Returns:

List of (fields, level) tuples for required calculations.

Cooking (nachos.core.cooking)

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

Extract computed properties from quantum chemistry calculation results.

This class processes output files from quantum chemistry packages and collects computed derivatives for storage in a computational results file.

Parameters:
  • recipe – Recipe object defining the differentiation parameters.

  • directory – Working directory where storage will be written.

cook(directories: list[str], out: ~typing.TextIO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, verbosity_level: int = 0, use_gaussian_logs: bool = False) ComputationalResults

Process quantum chemistry output files and collect computed derivatives.

Searches directories for calculation output files, extracts computed properties (energies, derivatives), and stores them in a ComputationalResults object.

Parameters:
  • directories – List of directories to search for QM results.

  • out – File-like object for output messages (default: sys.stdout).

  • verbosity_level – Verbosity level (0=silent, 1=verbose).

  • use_gaussian_logs – Use Gaussian LOG files instead of FCHK (not recommended).

Returns:

ComputationalResults object containing all extracted derivatives.

cook_from_file(f: object, name: str, storage: ComputationalResults) list[str]

Extract derivatives from a single quantum chemistry output file.

Processes a chemistry file to extract computed energies, electrical derivatives, and geometrical derivatives, storing results in the provided storage object.

Parameters:
  • f – Chemistry file object opened for reading.

  • name – Path to the file being processed.

  • storage – ComputationalResults object to store extracted data.

Returns:

List of derivative identifiers that were successfully extracted.

static real_fields_from_geometry(geometry: Molecule, deformed_geometry: Molecule, threshold: float = 0.0001) list[float]

Calculate real-valued field displacements from geometry deformation.

Compares two molecular geometries to extract field-dependent atomic displacements, useful for identifying field values from geometrically distorted structures.

Parameters:
  • geometry – Reference molecular geometry.

  • deformed_geometry – Deformed molecular geometry.

  • threshold – Minimum displacement magnitude to consider non-zero (default: 1e-4).

Returns:

List of real-valued field displacements in atomic units.

Raises:

ValueError – If geometries have different atoms or structures.

static real_fields_to_fields(real_field: list, min_field: float, ratio: float) list[int]

Convert real field values to discretized field indices.

Transforms continuous field values into discrete indices based on geometric progression with specified minimum field and ratio.

Parameters:
  • real_field – List of real-valued field strengths.

  • min_field – Minimum field value (first non-zero index).

  • ratio – Geometric progression ratio for field discretization.

Returns:

List of integer field indices (0 for zero values).

Baking (nachos.core.baking)

exception nachos.core.baking.BadBaking
class nachos.core.baking.Baker(recipe: Recipe, storage, directory: str = '.', original_cf: ChemistryDataFile | None = None)

Perform numerical differentiation on quantum chemistry results.

This class computes finite-difference derivatives from computed molecular properties using Romberg extrapolation for improved accuracy.

Parameters:
  • recipe – Recipe object defining differentiation parameters.

  • storage – ComputationalResults object containing computed values.

  • directory – Working directory for file operations.

  • original_cf – Optional existing chemistry datafile to append derivatives to.

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

Compute numerical derivatives from stored quantum chemistry results.

Performs finite-difference numerical differentiation using Romberg extrapolation on computed derivatives, with optional filtering and customization.

Parameters:
  • only – List of (derivative, level) tuples to compute (None = all).

  • out – File-like object for output messages (default: sys.stdout).

  • verbosity_level – Verbosity level (0=silent, 1+=verbose with increasing detail).

  • copy_zero_field_basis – Copy zero-field results to all field configurations.

  • force_choice – Force specific Romberg triangle choice (advanced).

Returns:

ChemistryDataFile object with computed derivatives appended.

static make_uncertainty_tensor(romberg_triangles: dict, initial_derivative: Derivative, diff_derivative: Derivative, frequency: str | float) Tensor

Compute error estimates from Romberg extrapolation triangles.

Creates a tensor of uncertainties by extracting convergence error estimates from Romberg triangles used in numerical differentiation.

Parameters:
  • romberg_triangles – Dictionary mapping component indices to Romberg triangles.

  • initial_derivative – Starting derivative before differentiation.

  • diff_derivative – Differentiation derivative to apply.

  • frequency – Frequency value (for frequency-dependent properties).

Returns:

Tensor object containing uncertainty estimates.

static output_information(recipe: Recipe, initial_derivative: Derivative, diff_derivative: Derivative, final_result: Tensor, romberg_triangles: dict, tensor_access, out: TextIO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, verbosity_level: int = 0) None

Display detailed computation information and validation statistics.

Outputs information about the numerical differentiation computation at various verbosity levels, including Romberg triangles, Kleinman conditions, and uncertainty estimates.

Verbosity levels:

0: Silent 1: Output final tensor 2: Include Romberg triangles and best value selection 3+: Include decision process and convergence details

Parameters:
  • recipe – Recipe defining differentiation parameters.

  • initial_derivative – Starting derivative.

  • diff_derivative – Applied differentiation.

  • final_result – Computed final derivative tensor.

  • romberg_triangles – Romberg extrapolation triangles for each component.

  • tensor_access – Function to access tensor components from storage.

  • out – File-like object for output (default: sys.stdout).

  • verbosity_level – Verbosity level (0-3+).

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

Project geometrical derivatives onto normal modes.

Converts geometrical derivatives from Cartesian to normal mode coordinates using mass-weighted Hessian transformation, useful for vibrational analysis.

Parameters:
  • recipe – Recipe defining differentiation parameters.

  • datafile – ChemistryDataFile containing computed derivatives.

  • mass_weighted_hessian – Mass-weighted Hessian for coordinate transformation.

  • out – File-like object for output messages (default: sys.stdout).

  • verbosity_level – Verbosity level for informational output.

Raises:

ValueError – If Hessian dimensions don’t match recipe degrees of freedom.

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)

Compute vibrational contributions to electrical derivatives.

This class calculates zero-point vibrational averages and perturbative vibrational contributions using mass-weighted Hessian and normal mode analysis.

Parameters:

datafile – ChemistryDataFile object with computed derivatives and Hessian.

__make_availability() None

Build internal availability tables for derivatives and frequencies.

Populates lookup tables for available geometrical derivatives and dynamic frequencies from the datafile.

_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{aligned} [\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{aligned}\]
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{aligned} [\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{aligned}\]
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{aligned} [\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{aligned}\]
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{aligned} [\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{aligned}\]
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{aligned} [\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{aligned}\]
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{aligned} [\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{aligned}\]
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{aligned} [\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{aligned}\]
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{aligned} [\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{aligned}\]
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{aligned} [\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{aligned}\]
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{aligned} [\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{aligned}\]
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{aligned} [\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{aligned}\]
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{aligned} [\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{aligned}\]
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

\[[\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}\]
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{aligned} [\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{aligned}\]
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{aligned} [\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{aligned}\]
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{aligned} [\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{aligned}\]
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{aligned} [\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{aligned}\]
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{aligned} [\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{aligned}\]
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{aligned} [\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{aligned}\]
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: object, frequencies: list) dict

Compute ZPVA contribution from mechanical anharmonicity.

Parameters:
  • derivative – Derivative for which contribution is computed.

  • frequencies – List of frequencies for evaluation.

Returns:

Dictionary mapping frequencies to computed tensors.

_compute_zpva_10(derivative: object, frequencies: list) object

Compute ZPVA contribution from electrical anharmonicity.

Parameters:
  • derivative – Derivative for which contribution is computed.

  • frequencies – List of frequencies for evaluation.

Returns:

Dictionary mapping frequencies to computed tensors.

_create_tensors(derivative: object, frequencies: list, callback: str, **kwargs: dict) dict

Create tensors by computing contributions for many frequencies efficiently.

Leverages the fact that contributions for multiple frequencies can be computed together. The callback function must accept input_fields, frequencies, and **kwargs.

Parameters:
  • derivative – Derivative for which tensors are computed.

  • frequencies – List of frequencies for computation.

  • callback – Name of callback method in this class.

  • **kwargs – Additional arguments passed to callback.

Returns:

Dictionary mapping frequencies to computed tensors.

check_availability(vc: object, limit_anharmonicity_usage: bool = True) bool

Verify required derivatives are available for computation.

Parameters:
  • vc – VibrationalContribution to check.

  • limit_anharmonicity_usage – Limit to first-order anharmonicity effects.

Returns:

True if all required derivatives are available, False otherwise.

compute_pv(vc: object, derivative: object, frequencies: list, limit_anharmonicity_usage: bool = True) dict

Compute a perturbative vibrational contribution.

Parameters:
  • vc – VibrationalContribution to compute.

  • derivative – Derivative object or representation.

  • frequencies – List of frequencies for evaluation.

  • limit_anharmonicity_usage – Limit to first-order anharmonicity effects.

Returns:

Dictionary of computed tensors.

Raises:

BadShaking – If derivative is geometrical, order mismatch, or derivatives unavailable.

compute_zpva(vc: object, derivative: object, frequencies: list) dict

Compute a zero-point vibrational average (ZPVA) contribution.

Computes ZPVA without permutations, working with the entire tensor as one.

Parameters:
  • vc – VibrationalContribution to compute.

  • derivative – Derivative object or representation.

  • frequencies – List of frequencies for evaluation.

Returns:

Dictionary of computed tensors.

Raises:

BadShaking – If derivative is geometrical or vc specifications are invalid.

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

Output a message if verbosity level permits.

Parameters:
  • message – The message text to output.

  • out – Output file object for printing (default: stdout).

  • verbosity_level – Verbosity level (0=silent, 1=normal, 2+=verbose).

static get_iterator(coordinates: tuple, input_fields: tuple) tuple

Get all possible permutations for coordinate and field combinations.

Parameters:
  • coordinates – Tuple of coordinate labels.

  • input_fields – Tuple of input fields.

Returns:

Tuple of (permutation_count, set of permutations).

static lambda_(up: float | list | tuple, down: float | list | tuple) float

Compute the lambda quantity from Kirtman and Bishop papers.

Used in perturbative vibrational calculations.

Parameters:
  • up – Upper argument (optical frequencies: $omega_{i}$, …).

  • down – Down argument (vibrational frequencies: $omega_{x}$, …).

Returns:

Computed lambda value.

static output_tensors(base: object, vc: object | None, tensors: dict, frequencies: list, out: object = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, verbosity_level: int = 0, what: str = '') None

Output computed tensor information if verbosity level permits.

Parameters:
  • base – Base electrical derivative.

  • vc – VibrationalContribution (None if displaying total).

  • tensors – Dictionary of computed tensors.

  • frequencies – List of frequencies to output.

  • out – Output file object for printing (default: stdout).

  • verbosity_level – Verbosity level (0=silent, 1=normal, 3+=verbose).

  • what – Label to use when no vc is given (default: empty).

shake(only: list | tuple | None = None, frequencies: list | None = None, out: object = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, verbosity_level: int = 0, limit_anharmonicity_usage: bool = True) dict

Compute vibrational contributions to electrical derivatives.

Parameters:
  • only – Restrict computation to specific derivatives with max perturbation order.

  • frequencies – List of frequencies (if not provided, ZPVA won’t be computed).

  • out – Output file object for printing information.

  • verbosity_level – Verbosity level for output (0=none, 1=standard, 2+=detailed).

  • limit_anharmonicity_usage – Limit to first-order anharmonicity effects.

Returns:

Dictionary mapping derivatives to VibrationalContributionsData objects.

Raises:

BadShaking – If requested derivatives cannot be computed.

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

Represent a single vibrational contribution term.

Encodes the type, order, and anharmonicity of a vibrational contribution to electrical derivatives (ZPVA or perturbative).

Parameters:
  • derivatives – Tuple or list of Derivative objects or string representations.

  • m – Electrical anharmonicity order (default: 0).

  • n – Mechanical anharmonicity order (default: 0).

  • dof – Spatial degrees of freedom (default: 3).

derivatives_needed(limit_anharmonicity_usage: bool = True, dof: int | None = None) list

Identify all derivatives required to compute this contribution.

Parameters:
  • limit_anharmonicity_usage – Limit to first-order anharmonicity effects.

  • dof – Spatial degrees of freedom (uses instance value if None).

Returns:

List of Derivative objects needed for computation.

static from_representation(representation: str, dof: int = 3) VibrationalContribution

Create a VibrationalContribution from its string representation.

Parses the non-fancy notation format (X_Y_Z__m_n) to reconstruct the original object.

Parameters:
  • representation – String representation of vibrational contribution.

  • dof – Spatial degrees of freedom (default: 3).

Returns:

Reconstructed VibrationalContribution object.

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

Store vibrational contributions for a given derivative.

Manages the collection of zero-point vibrational and perturbative vibrational contributions to electrical derivatives.

Parameters:
  • derivative – Derivative object to store contributions for.

  • spacial_dof – Number of spatial degrees of freedom.

add_contribution(vc: object, values: dict) None

Register a vibrational contribution with its computed values.

Parameters:
  • vc – VibrationalContribution object to add.

  • values – Dictionary mapping frequencies to computed tensors.

sort_per_type_and_order() dict

Organize vibrational contributions by type and perturbation order.

Returns:

Dictionary with ZPVA and pV contributions grouped by base derivative and order.

write_in_group(group: object) None

Serialize contributions to an HDF5 group.

Parameters:

group – HDF5 group for storing derivatives.

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: str, spacial_dof: int) dict

Load vibrational contributions from an HDF5 file.

Parameters:
  • path – Path to the HDF5 file.

  • spacial_dof – Number of spatial degrees of freedom.

Returns:

Dictionary of loaded VibrationalContributionsData objects.

nachos.core.shaking.save_vibrational_contributions(path: str, contributions: dict) None

Persist vibrational contributions to an HDF5 file.

Parameters:
  • path – Path to the HDF5 file.

  • contributions – Dictionary of VibrationalContributionsData objects.

Analyzing (nachos.core.analyzing)

class nachos.core.analyzing.Analyzer(datafile: Any, vibrational_contributions: dict[Any, Any] | None = None)

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

Parameters:
  • datafile – Input for derivatives.

  • vibrational_contributions – Eventual vibrational contributions.

analyze(properties: dict[int, list[~typing.Any]], out: ~typing.TextIO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, only: list[~typing.Any] | None = None, frequencies_to_show: list[str] | None = None, inverse_vibs: bool | None = None, group_vibs: bool = False) None

Display the different values, as requested.

Parameters:
  • properties – Different properties.

  • out – Output stream or file.

  • only – Derivatives for which properties must be shown.

  • frequencies_to_show – Only show given frequencies.

  • inverse_vibs – For vibrational, show value(total - current) rather than value(current).

  • group_vibs – For vibrational, group by perturbation order rather than detailed.

Raises:

BadAnalysis – If a derivative base is not found in the datafile or vibrational contributions.

exception nachos.core.analyzing.BadAnalysis
class nachos.core.analyzing.GetPropertyOfTensor(accessor: ~typing.Callable[[...], ~typing.Any], converter: ~typing.Callable[[~typing.Any], ~typing.Any] = <function GetPropertyOfTensor.<lambda>>, explain: str | None = None, **kwargs: ~typing.Any)

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

Parameters:
  • accessor – Callback function to access the property.

  • converter – Callback to convert Tensor to a more specialized tensor.

  • explain – Explanation of the property.

  • **kwargs – Additional keyword arguments passed to the accessor.

execute(obj: Any, total: Any | None = None) Any

Execute callback on obj, after conversion.

Parameters:
  • obj – The tensor object.

  • total – Use callback on total - obj rather than obj.

Returns:

The property value extracted by the accessor.

nachos.core.analyzing.component_access(obj: Any, **kwargs: Any) float

Access to a coordinate of the tensor.

Parameters:
  • obj – The tensor object.

  • **kwargs – Keyword arguments, must include ‘component’.

Returns:

The coordinate value.

Raises:

ValueError – If coordinates shape does not match with the tensor.

nachos.core.analyzing.get_tensor_converter(type_: Any) Callable[[Any], Any]

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

Parameters:

type – The specialized type class.

Returns:

A converter function.

nachos.core.analyzing.get_vibrational_contributions(order: int) list[str]

Get the different vibrational contribution to a given order.

Parameters:

order – Order (1=dipole, 2=polarizability, …).

Returns:

A list of vibrational contributions.

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

Access to a property of the tensor.

Parameters:
  • obj – The tensor object.

  • **kwargs – Keyword arguments, must include ‘function’.

Returns:

The property value.

Raises:

ValueError – If object has no function with the specified name.