GauXC Molecule API#

This section provides a reference for the GauXC API related to molecule objects, including C++ class definitions, C bindings, and Fortran bindings.

C++ defintions#

class GauXC::Molecule : public std::Vector<GauXC::Atom>#

A class to represent a collection of atoms in a molecule.

inline Molecule(std::vector<Atom> atoms)#

Construct a Molecule object from a vector of Atom objects.

Parameters:

atoms – A vector of Atom objects representing the atoms in the molecule.

Returns:

A Molecule object initialized with the given atoms.

inline size_t natoms() const#

Get the number of atoms in the molecule.

Returns:

The number of atoms in the molecule.

inline AtomicNumber maxZ() const#

Get the maximum atomic number among the atoms in the molecule.

Returns:

The maximum atomic number among the atoms in the molecule.

inline bool operator==(const Molecule &other) const#

Compare this molecule with another molecule for equality.

Parameters:

other – Another molecule to compare with.

Returns:

True if this molecule is equal to the other molecule, false otherwise.

struct GauXC::Atom#

Representation of an atom in a molecule, containing its atomic number and Cartesian coordinates.

AtomicNumber Z#

The atomic number of the atom.

double x#

The x-coordinate of the atom in Cartesian coordinates.

double y#

The y-coordinate of the atom in Cartesian coordinates.

double z#

The z-coordinate of the atom in Cartesian coordinates.

inline Atom(AtomicNumber Z, double x, double y, double z)#

Construct an Atom object with the given atomic number and coordinates.

Parameters:
  • Z – The atomic number of the atom.

  • x – The x-coordinate of the atom in Cartesian coordinates.

  • y – The y-coordinate of the atom in Cartesian coordinates.

  • z – The z-coordinate of the atom in Cartesian coordinates.

Returns:

An Atom object initialized with the given atomic number and coordinates.

using GauXC::AtomicNumber = int64_t#

A type to represent the atomic number of an atom.

C bindings#

struct GauXCMolecule#

Opaque struct representing a molecule in the GauXC C API.

GauXCMolecule gauxc_molecule_new(GauXCStatus *status)#

Create a new GauXCMolecule object.

Parameters:
  • status – Pointer to a GauXCStatus variable to store the status of the operation.

Returns:

A new GauXCMolecule object.

GauXCMolecule gauxc_molecule_new_from_atoms(GauXCStatus *status, const GauXCAtom *atoms, size_t natoms)#

Create a new GauXCMolecule object from an array of GauXCAtom structs.

Parameters:
  • status – Pointer to a GauXCStatus variable to store the status of the operation.

  • atoms – Pointer to an array of GauXCAtom structs representing the atoms in the molecule.

  • natoms – The number of atoms in the molecule.

Returns:

A new GauXCMolecule object initialized with the given atoms.

void gauxc_molecule_delete(GauXCStatus *status, GauXCMolecule *molecule)#

Delete a GauXCMolecule object.

Parameters:
  • status – Pointer to a GauXCStatus variable to store the status of the operation.

  • molecule – Pointer to the GauXCMolecule object to be deleted.

struct GauXCAtom#

Representation of an atom in a molecule for the GauXC C API, containing its atomic number and Cartesian coordinates.

int64_t Z#

The atomic number of the atom.

double x#

The x-coordinate of the atom in Cartesian coordinates.

double y#

The y-coordinate of the atom in Cartesian coordinates.

double z#

The z-coordinate of the atom in Cartesian coordinates.

Fortran bindings#

type  gauxc_molecule_type#

Opaque type representing a molecule in the GauXC Fortran API. Available from the module gauxc_molecule.

function  gauxc_molecule_new(status)#

Create a new gauxc_molecule_type object.

Parameters:

status [type(gauxc_status_type)] :: A variable to store the status of the operation.

Return:

type (gauxc_molecule_type) :: A new gauxc_molecule_type object.

function  gauxc_molecule_new_from_atoms(status, atoms, natoms)#

Create a new gauxc_molecule_type object from an array of gauxc_atom_type objects.

Parameters:
  • status [type(gauxc_status_type)] :: A variable to store the status of the operation.

  • atoms (*) [type(gauxc_atom_type)] :: An array of gauxc_atom_type objects representing the atoms in the molecule.

  • natoms [integer(c_int64_t)] :: The number of atoms in the molecule.

Return:

type (gauxc_molecule_type) :: A new gauxc_molecule_type object initialized with the given atoms.

function  gauxc_molecule_delete(status, molecule)#

Delete a gauxc_molecule_type object. Part of the gauxc_delete() interface.

Parameters:
  • status [type(gauxc_status_type)] :: A variable to store the status of the operation.

  • molecule [type(gauxc_molecule_type)] :: The gauxc_molecule_type object to be deleted.

type  gauxc_atom_type#

A derived type representing an atom in the GauXC Fortran API, containing its atomic number and Cartesian coordinates.

Type fields:
  • % Z [integer(c_int64_t)] :: The atomic number of the atom.

  • % x [real(c_double)] :: The x-coordinate of the atom in Cartesian coordinates.

  • % y [real(c_double)] :: The y-coordinate of the atom in Cartesian coordinates.

  • % z [real(c_double)] :: The z-coordinate of the atom in Cartesian coordinates.

Serialization to HDF5#

If GauXC has been built with HDF5 support GAUXC_HAS_HDF5, the GauXC::Molecule class can be serialized to and deserialized from HDF5 files using the provided HDF5 interface. This allows for easy storage and retrieval of molecular data in a standardized format.

void GauXC::write_hdf5_record(const Molecule &molecule, const std::string &filename, const std::string &group_name)#

Write a Molecule object to an HDF5 file.

Parameters:
  • molecule – The Molecule object to be written to the file.

  • filename – The name of the HDF5 file to write to.

  • group_name – The name of the group in the HDF5 file where the molecule data will be stored.

void GauXC::read_hdf5_record(Molecule &molecule, const std::string &filename, const std::string &group_name)#

Read a Molecule object from an HDF5 file.

Parameters:
  • molecule – The Molecule object to be populated with the data read from the file.

  • filename – The name of the HDF5 file to read from.

  • group_name – The name of the group in the HDF5 file where the molecule data is stored.

The same functions are available in the GauXC C API.

void gauxc_molecule_write_hdf5_record(GauXCMolecule molecule, const char *filename, const char *group_name)#

Write a GauXCMolecule object to an HDF5 file in C.

Parameters:
  • molecule – The GauXCMolecule object to be written to the file.

  • filename – The name of the HDF5 file to write to.

  • group_name – The name of the group in the HDF5 file where the molecule data will be stored.

void gauxc_molecule_read_hdf5_record(GauXCMolecule molecule, const char *filename, const char *group_name)#

Read a GauXCMolecule object from an HDF5 file in C.

Parameters:
  • molecule – The GauXCMolecule object to be populated with the data read from the file.

  • filename – The name of the HDF5 file to read from.

  • group_name – The name of the group in the HDF5 file where the molecule data is stored.

The same functions are also available in the GauXC Fortran API, available from the module gauxc_external_hdf5.

subroutine  gauxc_molecule_write_hdf5_record(molecule, filename, group_name)#

Write a gauxc_molecule_type object to an HDF5 file in Fortran.

Parameters:
  • molecule [type(gauxc_molecule_type)] :: The gauxc_molecule_type object to be written to the file.

  • filename [character(len=*)] :: The name of the HDF5 file to write to.

  • group_name [character(len=*)] :: The name of the group in the HDF5 file where the molecule data will be stored.

subroutine  gauxc_molecule_read_hdf5_record(molecule, filename, group_name)#

Read a gauxc_molecule_type object from an HDF5 file in Fortran.

Parameters:
  • molecule [type(gauxc_molecule_type)] :: The gauxc_molecule_type object to be populated with the data read from the file.

  • filename [character(len=*)] :: The name of the HDF5 file to read from.

  • group_name [character(len=*)] :: The name of the group in the HDF5 file where the molecule data is stored.