ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
unitcell Namespace Reference

Free functions for extracting atom/orbital info from Atom array. More...

Classes

struct  OrthogonalCell
struct  SlabCell
struct  AtomData
 Cartesian atom information in type-major order, matching ABACUS atom indices. More...

Functions

void bcast_atoms_tau (Atom *atoms, const int ntype)
 broadcast the tau array of the atoms
void bcast_atoms_pseudo (Atom *atoms, const int ntype)
 broadcast the pseduo of the atoms
void bcast_Lattice (Lattice &lat)
 broadcast the lattice
void bcast_magnetism (Magnetism &magnet, const int ntype, const int nspin)
 broadcast the magnetism
void bcast_unitcell (UnitCell &ucell, const int nspin)
 broadcast the unitcell
int cal_nlocal (const Atom *atoms, const int ntype, const int nspin)
 Calculate the total number of local numerical atomic orbitals.
void cal_nelec (const Atom *atoms, const int &ntype, double &nelec, const double nelec_delta)
 calculate the total number of electrons in system
void cal_nbands (const int &nelec, const int &nlocal, const std::vector< double > &nelec_spin, int &nbands, const std::string &esolver_type, const bool lspinorb, const int nspin, const std::string &basis_type, const std::string &smearing_method)
 Calculate the number of bands.
void cal_ux (UnitCell &ucell, const int nspin)
 Calculate ux for the unit cell.
bool judge_parallel (double a[3], ModuleBase::Vector3< double > b)
 Judge if two vectors are parallel.
void cal_nwfc (std::ofstream &log, UnitCell &ucell, Atom *atoms, const int nspin, const int nlocal, const int npol, const std::string &basis_type, const std::string &esolver_type, const std::string &init_wfc, const int nbands)
 Calculate the total number of local basis.
void cal_meshx (int &meshx, const Atom *atoms, const int ntype)
 Calculate meshx.
void cal_natomwfc (std::ofstream &log, int &natomwfc, const int ntype, const Atom *atoms, const int nspin)
 Calculate natomwfc.
bool make_orthogonal_cell (const ModuleBase::Matrix3 &lattice, const double lattice_scale, const double relative_tolerance, OrthogonalCell &cell)
ModuleBase::Vector3< double > relative_position (const ModuleBase::Vector3< double > &position, const OrthogonalCell &cell)
ModuleBase::Vector3< double > weighted_center (const std::vector< ModuleBase::Vector3< double > > &positions, const std::vector< double > &weights, const OrthogonalCell &cell)
bool make_slab_cell (const ModuleBase::Matrix3 &lattice, const double lattice_scale, const int open_axis, const double relative_tolerance, SlabCell &cell)
double relative_coordinate (const ModuleBase::Vector3< double > &position, const SlabCell &cell)
 Normal displacement in [-L/2, L/2); requires a validated cell and position.
double weighted_center (const std::vector< ModuleBase::Vector3< double > > &positions, const std::vector< double > &weights, const SlabCell &cell)
int pseudo_atom_z (const Atom &atom)
std::vector< AtomData > get_atom_data (const Atom *atoms, const int ntype, const double lattice_scale)
std::vector< std::string > get_atomLabels (const Atom *atoms, const int ntype)
 Get atom labels for each atom type.
std::vector< int > get_atomCounts (const Atom *atoms, const int ntype)
 Get atom counts (number of atoms) for each atom type.
std::vector< std::vector< int > > get_lnchiCounts (const Atom *atoms, const int ntype)
 Get lnchi counts (number of chi functions per L) for each atom type.
std::vector< ModuleBase::Vector3< double > > get_target_mag (const Atom *atoms, const int ntype, const int nat)
 Get target magnetic moment for each atom (used by deltaspin).
std::vector< ModuleBase::Vector3< double > > get_lambda (const Atom *atoms, const int ntype, const int nat)
 Get Lagrange multiplier for each atom (used by deltaspin).
std::vector< ModuleBase::Vector3< int > > get_constrain (const Atom *atoms, const int ntype, const int nat)
 Get constrain flag for each atom (used by deltaspin).
bool if_atoms_can_move (const Atom *atoms, const int ntype)
 Judge if any atom can move (any mbl component is non-zero).
bool if_cell_can_change (const std::vector< int > &lat_axis_free)
 Judge if any lattice vector can change.
void check_atomic_stru (UnitCell &ucell, const double &factor)
 Check atomic structure.
void print_tau (Atom *atoms, const std::string &Coordinate, const int ntype, const double lat0, std::ofstream &ofs)
 Print atom positions (tau).
void print_stru_file (const UnitCell &ucell, const Atom *atoms, const ModuleBase::Matrix3 &latvec, const std::string &fn, const std::string &header, const int &nspin, const bool &vel, const bool &magmom, const bool &orb, const bool &dpks_desc, const int &iproc, const ModuleBase::matrix &force, const bool &has_force, const bool append)
 Print STRU file according to given settings.
void print_cell (const UnitCell &ucell, std::ofstream &ofs)
 Print basic unitcell information to output stream.
StruMeta make_stru_meta (const UnitCell &ucell)
bool read_atom_species (std::ifstream &ifa, std::ofstream &ofs_running, UnitCell &ucell, const std::string &basis_type, const std::string &orbital_dir, const std::string &init_wfc, const double onsite_radius, const bool deepks_setorb, const bool rpa)
 Read atom species information.
bool read_lattice_constant (std::ifstream &ifa, std::ofstream &ofs_running, Lattice &lat)
 Read lattice constant.
bool validate_coordinate_system (const std::string &Coordinate, std::ofstream &ofs_warning)
 Validate coordinate system type.
void allocate_atom_properties (Atom &atom, int na)
 Allocate and initialize atom property vectors.
void set_atom_movement_flags (Atom &atom, int ia, const ModuleBase::Vector3< int > &mv, const bool fixed_atoms)
 Set atom movement constraints based on fixed_atoms parameter.
bool is_magnetization_all_zero (const UnitCell &ucell)
 Check whether every atom carries a zero collinear magnetic moment.
void autoset_magnetization (UnitCell &ucell, int nspin, std::ofstream &ofs_running)
 Set default magnetization if not explicitly specified.
void warn_zero_magnetization_nspin4 (const UnitCell &ucell, std::ofstream &ofs_running)
 Warn when a nspin=4 run starts from an all-zero magnetization vector.
void warn_xy_magnetization_ignored (const std::string &label, int n_discarded, int na, std::ofstream &ofs_running)
 Report, once per atom type, that x/y magnetization was discarded.
bool finalize_atom_positions (UnitCell &ucell, std::ofstream &ofs_running, std::ofstream &ofs_warning, const std::string &calculation, const std::string &esolver_type)
 Perform final validation and output.
ModuleBase::Vector3< double > calculate_lattice_center (const ModuleBase::Matrix3 &latvec, const std::string &center_mode)
 Calculate lattice center for different centering modes.
void transform_atom_coordinates (Atom &atom, int ia, const std::string &Coordinate, const ModuleBase::Vector3< double > &v, const ModuleBase::Matrix3 &latvec, double lat0, ModuleBase::Vector3< double > &latcenter)
 Convert between different coordinate systems.
bool process_magnetization (Atom &atom, int it, int ia, int nspin, bool input_vec_mag, bool input_angle_mag, std::ofstream &ofs_running, const bool noncolin)
 Convert between magnetization representations and output.
bool parse_atom_properties (std::ifstream &ifpos, Atom &atom, int ia, ModuleBase::Vector3< int > &mv, bool &input_vec_mag, bool &input_angle_mag, bool &set_element_mag_zero)
 Parse optional atom properties (mag, angle1, angle2, lambda, sc, m, v).
bool read_atom_type_header (int it, UnitCell &ucell, std::ifstream &ifpos, std::ofstream &ofs_running, std::ofstream &ofs_warning, bool &set_element_mag_zero, const std::string &basis_type, const std::string &orbital_dir, const std::string &init_wfc, const double onsite_radius)
 Read atom type metadata (label, magnetization, orbital info, atom count).
bool read_orb_file (int it, std::string &orb_file, std::ofstream &ofs_running, Atom *atom)
 read number of numerical orbitals for each angular momentum
AtomsInfoResult read_pseudo (std::ofstream &ofs, UnitCell &ucell, const std::string &pseudo_dir, const std::string &global_out_dir, const bool out_element_info, const std::string &dft_functional, const bool lspinorb, const double pseudo_rcut, const double soc_lambda, const int nspin, const int npol, const std::string &basis_type, const std::string &esolver_type, const std::string &init_wfc, const int nbands, const bool two_fermi, const double nelec_delta, const std::string &smearing_method, const std::string &ks_solver, const int bndpar, const double nelec, const double nupdown)
 Read pseudopotential files and calculate atom information.
void read_cell_pseudopots (const std::string &fn, std::ofstream &log, UnitCell &ucell, const std::string &global_out_dir, const std::string &dft_functional, const bool lspinorb, const double pseudo_rcut, const double soc_lambda)
 Read pseudopotential from files for each type of atom.
void print_unitcell_pseudo (const std::string &fn, UnitCell &ucell)
 Print unit cell pseudopotential information.
void compare_atom_labels (const std::string &label1, const std::string &label2)
 Check consistency between two atom labels from STRU and pseudo or orb file.
bool check_tau (const Atom *atoms, const int &ntype, const double &lat0)
 Check atom positions (tau).
void check_dtau (Atom *atoms, const int &ntype, const double &lat0, ModuleBase::Matrix3 &latvec)
 Check atom displacements (dtau).
bool read_atom_positions (UnitCell &ucell, std::ifstream &ifpos, std::ofstream &ofs_running, std::ofstream &ofs_warning, const int nspin, const std::string &basis_type, const std::string &orbital_dir, const std::string &init_wfc, const double onsite_radius, const bool fixed_atoms, const bool noncolin, const std::string &calculation, const std::string &esolver_type, const int symmetry)
 Read atomic positions.
bool read_atom_positions (UnitCell &ucell, std::ifstream &ifpos, std::ofstream &ofs_running, std::ofstream &ofs_warning)
void remake_cell (Lattice &lat)
 Adjust lattice vectors for constrained vc-relaxation.
void setup_cell_after_vc (UnitCell &ucell, std::ofstream &log, const int nspin)
 Setup cell after vc-relaxation.
void update_pos_tau (const Lattice &lat, const double *pos, const int ntype, const int nat, Atom *atoms)
 Update the position and tau of the atoms.
void update_pos_taud (const Lattice &lat, const double *posd_in, const int ntype, const int nat, Atom *atoms)
 Update the position and taud of the atoms.
void update_pos_taud (const Lattice &lat, const ModuleBase::Vector3< double > *posd_in, const int ntype, const int nat, Atom *atoms)
 Update the position and taud of the atoms (Vector3 version).
void update_vel (const ModuleBase::Vector3< double > *vel_in, const int ntype, const int nat, Atom *atoms)
 Update the velocity of the atoms.
void periodic_boundary_adjustment (Atom *atoms, const ModuleBase::Matrix3 &latvec, const int ntype)
 Check the boundary of the cell.
void reset_remake_cell_mock ()
bool was_remake_cell_called ()

Variables

bool allow_cell_change = false

Detailed Description

Free functions for extracting atom/orbital info from Atom array.

The running-log convergence reporting is centralized in IonCellOptimizer::relax_step. These tests lock the unified format shared by every relax method (sd/cg_trad/bfgs/bfgs_trad/lbfgs) and by cell-relax: Largest force is ... eV/Angstrom while threshold is ... eV/Angstrom Largest stress is ... kbar while threshold is ... kbar Relaxation is converged! Relaxation is not converged yet! The markers are what the ASE interface greps for (issue #6546).

Function Documentation

◆ allocate_atom_properties()

void unitcell::allocate_atom_properties ( Atom & atom,
int na )

Allocate and initialize atom property vectors.

Parameters
atomThe atom object to allocate properties for
naNumber of atoms
massAtomic mass
Here is the caller graph for this function:

◆ autoset_magnetization()

void unitcell::autoset_magnetization ( UnitCell & ucell,
int nspin,
std::ofstream & ofs_running )

Set default magnetization if not explicitly specified.

Parameters
ucellUnit cell object
nspinNumber of spin components
ofs_runningOutput stream for running information
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bcast_atoms_pseudo()

void unitcell::bcast_atoms_pseudo ( Atom * atoms,
const int ntype )

broadcast the pseduo of the atoms

Parameters
atomsthe atoms to be broadcasted [in/out]
ntypethe number of types of the atoms [in]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bcast_atoms_tau()

void unitcell::bcast_atoms_tau ( Atom * atoms,
const int ntype )

broadcast the tau array of the atoms

Parameters
atomsthe atoms to be broadcasted [in/out]
ntypethe number of types of the atoms [in]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bcast_Lattice()

void unitcell::bcast_Lattice ( Lattice & lat)

broadcast the lattice

Parameters
latthe lattice to be broadcasted [in/out]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bcast_magnetism()

void unitcell::bcast_magnetism ( Magnetism & magnet,
const int ntype,
const int nspin )

broadcast the magnetism

Parameters
magnetthe magnetism to be broadcasted [in/out]
nytpethe number of types of the atoms [in]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bcast_unitcell()

void unitcell::bcast_unitcell ( UnitCell & ucell,
const int nspin )

broadcast the unitcell

Parameters
ucellthe unitcell to be broadcasted [in/out]
nspinthe number of spin components
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cal_meshx()

void unitcell::cal_meshx ( int & meshx,
const Atom * atoms,
const int ntype )

Calculate meshx.

Demand: atoms[].msh

Parameters
meshxoutput mesh size [out]
atomsatom pointer [in]
ntypenumber of atom types [in]
Here is the caller graph for this function:

◆ cal_natomwfc()

void unitcell::cal_natomwfc ( std::ofstream & log,
int & natomwfc,
const int ntype,
const Atom * atoms,
const int nspin )

Calculate natomwfc.

Demand: atoms[].nchi, atoms[].lchi, atoms[].oc, atoms[].na

Parameters
logoutput file stream [in]
natomwfcoutput number of atomic wavefunctions [out]
ntypenumber of atom types [in]
atomsatom pointer [in]
nspinnumber of spin components [in]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cal_nbands()

void unitcell::cal_nbands ( const int & nelec,
const int & nlocal,
const std::vector< double > & nelec_spin,
int & nbands,
const std::string & esolver_type,
const bool lspinorb,
const int nspin,
const std::string & basis_type,
const std::string & smearing_method )

Calculate the number of bands.

IMPORTANT: The nbands parameter must be the user-specified value from INPUT file. If nbands is 0, this function will auto-calculate a default value based on nelec. If nbands is non-zero (user-specified), this function will validate and use it.

BUG FIX NOTE: Previously, cal_atoms_info() did not pass the user-specified nbands, causing result.nbands to always be 0 and triggering auto-calculation regardless of user input. This led to incorrect energy calculations (deviation ~139 eV).

Parameters
nelec[in] total number of electrons
nlocal[in] total number of local basis
nelec_spin[in] number of electrons for each spin
nbands[in/out] number of bands - must be user-specified value on input, will be updated if auto-calculation is triggered (nbands==0)
esolver_type[in] solver type
lspinorb[in] spin-orbit coupling flag
nspin[in] number of spin components
basis_type[in] basis type
smearing_method[in] smearing method
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cal_nelec()

void unitcell::cal_nelec ( const Atom * atoms,
const int & ntype,
double & nelec,
const double nelec_delta )

calculate the total number of electrons in system

Parameters
atoms[in] atom pointer
ntype[in] number of atom types
nelec[out] total number of electrons
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cal_nlocal()

int unitcell::cal_nlocal ( const Atom * atoms,
const int ntype,
const int nspin )

Calculate the total number of local numerical atomic orbitals.

nlocal = sum over all atom types of (atoms[it].nw * atoms[it].na). For nspin == 4 (non-collinear) each basis function carries 2 polarizations, so nlocal is doubled.

Shared by cal_atoms_info() (which stores the result in PARAM.globalv.nlocal) and GintInfo::init_trace_lo_(), so those two can no longer drift apart. cal_wfc() still repeats the loop inline because it also needs the per-type prefix sums for Atom::stapos_wf, and asserts its own total against the value cal_atoms_info() produced.

Note
atoms[it].nw must already be populated, i.e. Atom::set_index() must have run for every type before calling this.
Parameters
atoms[in] atom pointer
ntype[in] number of atom types
nspin[in] number of spin components
Returns
total number of local basis functions
Here is the caller graph for this function:

◆ cal_nwfc()

void unitcell::cal_nwfc ( std::ofstream & log,
UnitCell & ucell,
Atom * atoms,
const int nspin,
const int nlocal,
const int npol,
const std::string & basis_type,
const std::string & esolver_type,
const std::string & init_wfc,
const int nbands )

Calculate the total number of local basis.

Target: nwfc, lmax, atoms[].stapos_wf, PARAM.inp.nbands

Parameters
logoutput file stream [in]
ucellunit cell [in/out]
atomsatom pointer [in/out]
nspinnumber of spin components [in]
nlocaltotal number of local basis [in]
npolnumber of polarizations [in]
basis_typebasis type [in]
esolver_typesolver type [in]
init_wfcinitial wavefunction type [in]
nbandsnumber of bands [in]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cal_ux()

void unitcell::cal_ux ( UnitCell & ucell,
const int nspin )

Calculate ux for the unit cell.

Parameters
ucellunit cell [in/out]
nspinnumber of spin components [in]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculate_lattice_center()

ModuleBase::Vector3< double > unitcell::calculate_lattice_center ( const ModuleBase::Matrix3 & latvec,
const std::string & center_mode )

Calculate lattice center for different centering modes.

Parameters
latvecLattice vectors
center_modeCentering mode: "xy", "xz", "yz", or "xyz"
Returns
Lattice center coordinates
Here is the caller graph for this function:

◆ check_atomic_stru()

void unitcell::check_atomic_stru ( UnitCell & ucell,
const double & factor )

Check atomic structure.

Parameters
ucellunit cell [in/out]
factorscaling factor [in]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_dtau()

void unitcell::check_dtau ( Atom * atoms,
const int & ntype,
const double & lat0,
ModuleBase::Matrix3 & latvec )

Check atom displacements (dtau).

Parameters
atomsatom pointer [in/out]
ntypenumber of atom types [in]
lat0lattice constant [in]
latveclattice vectors [in]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_tau()

bool unitcell::check_tau ( const Atom * atoms,
const int & ntype,
const double & lat0 )

Check atom positions (tau).

Parameters
atomsatom pointer [in]
ntypenumber of atom types [in]
lat0lattice constant [in]
Returns
true if check passes
Here is the call graph for this function:
Here is the caller graph for this function:

◆ compare_atom_labels()

void unitcell::compare_atom_labels ( const std::string & label1,
const std::string & label2 )

Check consistency between two atom labels from STRU and pseudo or orb file.

Parameters
label1atom label from STRU [in]
label2atom label from pseudo or orbital file [in]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ finalize_atom_positions()

bool unitcell::finalize_atom_positions ( UnitCell & ucell,
std::ofstream & ofs_running,
std::ofstream & ofs_warning,
const std::string & calculation,
const std::string & esolver_type )

Perform final validation and output.

Parameters
ucellUnit cell object
ofs_runningOutput stream for running information
ofs_warningOutput stream for warnings
Returns
true if validation passes, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_atom_data()

std::vector< AtomData > unitcell::get_atom_data ( const Atom * atoms,
int ntype,
double lattice_scale )

Extract positions, masses and pseudopotential valence charges. Requires initialized Atom storage and a positive lattice scale in Bohr.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_atomCounts()

std::vector< int > unitcell::get_atomCounts ( const Atom * atoms,
const int ntype )

Get atom counts (number of atoms) for each atom type.

Parameters
atomsatom pointer [in]
ntypenumber of atom types [in]
Returns
vector of atom counts, one per type
Here is the caller graph for this function:

◆ get_atomLabels()

std::vector< std::string > unitcell::get_atomLabels ( const Atom * atoms,
const int ntype )

Get atom labels for each atom type.

Parameters
atomsatom pointer [in]
ntypenumber of atom types [in]
Returns
vector of atom labels, one per type
Here is the caller graph for this function:

◆ get_constrain()

std::vector< ModuleBase::Vector3< int > > unitcell::get_constrain ( const Atom * atoms,
const int ntype,
const int nat )

Get constrain flag for each atom (used by deltaspin).

Parameters
atomsatom pointer [in]
ntypenumber of atom types [in]
nattotal number of atoms [in]
Returns
vector of constrain flags, one per atom
Here is the caller graph for this function:

◆ get_lambda()

std::vector< ModuleBase::Vector3< double > > unitcell::get_lambda ( const Atom * atoms,
const int ntype,
const int nat )

Get Lagrange multiplier for each atom (used by deltaspin).

Parameters
atomsatom pointer [in]
ntypenumber of atom types [in]
nattotal number of atoms [in]
Returns
vector of Lagrange multipliers, one per atom
Here is the caller graph for this function:

◆ get_lnchiCounts()

std::vector< std::vector< int > > unitcell::get_lnchiCounts ( const Atom * atoms,
const int ntype )

Get lnchi counts (number of chi functions per L) for each atom type.

Parameters
atomsatom pointer [in]
ntypenumber of atom types [in]
Returns
vector of lnchi counts, one vector per type
Here is the caller graph for this function:

◆ get_target_mag()

std::vector< ModuleBase::Vector3< double > > unitcell::get_target_mag ( const Atom * atoms,
const int ntype,
const int nat )

Get target magnetic moment for each atom (used by deltaspin).

Parameters
atomsatom pointer [in]
ntypenumber of atom types [in]
nattotal number of atoms [in]
Returns
vector of target magnetic moments, one per atom
Here is the caller graph for this function:

◆ if_atoms_can_move()

bool unitcell::if_atoms_can_move ( const Atom * atoms,
const int ntype )

Judge if any atom can move (any mbl component is non-zero).

Parameters
atomsatom pointer [in]
ntypenumber of atom types [in]
Returns
true if at least one atom is allowed to move
Here is the caller graph for this function:

◆ if_cell_can_change()

bool unitcell::if_cell_can_change ( const std::vector< int > & lat_axis_free)

Judge if any lattice vector can change.

Parameters
lat_axis_freelattice-axis freedom flags (size 3) [in]
Returns
true if at least one lattice axis is free to change
Here is the caller graph for this function:

◆ is_magnetization_all_zero()

bool unitcell::is_magnetization_all_zero ( const UnitCell & ucell)

Check whether every atom carries a zero collinear magnetic moment.

Parameters
ucellUnit cell object
Returns
true if |mag| of every atom is below the magnetization threshold
Here is the caller graph for this function:

◆ judge_parallel()

bool unitcell::judge_parallel ( double a[3],
ModuleBase::Vector3< double > b )

Judge if two vectors are parallel.

Parameters
afirst vector [in]
bsecond vector [in]
Returns
true if vectors are parallel
Here is the caller graph for this function:

◆ make_orthogonal_cell()

bool unitcell::make_orthogonal_cell ( const ModuleBase::Matrix3 & lattice,
double lattice_scale,
double relative_tolerance,
OrthogonalCell & cell )

Accept rectangular cells, including rotated cells. Return false if the lattice vectors are not mutually perpendicular within relative_tolerance.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_slab_cell()

bool unitcell::make_slab_cell ( const ModuleBase::Matrix3 & lattice,
double lattice_scale,
int open_axis,
double relative_tolerance,
SlabCell & cell )

Return false if the open lattice vector is not perpendicular to the periodic plane within relative_tolerance.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_stru_meta()

StruMeta unitcell::make_stru_meta ( const UnitCell & ucell)
Here is the caller graph for this function:

◆ parse_atom_properties()

bool unitcell::parse_atom_properties ( std::ifstream & ifpos,
Atom & atom,
int ia,
ModuleBase::Vector3< int > & mv,
bool & input_vec_mag,
bool & input_angle_mag,
bool & set_element_mag_zero )

Parse optional atom properties (mag, angle1, angle2, lambda, sc, m, v).

Parameters
ifposInput file stream
atomThe atom object
iaAtom index
mvMovement vector (output parameter)
input_vec_magWhether vector magnetization was input (output parameter)
input_angle_magWhether angle magnetization was input (output parameter)
set_element_mag_zeroWhether to reset element magnetization (output parameter)
Returns
true if parsing succeeds, false otherwise
Here is the caller graph for this function:

◆ periodic_boundary_adjustment()

void unitcell::periodic_boundary_adjustment ( Atom * atoms,
const ModuleBase::Matrix3 & latvec,
const int ntype )

Check the boundary of the cell.

For each atom, the taud in three directions should be in the range of [-1,1).

Parameters
atomsthe atoms to be adjusted [in/out]
latvecthe lattice of the atoms [in]
ntypethe number of types of the atoms [in]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_cell()

void unitcell::print_cell ( const UnitCell & ucell,
std::ofstream & ofs )

Print basic unitcell information to output stream.

Parameters
ucellreference of unitcell [in]
ofsoutput file stream [in]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_stru_file()

void unitcell::print_stru_file ( const UnitCell & ucell,
const Atom * atoms,
const ModuleBase::Matrix3 & latvec,
const std::string & fn,
const std::string & header,
const int & nspin,
const bool & vel,
const bool & magmom,
const bool & orb,
const bool & dpks_desc,
const int & iproc,
const ModuleBase::matrix & force,
const bool & has_force,
const bool append )

Print STRU file according to given settings.

Note
UnitCell class is too heavy, this function would be moved elsewhere.
Parameters
ucellreference of unitcell [in]
atomsAtom list [in]
latveclattice parameter vector [in]
fnSTRU file name [in]
headercomment lines written at the top of the file [in]
Note
Positions are always written in Cartesian_angstrom, independent of force availability, so that all STRU outputs share one coordinate format. has_force only controls the per-atom f fields.
Parameters
nspinnumber of spin channels [in]
veltrue for printing velocities [in]
magmomtrue for printing Mulliken population analysis produced magmom [in]
orbtrue for printing NUMERICAL_ORBITAL section [in]
dpks_desctrue for printing NUMERICAL_DESCRIPTOR section [in]
iprocGlobalV::MY_RANK [in]
forceatomic forces in Ry/Bohr, used only when has_force is true [in]
has_forcetrue to emit per-atom f fields; force matrix must match nat [in]
appendtrue to append the structure block to an existing file (out_app_flag == 1 multi-step runs); false truncates [in]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_tau()

void unitcell::print_tau ( Atom * atoms,
const std::string & Coordinate,
const int ntype,
const double lat0,
std::ofstream & ofs )

Print atom positions (tau).

Parameters
atomsatom pointer [in]
Coordinatecoordinate system type [in]
ntypenumber of atom types [in]
lat0lattice constant [in]
ofsoutput file stream [in]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_unitcell_pseudo()

void unitcell::print_unitcell_pseudo ( const std::string & fn,
UnitCell & ucell )

Print unit cell pseudopotential information.

Parameters
fnfilename [in]
ucellunit cell [in]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_magnetization()

bool unitcell::process_magnetization ( Atom & atom,
int it,
int ia,
int nspin,
bool input_vec_mag,
bool input_angle_mag,
std::ofstream & ofs_running,
const bool noncolin )

Convert between magnetization representations and output.

Parameters
atomThe atom object
itAtom type index
iaAtom index
nspinNumber of spin components
input_vec_magWhether vector magnetization was input
input_angle_magWhether angle magnetization was input
ofs_runningOutput stream for running information
Returns
true if the x/y components were discarded by the collinear projection applied when nspin=4 and noncolin=0
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pseudo_atom_z()

int unitcell::pseudo_atom_z ( const Atom & atom)

Atomic number of the pseudopotential element of one atom type; 0 if the element symbol is not recognized.

Here is the caller graph for this function:

◆ read_atom_positions() [1/2]

bool unitcell::read_atom_positions ( UnitCell & ucell,
std::ifstream & ifpos,
std::ofstream & ofs_running,
std::ofstream & ofs_warning )

◆ read_atom_positions() [2/2]

bool unitcell::read_atom_positions ( UnitCell & ucell,
std::ifstream & ifpos,
std::ofstream & ofs_running,
std::ofstream & ofs_warning,
const int nspin,
const std::string & basis_type,
const std::string & orbital_dir,
const std::string & init_wfc,
const double onsite_radius,
const bool fixed_atoms,
const bool noncolin,
const std::string & calculation,
const std::string & esolver_type,
const int symmetry )

Read atomic positions.

Returns
true (1): no problem.
false (0): some problems.
Parameters
ucellunit cell [in/out]
ifposinput file stream [in]
ofs_runningoutput file stream [in]
ofs_warningwarning output file stream [in]
nspinnumber of spin components [in]
basis_typebasis type [in]
orbital_dirorbital directory [in]
init_wfcinitial wavefunction type [in]
onsite_radiusonsite radius [in]
fixed_atomswhether atoms are fixed [in]
noncolinnon-collinear flag [in]
calculationcalculation type [in]
esolver_typesolver type [in]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_atom_species()

bool unitcell::read_atom_species ( std::ifstream & ifa,
std::ofstream & ofs_running,
UnitCell & ucell,
const std::string & basis_type,
const std::string & orbital_dir,
const std::string & init_wfc,
const double onsite_radius,
const bool deepks_setorb,
const bool rpa )

Read atom species information.

Parameters
ifainput file stream [in]
ofs_runningoutput file stream [in]
ucellunit cell [in/out]
basis_typebasis type [in]
orbital_dirorbital directory [in]
init_wfcinitial wavefunction type [in]
onsite_radiusonsite radius [in]
deepks_setorbwhether to set orb for deepks [in]
rpaRPA flag [in]
Returns
true if reading succeeds
Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_atom_type_header()

bool unitcell::read_atom_type_header ( int it,
UnitCell & ucell,
std::ifstream & ifpos,
std::ofstream & ofs_running,
std::ofstream & ofs_warning,
bool & set_element_mag_zero,
const std::string & basis_type,
const std::string & orbital_dir,
const std::string & init_wfc,
const double onsite_radius )

Read atom type metadata (label, magnetization, orbital info, atom count).

Parameters
itAtom type index
ucellUnit cell object
ifposInput file stream
ofs_runningOutput stream for running information
ofs_warningOutput stream for warnings
set_element_mag_zeroWhether to reset element magnetization (output parameter)
Returns
true if reading succeeds, false otherwise

liuyu update 2023-05-11 In order to employ the DP model as esolver, all atom types must be specified in the STRU in the order consistent with that of the DP model, even if the number of ucell.atoms is zero!

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_cell_pseudopots()

void unitcell::read_cell_pseudopots ( const std::string & fn,
std::ofstream & log,
UnitCell & ucell,
const std::string & global_out_dir,
const std::string & dft_functional,
const bool lspinorb,
const double pseudo_rcut,
const double soc_lambda )

Read pseudopotential from files for each type of atom.

Parameters
fnfilename [in]
logoutput file stream [in]
ucellunit cell [in/out]
global_out_dirglobal output directory [in]
dft_functionalDFT functional [in]
lspinorbspin-orbit coupling flag [in]
pseudo_rcutpseudo cut-off radius [in]
soc_lambdaSOC lambda parameter [in]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_lattice_constant()

bool unitcell::read_lattice_constant ( std::ifstream & ifa,
std::ofstream & ofs_running,
Lattice & lat )

Read lattice constant.

Parameters
ifainput file stream [in]
ofs_runningoutput file stream [in]
latlattice object [in/out]
Returns
true if reading succeeds
Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_orb_file()

bool unitcell::read_orb_file ( int it,
std::string & orb_file,
std::ofstream & ofs_running,
Atom * atom )

read number of numerical orbitals for each angular momentum

Parameters
itindex of atom type
orb_fileorbital filename
ofs_runningofstream
atomAtom instance stored in UnitCell
Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_pseudo()

AtomsInfoResult unitcell::read_pseudo ( std::ofstream & ofs,
UnitCell & ucell,
const std::string & pseudo_dir,
const std::string & global_out_dir,
const bool out_element_info,
const std::string & dft_functional,
const bool lspinorb,
const double pseudo_rcut,
const double soc_lambda,
const int nspin,
const int npol,
const std::string & basis_type,
const std::string & esolver_type,
const std::string & init_wfc,
const int nbands,
const bool two_fermi,
const double nelec_delta,
const std::string & smearing_method,
const std::string & ks_solver,
const int bndpar,
const double nelec,
const double nupdown )

Read pseudopotential files and calculate atom information.

Parameters
ofsoutput file stream [in]
ucellunit cell [in/out]
pseudo_dirpseudopotential directory [in]
global_out_dirglobal output directory [in]
out_element_infowhether to output element information [in]
dft_functionalDFT functional [in]
lspinorbspin-orbit coupling flag [in]
pseudo_rcutpseudo cut-off radius [in]
soc_lambdaSOC lambda parameter [in]
nspinnumber of spin components [in]
npolnumber of polarizations [in]
basis_typebasis type [in]
esolver_typesolver type [in]
init_wfcinitial wavefunction type [in]
nbandsnumber of bands [in]
two_fermitwo Fermi levels flag [in]
nelec_deltaelectron number delta [in]
smearing_methodsmearing method [in]
ks_solverKS solver type [in]
bndparband parallel parameter [in]
nelecnumber of electrons [in]
nupdownspin polarization [in]
Returns
AtomsInfoResult containing calculated atom information
Here is the call graph for this function:
Here is the caller graph for this function:

◆ relative_coordinate()

double unitcell::relative_coordinate ( const ModuleBase::Vector3< double > & position,
const SlabCell & cell )

Normal displacement in [-L/2, L/2); requires a validated cell and position.

Here is the caller graph for this function:

◆ relative_position()

ModuleBase::Vector3< double > unitcell::relative_position ( const ModuleBase::Vector3< double > & position,
const OrthogonalCell & cell )

Minimum-image displacement from origin, with projections in [-L/2, L/2). Requires a cell constructed above and a finite Cartesian position.

Here is the caller graph for this function:

◆ remake_cell()

void unitcell::remake_cell ( Lattice & lat)

Adjust lattice vectors for constrained vc-relaxation.

For constrained vc-relaxation where type of lattice is fixed, adjust the lattice vectors.

Parameters
latlattice object [in/out]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_remake_cell_mock()

void unitcell::reset_remake_cell_mock ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_atom_movement_flags()

void unitcell::set_atom_movement_flags ( Atom & atom,
int ia,
const ModuleBase::Vector3< int > & mv,
const bool fixed_atoms )

Set atom movement constraints based on fixed_atoms parameter.

Parameters
atomThe atom object
iaAtom index
mvMovement vector (1=movable, 0=fixed)
Here is the caller graph for this function:

◆ setup_cell_after_vc()

void unitcell::setup_cell_after_vc ( UnitCell & ucell,
std::ofstream & log,
const int nspin )

Setup cell after vc-relaxation.

Parameters
ucellunit cell [in/out]
logoutput file stream [in]
nspinnumber of spin components [in]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ transform_atom_coordinates()

void unitcell::transform_atom_coordinates ( Atom & atom,
int ia,
const std::string & Coordinate,
const ModuleBase::Vector3< double > & v,
const ModuleBase::Matrix3 & latvec,
double lat0,
ModuleBase::Vector3< double > & latcenter )

Convert between different coordinate systems.

Parameters
atomThe atom object
iaAtom index
CoordinateCoordinate system type
vInput position vector
latvecLattice vectors
lat0Lattice constant
latcenterLattice center (output parameter)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_pos_tau()

void unitcell::update_pos_tau ( const Lattice & lat,
const double * pos,
const int ntype,
const int nat,
Atom * atoms )

Update the position and tau of the atoms.

Parameters
latthe lattice of the atoms [in]
posthe position of the atoms [in]
ntypethe number of types of the atoms [in]
natthe number of atoms [in]
atomsthe atoms to be updated [out]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_pos_taud() [1/2]

void unitcell::update_pos_taud ( const Lattice & lat,
const double * posd_in,
const int ntype,
const int nat,
Atom * atoms )

Update the position and taud of the atoms.

Parameters
latthe lattice of the atoms [in]
posd_inthe position of the atoms in direct coordinate system [in]
ntypethe number of types of the atoms [in]
natthe number of atoms [in]
atomsthe atoms to be updated [out]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_pos_taud() [2/2]

void unitcell::update_pos_taud ( const Lattice & lat,
const ModuleBase::Vector3< double > * posd_in,
const int ntype,
const int nat,
Atom * atoms )

Update the position and taud of the atoms (Vector3 version).

Parameters
latthe lattice of the atoms [in]
posd_inthe position of the atoms in direct coordinate system [in]
ntypethe number of types of the atoms [in]
natthe number of atoms [in]
atomsthe atoms to be updated [out]
Here is the call graph for this function:

◆ update_vel()

void unitcell::update_vel ( const ModuleBase::Vector3< double > * vel_in,
const int ntype,
const int nat,
Atom * atoms )

Update the velocity of the atoms.

Parameters
vel_inthe velocity of the atoms [in]
ntypethe number of types of the atoms [in]
natthe number of atoms [in]
atomsthe atoms to be updated [out]
Here is the caller graph for this function:

◆ validate_coordinate_system()

bool unitcell::validate_coordinate_system ( const std::string & Coordinate,
std::ofstream & ofs_warning )

Validate coordinate system type.

Parameters
CoordinateThe coordinate system string to validate
ofs_warningOutput stream for warnings
Returns
true if valid, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ warn_xy_magnetization_ignored()

void unitcell::warn_xy_magnetization_ignored ( const std::string & label,
int n_discarded,
int na,
std::ofstream & ofs_running )

Report, once per atom type, that x/y magnetization was discarded.

Parameters
labelElement label of the atom type
n_discardedNumber of atoms of this type whose x/y moment was dropped
naNumber of atoms of this type
ofs_runningOutput stream for running information
Here is the call graph for this function:
Here is the caller graph for this function:

◆ warn_zero_magnetization_nspin4()

void unitcell::warn_zero_magnetization_nspin4 ( const UnitCell & ucell,
std::ofstream & ofs_running )

Warn when a nspin=4 run starts from an all-zero magnetization vector.

The check uses m_loc_, the vector actually consumed by cal_ux(), and not mag: the collinear projection applied when noncolin=0 can leave mag non-zero while m_loc_ is already zero, so keying the check on mag would miss exactly the silent zero-moment start this warning reports.

Parameters
ucellUnit cell object
ofs_runningOutput stream for running information
Here is the call graph for this function:
Here is the caller graph for this function:

◆ was_remake_cell_called()

bool unitcell::was_remake_cell_called ( )
Here is the caller graph for this function:

◆ weighted_center() [1/2]

ModuleBase::Vector3< double > unitcell::weighted_center ( const std::vector< ModuleBase::Vector3< double > > & positions,
const std::vector< double > & weights,
const OrthogonalCell & cell )

Unwrap positions about the first position, take their positive-weight center, then wrap the center about cell.origin. Intended for localized systems whose extent about the first position is less than half a cell in each direction. Requires a cell constructed by make_orthogonal_cell, at least one position and positive weights.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ weighted_center() [2/2]

double unitcell::weighted_center ( const std::vector< ModuleBase::Vector3< double > > & positions,
const std::vector< double > & weights,
const SlabCell & cell )

Mass/weight center along the normal, unwrapped about the first position. Requires a localized slab of extent less than half the normal period.

Here is the call graph for this function:

Variable Documentation

◆ allow_cell_change

bool unitcell::allow_cell_change = false