iodata.convert module¶
Functions to convert IOData-related objects.
This module includes the lower-level implementations to the functions in the prepare module. The functions in this module can be used without writing data to files. Most of them are used by the prepare module.
- convert_conventions(molbasis, new_conventions, reverse=False)[source]¶
Return a permutation vector and sign changes to convert from 1 to 2.
The transformation from molbasis.convention to the new convention can be done applying the results of this function as follows:
vector2 = vector1[permutation]*signs
When using the option
reverse=True, one can use the results to convert in the opposite sense:vector1 = vector2[permutation]*signs
- Parameters:
molbasis (
MolecularBasis) – The description of a molecular basis set.new_conventions (
dict[str,list[str]]) – The new conventions for ordering and signs, to which data for the orbital basis needs to be converted.reverse – When, true the conversion from 2 to 1 is returned.
- Return type:
- Returns:
permutation – An integer array that permutes basis function from 1 to 2.
signs – Sign changes when going from 1 to 2, must be applied after permutation
- convert_to_cartesian(obasis, new_conventions)[source]¶
Convert a basis set to Cartesian functions with given conventions.
This is needed for file formats that do not support pure functions, such as WFN and WFX. The new basis spans the same space as the old one, so no information is lost. The Cartesian functions are ordered following the conventions of the destination format, so the Cartesian functions that were already in the basis may be reordered too.
- Parameters:
- Return type:
- Returns:
obasis_cart – A new
MolecularBasisinstance in which all shells are Cartesian, withnew_conventionsas its conventions.transform – A sparse matrix with shape
(obasis_cart.nbasis, obasis.nbasis). The coefficients of a function in the old basis,coeffs, becometransform @ coeffsin the new basis. The same function, expressed in the new basis, has identical values everywhere in space. An overlap matrix transforms astransform.T @ overlap_cart @ transform.
- Raises:
ValueError – If
new_conventionshas no Cartesian convention for an angular momentum of the basis set, or if the basis has pure shells and the primitives are not L2 normalized.
- convert_to_segmented(obasis, keep_sp=False)[source]¶
Convert basis with generalized contractions to one with only single contractions.
- Parameters:
obasis (
MolecularBasis) – The basis set to convert.keep_sp (
bool) – If True, SP shells are not split up. This can be useful for file formats only support SP-generalized contractions and no other ones.
- Return type:
- Returns:
A new
MolecularBasisinstance with separate single contractions.
- convert_to_unrestricted(mo)[source]¶
Convert orbitals to
kind="unrestricted".- Parameters:
mo (
MolecularOrbitals) – Restricted molecular orbitals to be converted.- Return type:
- Returns:
new_mo – The given object if the orbitals were already unrestricted or a new unrestricted copy.
- Raises:
ValueError – When the given orbitals are generalized.
- decontract(obasis)[source]¶
Convert a contracted basis set to one with only primitive functions.
Primitives that appear several times on the same center with the same angular momentum and kind, e.g. in a general contraction or in a shell that shares an exponent with another shell, are included only once in the new basis. The new basis spans a space that contains the old one, so no information is lost.
- Parameters:
obasis (
MolecularBasis) – The basis set to convert.- Return type:
- Returns:
obasis_prim – A new
MolecularBasisinstance in which each shell has a single primitive and a single contraction.transform – A sparse matrix with shape
(obasis_prim.nbasis, obasis.nbasis). The coefficients of a function in the old basis,coeffs, becometransform @ coeffsin the new basis. The same function, expressed in the new basis, has identical values everywhere in space. An overlap matrix transforms astransform.T @ overlap_prim @ transformand a density matrix astransform @ dm @ transform.T.