Calculators#
The evaluation of correlation energy and spectrum of a coupled system is handled by calculator objects. These calculators use different internal representations of the response functions of the polarizable objects that build up the coupled system.
CasidaCalculator#
- class strongcoca.calculators.CasidaCalculator(coupled_system, broadening=NoArtificialBroadening, name='CasidaCalculator')[source]#
Instances of this class enable the calculation of correlation energy and spectrum of a coupled system, all polarizable objects in which have an internal representation in the form of a Casida matrix.
The calculations are done for discrete excitations, and continuous spectra calculated with this calculator use the given broadening.
- Parameters:
coupled_system (
CoupledSystem) – Coupled system for which to carry out calculations.broadening (
Broadening) – Artificial broadening used for the continuous response; defaults to no broadening.name (
str) – Name of response.
Examples
The following code snippet shows the calculation of the correlation energy for a simple demo system:
>>> from strongcoca import CoupledSystem, PolarizableUnit >>> from strongcoca.response import build_random_casida >>> from strongcoca.calculators import CasidaCalculator >>> >>> # construct coupled system >>> response = build_random_casida(n_states=2, name='Tiger', random_seed=42) >>> pu1 = PolarizableUnit(response, [0, 0, 0], name='Cheetah') >>> pu2 = PolarizableUnit(response, [3, 0, 0], name='Leopard') >>> cs = CoupledSystem([pu1, pu2]) >>> >>> # set up calculator >>> calc = CasidaCalculator(cs) >>> >>> # ... and compute the correlation energy >>> calc.get_correlation_energy() -0.050798240...
- property atoms: Atoms | None#
Atomic structure associated with this response function. None if not available.
- property broadening: Broadening#
Broadening of the response.
- property coupled_system: CoupledSystem#
Coupled system for which calculations are carried out.
- property excitations: Excitations#
Excitations as
Excitations.
- get_correlation_energy()#
Return the correlation energy of the coupled system in units of eV.
- get_dipole_strength_function(frequencies)#
Returns the dipole strength function.
- get_dynamic_polarizability(frequencies)#
Returns the dynamic polarizability in the real frequency domain.
- get_dynamic_polarizability_imaginary_frequency(frequencies)#
Returns the dynamic polarizability in the imaginary frequency domain.
- is_dirty()#
Returns True if the state of the underlying coupled system has changed since the last calculation.
- Return type:
bool
- property name: str#
Name of response function.
- property pbc: bool#
True if underlying system is periodic.
PolarizabilityCalculator#
- class strongcoca.calculators.PolarizabilityCalculator(coupled_system, imaginary_frequencies, units='eV', name='PolarizabilityCalculator')[source]#
Instances of this class enable the calculation of correlation energy and spectrum of a coupled system, all polarizable objects in which have an internal representation in the form of a polarizability tensor.
Spectra calculated with this calculator derive broadening from the underlying polarizable units. Any additional or separate broadening is not added.
- Parameters:
coupled_system (
CoupledSystem) – Coupled system for which to carry out calculations.imaginary_frequencies (
Union[ndarray,Sequence[float]]) – Frequency grid along imaginary axis used for correlation energy calculation; eV by default, optionally atomic units (seeunits).units (
str) –eVto specify energies in eV orauto specify inputs in atomic units.This parameter determines whether conversion should be performed during initialization and has no effect on instance methods and variables.
name (
str) – Name of response.
Examples
The following code snippet shows the calculation of the correlation energy for a simple demo system:
>>> import numpy as np >>> from strongcoca import CoupledSystem, PolarizableUnit >>> from strongcoca.response import build_random_casida >>> from strongcoca.calculators import PolarizabilityCalculator >>> >>> # construct coupled system >>> response = build_random_casida(n_states=2) >>> pu1 = PolarizableUnit(response, [0, 0, 0]) >>> pu2 = PolarizableUnit(response, [2, 0, 0]) >>> cs = CoupledSystem([pu1, pu2]) >>> >>> # set up calculator >>> calc = PolarizabilityCalculator(cs, np.linspace(0, 10, 100)) >>> >>> # ... and compute the correlation energy >>> calc.get_correlation_energy() -0.72084000362...
- property atoms: Atoms | None#
Atomic structure associated with this response function. None if not available.
- property broadening: Broadening#
Broadening of the response.
- property coupled_system: CoupledSystem#
Coupled system for which calculations are carried out.
- property coupling_matrix: ndarray#
The coupling matrix
\[\boldsymbol{T}_{ij} = \frac{3\boldsymbol{r}^{(ij)}(\boldsymbol{r}^{(ij)})^\text{T}}{\left|r^{(ij)}\right|^5} - \frac{1}{\left|r^{(ij)}\right|^3}\]as a matrix where the rows and columns each correspond to the system index \(i\) or \(j\) and the Cartesian direction.
This quantity is calculated on first use and then buffered.
- get_correlation_energy()#
Return the correlation energy of the coupled system in units of eV.
- get_dipole_strength_function(frequencies)#
Returns the dipole strength function.
- get_dynamic_polarizability(frequencies)#
Returns the dynamic polarizability in the real frequency domain.
- get_dynamic_polarizability_imaginary_frequency(frequencies)#
Returns the dynamic polarizability in the imaginary frequency domain.
- is_dirty()#
Returns True if the state of the underlying coupled system has changed since the last calculation.
- Return type:
bool
- property name: str#
Name of response function.
- property pbc: bool#
True if underlying system is periodic.