Quantum 3xplorer (Q3)
An AI-native quantum simulation engine
Loading...
Searching...
No Matches
q3::Crystal Class Reference

#include <crystal.hpp>

Public Member Functions

 Crystal ()=default
 
void add_atom (const Atom &atom)
 
void add_species (const AtomSpecies &species)
 
int atomic_number (int atom_index) const
 
const std::vector< Atom > & atoms () const
 
int bravais_lattice_index () const
 
Real cell_volume () const
 
void compute_derived_quantities ()
 
Vector3D convert_from_crystal_to_cartesian (int atom_index) const
 
const std::string & element (int atom_index) const
 
Vector3D fractional_position (int atom_index) const
 
bool has_site_symmetry_classes () const
 
Vector3D home_cell_separation (int atom_index_a, int atom_index_b) const
 
Real lattice_parameter () const
 
const Matrix3x3 & lattice_vectors () const
 
Matrix3x3 lattice_vectors_bohr () const
 
int number_of_atoms () const
 
int number_of_species () const
 
const Matrix3x3 & reciprocal_lattice_vectors () const
 
Matrix3x3 reciprocal_vectors_bohr () const
 
void set_atomic_positions (const std::vector< Vector3D > &positions)
 
void set_from_lattice_type (int bravais_lattice_index, Real cell_dimension_1)
 
void set_from_lattice_type (int bravais_lattice_index, Real cell_dimension_1, Real cell_dimension_2, Real cell_dimension_3, Real cell_dimension_4, Real cell_dimension_5, Real cell_dimension_6)
 
void set_lattice (const Matrix3x3 &lattice_vectors)
 
void set_site_symmetry_classes (const std::vector< int > &classes)
 
int site_symmetry_class (int atom_index) const
 
const std::vector< AtomSpecies > & species () const
 
int species_type_index (int atom_index) const
 
Real two_pi_over_lattice_parameter () const
 
Real two_pi_over_lattice_parameter_squared () const
 
Real valence_charge (int species_index) const
 

Static Public Member Functions

static Crystal from_input_data (int bravais_lattice_index, Real cell_dimension_1, const std::vector< AtomSpecies > &species, const std::vector< Atom > &atoms, Real cell_dimension_2=0, Real cell_dimension_3=0, Real cell_dimension_4=0, Real cell_dimension_5=0, Real cell_dimension_6=0)
 
static Crystal from_lattice_vectors (Real lattice_parameter, const Matrix3x3 &lattice_vectors, const std::vector< AtomSpecies > &species, const std::vector< Atom > &atoms)
 

Detailed Description

Crystal structure container.

Holds lattice vectors, atomic species, atom positions, and derived quantities (reciprocal lattice, cell volume, etc.).

Definition at line 30 of file crystal.hpp.

Constructor & Destructor Documentation

◆ Crystal()

q3::Crystal::Crystal ( )
default

Member Function Documentation

◆ add_atom()

void q3::Crystal::add_atom ( const Atom &  atom)
inline

Add an atom (position in crystal coords). Any installed site symmetry partition no longer covers every atom, so it is reset to the default.

Definition at line 135 of file crystal.hpp.

Referenced by from_input_data(), and from_lattice_vectors().

◆ add_species()

void q3::Crystal::add_species ( const AtomSpecies &  species)
inline

Add an atomic species.

Definition at line 127 of file crystal.hpp.

References species().

Referenced by from_input_data(), and from_lattice_vectors().

◆ atomic_number()

int q3::Crystal::atomic_number ( int  atom_index) const
inline

Atomic number (Z) for atom i. Inferred from element symbol.

Definition at line 338 of file crystal.hpp.

References q3::PeriodicTable::atomic_number_by_element_symbol().

Referenced by q3::build_mean_field_record(), q3::D3BJDispersionCalculator::compute_energy(), and q3::D3BJDispersionCalculator::compute_gradients().

◆ atoms()

const std::vector< Atom > & q3::Crystal::atoms ( ) const
inline

Definition at line 215 of file crystal.hpp.

Referenced by from_input_data(), and from_lattice_vectors().

◆ bravais_lattice_index()

int q3::Crystal::bravais_lattice_index ( ) const
inline

QE ibrav convention this crystal was built from (0 for "free"/explicit lattice vectors, i.e. Crystal::from_lattice_vectors() – see set_from_lattice_type()'s docstring for the full ibrav -> Bravais-type mapping). Consumers that need a specific lattice symmetry (e.g. isolated_system_correction/'s Makov-Payne Madelung-constant lookup, cubic-only) must check this explicitly.

Definition at line 190 of file crystal.hpp.

Referenced by q3::build_mean_field_record(), q3::MakovPayneCorrectionCalculator::compute(), from_input_data(), set_from_lattice_type(), and set_from_lattice_type().

◆ cell_volume()

Real q3::Crystal::cell_volume ( ) const
inline

Definition at line 193 of file crystal.hpp.

Referenced by q3::PlanewaveWavefunctionProjectionCalculator::PlanewaveWavefunctionProjectionCalculator(), q3::PlanewaveBlochOverlapCalculator::add_augmentation_contribution(), q3::PlanewaveHydrogenicOrbitalSet::build(), q3::build_mean_field_record(), q3::EwaldStressTensorCalculator::compute(), q3::ExchangeCorrelationStressTensorCalculator::compute(), q3::HartreeStressTensorCalculator::compute(), q3::KineticStressTensorCalculator::compute(), q3::CoreCorrectionStressTensorCalculator::compute(), q3::HubbardStressTensorCalculator::compute(), q3::EwaldForceCalculator::compute(), q3::HubbardForceCalculator::compute(), q3::UltrasoftPlanewaveEffectivePotential::compute(), q3::UltrasoftForceCalculator::compute(), q3::MakovPayneCorrectionCalculator::compute(), q3::MartynaTuckermanCorrectionCalculator::compute(), q3::LocalPseudopotentialForceCalculator::compute(), q3::PlanewaveKohnShamSCFIterator::compute_delta_escf_correction(), q3::PlanewaveKohnShamSCFIterator::compute_double_counting_correction(), q3::compute_ewald(), q3::D3BJDispersionCalculator::compute_gradients(), q3::compute_kleinman_bylander_projectors(), q3::compute_ultrasoft_effective_d_matrix(), q3::PlanewaveKohnShamSCFIterator::hartree_metric_prefactor(), q3::NormConservingPlanewaveBasis::init(), q3::UltrasoftPlanewaveBasis::init_ultrasoft(), q3::PlanewaveKohnShamSCFIterator::log_representation_summary(), q3::PlanewaveKohnShamSCFIterator::magnetization_metric_weight(), q3::PlanewaveKohnShamSCFIterator::report_convergence_details(), q3::PlanewaveKohnShamSCFIterator::scale_loaded_charge_density_to_electron_count(), and q3::PlanewaveKohnShamSCFIterator::warn_if_total_charge_deviates().

◆ compute_derived_quantities()

void q3::Crystal::compute_derived_quantities ( )
inline

Compute derived quantities from lattice vectors and alat: reciprocal lattice vectors, cell volume, two_pi_over_lattice_parameter, two_pi_over_lattice_parameter_squared. Must be called after setting lattice vectors and alat.

Definition at line 156 of file crystal.hpp.

References q3::Matrix3x3::determinant(), q3::Matrix3x3::inverse(), and q3::Matrix3x3::transpose().

Referenced by from_input_data(), from_lattice_vectors(), and q3::PlanewaveKohnShamSCFIterator::initialize_representation().

◆ convert_from_crystal_to_cartesian()

◆ element()

const std::string & q3::Crystal::element ( int  atom_index) const
inline

◆ fractional_position()

Vector3D q3::Crystal::fractional_position ( int  atom_index) const
inline

◆ from_input_data()

static Crystal q3::Crystal::from_input_data ( int  bravais_lattice_index,
Real  cell_dimension_1,
const std::vector< AtomSpecies > &  species,
const std::vector< Atom > &  atoms,
Real  cell_dimension_2 = 0,
Real  cell_dimension_3 = 0,
Real  cell_dimension_4 = 0,
Real  cell_dimension_5 = 0,
Real  cell_dimension_6 = 0 
)
inlinestatic

Construct a fully initialized crystal from raw input parameters.

Builds the lattice from Bravais index, populates species and atoms, and computes all derived quantities (reciprocal lattice, volume, etc.).

Definition at line 40 of file crystal.hpp.

References add_atom(), add_species(), atoms(), bravais_lattice_index(), compute_derived_quantities(), set_from_lattice_type(), and species().

Referenced by q3::build_crystal_from_input().

◆ from_lattice_vectors()

static Crystal q3::Crystal::from_lattice_vectors ( Real  lattice_parameter,
const Matrix3x3 &  lattice_vectors,
const std::vector< AtomSpecies > &  species,
const std::vector< Atom > &  atoms 
)
inlinestatic

Construct a fully initialized crystal from explicit lattice vectors ("free" lattice, Bravais index 0).

Parameters
lattice_parameteralat in bohr.
lattice_vectorsrows a1,a2,a3 in units of alat.

Definition at line 75 of file crystal.hpp.

References add_atom(), add_species(), atoms(), compute_derived_quantities(), lattice_parameter(), lattice_vectors(), set_lattice(), and species().

Referenced by q3::build_crystal_from_input().

◆ has_site_symmetry_classes()

bool q3::Crystal::has_site_symmetry_classes ( ) const
inline

Definition at line 314 of file crystal.hpp.

◆ home_cell_separation()

Vector3D q3::Crystal::home_cell_separation ( int  atom_index_a,
int  atom_index_b 
) const
inline

The separation r_a − r_b of two atoms (Cartesian, units of alat), moved by a lattice vector so that each of its crystal coordinates lies in [−1/2, 1/2].

Positions are kept as given, and crystal coordinates outside [0, 1) are legal input, so the plain difference of two positions can lie several cells away. A real-space lattice sum that visits the images within a distance R by running ±ceil(R / h_k) cells along each axis around this separation – h_k the spacing of the lattice planes parallel to the other two vectors – reaches all of them: an image's crystal coordinate along k is at most R / h_k in magnitude, and this separation's own is at most 1/2. Around the plain difference the same loop can miss even the nearest image; the Ewald sums did, for an O-O pair 1.08 Å apart in camsai/q3#18.

Definition at line 253 of file crystal.hpp.

References q3::Vector3D::x, q3::Vector3D::y, and q3::Vector3D::z.

Referenced by q3::EwaldStressTensorCalculator::compute(), q3::EwaldForceCalculator::compute(), and q3::compute_ewald().

◆ lattice_parameter()

◆ lattice_vectors()

◆ lattice_vectors_bohr()

Matrix3x3 q3::Crystal::lattice_vectors_bohr ( ) const
inline

Lattice vectors in Bohr (Cartesian).

Definition at line 324 of file crystal.hpp.

Referenced by q3::build_material_json(), q3::D3BJDispersionCalculator::compute_energy(), and q3::D3BJDispersionCalculator::compute_gradients().

◆ number_of_atoms()

int q3::Crystal::number_of_atoms ( ) const
inline

Definition at line 209 of file crystal.hpp.

Referenced by q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::accumulate_projector_overlaps(), q3::UltrasoftPlanewaveBasis::add_augmentation_charges(), q3::PlanewaveBlochOverlapCalculator::add_augmentation_contribution(), q3::add_kleinman_bylander_projectors_to_mean_field_record(), q3::paw_one_center::PawOneCenterTerms::build(), q3::ProjectorMappingTable::build(), q3::build_atomic_orbitals_g_space(), q3::UltrasoftPseudopotentialOverlapOperator::build_dense_matrix(), q3::build_mean_field_record(), q3::NormConservingPlanewaveForceCalculator::compute(), q3::EwaldStressTensorCalculator::compute(), q3::CoreCorrectionStressTensorCalculator::compute(), q3::HubbardStressTensorCalculator::compute(), q3::LocalPseudopotentialStressTensorCalculator::compute(), q3::NonlocalPseudopotentialStressTensorCalculator::compute(), q3::EwaldForceCalculator::compute(), q3::HubbardForceCalculator::compute(), q3::NonlocalPseudopotentialForceCalculator::compute(), q3::UltrasoftPlanewaveEffectivePotential::compute(), q3::UltrasoftForceCalculator::compute(), q3::MakovPayneCorrectionCalculator::compute(), q3::MartynaTuckermanCorrectionCalculator::compute(), q3::LocalPseudopotentialForceCalculator::compute(), q3::CoreCorrectionForceCalculator::compute(), q3::D3BJDispersionCalculator::compute_energy(), q3::compute_ewald(), q3::D3BJDispersionCalculator::compute_gradients(), q3::compute_kleinman_bylander_projectors(), q3::PlanewaveKohnShamSCFIterator::compute_number_of_electrons(), q3::compute_ultrasoft_effective_d_matrix(), q3::count_atomic_orbitals(), q3::detail::crystal_to_spglib(), q3::enumerate_atomic_orbitals(), q3::SymmetryAnalyzer::find_spacegroup(), q3::SymmetryAnalyzer::get_symmetry_operations(), q3::NormConservingPlanewaveBasis::init(), q3::CoreChargeData::initialize(), q3::PlanewaveKohnShamSCFIterator::log_representation_summary(), q3::SymmetryAnalyzer::number_of_symmetry_operations(), q3::UltrasoftPlanewaveEffectivePotential::precompute_structure_factors(), q3::SymmetryAnalyzer::reduce_kpoints(), q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::reset_projector_overlap_coefficients(), q3::resolve_hubbard_manifolds(), q3::PlanewaveDirectDiagonalizer::solve(), q3::paw_one_center::OnSiteOccupationSymmetrizer::symmetrize(), q3::SymmetryAnalyzer::symmetrize_vector(), q3::tabulate_core_charge_density_in_g_space(), q3::tabulate_local_potential_in_g_space(), and q3::paw_one_center::PawOneCenterTerms::update_by_spin().

◆ number_of_species()

int q3::Crystal::number_of_species ( ) const
inline

◆ reciprocal_lattice_vectors()

◆ reciprocal_vectors_bohr()

Matrix3x3 q3::Crystal::reciprocal_vectors_bohr ( ) const
inline

◆ set_atomic_positions()

void q3::Crystal::set_atomic_positions ( const std::vector< Vector3D > &  positions)
inline

Update the positions of all atoms (in crystal/fractional coordinates).

Definition at line 143 of file crystal.hpp.

◆ set_from_lattice_type() [1/2]

void q3::Crystal::set_from_lattice_type ( int  bravais_lattice_index,
Real  cell_dimension_1 
)
inline

Build lattice from Bravais index convention. Supported bravais_lattice_index values: 0, 1 (SC), 2 (FCC), 3/-3 (BCC), 4 (hex), 5/-5 (trig R), 6 (tet), 7 (bct), 8 (ort), 9 (bco), 10 (fco), 11 (bort), 12/-12 (mono), 14 (tri).

Definition at line 97 of file crystal.hpp.

References bravais_lattice_index(), and set_from_lattice_type().

Referenced by from_input_data(), and set_from_lattice_type().

◆ set_from_lattice_type() [2/2]

void q3::Crystal::set_from_lattice_type ( int  bravais_lattice_index,
Real  cell_dimension_1,
Real  cell_dimension_2,
Real  cell_dimension_3,
Real  cell_dimension_4,
Real  cell_dimension_5,
Real  cell_dimension_6 
)
inline

◆ set_lattice()

void q3::Crystal::set_lattice ( const Matrix3x3 &  lattice_vectors)
inline

Set lattice vectors directly (in units of alat).

Definition at line 120 of file crystal.hpp.

References lattice_vectors().

Referenced by from_lattice_vectors().

◆ set_site_symmetry_classes()

void q3::Crystal::set_site_symmetry_classes ( const std::vector< int > &  classes)
inline

Install a per-atom symmetry partition (one non-negative integer per atom; equal integers = interchangeable sites). It must refine the species partition: atoms of different species never share a class. An empty vector restores the default (class = species index).

Definition at line 295 of file crystal.hpp.

Referenced by q3::build_crystal_from_input().

◆ site_symmetry_class()

int q3::Crystal::site_symmetry_class ( int  atom_index) const
inline

Symmetry class of atom i: two atoms may be mapped onto each other by a symmetry operation only if their classes agree. By default the class is the species index. A finer partition (set_site_symmetry_classes) lets a caller distinguish atoms of one species that a higher layer treats as inequivalent, e.g. sites seeded with opposite starting moments.

Definition at line 284 of file crystal.hpp.

Referenced by q3::detail::crystal_to_spglib(), and q3::SymmetryAnalyzer::get_symmetry_operations().

◆ species()

const std::vector< AtomSpecies > & q3::Crystal::species ( ) const
inline

Definition at line 218 of file crystal.hpp.

Referenced by add_species(), from_input_data(), and from_lattice_vectors().

◆ species_type_index()

int q3::Crystal::species_type_index ( int  atom_index) const
inline

Definition at line 273 of file crystal.hpp.

Referenced by q3::UltrasoftPlanewavePseudopotentialKohnShamSCFIterator::accumulate_projector_overlaps(), q3::UltrasoftPlanewaveBasis::add_augmentation_charges(), q3::PlanewaveBlochOverlapCalculator::add_augmentation_contribution(), q3::add_kleinman_bylander_projectors_to_mean_field_record(), q3::ProjectorMappingTable::build(), q3::build_atomic_orbitals_g_space(), q3::UltrasoftPseudopotentialOverlapOperator::build_dense_matrix(), q3::EwaldStressTensorCalculator::compute(), q3::CoreCorrectionStressTensorCalculator::compute(), q3::HubbardStressTensorCalculator::compute(), q3::LocalPseudopotentialStressTensorCalculator::compute(), q3::NonlocalPseudopotentialStressTensorCalculator::compute(), q3::EwaldForceCalculator::compute(), q3::NonlocalPseudopotentialForceCalculator::compute(), q3::UltrasoftPlanewaveEffectivePotential::compute(), q3::UltrasoftForceCalculator::compute(), q3::MakovPayneCorrectionCalculator::compute(), q3::MartynaTuckermanCorrectionCalculator::compute(), q3::LocalPseudopotentialForceCalculator::compute(), q3::CoreCorrectionForceCalculator::compute(), q3::compute_ewald(), q3::compute_kleinman_bylander_projectors(), q3::compute_ultrasoft_effective_d_matrix(), q3::count_atomic_orbitals(), q3::enumerate_atomic_orbitals(), q3::NormConservingPlanewaveBasis::init(), q3::CoreChargeData::initialize(), q3::PlanewaveDirectDiagonalizer::solve(), q3::paw_one_center::OnSiteOccupationSymmetrizer::symmetrize(), q3::tabulate_core_charge_density_in_g_space(), q3::tabulate_local_potential_in_g_space(), and q3::paw_one_center::PawOneCenterTerms::update_by_spin().

◆ two_pi_over_lattice_parameter()

◆ two_pi_over_lattice_parameter_squared()

◆ valence_charge()


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