gbasis package

Contents

gbasis package#

Module for evaluating, differentiating, and integrating Gaussian functions.

Subpackages#

Submodules#

gbasis.base module#

Base class for arrays that depend on one or more contracted Gaussians.

class gbasis.base.BaseGaussianRelatedArray(*contractions)#

Bases: ABC

Base class for constructing arrays associated with contracted Gaussians.

Attributes#

_axes_contractionstuple of tuple of GeneralizedContractionShell

Contractions that are associated with each index of the array. Each tuple of GeneralizedContractionShell corresponds to an index of the array.

Methods#

__init__(self, *axes_contractions)

Initialize.

construct_array_contraction(self, *contraction, **kwargs)np.ndarray

Return the array associated with a GeneralizedContractionShell instance.

construct_array_cartesian(self, **kwargs)np.ndarray

Return the array associated with Cartesian Gaussians.

construct_array_spherical(self, **kwargs)np.ndarray

Return the array associated with spherical Gaussians (atomic orbitals).

construct_array_lincomb(self, *transform, coord_types, **kwargs)np.ndarray

Return the array associated with linear combinations of contractions in the given coordinate system.

abstract construct_array_cartesian(**kwargs)#

Return the array associated with the given set of contracted Cartesian Gaussians.

Parameters#

kwargsdict

Other keyword arguments that will be used to construct the array.

Returns#

arraynp.ndarray

Array associated with the given set of contracted Cartesian Gaussians.

abstract construct_array_contraction(*contractions, **kwargs)#

Return the array associated with a contracted Cartesian Gaussian.

Parameters#

contractionsGeneralizedContractionShell

Contracted Cartesian Gaussians (of the same shell) that will be used to construct an array. Note that multiple instances may be needed to construct the array.

kwargsdict

Other keyword arguments that will be used to construct the array.

Returns#

array_contractionnp.ndarray

Array associated with the given instance(s) of GeneralizedContractionShell.

Notes#

The next level of classes will be divided by number of indices associated with GeneralizedContractionShell. Then this method’s parameters will likely be different from it’s children. This means that using this method’s API blindly (by simply copying and pasting) will not be suitable for all its children. Here, we allow arbitrary number of contractions to indicate that its children may have different number of contractions in its parameters. However, in actual implementations, the number of contractions will likely be fixed, in which case, an arbitrary number of contractions should not be accepted.

abstract construct_array_lincomb(*transform, coord_type, **kwargs)#

Return the array associated with linear combinations of contractions.

Parameters#

transformnp.ndarray

Transformation matrix that will be used for linearly combining the spherical contractions. Note that multiple instances may be needed to construct the array.

coord_typelist/tuple of str

Types of the coordinate system for each GeneralizedContractionShell. Each entry must be one of “cartesian” or “spherical”. If multiple instances of GeneralizedContractionShell are given but only one string (“cartesian” or “spherical”) is provided in the list/tuple, all of the contractions will be treated according to that string.

kwargsdict

Other keyword arguments that will be used to construct the array.

Returns#

arraynp.ndarray

Array associated with the atomic orbitals associated with the given set of contracted Cartesian Gaussians.

Notes#

The next level of classes will be divided by number of indices associated with GeneralizedContractionShell. Then this method’s parameters will likely be different from it’s children. This means that using this method’s API blindly (by simply copying and pasting) will not be suitable for all its children. Here, we allow arbitrary number of transform to indicate that its children may have different number of transform in its parameters. However, in actual implementations, the number of transform will likely be fixed, in which case, an arbitrary number of transform should not be accepted.

abstract construct_array_mix(coord_types, **kwargs)#

Return the array associated with a set of Gaussians of the given coordinate systems.

Parameters#

coord_typeslist/tuple of str

Types of the coordinate system for each GeneralizedContractionShell. Each entry must be one of “cartesian” or “spherical”.

kwargsdict

Other keyword arguments that will be used to construct the array.

Returns#

arraynp.ndarray

Array associated with the atomic orbitals associated with the given set of contracted Cartesian Gaussians.

abstract construct_array_spherical(**kwargs)#

Return the array associated with spherical Gaussians (atomic orbitals).

Parameters#

kwargsdict

Other keyword arguments that will be used to construct the array.

Returns#

arraynp.ndarray

Array associated with the atomic orbitals associated with the given set of contracted Cartesian Gaussians.

gbasis.base_four_symm module#

Base class for arrays that depend on four contracted Gaussians.

class gbasis.base_four_symm.BaseFourIndexSymmetric(contractions)#

Bases: BaseGaussianRelatedArray

Base class for constructing arrays associated with four contracted Gaussian.

The first four axes of the returned array are associated with the given set of contracted Gaussian (or a linear combination of a set of Gaussians).

Attributes#

_axes_contractionstuple of tuple of GeneralizedContractionShell

Sets of contractions associated with each axis of the array.

contractionstuple of GeneralizedContractionShell

Contractions that are associated with the first four indices of the array. Property of BaseFourIndexSymmetric.

Methods#

__init__(self, contractions)

Initialize.

construct_array_contraction(self, cont1, cont2, cont3, cont4, **kwargs) :

np.ndarray(M_1, L_cart_1, M_2, L_cart_2, M_3, L_cart_3, …)

Return the array associated with a GeneralizedContractionShell instances. M_1 is the number of segmented contractions with the same exponents (and angular momentum) associated with the first index. L_cart_1 is the number of Cartesian contractions for the given angular momentum associated with the first index. M_2 is the number of segmented contractions with the same exponents (and angular momentum) associated with the second index. L_cart_2 is the number of Cartesian contractions for the given angular momentum associated with the second index. M_3 is the number of segmented contractions with the same exponents (and angular momentum) associated with the third index. L_cart_3 is the number of Cartesian contractions for the given angular momentum associated with the third index. M_4 is the number of segmented contractions with the same exponents (and angular momentum) associated with the fourth index. L_cart_4 is the number of Cartesian contractions for the given angular momentum associated with the fourth index.

construct_array_cartesian(self, **kwargs)np.ndarray(K_cart, K_cart, K_cart, K_cart, …)

Return the array associated with Cartesian Gaussians. K_cart is the total number of Cartesian contractions within the instance.

construct_array_spherical(self, **kwargs)np.ndarray(K_sph, K_sph, K_sph, K_sph, …)

Return the array associated with spherical Gaussians (atomic orbitals). K_sph is the total number of spherical contractions within the instance.

construct_array_mix(self, coord_types, **kwargs) :

np.ndarray(K_cont, K_cont, K_cont, K_cont, …)

Return the array associated with all of the contraction in the given coordinate system. K_cont is the total number of contractions within the given basis set.

construct_array_lincomb(self, transform, coord_type) :

np.ndarray(K_orbs, K_orbs, K_orbs, K_orbs, …)

Return the array associated with linear combinations of contractions in the given coordinate system. K_orbs is the number of basis functions produced after the linear combinations.

construct_array_cartesian(**kwargs)#

Return the array associated with the given set(s) of contracted Cartesian Gaussians.

Parameters#

kwargsdict

Other keyword arguments that will be used to construct the array. These keyword arguments are passed entirely to construct_array_contraction. See construct_array_contraction for details on the keyword arguments.

Returns#

arraynp.ndarray(K_cart, K_cart, K_cart, K_cart, …)

Array associated with the given set of contracted Cartesian Gaussians. Dimensions 0, 1, 2, and 3 of the array are associated with the contracted Cartesian Gaussians. K_cart is the total number of Cartesian contractions within the instance.

Notes#

The blocks along the diagonal, i.e. blocks where the first two axes belong to the same set of contractions, are transposed in the process of constructing the whole array. It is assumed that the array returned from construct_array_contraction is symmetric with respect to the swapping of the axes 0 and 1.

abstract construct_array_contraction(cont1, cont2, cont3, cont4, **kwargs)#

Return the array associated with a set of contracted Cartesian Gaussians.

Parameters#

cont1GeneralizedContractionShell

Generalized contracted (Cartesian) shell associated with the first index of the array.

cont2GeneralizedContractionShell

Generalized contracted (Cartesian) shell associated with the second index of the array.

cont3GeneralizedContractionShell

Generalized contracted (Cartesian) shell associated with the three index of the array.

cont4GeneralizedContractionShell

Generalized contracted (Cartesian) shell associated with the four index of the array.

kwargsdict

Other keyword arguments that will be used to construct the array.

Returns#

array_contnp.ndarray(M_1, L_cart_1, M_2, L_cart_2, M_3, L_cart_3, M_4, L_cart_4, …)

Return the array associated with a GeneralizedContractionShell instances. Dimension 0 corresponds to the segmented contraction within cont_one. M_1 is the number of segmented contractions with the same exponents (and angular momentum) associated with the first index. Dimension 1 corresponds to the angular momentum vector of the cont_one. L_cart_1 is the number of Cartesian contractions for the given angular momentum associated with the first index. Dimension 2 corresponds to the segmented contraction within cont_two. M_2 is the number of segmented contractions with the same exponents (and angular momentum) associated with the second index. Dimension 3 corresponds to the angular momentum vector of the cont_two. L_cart_2 is the number of Cartesian contractions for the given angular momentum associated with the second index. Dimension 4 corresponds to the segmented contraction within cont_three. M_3 is the number of segmented contractions with the same exponents (and angular momentum) associated with the third index. Dimension 5 corresponds to the angular momentum vector of the cont_three. L_cart_3 is the number of Cartesian contractions for the given angular momentum associated with the third index. Dimension 6 corresponds to the segmented contraction within cont_four. M_4 is the number of segmented contractions with the same exponents (and angular momentum) associated with the fourth index. Dimension 7 corresponds to the angular momentum vector of the cont_four. L_cart_4 is the number of Cartesian contractions for the given angular momentum associated with the fourth index.

Notes#

The next level of classes will be the construction of specific arrays given a set of contracted Cartesian Gaussians. The keyword arguments will be different depending on its functionality. You should use explicit keyword arguments when defining this function, rather than the arbitrary number of keywords (as is done here).

The methods construct_array_cartesian, construct_array_spherical, and construct_array_lincomb depend on this function to produce an array with dimensions 0, 1 corresponding to the contraction (within a generalized contraction) and angular momentum vector of cont_one, dimensions 2, 3 corresponding to the contraction (within a generalized contraction) and angular momentum vector of cont_two, and so on for cont_three and cont_four. These other methods will fail with little warning if the shape of the output is different. Even if all of cont1, cont2, cont3, and cont4 are segmented contractions, dimensions 0, 2, 4, and 6 must correspond to the contraction. In other words, the shape must still be (1, L_1, 1, L_2, 1, L_3, 1, L_4).

construct_array_lincomb(transform, coord_type, **kwargs)#

Return the array associated with linear combinations of contractions.

\[\sum_{j} T_{i_1 j} \sum_{k} T_{i_2 k} M_{jklm...} = M^{trans}_{i_1 i_2 lm...}\]

Parameters#

transformnp.ndarray(K_orbs, K_cont)

Transformation matrix from contractions in the given coordinate system (e.g. AO) to linear combinations of contractions (e.g. MO). Transformation is applied to the left. Rows correspond to the linear combinations (i.e. MO) and the columns correspond to the contractions (i.e. AO).

coord_typelist/tuple of str

Types of the coordinate system for each GeneralizedContractionShell. Each entry must be one of “cartesian” or “spherical”. If multiple instances of GeneralizedContractionShell are given but only one string (“cartesian” or “spherical”) is provided in the list/tuple, all of the contractions will be treated according to that string.

kwargsdict

Other keyword arguments that will be used to construct the array. These keyword arguments are passed directly to construct_array_spherical, which will then pass it down to construct_array_contraction. See construct_array_contraction for details on the keyword arguments.

Returns#

arraynp.ndarray(K_orbs, K_orbs, K_orbs, K_orbs, …)

Array whose first four indices are associated with the linear combinations of the contractions. Dimensions 0, 1, 2 and 3 of the array correspond to the linear combination of contracted spherical Gaussians. K_orbs is the number of basis functions produced after the linear combinations.

Raises#

TypeError

If coord_type is not a list/tuple of the strings ‘cartesian’ or ‘spherical’.

construct_array_mix(coord_types, **kwargs)#

Return the array associated with a set of Gaussians of the given coordinate systems.

Parameters#

coord_typeslist/tuple of str

Types of the coordinate system for each GeneralizedContractionShell. Each entry must be one of “cartesian” or “spherical”.

kwargsdict

Other keyword arguments that will be used to construct the array.

Returns#

arraynp.ndarray(K_cont, K_cont, K_cont, K_cont, …)

Array associated with the atomic orbitals associated with the given set of contracted Cartesian Gaussians. Dimensions 0, 1, 2 and 3 of the array are associated with two contractions in the given coordinate system. K_cont is the total number of contractions within the instance.

Raises#

TypeError

If coord_types is not a list/tuple.

ValueError

If coord_types has an entry that is not “cartesian” or “spherical”. If coord_types has different number of entries as the number of GeneralizedContractionShell (contractions) in instance.

construct_array_spherical(**kwargs)#

Return the array associated with four contracted spherical Gaussians (atomic orbitals).

Parameters#

kwargsdict

Other keyword arguments that will be used to construct the array. These keyword arguments are passed entirely to construct_array_contraction. See construct_array_contraction for details on the keyword arguments.

Returns#

arraynp.ndarray(K_sph, K_sph, K_sph, K_sph, …)

Array associated with the atomic orbitals associated with the given set(s) of contracted Cartesian Gaussians. Dimensions 0, 1, 2 and 3 of the array are associated with four contracted spherical Gaussians (atomic orbitals). K_sph is the total number of spherical contractions within the instance.

Notes#

The blocks along the diagonal, i.e. blocks where the first two axes belong to the same set of contractions, are transposed in the process of constructing the whole array. It is assumed that the array returned from construct_array_contraction is symmetric with respect to the swapping of the axes 0 and 1.

property contractions#

Contractions that are associated with the first four indices of the array.

Returns#

contractionstuple of GeneralizedContractionShell

Generalized contraction shell that is associated with the first four indices of the array.

gbasis.base_one module#

Base class for arrays that depend on one contracted Gaussian.

class gbasis.base_one.BaseOneIndex(contractions)#

Bases: BaseGaussianRelatedArray

Base class for constructing arrays associated with one contracted Gaussian.

The first dimension (axis 0) of the returned array is associated with a contracted Gaussian (or a linear combination of a set of Gaussians).

Attributes#

_axes_contractionstuple of tuple of GeneralizedContractionShell

Contractions that are associated with each index of the array. Each tuple of GeneralizedContractionShell corresponds to an index of the array.

contractionstuple of GeneralizedContractionShell

Contractions that are associated with the first index of the array. Property of BaseOneIndex.

Methods#

__init__(self, contractions)

Initialize.

construct_array_contraction(self, contraction)np.ndarray(M, L_cart, …)

Return the array associated with a GeneralizedContractionShell instance. M is the number of segmented contractions with the same exponents (and angular momentum). L_cart is the number of Cartesian contractions for the given angular momentum.

construct_array_cartesian(self)np.ndarray(K_cart, …)

Return the array associated with Cartesian Gaussians. K_cart is the total number of Cartesian contractions within the instance.

construct_array_spherical(self)np.ndarray(K_sph, …)

Return the array associated with spherical Gaussians (atomic orbitals). K_sph is the total number of spherical contractions within the instance.

construct_array_mix(self, coord_types, **kwargs)np.ndarray(K_cont, …)

Return the array associated with all of the contraction in the given coordinate system. K_cont is the total number of contractions within the given basis set.

construct_array_lincomb(self, transform, coord_type)np.ndarray(K_orbs, …)

Return the array associated with linear combinations of contractions in the given coordinate system. K_orbs is the number of basis functions produced after the linear combinations.

construct_array_cartesian(**kwargs)#

Return the array associated with the given set of contracted Cartesian Gaussians.

Parameters#

kwargsdict

Other keyword arguments that will be used to construct the array. These keyword arguments are passed entirely to construct_array_contraction. See construct_array_contraction for details on the keyword arguments.

Returns#

arraynp.ndarray(K_cart, …)

Array associated with the given set of contracted Cartesian Gaussians. Dimension 0 is associated with the contracted Cartesian Gaussian. K_cart is the total number of Cartesian contractions within the instance.

abstract construct_array_contraction(contractions, **kwargs)#

Return the array associated with a set of contracted Cartesian Gaussians.

Parameters#

contractionsGeneralizedContractionShell

Contracted Cartesian Gaussians (of the same shell) that will be used to construct an array.

kwargsdict

Other keyword arguments that will be used to construct the array.

Returns#

array_contractionnp.ndarray(M, L_cart, …)

Array associated with the given instance(s) of GeneralizedContractionShell. Dimension 0 corresponds to segmented contractions within the given generalized contraction (same exponents and angular momentum, but different coefficients). M is the number of segmented contractions with the same exponents (and angular momentum). Dimension 1 corresponds to angular momentum vector. L_cart is the number of Cartesian contractions for the given angular momentum.

Notes#

The next level of classes will be the construction of specific arrays given a set of contracted Cartesian Gaussians. The keyword arguments will be different depending on its functionality. You should use explicit keyword arguments when defining this function, rather than the arbitrary number of keywords (as is done here).

The methods construct_array_cartesian, construct_array_spherical, and construct_array_lincomb depend on this function to produce an array with dimension 0 corresponding to the contraction (within a generalized contraction) and dimension 1 corresponding to the angular momentum vector. These other methods will fail with little warning if the shape of the output is different. Even if there is only one contraction (i.e. segmented contraction), the first index must correspond to the contraction. In other words, the shape must still be (1, L, N).

construct_array_lincomb(transform, coord_type, **kwargs)#

Return the array associated with linear combinations of contractions.

\[\sum_{j} T_{i j} M_{jklm...} = M^{trans}_{iklm...}\]

Parameters#

transformnp.ndarray(K_orbs, K_cont)

Transformation matrix from contractions in the given coordinate system (e.g. AO) to linear combinations of contractions (e.g. MO). Transformation is applied to the left. Rows correspond to the linear combinationes (i.e. MO) and the columns correspond to the contractions (i.e. AO).

coord_typelist/tuple of str

Types of the coordinate system for each GeneralizedContractionShell. Each entry must be one of “cartesian” or “spherical”. If multiple instances of GeneralizedContractionShell are given but only one string (“cartesian” or “spherical”) is provided in the list/tuple, all of the contractions will be treated according to that string.

kwargsdict

Other keyword arguments that will be used to construct the array. These keyword arguments are passed directly to construct_array_spherical, which will then pass it down to construct_array_contraction. See construct_array_contraction for details on the keyword arguments.

Returns#

arraynp.ndarray(K_orbs, …)

Array whose first index is associated with the linear combinations of the contractions. K_orbs is the number of basis functions produced after the linear combinations.

Raises#

TypeError

If coord_type is not a list/tuple of the strings ‘cartesian’ or ‘spherical’.

construct_array_mix(coord_types, **kwargs)#

Return the array associated with all of the contractions in the given coordinate system.

Parameters#

coord_typeslist/tuple of str

Types of the coordinate system for each GeneralizedContractionShell. Each entry must be one of “cartesian” or “spherical”.

kwargsdict

Other keyword arguments that will be used to construct the array. These keyword arguments are passed entirely to construct_array_contraction. See construct_array_contraction for details on the keyword arguments.

Returns#

arraynp.ndarray(K_cont, …)

Array associated with the spherical contrations of the basis set. Dimension 0 is associated with each spherical contraction in the basis set. K_cont is the total number of contractions within the given basis set.

Raises#

TypeError

If coord_types is not a list/tuple.

ValueError

If coord_types has an entry that is not “cartesian” or “spherical”. If coord_types has different number of entries as the number of GeneralizedContractionShell (contractions) in instance.

construct_array_spherical(**kwargs)#

Return the array associated with contracted spherical Gaussians (atomic orbitals).

Parameters#

kwargsdict

Other keyword arguments that will be used to construct the array. These keyword arguments are passed entirely to construct_array_contraction. See construct_array_contraction for details on the keyword arguments.

Returns#

arraynp.ndarray(K_sph, …)

Array associated with the atomic orbitals associated with the given set of contracted Cartesian Gaussians. Dimension 0 is associated with the contracted spherical Gaussian. K_sph is the total number of Cartesian contractions within the instance.

property contractions#

Contractions that are associated with the first index of the array.

Returns#

contractionstuple of GeneralizedContractionShell

Contractions that are associated with the first index of the array.

gbasis.base_two_asymm module#

Base class for arrays that depend on two contracted Gaussians.

class gbasis.base_two_asymm.BaseTwoIndexAsymmetric(contractions_one, contractions_two)#

Bases: BaseGaussianRelatedArray

Base class for constructing arrays with two indices associated with two sets of contractions.

The first index of the returned array is associated with the first set of contracted Gaussians (or some linear combination of them). The second index of the returned array is associated with the second set of contracted Gaussians (or some linear combination of them).

Attributes#

_axes_contractionstuple of tuple of GeneralizedContractionShell

Sets of contractions associated with each axis of the array.

contractions_onetuple of GeneralizedContractionShell

Contractions that are associated with the first index of the array. Property of BaseTwoIndexAsymmetric.

contractions_twotuple of GeneralizedContractionShell

Contractions that are associated with the second index of the array. Property of BaseTwoIndexAsymmetric.

Methods#

__init__(self, contractions_one, contractions_two)

Initialize.

construct_array_contraction(self, contractions_one, contractions_two, **kwargs) :

np.ndarray(M_1, L_cart_1, M_2, L_cart_2, …)

Return the array associated with a GeneralizedContractionShell instance. M_1 is the number of segmented contractions with the same exponents (and angular momentum) associated with the first index. L_cart_1 is the number of Cartesian contractions for the given angular momentum associated with the first index. M_2 is the number of segmented contractions with the same exponents (and angular momentum) associated with the second index. L_cart_2 is the number of Cartesian contractions for the given angular momentum associated with the second index.

construct_array_cartesian(self, **kwargs)np.ndarray(K_cart_1, K_cart_2, …)

Return the array associated with Cartesian Gaussians. K_cart_1 is the total number of Cartesian contractions within contractions_one. K_cart_2 is the total number of Cartesian contractions within contractions_two.

construct_array_spherical(self, **kwargs)np.ndarray(K_sph_1, K_sph_2, …)

Return the array associated with spherical Gaussians (atomic orbitals). K_sph_1 is the total number of spherical contractions within contractions_one. K_sph_2 is the total number of spherical contractions within contractions_two.

construct_array_lincomb(self, transform_one, transform_two, coord_type, **kwargs) :

np.ndarray(K_orbs_1, K_orbs_2, …)

Return the array associated with linear combinations of contractions in the given coordinate system. K_orbs_1 is the number of basis functions produced by linear combinations of the spherical contractions associated with contractions_one. K_orbs_2 is the number of basis functions produced by linear combinations of the spherical contractions associated with contractions_two.

construct_array_cartesian(**kwargs)#

Return the array associated with the given set(s) of contracted Cartesian Gaussians.

Parameters#

kwargsdict

Other keyword arguments that will be used to construct the array. These keyword arguments are passed entirely to construct_array_contraction. See construct_array_contraction for details on the keyword arguments.

Returns#

arraynp.ndarray(K_cart_1, K_cart_2, …)

Array associated with the given set of contracted Cartesian Gaussians. Dimension 0 corresponds to the Cartesian contraction within contractions_one. K_cart_1 is the total number of Cartesian contractions within contractions_one. Dimension 1 corresponds to the Cartesian contraction within contractions_two. K_cart_2 is the total number of Cartesian contractions within contractions_two.

abstract construct_array_contraction(contractions_one, contractions_two, **kwargs)#

Return the array associated with two sets of contracted Cartesian Gaussians.

Parameters#

contractions_oneGeneralizedContractionShell

Contracted Cartesian Gaussians (of the same shell) associated with the first index of the array.

contractions_twoGeneralizedContractionShell

Contracted Cartesian Gaussians (of the same shell) associated with the second index of the array.

kwargsdict

Other keyword arguments that will be used to construct the array.

Returns#

array_contractionnp.ndarray(M_1, L_cart_1, M_2, L_cart_2, …)

Array associated with the given instance(s) of GeneralizedContractionShell. Dimension 0 corresponds to the segmented contraction within contractions_one. M_1 is the number of segmented contractions with the same exponents (and angular momentum) associated with the first index. Dimension 1 corresponds to the angular momentum vector of the contractions_one. L_cart_1 is the number of Cartesian contractions for the given angular momentum associated with the first index. Dimension 2 corresponds to the segmented contraction within contractions_two. M_2 is the number of segmented contractions with the same exponents (and angular momentum) associated with the second index. Dimension 3 corresponds to the angular momentum vector of the contractions_two. L_cart_2 is the number of Cartesian contractions for the given angular momentum associated with the second index.

Notes#

The next level of classes will be the construction of specific arrays given a set of contracted Cartesian Gaussians. The keyword arguments will be different depending on its functionality. You should use explicit keyword arguments when defining this function, rather than the arbitrary number of keywords (as is done here).

The methods construct_array_cartesian, construct_array_spherical, and construct_array_lincomb depend on this function to produce an array with dimensions 0, 1 corresponding to the contraction (within a generalized contraction) and the angular momentum vector of contractions_one, and dimensions 2, 3 corresponding to the contraction (within a generalized contraction) and the angular momentum vector of contractions_two. These other methods will fail with little warning if the shape of the output is different. Even if both contractions_one and contractions_two are segmented contractions, the first and third indices must correspond to the contraction. In other words, the shape must still be (1, L_1, 1, L_2).

construct_array_lincomb(transform_one, transform_two, coord_type_one, coord_type_two, **kwargs)#

Return the array associated with linear combinations of contractions.

\[\sum_{j} T^{one}_{i_1 j} \sum_{k} T^{two}_{i_2 k} M_{jklm...} = M^{trans}_{i_1 i_2 lm...}\]

Parameters#

transform_onenp.ndarray

Array associated with the linear combinations of spherical Gaussians (LCAO’s) associated with the first index. If None, then transformation is skipped.

transform_twonp.ndarray

Array associated with the linear combinations of spherical Gaussians (LCAO’s) associated with the second index. If None, then transformation is skipped.

coord_type_onelist/tuple of string

Types of the coordinate system for the contractions associated with the first index. Each entry must be one of “cartesian” or “spherical”. If multiple instances of GeneralizedContractionShell are given but only one string (“cartesian” or “spherical”) is provided in the list/tuple, all of the contractions will be treated according to that string.

coord_type_twolist/tuple of string

Types of the coordinate system for the contractions associated with the second index. Each entry must be one of “cartesian” or “spherical”. If multiple instances of GeneralizedContractionShell are given but only one string (“cartesian” or “spherical”) is provided in the list/tuple, all of the contractions will be treated according to that string.

kwargsdict

Other keyword arguments that will be used to construct the array. These keyword arguments are passed directly to construct_array_spherical, which will then pass it down to construct_array_contraction. See construct_array_contraction for details on the keyword arguments.

Returns#

arraynp.ndarray(K_orbs_1, K_orbs_2, …)

Array associated with the linear combinations of given two sets of contractions. Dimension 0 corresponds to the linear combination of contractions with the first set of contractions, contractions_one. K_orbs_1 is the number of basis functions produced by linear combination of the spherical contractions associated with contractions_one. Dimension 1 corresponds to the linear combination of contractions associated with the second set of contractions, contractions_two. K_orbs_2 is the number of basis functions produced by linear combinations of the spherical contractions associated with contractions_two.

Raises#

TypeError

If coord_type is not a list/tuple of the strings ‘cartesian’ or ‘spherical’.

construct_array_mix(coord_types_one, coord_types_two, **kwargs)#

Return the array associated with a set of Gaussians of the given coordinate systems.

Parameters#

coord_types_onelist/tuple of str

Types of the coordinate system for GeneralizedContractionShell associated with the first index of the array. Each entry must be one of “cartesian” or “spherical”.

coord_types_twolist/tuple of str

Types of the coordinate system for GeneralizedContractionShell associated with the second index of the array. Each entry must be one of “cartesian” or “spherical”.

kwargsdict

Other keyword arguments that will be used to construct the array.

Returns#

arraynp.ndarray(K_cont, K_cont, …)

Array associated with the atomic orbitals associated with the given set of contracted Cartesian Gaussians. First two indices of the array are associated with two contractions in the given coordinate system. K_cont is the total number of contractions within the instance.

Raises#

TypeError

If coord_types_one is not a list/tuple. If coord_types_two is not a list/tuple.

ValueError

If coord_types_one has an entry that is not “cartesian” or “spherical”. If coord_types_one has different number of entries as the number of GeneralizedContractionShell (contractions) in instance. If coord_types_two has an entry that is not “cartesian” or “spherical”. If coord_types_two has different number of entries as the number of GeneralizedContractionShell (contractions) in instance.

construct_array_spherical(**kwargs)#

Return the array associated with two contracted spherical Gaussians (atomic orbitals).

Parameters#

kwargsdict

Other keyword arguments that will be used to construct the array. These keyword arguments are passed entirely to construct_array_contraction. See construct_array_contraction for details on the keyword arguments.

Returns#

arraynp.ndarray(K_sph_1, K_sph_2, …)

Array associated with the atomic orbitals associated with the given set(s) of contracted Cartesian Gaussians. Dimension 0 corresponds to the Cartesian contraction within contractions_one. K_sph_1 is the total number of Cartesian contractions within contractions_one. Dimension 1 corresponds to the Cartesian contraction within contractions_two. K_sph_2 is the total number of Cartesian contractions within contractions_two.

property contractions_one#

Contractions that are associated with the first index of the array.

Returns#

contractions_onetuple of GeneralizedContractionShell

Contractions that are associated with the first index of the array.

property contractions_two#

Contractions that are associated with the second index of the array.

Returns#

contractions_twotuple of GeneralizedContractionShell

Contractions that are associated with the second index of the array.

gbasis.base_two_symm module#

Base class for arrays that depend on two contracted Gaussians.

class gbasis.base_two_symm.BaseTwoIndexSymmetric(contractions)#

Bases: BaseGaussianRelatedArray

Base class for constructing arrays associated with two contracted Gaussian.

The first two axes of the returned array is associated with the given set of contracted Gaussian (or a linear combination of a set of Gaussians).

Attributes#

_axes_contractionstuple of tuple of GeneralizedContractionShell

Sets of contractions associated with each axis of the array.

contractionstuple of GeneralizedContractionShell

Contractions that are associated with the first and second indices of the array. Property of BaseTwoIndexSymmetric.

Methods#

__init__(self, contractions)

Initialize.

construct_array_contraction(self, contraction, **kwargs) :

np.ndarray(M_1, L_cart_1, M_2, L_cart_2, …)

Return the array associated with a GeneralizedContractionShell instance. M_1 is the number of segmented contractions with the same exponents (and angular momentum) associated with the first index. L_cart_1 is the number of Cartesian contractions for the given angular momentum associated with the first index. M_2 is the number of segmented contractions with the same exponents (and angular momentum) associated with the second index. L_cart_2 is the number of Cartesian contractions for the given angular momentum associated with the second index.

construct_array_cartesian(self, **kwargs)np.ndarray(K_cart, K_cart, …)

Return the array associated with Cartesian Gaussians. K_cart is the total number of Cartesian contractions within the instance.

construct_array_spherical(self, **kwargs)np.ndarray(K_sph, K_sph, …)

Return the array associated with spherical Gaussians (atomic orbitals). K_sph is the total number of spherical contractions within the instance.

construct_array_lincomb(self, transform, coord_type)np.ndarray(K_orbs, K_orbs, …)

Return the array associated with linear combinations of contractions in the given coordinate system. K_orbs is the number of basis functions produced after the linear combinations.

construct_array_cartesian(**kwargs)#

Return the array associated with the given set(s) of contracted Cartesian Gaussians.

Parameters#

kwargsdict

Other keyword arguments that will be used to construct the array. These keyword arguments are passed entirely to construct_array_contraction. See construct_array_contraction for details on the keyword arguments.

Returns#

arraynp.ndarray(K_cart, K_cart, …)

Array associated with the given set of contracted Cartesian Gaussians. Dimensions 0 and 1 of the array are associated with the contracted Cartesian Gaussians. K_cart is the total number of Cartesian contractions within the instance.

Notes#

The blocks along the diagonal, i.e. blocks where the first two axes belong to the same set of contractions, are transposed in the process of constructing the whole array. It is assumed that the array returned from construct_array_contraction is symmetric with respect to the swapping of the first two axes.

abstract construct_array_contraction(contractions_one, contractions_two, **kwargs)#

Return the array associated with a set of contracted Cartesian Gaussians.

Parameters#

contractions_oneGeneralizedContractionShell

Contracted Cartesian Gaussians (of the same shell) associated with the first index of the array.

contractions_twoGeneralizedContractionShell

Contracted Cartesian Gaussians (of the same shell) associated with the second index of the array.

kwargsdict

Other keyword arguments that will be used to construct the array.

Returns#

array_contractionnp.ndarray(M_1, L_cart_1, M_2, L_cart_2, …)

Array associated with the given instances of GeneralizedContractionShell. Dimension 0 corresponds to the segmented contraction within contractions_one. M_1 is the number of segmented contractions with the same exponents (and angular momentum) associated with the first index. Dimension 1 corresponds to the angular momentum vector of the contractions_one. L_cart_1 is the number of Cartesian contractions for the given angular momentum associated with the first index. Dimension 2 corresponds to the segmented contraction within contractions_two. M_2 is the number of segmented contractions with the same exponents (and angular momentum) associated with the second index. Dimension 3 corresponds to the angular momentum vector of the contractions_two. L_cart_2 is the number of Cartesian contractions for the given angular momentum associated with the second index.

Notes#

The next level of classes will be the construction of specific arrays given a set of contracted Cartesian Gaussians. The keyword arguments will be different depending on its functionality. You should use explicit keyword arguments when defining this function, rather than the arbitrary number of keywords (as is done here).

The methods construct_array_cartesian, construct_array_spherical, and construct_array_lincomb depend on this function to produce an array with dimensions 0, 1 corresponding to the contraction (within a generalized contraction) and the angular momentum vector of contractions_one, and dimensions 2, 3 corresponding to the contraction (within a generalized contraction) and the angular momentum vector of contractions_two,. These other methods will fail with little warning if the shape of the output is different. Even if both contractions_one and contractions_two are segmented contractions, the dimensions 0 and 2 must correspond to the contraction. In other words, the shape must still be (1, L_1, 1, L_2).

construct_array_lincomb(transform, coord_type, **kwargs)#

Return the array associated with linear combinations of contractions.

\[\sum_{j} T_{i_1 j} \sum_{k} T_{i_2 k} M_{jklm...} = M^{trans}_{i_1 i_2 lm...}\]

Parameters#

transformnp.ndarray(K_orbs, K_cont)

Transformation matrix from contractions in the given coordinate system (e.g. AO) to linear combinations of contractions (e.g. MO). Transformation is applied to the left. Rows correspond to the linear combinations (i.e. MO) and the columns correspond to the contractions (i.e. AO).

coord_typelist/tuple of str

Types of the coordinate system for each GeneralizedContractionShell. Each entry must be one of “cartesian” or “spherical”. If multiple instances of GeneralizedContractionShell are given but only one string (“cartesian” or “spherical”) is provided in the list/tuple, all of the contractions will be treated according to that string.

kwargsdict

Other keyword arguments that will be used to construct the array. These keyword arguments are passed directly to construct_array_spherical, which will then pass it down to construct_array_contraction. See construct_array_contraction for details on the keyword arguments.

Returns#

arraynp.ndarray(K_orbs, K_orbs, …)

Array whose first two indices are associated with the linear combinations of the contractions. Dimensions 0 and 1 correspond to the linear combination of contracted spherical Gaussians. K_orbs is the number of basis functions produced after the linear combinations.

Raises#

TypeError

If coord_type is not a list/tuple of the strings ‘cartesian’ or ‘spherical’.

construct_array_mix(coord_types, **kwargs)#

Return the array associated with a set of Gaussians of the given coordinate systems.

Parameters#

coord_typeslist/tuple of str

Types of the coordinate system for each GeneralizedContractionShell. Each entry must be one of “cartesian” or “spherical”.

kwargsdict

Other keyword arguments that will be used to construct the array.

Returns#

arraynp.ndarray(K_cont, K_cont, …)

Array associated with the atomic orbitals associated with the given set of contracted Cartesian Gaussians. Dimensions 0 and 1 are associated with two contractions in the given coordinate system. K_cont is the total number of contractions within the instance.

Raises#

TypeError

If coord_types is not a list/tuple.

ValueError

If coord_types has an entry that is not “cartesian” or “spherical”. If coord_types has different number of entries as the number of GeneralizedContractionShell (contractions) in instance.

construct_array_spherical(**kwargs)#

Return the array associated with two contracted spherical Gaussians (atomic orbitals).

Parameters#

kwargsdict

Other keyword arguments that will be used to construct the array. These keyword arguments are passed entirely to construct_array_contraction. See construct_array_contraction for details on the keyword arguments.

Returns#

arraynp.ndarray(K_sph, K_sph, …)

Array associated with the atomic orbitals associated with the given set(s) of contracted Cartesian Gaussians. Dimensions 0 and 1 are associated with two contracted spherical Gaussians (atomic orbitals). K_sph is the total number of spherical contractions within the instance.

Notes#

The blocks along the diagonal, i.e. blocks where the first two axes belong to the same set of contractions, are transposed in the process of constructing the whole array. It is assumed that the array returned from construct_array_contraction is symmetric with respect to the swapping of the first two axes.

property contractions#

Contractions that are associated with the first two indices of the array.

Returns#

contractionstuple of GeneralizedContractionShell

Contractions that are associated with the first two indices of the array.

gbasis.contractions module#

Data class for contractions of Gaussian-type primitives.

class gbasis.contractions.GeneralizedContractionShell(angmom, coord, coeffs, exps, coord_type, icenter=None, tol=1e-15, ovr_screen=False)#

Bases: object

Data class for generalized contractions.

Generalized contractions are defined to be a set of contractions that have the same angular momentum, center, and the same set of exponents. To avoid confusion with the term “contraction”, we add “shell” to indicate that this instance refers to a collection of contractions.

A Cartesian primitive, \(g_i\), is

\[g_i (\mathbf{r} | \vec{a}, \vec{R}_A) = N_g (\alpha, \vec{a}) (x - X_A)^{a_x} (y - Y_A)^{a_y} (z - Z_A)^{a_z} \exp{-\alpha_i |\vec{r} - \vec{R}_A|^2}\]

where \(\vec{a} = (a_x, a_y, az)\) is the angular momentum components in Cartesian coordinates, \(\vec{R}_A\) is the coordinate of the center \(A\), \(N_g\) is the normalization constant of the primitive, and \(\alpha_i\) is the exponent of the primitive.

A Cartesian contraction is a linear combination of Cartesian primitives:

\[\phi_{\vec{a}, \vec{R}_A} (\mathbf{r}) = N_{\phi} (\vec{a}, \vec{R}_A) \sum_i d_i g_i (\vec{r} | \vec{a}, \vec{R}_A)\]

where \(d_i\) is the contraction coefficient of the primitive and \(N_{\phi}\) is the normalization constant of the contraction.

Note that the Cartesian contraction depends on the angular momentum components in the Cartesian coordinate, \(\vec{a}\). At a given angular momentum, \(\ell\), we have \(\frac{(\ell + 1) (\ell + 2)}{2}\) different components. We can linearly transform these contractions to obtain the \(2 \ell + 1\) spherical contractions. Since we can convert the contractions in one coordinate system to another, we use the term contraction to describe both cases, unless otherwise stated.

In order to obtain the spherical contractions for a given angular momentum, we need all of the contractions at that angular momentum (each with a different combination of angular momentum components. We will denote the collection of these contractions as a segmented contraction shell. Note that contractions within segmented contraction shell all have the same angular momentum, center, and the same set of exponents and contraction coefficients.

Some basis sets, e.g. ANO-RCC, group together multiple segmented contractions that only differ by the contraction coefficients and angular momentums. Here, we denote a collection of contractions with the same angular momentum, center, and the same set of exponents as a generalized contraction shell. Note that we do not support generalized contractions with different angular momentum.

We can think of a generalized contraction shell as a union of segmented contraction shells with the same angular momentum, center, and the same set of exponents. Now, the contraction coefficients depend on the specific segmented contraction shell, \(j\), to which the contraction belongs:

\[\phi_{j, \vec{a}, \vec{R}_A} (\mathbf{r}) = N_{\phi} (\vec{a}, \vec{R}_A) \sum_i d_{ij} g_i (\vec{r} | \vec{a}, \vec{R}_A)\]

Attributes#

coordnp.ndarray(3,)

Coordinate of the center of the contractions.

angmomint

Angular momentum of the contractions.

\[\ell = \sum_i (\vec{a})_i = a_x + a_y + a_z\]
angmom_components_cartnp.ndarray(L, 3)

The x, y, and z components of the angular momentum vectors (\(\vec{a} = (a_x, a_y, a_z)\) where \(a_x + a_y + a_z = \ell\)). L is the number of Cartesian contracted Gaussian functions for the given angular momentum, i.e. \((\ell + 1) * (\ell + 2) / 2\). Property of GeneralizedContractionShell.

angmom_components_sphtuple of int

Tuple of magnetic quantum numbers of the contractions that specifies the ordering after transforming the contractions from the Cartesian to spherical coordinate system. Property of GeneralizedContractionShell.

expsnp.ndarray(K,)

Exponents of the primitives, \(\{\alpha_i\}_{i=1}^K\).

coeffsnp.ndarray(K, M)

Contraction coefficients, \(\{d_{ij}\}\), of the primitives. First axis corresponds to the primitive and the second axis corresponds to the segmented contraction shell.

coord_typestr

Type of the coordinate system used to specify the contractions.

norm_contnp.ndarray(M, L)

Normalization constants of the Cartesian contractions of different angular momentum components and segmented contraction shells.

norm_prim_cartnp.ndarray(L, K)

The normalization constants of the Cartesian Gaussian primitives. L is the number of contracted Cartesian Gaussian functions for the given angular momentum, i.e. \((\ell + 1) * (\ell + 2) / 2\). Property of GeneralizedContractionShell.

num_cartint

Number of Cartesian contractions of angular momentum, \(\ell\). Property of GeneralizedContractionShell.

num_sphint

Number of spherical contractions of angular momentum, \(\ell\). Property of GeneralizedContractionShell.

Methods#

assign_norm_contr(self)

Assign normalization constants for the contractions.

property angmom#

Angular momentum of the contractions.

Returns#

angmomint

Angular momentum of the set of contractions.

\(\sum_i (\vec{a})_i = a_x + a_y + a_z\)

property angmom_components_cart#

Return the components of the angular momentum vectors for the given angular momentum.

Returns#

angmom_components_cartnp.ndarray(L, 3)

The x, y, and z components of the angular momentum vectors (\(\vec{a} = (a_x, a_y, a_z)\) where \(a_x + a_y + a_z = \ell\)). L is the number of Cartesian contracted Gaussian functions for the given angular momentum, i.e. \((\ell + 1) * (\ell + 2) / 2\)

Notes#

In HORTON2, \((a_x, a_y, a_z)\) is represented by a string of X, Y, and Z characters, such that \(a_x\) X characters, \(a_y\) Y characters, and \(a_z\) Z characters appear. For example, (2, 1, 1) corresponds to XXYZ

property angmom_components_sph#

Return the ordering of the magnetic quantum numbers for the given angular momentum.

We define spherical components as regular solid harmonics \(R_{\ell, m}\) such that

\[\begin{align} R_{\ell, m} &= C_{\ell, m}, \quad &m = 0 ... \ell R_{\ell, -m} &= S_{\ell, m}, \quad &m = 1 ... \ell \end{align}\]

where \(C_{\ell, m}\) and \(S_{\ell, m}\) are Cosine- and Sine-like real regular solid harmonics (respectively).

We will use these definitions to represent pure (spherical) functions as strings of the form c{m} and s{m}. By this definition, for pure f functions, the ordering by magnetic quantum number [0, 1, -1, 2, -2, 3, -3] corresponds to [‘c0’, ‘c1’, ‘s1’, ‘c2’, ‘s2’, ‘c3’, ‘s3’].

Some quantum chemistry codes use different conventions that cause compatibility issues. For these conventions, it may be necessary to change the sign of specific pure functions, denoted by a minus sign, e.g. -c3. A primary example is for Molden files written by ORCA; these files use the conventions [‘c0’, ‘c1’, ‘s1’, ‘c2’, ‘s2’, ‘-c3’, ‘-s3’].

Returns#

angmom_components_sphtuple of str

Tuple of strings representing the cosine- and sine-like real regular solid harmonics representing the magnetic quantum numbers of the contractions specifying the ordering after transforming the contractions from the Cartesian to spherical coordinate system.

Notes#

Our default ordering is from -m to m, e.g. for \(\ell = 2\), [‘s2’, ‘s1’, ‘c0’, ‘c1’, ‘c2’].

assign_norm_cont()#

Store the normalization constants of the contractions.

\[\begin{split}\int \phi_i(\mathbf{r}) \phi_i(\mathbf{r}) d\mathbf{r} &= N\\ \frac{1}{N} \int \phi_i(\mathbf{r}) \phi_i(\mathbf{r}) d\mathbf{r} &= 1\\ \int \left(\frac{1}{\sqrt{N}} \phi_i(\mathbf{r})\right) \left(\frac{1}{\sqrt{N}} \phi_i(\mathbf{r})\right) d\mathbf{r} &= 1\\\end{split}\]

where \(N\) is the norm of contraction \(\phi_i\).

Notes#

Since the overlap module also depends on this (contractions) module, if the overlap module is imported at the start of this module, there is a circular import error. Therefore, the overlap module must be imported within this method.

property coeffs#

Contraction coefficients of the Gaussian primitives.

Returns#

coeffsnp.ndarray(K, M)

Contraction coefficients, \(\{d_{ij}\}\), of the primitives. Dimension 0 corresponds to the primitive and the dimension 1 corresponds to the segmented contraction shell.

property coord#

Coordinate of the center of the contractions.

Returns#

coordnp.ndarray(3,)

Coordinate of the center of the contractions.

property coord_type#

Return the coordinate type.

Returns#

coord_typestr

Coordinate type of the contraction.

property exps#

Exponents of the Gaussian primitives.

Returns#

expsnp.ndarray(K,)

Exponents of the primitives, \(\{\alpha_i\}_{i=1}^K\).

property icenter#

Atom center index for the contractions.

Returns
icenterint or None

Index for the corresponding atom center of the contractions.

property norm_prim_cart#

Return the normalization constants of the Cartesian Gaussian primitives.

For a Cartesian primitive with exponent \(\alpha_i\), the normalization constant is:

\[N(\alpha_i, \vec{a}) = \sqrt { \left(\frac{2\alpha_i}{\pi}\right)^\frac{3}{2} \frac{(4\alpha_i)^{a_x + a_y + a_z}}{(2a_x - 1)!! (2a_y - 1)!! (2a_z - 1)!!}}\]

Returns#

norm_prim_cartnp.ndarray(L, K)

The normalization constants of the Cartesian Gaussian primitives. L is the number of contracted Cartesian Gaussian functions for the given angular momentum, i.e. \((\ell + 1) * (\ell + 2) / 2\) K is the number of exponents (i.e. primitives).

property num_cart#

Return the number of Cartesian contractions of the given angular momentum.

\[\frac{(\ell + 1)(\ell + 2)}{2}\]

Returns#

num_cartint

Number of Cartesian contractions of angular momentum, angmom.

property num_seg_cont#

Return the number of segmented contractions.

Returns#

num_seg_contint

Number of segmented contractions.

property num_sph#

Return the number of spherical contractions of the given angular momentum.

\[1 + 2\ell\]

Returns#

num_sphint

Number of spherical contractions of angular momentum, angmom.

property ovr_screen#

Flag for performing overlap screening.

Returns#

ovr_screenbool

Flag for using overlap screening.

property ovr_tol#

Tolerance used in overlap screening.

Returns#

ovr_stolfloat

Tolerance for using overlap screening

gbasis.parsers module#

Parsers for reading basis set files.

gbasis.parsers.make_contractions(basis_dict, atoms, coords, coord_types, tol=1e-20, overlap=False)#

Return the contractions that correspond to the given atoms for the given basis.

Parameters#

basis_dictdict of str to list of 3-tuple of (int, np.ndarray, np.ndarray)

Output of the parsers from gbasis.parsers.

atomsN-list/tuple of str

Atoms at which the contractions are centered.

coordsnp.ndarray(N, 3)

Coordinates of each atom.

coord_types{“cartesian”/”c”, list/tuple of “cartesian”/”c” or “spherical”/”p”, “spherical”/”p”}

Types of the coordinate system for the contractions. If “cartesian” or “c”, then all of the contractions are treated as Cartesian contractions. If “spherical” or “p”, then all of the contractions are treated as spherical contractions. If list/tuple, then each entry must be a “cartesian” (or “c”) or “spherical” (or “p”) to specify the coordinate type of each GeneralizedContractionShell instance. Default value is “spherical”.

ovrbool

Flag for performing overlap screening between contractions.

tolfloat

Tolerance used in overlap screening.

Returns#

basistuple of GeneralizedContractionShell

Contractions for each atom. Contractions are ordered in the same order as in the values of basis_dict.

Raises#

TypeError

If atoms is not a list or tuple of strings. If coords is not a two-dimensional numpy array with 3 columns. If tol is not a float. If ovr is not boolean

ValueError

If the length of atoms is not equal to the number of rows of coords.

gbasis.parsers.parse_gbs(gbs_basis_file)#

Parse Gaussian94 basis set file.

Parameters#

gbs_basis_filestr

Path to the Gaussian94 basis set file.

Returns#

basis_dictdict of str to list of 3-tuple of (int, np.ndarray, np.ndarray)

Dictionary of the element to the list of angular momentum, exponents, and contraction coefficients associated with each contraction at the given atom.

Notes#

Angular momentum symbol is hard-coded into this function. This means that if the selected basis set has an angular momentum greater than “k”, an error will be raised.

Since Gaussian94 basis format does not explicitly state which contractions are generalized, we infer that subsequent contractions belong to the same generalized shell if they have the same exponents and angular momentum. If two contractions are not one after another or if they are associated with more than one angular momentum, they are treated to be segmented contractions.

gbasis.parsers.parse_nwchem(nwchem_basis_file)#

Parse nwchem basis set file.

Parameters#

nwchem_basis_filestr

Path to the nwchem basis set file.

Returns#

basis_dictdict of str to list of 3-tuple of (int, np.ndarray, np.ndarray)

Dictionary of the element to the list of angular momentum, exponents, and contraction coefficients associated with each contraction at the given atom.

Notes#

Angular momentum symbol is hard-coded into this function. This means that if the selected basis set has an angular momentum greater than “k”, an error will be raised.

gbasis.spherical module#

Convert from Cartesian Gaussians to spherical Gaussians.

gbasis.spherical.expansion_coeff(angmom, mag, i, j, k)#

Calculate the real solid harmonic expansion coefficient.

\[C^{angmom,mag,i,j,k} = -1^{i + k - \text{shift_factor}} * (1/4)^i * {angmom \choose i} * {(angmom - i) \choose (|mag| + i)} * {i \choose j} * {|mag| \choose 2 * k},\]

where \(shift_factor = 0\) if \(mag >= 0\) and \(shift_factor = 1/2\) if \(mag < 0\) .

Parameters#

angmomint

The angular momentum of the Gaussian primitive(s).

magint

The magnetic quantum number(s) of the Gaussian primitive(s).

i, jint

The generator indices for the expansion coefficient.

kfloat

The generator indices for the expansion coefficient.

Returns#

coefffloat

The real solid harmonic expansion coefficient.

Raises#

TypeError

If angmom is not an integer. If mag is not an integer. If i is not an integer. If j is not an integer. If k is not a float.

ValueError

If angmom is negative. If mag has a greater magnitude than angmom. If `k is not either an integer (mag >= 0) or a half integer (mag < 0).

gbasis.spherical.generate_transformation(angmom, cartesian_order, spherical_order, apply_from)#

Generate the transformation matrix for a given shell.

The Cartesian contractions are ordered as given in cartesian_order. The spherical contractions are ordered as given in spherical_order.

Parameters#

angmomint

The angular momentum \(\ell\) of the basis function(s).

cartesian_ordernp.ndarray((angmom + 1) * (angmom + 2) / 2, 3)

The x, y, and z components of the angular momentum for each primitive, (\(\vec{a} = (a_x, a_y, a_z)\), where \(a_x + a_y + a_z = \ell\)). The order in which the contractions are given defines the order in which they will appear in the transformation matrix.

spherical_order(2 * angmom + 1)-tuple/list of int

Order of the spherical contractions that are produced by the transformation matrix. Given in cosine- and sine-like pure function notation. See GeneralizedContractionShell.angmom_conventions_sph for details.

apply_fromstr

The side on which the transformation matrix is applied. One of {“left”, “right”}.

Returns#

transformnp.ndarray((angmom + 1)*(angmom + 2) / 2, 2 * angmom + 1)

The transformation matrix from Cartesian primitives to spherical primitives.

Raises#

TypeError

If angmom is not an integer. If cartesian_order is not an array. If each member of cartesian_order is not a tuple. If spherical_order is not a list/tuple of strings

ValueError

If angmom is negative. If cartesian_order does not have shape \((\ell, 3)\). If the Cartesian components of any contractions do not sum to angmom. If apply_from is not one of “left” or “right”. If spherical_order contains elements not of the form c{m}, s{m}, -c{m}, or -s{m}, m < L. If spherical_order does not contain exactly \(2 * \ell + 1\) elements.

gbasis.spherical.harmonic_norm(angmom, mag)#

Calculate the normalization constant of a real solid harmonic.

\[N^S_{angmom,m} = 1/(2^{|m|} * angmom!) * \sqrt{2 * (angmom + |{m}|)! * (angmom - |{m}|)! / 2^{\delta_0^m}},\]

where :math: del{0, m} is the Kronecker delta of 0 and m.

Parameters#

angmomint

The angular momentum of the basis function(s).

magint

The magnetic quantum number(s) of the basis function(s).

Returns#

normfloat

The normalization constant of the real solid harmonic.

Raises#

TypeError

If angmom is not an integer. If mag is not an integer.

ValueError

If angmom is negative. If mag has a greater magnitude than angmom.

gbasis.spherical.real_solid_harmonic(angmom, mag)#

Calculate a real solid harmonic.

\[S_{angmom,mag} = N^{S}_{angmom,mag} \sum_{i=0}^{(angmom-|{mag}|)/2} \sum_{j=0}^i \sum_k={shift_factor}^{[(|{mag}|-1)/2] + 0.5} C^{angmom,m_i,j,k} x^a_x y^a_y z^a_z,\]

where \(a_x = 2t + |mag| - 2(u + v)\), \(a_y = 2(u + v)\), and \(a_z = angmom - 2t - |mag|\).

Parameters#

angmomint

The angular momentum of the basis function(s).

magint

The magnetic quantum number(s) of the basis function(s).

Returns#

harmonicdict

The Cartesian components of a Gaussian primitive, linked to the associated coefficient.

Raises#

TypeError

If angmom is not an integer. If mag is not an integer.

ValueError

If angmom is negative. If mag has a greater magnitude than angmom.

gbasis.spherical.shift_factor(mag)#

Calculate the shift factor for solid harmonics.

\[\begin{split}\mathrm{shift\_factor} = \begin{cases} 0 & \mathrm{mag} \geq 0\\ \frac{1}{2} & \mathrm{mag} < 0 \end{cases}\end{split}\]

Parameters#

magint

The magnetic quantum number of the basis function.

Returns#

shift_factorfloat

The shift factor for calculating solid harmonics.

Raises#

TypeError

If mag is not an integer.

gbasis.utils module#

Utility functions for gbasis.

gbasis.utils.factorial2(n)#

Wrap scipy.special.factorial2 to return 1.0 when the input is not positive.

This is a temporary workaround to address issue #129, while we wait for Scipy’s update. To learn more, see scipy/scipy#18409.

Parameters#

nint or np.ndarray

Values to calculate n!! for. If n <= 0, the return value is 1.

gbasis.wrappers module#

Module for interfacing to other quantum chemistry packages.

gbasis.wrappers.from_iodata(mol, tol=1e-20, overlap=False)#

Return basis set stored within the IOData instance in iodata.

Parameters#

moliodata.iodata.IOData

IOData instance from iodata module.

tolfloat

Tolerance used in overlap screening.

overlapbool

Flag for performing overlap screening between contractions.

Returns#

basistuple of gbasis.contraciton.GeneralizedContractionShell

Basis set object used within the gbasis module. GeneralizedContractionShell corresponds to the Shell object within iodata.basis.

Raises#

ValueError

If mol is not an iodata.iodata.IOData instance. If the primitive normalization scheme of the shells in IOData instance is not “L2”.

AssertionError

If generalized contractions are found in the shells in IOData instance.

Notes#

The version of the module iodata must be greater than 0.1.7.

gbasis.wrappers.from_pyscf(mol)#

Return basis set stored within the Mole instance in pyscf.

Parameters#

molpyscf.gto.mole.Mole

Mole object in pyscf.

Returns#

basistuple of gbasis.contraciton.GeneralizedContractionShell

Contractions for each atom. Contractions are ordered by the atom first, then the contractions as ordered in pyscf.

Raises#

ValueError

If mol is not a pyscf.gto.mole.Mole instance.

Notes#

This function touches the internal components of pyscf, which may or may not be documented. This function will break as soon as the internal components change. If so, please raise an issue at theochem/gbasis. It is supported for, at least, pyscf version 1.6.1.