Scine::Sparrow  5.1.0
Library for fast and agile quantum chemical calculations with semiempirical methods.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Scine::Sparrow::TimeDependentUtils Class Reference

Class containing utility functions for excites-states calculations such as (NDDO-)CIS or TD-DFT(B).This class contains static functions to calculate occupied-virtual energy difference vectors, generate excitation labels (occ -> vir) for restricted and unrestricted reference calculations. More...

Collaboration diagram for Scine::Sparrow::TimeDependentUtils:
Collaboration graph

Public Types

enum  Direction { To, From }
 

Static Public Member Functions

static Eigen::VectorXd generateEnergyDifferenceVector (int nOccupiedOrbitals, int nVirtualOrbitals, const Utils::SingleParticleEnergies &energies)
 Calculates the occupied->virtual energy difference vector. More...
 
template<Utils::Reference restrictedness>
static std::vector< std::string > generateExcitationsLabels (const Utils::SpinAdaptedContainer< restrictedness, std::vector< Utils::Excitation >> &excitations)
 Function generating a vector of "occ->vir" excitation labels. More...
 
static std::vector< std::string > generateExcitationsLabels (const std::vector< Utils::Excitation > &excitations, const Eigen::Matrix< bool,-1, 1 > &isBeta={})
 Function generating a vector of "occ->vir" excitation labels. More...
 
template<Utils::Reference restrictedness>
static void generateEnergyDifferenceVector (const Utils::SingleParticleEnergies &energies, const Utils::LcaoUtils::ElectronicOccupation &occupation, Utils::SpinAdaptedContainer< restrictedness, Eigen::VectorXd > &energyDifferenceVector)
 Calculated the occupied->virtual energy difference vector. More...
 
static void generateVirtualOrbitalIndices (const std::vector< int > &occupiedOrbitalsIndices, std::vector< int > &virtualOrbitalsIndices)
 Fills a vector of virtual orbital indices having just size and occupied indices. More...
 
static std::vector
< Utils::Excitation
generateExcitations (const std::vector< int > &occupiedOrbitalsIndices, const std::vector< int > &virtualOrbitalsIndices)
 Given occupied and virtual orbital indices, generates a vector of occ->vir excitations. More...
 
template<Utils::Reference restrictedness>
static
Utils::SpinAdaptedContainer
< restrictedness, std::vector
< Utils::Excitation > > 
generateExcitations (const Utils::MolecularOrbitals &mos, const Utils::LcaoUtils::ElectronicOccupation &occupation)
 Given occupied and virtual orbital indices, generates a vector of occ->vir excitations. More...
 
template<Utils::Reference restrictedness>
static std::vector< int > generateEnergyOrderMap (const Utils::SpinAdaptedContainer< restrictedness, Eigen::VectorXd > &energyDifferenceVector)
 Generates a mapping from the "standard" excitation order to increasing energy order. More...
 
template<typename Derived , typename DerivedResult >
static void transformOrder (const Eigen::MatrixBase< Derived > &toTransform, const Eigen::MatrixBase< DerivedResult > &result, const std::vector< int > &orderVector, Direction direction)
 Transforms a vector or matrix from one ordering to another, or back. More...
 
template<typename Type >
static void transformOrder (const std::vector< Type > &toTransform, std::vector< Type > &result, const std::vector< int > &orderVector, Direction direction)
 Transforms a std::vector from one ordering to another, or back.
 
static auto flatten (const Utils::SpinAdaptedContainer< Utils::Reference::Restricted, Eigen::VectorXd > &in) -> Eigen::VectorXd
 Transforms the SpinAdaptedContainer to a Eigen::VectorXd by extracting its "restricted" member.
 
static auto flatten (const Utils::SpinAdaptedContainer< Utils::Reference::Unrestricted, Eigen::VectorXd > &in) -> Eigen::VectorXd
 Transforms the SpinAdaptedContainer to a Eigen::VectorXd by concatenating its "alpha" and "beta" member.
 
template<typename T >
static auto flatten (Utils::SpinAdaptedContainer< Utils::Reference::Restricted, std::vector< T >> in) -> std::vector< T >
 Transforms the SpinAdaptedContainer to a std::vector<T> by extracting its "restricted" member.
 
template<typename T >
static auto flatten (Utils::SpinAdaptedContainer< Utils::Reference::Unrestricted, std::vector< T >> in) -> std::vector< T >
 Transforms the SpinAdaptedContainer to a std::vector<T> by concatenating its "alpha" and "beta" member.
 

Detailed Description

Class containing utility functions for excites-states calculations such as (NDDO-)CIS or TD-DFT(B).

This class contains static functions to calculate occupied-virtual energy difference vectors, generate excitation labels (occ -> vir) for restricted and unrestricted reference calculations.

Member Function Documentation

Eigen::VectorXd Scine::Sparrow::TimeDependentUtils::generateEnergyDifferenceVector ( int  nOccupiedOrbitals,
int  nVirtualOrbitals,
const Utils::SingleParticleEnergies energies 
)
inlinestatic

Calculates the occupied->virtual energy difference vector.

Precondition
This function assumes an electronic occupation according to the Aufbau principle (no fractional occupation).
Parameters
nOccupiedOrbitalsThe number of occupied orbitals.
nVirtualOrbitalsThe number of virtual orbitals.
energiesThe list of molecular orbital energies.
template<Utils::Reference restrictedness>
static void Scine::Sparrow::TimeDependentUtils::generateEnergyDifferenceVector ( const Utils::SingleParticleEnergies energies,
const Utils::LcaoUtils::ElectronicOccupation occupation,
Utils::SpinAdaptedContainer< restrictedness, Eigen::VectorXd > &  energyDifferenceVector 
)
static

Calculated the occupied->virtual energy difference vector.

Parameters
mosThe molecular orbitals, needed to know the number of occupied and virtual orbitals.
energiesThe list of molecular orbital energies.
occupationThe electronic, usually according to Aufbau principle. Here only integer occupations supported.
Template Parameters
restrictednessFlags whether it is a Restricted or Unrestricted reference calculation.
template<Utils::Reference restrictedness>
static std::vector<int> Scine::Sparrow::TimeDependentUtils::generateEnergyOrderMap ( const Utils::SpinAdaptedContainer< restrictedness, Eigen::VectorXd > &  energyDifferenceVector)
static

Generates a mapping from the "standard" excitation order to increasing energy order.

Returns
A vector with the indices in the new order. For example, let's assume there is an orbital energy difference vector en with elements: en[0] = 3.5 en[1] = 2.2 en[2] = 6.4 en[3] = 1.0

then the resulting vector res will contain res[0] = 3 res[1] = 1 res[2] = 0 res[3] = 2

So, to map an arbitrary vector standardV FROM the "standard" order TO the increasing energy ordering in a resut vector increasingEnergyV:

for (int i = 0; i < res.size(); ++i) increasingEnergyV[i] = standardV[res[i]];

And, to map an arbitrary vector increasingEnergyV FROM the increasing energy order TO the "standard" ordering in a resut vector standardV:

for (int i = 0; i < res.size(); ++i) standardV[res[i]] = increasingEnergyV[i];

std::vector< Utils::Excitation > Scine::Sparrow::TimeDependentUtils::generateExcitations ( const std::vector< int > &  occupiedOrbitalsIndices,
const std::vector< int > &  virtualOrbitalsIndices 
)
inlinestatic

Given occupied and virtual orbital indices, generates a vector of occ->vir excitations.

Parameters
occupiedOrbitalsIndicesA vector containing the index corresponding to occupied orbitals.
virtualOrbitalsIndicesA vector containing the index corresponding to virtual orbitals.
Returns
A vector of excitations, objects with an occupied and a virtual index.
template<Utils::Reference restrictedness>
static Utils::SpinAdaptedContainer<restrictedness, std::vector<Utils::Excitation> > Scine::Sparrow::TimeDependentUtils::generateExcitations ( const Utils::MolecularOrbitals mos,
const Utils::LcaoUtils::ElectronicOccupation occupation 
)
static

Given occupied and virtual orbital indices, generates a vector of occ->vir excitations.

Parameters
occupiedOrbitalsIndicesA vector containing the index corresponding to occupied orbitals.
virtualOrbitalsIndicesA vector containing the index corresponding to virtual orbitals.
Template Parameters
restrictednessFlags whether it is a Restricted or Unrestricted reference calculation.
Returns
A SpinAdaptedContained of excitations, objects with an occupied and a virtual index. If restricted, just contains one, if unrestricted, then contains alpha and beta.
template<Utils::Reference restrictedness>
static std::vector<std::string> Scine::Sparrow::TimeDependentUtils::generateExcitationsLabels ( const Utils::SpinAdaptedContainer< restrictedness, std::vector< Utils::Excitation >> &  excitations)
static

Function generating a vector of "occ->vir" excitation labels.

Precondition
This function assumes an occupation according to the Aufbau principle (no fractional occupation).
Parameters
excitationsA SpinAdaptedContainer vector containing the occupied->virtual (alpha/beta for unrestricted) excitations in standard order (vir fast index, occ slow index).
Template Parameters
restrictednessFlags whether it is a Restricted or Unrestricted reference calculation.
Returns
A vector with the excitations in same order as excitations, alpha/beta concatenated.
std::vector< std::string > Scine::Sparrow::TimeDependentUtils::generateExcitationsLabels ( const std::vector< Utils::Excitation > &  excitations,
const Eigen::Matrix< bool,-1, 1 > &  isBeta = {} 
)
inlinestatic

Function generating a vector of "occ->vir" excitation labels.

Precondition
This function assumes an occupation according to the Aufbau principle (no fractional occupation).
Parameters
excitationsA vector containing the occupied->virtual (alpha/beta for unrestricted) excitations in arbitrary order.
isBetaA bool vector indicating whether the excitation is alpha or beta.
Returns
A vector with the excitations in same order as excitations.
void Scine::Sparrow::TimeDependentUtils::generateVirtualOrbitalIndices ( const std::vector< int > &  occupiedOrbitalsIndices,
std::vector< int > &  virtualOrbitalsIndices 
)
inlinestatic

Fills a vector of virtual orbital indices having just size and occupied indices.

Parameters
occupiedOrbitalsIndicesA vector<int> containing the indices of the occupied orbitals.
virtualOrbitalsIndicesA vector<int> with size equal to the number of virtual orbitals, given by reference as its elements will be filled with the virtual orbital indices.
template<typename Derived , typename DerivedResult >
void Scine::Sparrow::TimeDependentUtils::transformOrder ( const Eigen::MatrixBase< Derived > &  toTransform,
const Eigen::MatrixBase< DerivedResult > &  result,
const std::vector< int > &  orderVector,
Direction  direction 
)
inlinestatic

Transforms a vector or matrix from one ordering to another, or back.

Parameters
toTransformThe vector or matrix whose rows to transform.
orderVectorThe vector with the ordering. For example, let's assume there is an orbital energy difference vector en with elements: en[0] = 3.5 en[1] = 2.2 en[2] = 6.4 en[3] = 1.0

then the resulting mapping vector res will contain res[0] = 3 res[1] = 1 res[2] = 0 res[3] = 2 This is also the vector returned by TimeDependentUtils::generateEnergyOrderMap()

Parameters
directionThe direction of the transformation.
  • Direction::To : transform a vector as implied by orderVector, i.e. in an the ordering according to energy difference, from the "standard" order to the order of increasing energy.
  • Direction::From : The opposite direction of transformation.
Returns
A vector transformed into the new order defined in the argument.

So, to map an arbitrary vector standardV FROM the "standard" order TO the increasing energy ordering in a resut vector increasingEnergyV:

Eigen::VectorXd increasingEnergyV = transformOrder(standardV, orderVec, Direction::To); and to transform it back: Eigen::VectorXd standardV2 = transformOrder(increasingEnergyV, orderVec, Direction::From); Then standardV and standardV2 should be equal.


The documentation for this class was generated from the following file: