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

Provide the basic information about unitcell. More...

#include <unitcell.h>

Inheritance diagram for UnitCell:
Collaboration diagram for UnitCell:

Public Member Functions

 UnitCell ()
 ~UnitCell ()
 UnitCell (const UnitCell &)=delete
UnitCell & operator= (const UnitCell &)=delete
 UnitCell (UnitCell &&)=delete
UnitCell & operator= (UnitCell &&)=delete
void setup_from_input (const std::string &latname_in, const int &ntype_in, const int &lmaxmax_in, const bool &init_vel_in, const std::string &fixed_axes_in)
 Initialize basic cell parameters (latname, ntype, lmaxmax, init_vel) from INPUT and parse fixed_axes into lat_axis_free flags.
void setup_cell (const std::string &fn, std::ofstream &log, const double symmetry_prec, const int dfthalf_type, const std::string &pseudo_dir, const int nspin, 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, const bool fixed_atoms, const bool noncolin, const std::string &calculation, const std::string &esolver_type, const int symmetry)
void set_iat2itia ()
void set_iat2iwt (const int &npol_in)
template<typename Tiait>
Tiait itiaiw2iwt (const Tiait &it, const Tiait &ia, const Tiait &iw) const
 Indexing tool for find orbital global index from it,ia,iw.
const int * get_iat2iwt () const
 Get iat2iwt.
const int & get_npol () const
 Get npol.
void set_iat2iwt_for_test (const std::vector< int > &iat2iwt_in, const int npol_in)
 Set iat2iwt (and npol) directly; intended for unit tests that build a minimal UnitCell without running the full indexing setup.
template<typename Tiat, typename Tiait>
bool iat2iait (const Tiat iat, Tiait *ia, Tiait *it) const
 Indexing tools for ia and it.
template<typename Tiat, typename Tiait>
bool ijat2iaitjajt (const Tiat ijat, Tiait *ia, Tiait *it, Tiait *ja, Tiait *jt) const
const ModuleBase::Vector3< double > & get_tau (const int &iat) const
 Get tau for atom iat.
const ModuleBase::Vector3< double > cal_dtau (const int &iat1, const int &iat2, const ModuleBase::Vector3< int > &R) const
 Calculate vector between two atoms with R cell.
std::map< int, int > get_atom_Counts () const
 get atomCounts, which is a map from element type to atom number
std::map< int, int > get_orbital_Counts () const
 get orbitalCounts, which is a map from element type to orbital number
std::map< int, std::map< int, int > > get_lnchi_Counts () const
 get lnchiCounts, which is a map from element type to the l:nchi map
Public Member Functions inherited from BaseCell
virtual ~BaseCell ()=default
Kind kind () const
std::int64_t nat () const
double lat0 () const
double omega () const
const ModuleBase::Matrix3 & latvec () const
const ModuleBase::Matrix3 & GT () const
void require_kind (const Kind &expected, const char *caller) const

Public Attributes

Atom * atoms = nullptr
Sep_Cell sep_cell
Lattice

these are newly added functions, the three above functions are deprecated and will be removed in the future

Lattice lat
std::string & Coordinate = lat.Coordinate
std::string & latName = lat.latName
double & lat0 = lat.lat0
double & lat0_angstrom = lat.lat0_angstrom
double & tpiba = lat.tpiba
double & tpiba2 = lat.tpiba2
double & omega = lat.omega
std::vector< int > & lat_axis_free = lat.lat_axis_free
ModuleBase::Matrix3 & latvec = lat.latvec
ModuleBase::Vector3< double > & a1 = lat.a1
ModuleBase::Vector3< double > & a2 = lat.a2
ModuleBase::Vector3< double > & a3 = lat.a3
ModuleBase::Vector3< double > & latcenter = lat.latcenter
ModuleBase::Matrix3 & latvec_supercell = lat.latvec_supercell
ModuleBase::Matrix3 & G = lat.G
ModuleBase::Matrix3 & GT = lat.GT
ModuleBase::Matrix3 & GGT = lat.GGT
ModuleBase::Matrix3 & invGGT = lat.invGGT
Statistics
int ntype = 0
 number of atom species in UnitCell
int nat = 0
 total number of atoms of all species in unitcell
std::vector< int > iat2it
 iat==>it, distinguish a atom belong to which type
std::vector< int > iat2ia
 iat==>ia
std::vector< int > iwt2iat
 iwt ==> iat
std::vector< int > iwt2iw
 iwt ==> iw (Peize Lin add 2018-07-02)
ModuleBase::IntArray itia2iat
 (it, ia)==>iat, the index in nat (add 2009-3-2 by mohan)
int namax = 0
 the max na among all atom species
int nwmax = 0
 the max nw among all atom species
Magnetism
Magnetism magnet
 magnetism Yu Liu 2021-07-03
std::vector< std::vector< double > > atom_mulliken
 [nat][nspin]
int n_mag_at = 0
 magnetism Yu Liu 2021-07-03
Symmetry
ModuleSymmetry::Symmetry symm
Pseudopotential / Orbital parameters

meshx : max number of mesh point in pseudopotential file

natomwfc : number of starting wavefunctions

lmax : Max L used for localized orbital

nmax : Max N used for localized orbital

lmax_ppwf : Max L of pseudo wave functions

lmaxmax : revert from INPUT

int meshx = 0
 mohan add 2009-09-10
int natomwfc = 0
 mohan add 2009-09-10
int lmax = 0
 mohan add 2009-09-10
int nmax = 0
 mohan add 2009-09-10
int nmax_total = 0
 mohan add 2009-09-10
int lmax_ppwf = 0
 mohan add 2009-09-10
int lmaxmax = 0
 liuyu 2021-07-04
bool init_vel = false
 liuyu 2021-07-15
File lists
std::vector< std::string > pseudo_fn
 filenames of orbitals, liuyu add 2022-10-19
std::vector< std::string > pseudo_type
 filenames of orbitals, liuyu add 2022-10-19
std::vector< std::string > orbital_fn
 filenames of orbitals, liuyu add 2022-10-19
std::string descriptor_file
 filenames of descriptor_file, liuyu add 2023-04-06
std::vector< std::string > abfs_orbital_files
 ABFS orbital filenames read from STRU "ABFS_ORBITAL" (used by LCAO EXX).
std::vector< std::string > jle_orbital_files
 JLE orbital filenames read from STRU "ABFS_JLES_ORBITAL" (used by LCAO EXX).
State flags
Todo
Encapsulate ionic_position_updated and cell_parameter_updated with setters that enforce state invariants; currently exposed as mutable flags that can be toggled from anywhere.
bool set_atom_flag = false
 added on 2009-3-8 by mohan
bool ionic_position_updated = false
 whether the ionic position has been updated
bool cell_parameter_updated = false
bool last_ion_step = false
 whether the current runner call is the last ionic step of the run.
Nonlocal info
std::unique_ptr< NonlocalInfoBase > infoNL
 Pointer to non-local pseudopotential information.

Private Member Functions

Kind get_kind () const override
std::int64_t get_nat () const override
double get_lat0 () const override
double get_omega () const override
const ModuleBase::Matrix3 & get_latvec () const override
const ModuleBase::Matrix3 & get_GT () const override

Private Attributes

std::vector< int > iat2iwt
 iat ==> iwt, the first global index for orbital of this atom
int npol = 1
ModuleBase::Matrix3 stress
 calculate stress on the cell

Additional Inherited Members

Public Types inherited from BaseCell
enum class  Kind { unitcell , mdcell }

Detailed Description

Provide the basic information about unitcell.

Constructor & Destructor Documentation

◆ UnitCell() [1/3]

UnitCell::UnitCell ( )
inline
Here is the caller graph for this function:

◆ ~UnitCell()

UnitCell::~UnitCell ( )
inline

◆ UnitCell() [2/3]

UnitCell::UnitCell ( const UnitCell & )
delete

Copy and move are both disabled. The defaulted move constructor shallow-copies the owning pointer 'atoms' and 'set_atom_flag' without resetting the source (double free), and the reference aliases into 'lat' (Coordinate, a1, latvec, ...) make the defaulted move assignment implicitly deleted (-Wdefaulted-function-deleted). Correct move semantics require an owning container for 'atoms' and removing the aliases; until then any accidental move must fail at compile time.

Here is the call graph for this function:

◆ UnitCell() [3/3]

UnitCell::UnitCell ( UnitCell && )
delete
Here is the call graph for this function:

Member Function Documentation

◆ cal_dtau()

const ModuleBase::Vector3< double > UnitCell::cal_dtau ( const int & iat1,
const int & iat2,
const ModuleBase::Vector3< int > & R ) const
inline

Calculate vector between two atoms with R cell.

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

◆ get_atom_Counts()

std::map< int, int > UnitCell::get_atom_Counts ( ) const

get atomCounts, which is a map from element type to atom number

Here is the caller graph for this function:

◆ get_GT()

const ModuleBase::Matrix3 & UnitCell::get_GT ( ) const
inlineoverrideprivatevirtual

Implements BaseCell.

◆ get_iat2iwt()

const int * UnitCell::get_iat2iwt ( ) const
inline

Get iat2iwt.

Here is the caller graph for this function:

◆ get_kind()

Kind UnitCell::get_kind ( ) const
inlineoverrideprivatevirtual

Implements BaseCell.

◆ get_lat0()

double UnitCell::get_lat0 ( ) const
inlineoverrideprivatevirtual

Implements BaseCell.

◆ get_latvec()

const ModuleBase::Matrix3 & UnitCell::get_latvec ( ) const
inlineoverrideprivatevirtual

Implements BaseCell.

◆ get_lnchi_Counts()

std::map< int, std::map< int, int > > UnitCell::get_lnchi_Counts ( ) const

get lnchiCounts, which is a map from element type to the l:nchi map

Here is the caller graph for this function:

◆ get_nat()

std::int64_t UnitCell::get_nat ( ) const
inlineoverrideprivatevirtual

Implements BaseCell.

◆ get_npol()

const int & UnitCell::get_npol ( ) const
inline

Get npol.

Here is the caller graph for this function:

◆ get_omega()

double UnitCell::get_omega ( ) const
inlineoverrideprivatevirtual

Implements BaseCell.

◆ get_orbital_Counts()

std::map< int, int > UnitCell::get_orbital_Counts ( ) const

get orbitalCounts, which is a map from element type to orbital number

Here is the caller graph for this function:

◆ get_tau()

const ModuleBase::Vector3< double > & UnitCell::get_tau ( const int & iat) const
inline

Get tau for atom iat.

Here is the caller graph for this function:

◆ iat2iait()

template<typename Tiat, typename Tiait>
bool UnitCell::iat2iait ( const Tiat iat,
Tiait * ia,
Tiait * it ) const
inline

Indexing tools for ia and it.

Returns
true if the last out is reset
Here is the caller graph for this function:

◆ ijat2iaitjajt()

template<typename Tiat, typename Tiait>
bool UnitCell::ijat2iaitjajt ( const Tiat ijat,
Tiait * ia,
Tiait * it,
Tiait * ja,
Tiait * jt ) const
inline
Here is the call graph for this function:

◆ itiaiw2iwt()

template<typename Tiait>
Tiait UnitCell::itiaiw2iwt ( const Tiait & it,
const Tiait & ia,
const Tiait & iw ) const
inline

Indexing tool for find orbital global index from it,ia,iw.

iat2iwt is the atom index iat to the first global index for orbital of this atom the size of iat2iwt is nat, the value should be sum_{i=0}^{iat-1} atoms[it].nw * npol where the npol is the number of polarizations, 1 for non-magnetic(NSPIN=1 or 2), 2 for magnetic(only NSPIN=4) this part only used for Atomic Orbital based calculation

Here is the caller graph for this function:

◆ operator=() [1/2]

UnitCell & UnitCell::operator= ( const UnitCell & )
delete
Here is the call graph for this function:

◆ operator=() [2/2]

UnitCell & UnitCell::operator= ( UnitCell && )
delete
Here is the call graph for this function:

◆ set_iat2itia()

void UnitCell::set_iat2itia ( )
inline
Here is the caller graph for this function:

◆ set_iat2iwt()

void UnitCell::set_iat2iwt ( const int & npol_in)
inline
Here is the caller graph for this function:

◆ set_iat2iwt_for_test()

void UnitCell::set_iat2iwt_for_test ( const std::vector< int > & iat2iwt_in,
const int npol_in )
inline

Set iat2iwt (and npol) directly; intended for unit tests that build a minimal UnitCell without running the full indexing setup.

Here is the caller graph for this function:

◆ setup_cell()

void UnitCell::setup_cell ( const std::string & fn,
std::ofstream & log,
const double symmetry_prec,
const int dfthalf_type,
const std::string & pseudo_dir,
const int nspin,
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,
const bool fixed_atoms,
const bool noncolin,
const std::string & calculation,
const std::string & esolver_type,
const int symmetry )
Here is the caller graph for this function:

◆ setup_from_input()

void UnitCell::setup_from_input ( const std::string & latname_in,
const int & ntype_in,
const int & lmaxmax_in,
const bool & init_vel_in,
const std::string & fixed_axes_in )

Initialize basic cell parameters (latname, ntype, lmaxmax, init_vel) from INPUT and parse fixed_axes into lat_axis_free flags.

Here is the caller graph for this function:

Member Data Documentation

◆ a1

ModuleBase::Vector3<double>& UnitCell::a1 = lat.a1

◆ a2

ModuleBase::Vector3<double> & UnitCell::a2 = lat.a2

◆ a3

ModuleBase::Vector3<double> & UnitCell::a3 = lat.a3

◆ abfs_orbital_files

std::vector<std::string> UnitCell::abfs_orbital_files

ABFS orbital filenames read from STRU "ABFS_ORBITAL" (used by LCAO EXX).

◆ atom_mulliken

std::vector<std::vector<double> > UnitCell::atom_mulliken

[nat][nspin]

◆ atoms

Atom* UnitCell::atoms = nullptr

◆ cell_parameter_updated

bool UnitCell::cell_parameter_updated = false

whether the cell parameters are updated

◆ Coordinate

std::string& UnitCell::Coordinate = lat.Coordinate

◆ descriptor_file

std::string UnitCell::descriptor_file

filenames of descriptor_file, liuyu add 2023-04-06

◆ G

ModuleBase::Matrix3& UnitCell::G = lat.G

◆ GGT

ModuleBase::Matrix3& UnitCell::GGT = lat.GGT

◆ GT

ModuleBase::Matrix3& UnitCell::GT = lat.GT

◆ iat2ia

std::vector<int> UnitCell::iat2ia

iat==>ia

◆ iat2it

std::vector<int> UnitCell::iat2it

iat==>it, distinguish a atom belong to which type

◆ iat2iwt

std::vector<int> UnitCell::iat2iwt
private

iat ==> iwt, the first global index for orbital of this atom

◆ infoNL

std::unique_ptr<NonlocalInfoBase> UnitCell::infoNL

Pointer to non-local pseudopotential information.

This pointer is set during LCAO initialization and provides access to non-local projector data. It is null for non-LCAO calculations.

◆ init_vel

bool UnitCell::init_vel = false

liuyu 2021-07-15

◆ invGGT

ModuleBase::Matrix3& UnitCell::invGGT = lat.invGGT

◆ ionic_position_updated

bool UnitCell::ionic_position_updated = false

whether the ionic position has been updated

◆ itia2iat

ModuleBase::IntArray UnitCell::itia2iat

(it, ia)==>iat, the index in nat (add 2009-3-2 by mohan)

◆ iwt2iat

std::vector<int> UnitCell::iwt2iat

iwt ==> iat

◆ iwt2iw

std::vector<int> UnitCell::iwt2iw

iwt ==> iw (Peize Lin add 2018-07-02)

◆ jle_orbital_files

std::vector<std::string> UnitCell::jle_orbital_files

JLE orbital filenames read from STRU "ABFS_JLES_ORBITAL" (used by LCAO EXX).

◆ last_ion_step

bool UnitCell::last_ion_step = false

whether the current runner call is the last ionic step of the run.

Set by the outer ionic driver (source_md) right before calling ESolver::runner, so the output layer can write the final ionic step even when it does not sit on the out_freq_ion cadence or its SCF did not converge. It is not a user input and stays false for single-shot runs.

◆ lat

Lattice UnitCell::lat

◆ lat0

double& UnitCell::lat0 = lat.lat0

◆ lat0_angstrom

double& UnitCell::lat0_angstrom = lat.lat0_angstrom

◆ lat_axis_free

std::vector<int>& UnitCell::lat_axis_free = lat.lat_axis_free

◆ latcenter

ModuleBase::Vector3<double>& UnitCell::latcenter = lat.latcenter

◆ latName

std::string& UnitCell::latName = lat.latName

◆ latvec

ModuleBase::Matrix3& UnitCell::latvec = lat.latvec

◆ latvec_supercell

ModuleBase::Matrix3& UnitCell::latvec_supercell = lat.latvec_supercell

◆ lmax

int UnitCell::lmax = 0

mohan add 2009-09-10

◆ lmax_ppwf

int UnitCell::lmax_ppwf = 0

mohan add 2009-09-10

◆ lmaxmax

int UnitCell::lmaxmax = 0

liuyu 2021-07-04

◆ magnet

Magnetism UnitCell::magnet

magnetism Yu Liu 2021-07-03

◆ meshx

int UnitCell::meshx = 0

mohan add 2009-09-10

◆ n_mag_at

int UnitCell::n_mag_at = 0

magnetism Yu Liu 2021-07-03

◆ namax

int UnitCell::namax = 0

the max na among all atom species

◆ nat

int UnitCell::nat = 0

total number of atoms of all species in unitcell

◆ natomwfc

int UnitCell::natomwfc = 0

mohan add 2009-09-10

◆ nmax

int UnitCell::nmax = 0

mohan add 2009-09-10

◆ nmax_total

int UnitCell::nmax_total = 0

mohan add 2009-09-10

◆ npol

int UnitCell::npol = 1
private

number of spin polarizations, initialized in set_iat2iwt --------------— END of iat2iwt part --------------—

◆ ntype

int UnitCell::ntype = 0

number of atom species in UnitCell

◆ nwmax

int UnitCell::nwmax = 0

the max nw among all atom species

◆ omega

double& UnitCell::omega = lat.omega

◆ orbital_fn

std::vector<std::string> UnitCell::orbital_fn

filenames of orbitals, liuyu add 2022-10-19

◆ pseudo_fn

std::vector<std::string> UnitCell::pseudo_fn

filenames of orbitals, liuyu add 2022-10-19

◆ pseudo_type

std::vector<std::string> UnitCell::pseudo_type

filenames of orbitals, liuyu add 2022-10-19

◆ sep_cell

Sep_Cell UnitCell::sep_cell

◆ set_atom_flag

bool UnitCell::set_atom_flag = false

added on 2009-3-8 by mohan

◆ stress

ModuleBase::Matrix3 UnitCell::stress
private

calculate stress on the cell

◆ symm

ModuleSymmetry::Symmetry UnitCell::symm

◆ tpiba

double& UnitCell::tpiba = lat.tpiba

◆ tpiba2

double& UnitCell::tpiba2 = lat.tpiba2

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