|
ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
|
Classes | |
| struct | ExxSourceHeader |
| class | CNPropPW |
| class | ETRSPropPW |
| struct | TDConserv |
| Globally reduced electron counts and orthogonality errors. More... | |
| class | TDHamiltPW |
| A call-scoped PW sample; every k update refreshes shifted projectors. More... | |
| struct | TDElecSnap |
| Electronic data at an accepted endpoint; orbitals and potential stay in TDHistoryPW. More... | |
| class | TDHistoryPW |
| Accepted endpoint wavefunctions and potential snapshots. More... | |
| struct | CurrentRequest |
| Independent requests; all ranks must use the same choices. More... | |
| struct | TDVelResultPW |
| Globally reduced currents; unrequested arrays stay zero or empty. More... | |
| struct | TDSpinResultPW |
| Endpoint observables replicated on all ranks after the appropriate reductions. More... | |
| class | PWProp |
| Method-specific wavefunction map; density and acceptance stay above it. More... | |
| class | TDPropPW |
| Sole PW propagation entry point, independent of the selected method. More... | |
| class | TDSpinPW |
| Endpoint magnetism with reusable device workspaces and position-aware caches. More... | |
| class | TDVelPW |
| Charge and spin currents sharing one velocity action per k point. More... | |
Enumerations | |
| enum class | PropStage { predictor , corrector } |
Functions | |
| bool | run_deltaspin_lambda_loop (const int iter, const double drho, const Input_para &inp, std::ostream &ofs_running) |
| Run the inner lambda loop for DeltaSpin method to constrain atomic magnetic moments. | |
| void | check_deltaspin_oscillation (const int iter, const double drho, Charge_Mixing *p_chgmix, const Input_para &inp) |
| Check if SCF oscillation occurs for DeltaSpin method. | |
| void | pauli_to_spin_basis (std::complex< double > *pot_onsite, int m_size) |
| double | compute_pot_onsite_spinor (std::complex< double > *pot_onsite, const double *occ, double u_value, double diag_coeff, double weight_eu, int m_size) |
| double | compute_pot_onsite_scalar (std::complex< double > *pot_onsite, const double *occ, double u_value, double diag_coeff, double weight_eu, int m_size) |
| void | accumulate_occ_spinor (double *occ_mat_out, const std::complex< double > *becp, int nbands, int npol, int nkb, int begin_ih, int m_begin, int tlp1, const ModuleBase::matrix &wg, int ik) |
| void | accumulate_occ_scalar (double *occ_mat_out, const std::complex< double > *becp, int nbands, int nkb, int begin_ih, int m_begin, int tlp1, const ModuleBase::matrix &wg, int ik) |
| void | reduce_occ_mat (const UnitCell &cell, const int nspin, const int kpar, const std::vector< int > &l_channel, OccupationMatrix &occmat) |
| void | compute_pot_uterm_and_energy (const UnitCell &cell, const int nspin, const std::vector< double > &u_current, const std::vector< int > &l_channel, const std::vector< int > &uterm_mat_index, const OccupationMatrix &occmat, std::vector< std::complex< double > > &uterm_mat, double &energy_u) |
| void | validate_hybrid_nscf (const Input_para &inp, const General_Exx_Info &info) |
| template<typename T, typename Device> | |
| void | prepare_exx_nscf (const Input_para &inp, const UnitCell &ucell, const ModulePW::PW_Basis_K *pw_wfc, hamilt::OperatorEXXPW< T, Device > &op_exx, const std::string &readin_dir) |
| ExxSourceHeader | read_exx_source_header (std::istream &in) |
| void | read_exx_source_occupations (std::istream &in, const std::vector< ExxSourceHeader > &headers, int nspin, ModuleBase::matrix &weights) |
| std::string | resolve_source_file (const std::vector< std::string > &directories, const std::string &fixed_name, const std::string &tail, const bool allow_electronic_suffix, int *ionic_step=nullptr, int *electronic_step=nullptr) |
| Locate the EXX source file written by the latest output step. | |
| template<typename T, typename Device> | |
| void | setup_pot (const int istep, UnitCell &ucell, const K_Vectors &kv, Structure_Factor &sf, elecstate::ElecState *pelec, const Parallel_Grid ¶_grid, const Charge &chr, pseudopot_cell_vl &locpp, pseudopot_cell_vnl &ppcell, VSep *vsep_cell, psi::Psi< T, Device > *kspw_psi, psi::Psi< std::complex< double >, Device > *onsite_psi, hamilt::HamiltBase *p_hamilt, ModulePW::PW_Basis_K *pw_wfc, const ModulePW::PW_Basis *pw_rhod, const std::string &out_dir, const Input_para &inp) |
| void | setup_pwrho (UnitCell &ucell, const bool double_grid, bool &pw_rho_flag, ModulePW::PW_Basis *&pw_rho, ModulePW::PW_Basis *&pw_rhod, ModulePW::PW_Basis_Big *&pw_big, const std::string &classname, const Input_para &inp) |
| void | teardown_pwrho (bool &pw_rho_flag, const bool double_grid, ModulePW::PW_Basis *&pw_rho, ModulePW::PW_Basis *&pw_rhod) |
| void | teardown_pwwfc (ModulePW::PW_Basis_K *&pw_wfc) |
| void | setup_pwwfc (const Input_para &inp, const UnitCell &ucell, const ModulePW::PW_Basis &pw_rho, K_Vectors &kv, ModulePW::PW_Basis_K *&pw_wfc) |
| void | update_cell_pw (const UnitCell &ucell, pseudopot_cell_vnl &ppcell, const K_Vectors &kv, ModulePW::PW_Basis_K *pw_wfc, const Input_para &inp) |
| void | validate_uspp_support (const bool use_uspp, const std::string &basis_type, const std::string &esolver_type, const int nspin, const int xc_func_type, const bool berry_phase, const bool towannier90, const bool cal_cond) |
| TDConserv | cal_td_conserv (double local_npsi, const Charge &charge, double omega, int pool_rank, double orth_before, double orth_after, bool full_gram) |
| Count each k-point pool once and integrate the charge channels. | |
| template<typename T, typename Device> | |
| void | orth_init_pw (hsolver::TDOrbOps< T, Device > &orbitals, hsolver::HSOperator< T, Device > &op, psi::Psi< T, Device > ¤t, elecstate::ElecStatePW< T, Device > &estate, Charge &charge, UnitCell &cell, const ModulePW::PW_Basis &rhod, int nspin, int nbands, int iter, bool do_orth) |
| Clean initial orbitals and rebuild occupations and density if orthogonalization changes them. | |
| template<typename T, typename Device> | |
| void | rebuild_td_end (psi::Psi< T, Device > ¤t, elecstate::ElecStatePW< T, Device > &estate, Charge &charge, UnitCell &cell, hamilt::HamiltPW< T, Device > &hamilt, hsolver::TDOrbOps< T, Device > &orbitals, const ModulePW::PW_Basis_K &basis, const ModulePW::PW_Basis &rhod, const ModuleBase::Vector3< double > &vecpot, int nspin, int imp_sol, bool sc_mag, int dft_u, const std::string &assume_iso) |
| Rebuild an accepted endpoint from its orbitals while retaining all occupations. | |
| template void | orth_init_pw (hsolver::TDOrbOps< std::complex< float >, base_device::DEVICE_CPU > &, hsolver::HSOperator< std::complex< float >, base_device::DEVICE_CPU > &, psi::Psi< std::complex< float >, base_device::DEVICE_CPU > &, elecstate::ElecStatePW< std::complex< float >, base_device::DEVICE_CPU > &, Charge &, UnitCell &, const ModulePW::PW_Basis &, int, int, int, bool) |
| template void | rebuild_td_end (psi::Psi< std::complex< float >, base_device::DEVICE_CPU > &, elecstate::ElecStatePW< std::complex< float >, base_device::DEVICE_CPU > &, Charge &, UnitCell &, hamilt::HamiltPW< std::complex< float >, base_device::DEVICE_CPU > &, hsolver::TDOrbOps< std::complex< float >, base_device::DEVICE_CPU > &, const ModulePW::PW_Basis_K &, const ModulePW::PW_Basis &, const ModuleBase::Vector3< double > &, int, int, bool, int, const std::string &) |
| template void | orth_init_pw (hsolver::TDOrbOps< std::complex< double >, base_device::DEVICE_CPU > &, hsolver::HSOperator< std::complex< double >, base_device::DEVICE_CPU > &, psi::Psi< std::complex< double >, base_device::DEVICE_CPU > &, elecstate::ElecStatePW< std::complex< double >, base_device::DEVICE_CPU > &, Charge &, UnitCell &, const ModulePW::PW_Basis &, int, int, int, bool) |
| template void | rebuild_td_end (psi::Psi< std::complex< double >, base_device::DEVICE_CPU > &, elecstate::ElecStatePW< std::complex< double >, base_device::DEVICE_CPU > &, Charge &, UnitCell &, hamilt::HamiltPW< std::complex< double >, base_device::DEVICE_CPU > &, hsolver::TDOrbOps< std::complex< double >, base_device::DEVICE_CPU > &, const ModulePW::PW_Basis_K &, const ModulePW::PW_Basis &, const ModuleBase::Vector3< double > &, int, int, bool, int, const std::string &) |
| TDElecSnap | capture_td (const elecstate::fenergy &energy, const ModuleBase::matrix &eigenvalues, const Charge &charge) |
| Copy energy, band expectations and density without advancing orbital history. | |
| void | restore_td (const TDElecSnap &state, elecstate::fenergy &energy, ModuleBase::matrix &eigenvalues, Charge &charge) |
| Restore electronic data on the unchanged density grid and refresh its mixing backup. | |
| template<typename T, typename Device> | |
| std::unique_ptr< TDPropPW< T, Device > > | make_td_prop (const ModulePW::PW_Basis_K &basis, const Input_para &input, int npol, const std::vector< int > &global_k, const hsolver::diag_comm_info &comm, std::ostream &log) |
| Resolve input controls and construct only the selected propagation method. | |
| template std::unique_ptr< TDPropPW< std::complex< float >, base_device::DEVICE_CPU > > | make_td_prop (const ModulePW::PW_Basis_K &, const Input_para &, int, const std::vector< int > &, const hsolver::diag_comm_info &, std::ostream &) |
| void | check_td_input (const Input_para &input, const UnitCell &cell, int xc_type, bool cal_exx) |
| Check PW propagation restrictions after resolving the XC functional and EXX configuration. | |
| double | td_momentum_bound (const ModulePW::PW_Basis_K &basis, const double tpiba) |
| Return the global unshifted momentum bound after updating the distributed basis. | |
| void | ensure_td_vnl (const UnitCell &cell, const double unshifted_bound, const ModuleBase::Vector3< double > &A_right_ha, const ModuleBase::Vector3< double > &A_prop_ha, pseudopot_cell_vnl *projectors) |
| Extend the projector table to cover both endpoint and propagation fields in Hartree atomic units. | |
| std::vector< int > | td_voronoi_pw (const UnitCell &cell, const ModulePW::PW_Basis &grid) |
| Periodic nearest-atom labels on the local charge grid, in global atom order. | |
Pure (side-effect free) functions for DFT+U PW basis calculations.
These functions are stateless and can be unit-tested directly. The member functions in dftu_pw.cpp call them after computing per-atom offsets and fetching the relevant member state.
|
strong |
| void pw::accumulate_occ_scalar | ( | double * | occ_mat_out, |
| const std::complex< double > * | becp, | ||
| int | nbands, | ||
| int | nkb, | ||
| int | begin_ih, | ||
| int | m_begin, | ||
| int | tlp1, | ||
| const ModuleBase::matrix & | wg, | ||
| int | ik ) |
accumulate occ_mat from becp for one atom, one k-point (nspin==1 or 2).
occ_mat_out points to occ_mat[iat][target_l][is].c, a single channel of size tlp1*tlp1. The caller selects the spin channel by passing the corresponding occ_mat pointer; this function does not need is. Adds contributions from all nbands bands.
becp, nbands, nkb, begin_ih, m_begin, tlp1: same as accumulate_occ_spinor
| void pw::accumulate_occ_spinor | ( | double * | occ_mat_out, |
| const std::complex< double > * | becp, | ||
| int | nbands, | ||
| int | npol, | ||
| int | nkb, | ||
| int | begin_ih, | ||
| int | m_begin, | ||
| int | tlp1, | ||
| const ModuleBase::matrix & | wg, | ||
| int | ik ) |
accumulate occ_mat from becp for one atom, one k-point (nspin==4, spinor).
occ_mat_out points to occ_mat[iat][target_l][0].c, which packs 4 Pauli blocks contiguously (each of size tlp1*tlp1). The function adds the contributions from all nbands bands for the given k-point.
becp: projector-bra overlap for this k-point npol: 2 for spinor (nspin==4) nkb: number of projectors per band per spin begin_ih: offset of this atom's projectors in becp m_begin: offset of the correlated l's first m within the atom's projectors tlp1: 2*target_l + 1
| TDConserv pw::cal_td_conserv | ( | double | local_npsi, |
| const Charge & | charge, | ||
| double | omega, | ||
| int | pool_rank, | ||
| double | orth_before, | ||
| double | orth_after, | ||
| bool | full_gram ) |
Count each k-point pool once and integrate the charge channels.
| TDElecSnap pw::capture_td | ( | const elecstate::fenergy & | energy, |
| const ModuleBase::matrix & | eigenvalues, | ||
| const Charge & | charge ) |
Copy energy, band expectations and density without advancing orbital history.
| void pw::check_deltaspin_oscillation | ( | const int | iter, |
| const double | drho, | ||
| Charge_Mixing * | p_chgmix, | ||
| const Input_para & | inp ) |
Check if SCF oscillation occurs for DeltaSpin method.
This function checks if the SCF iteration is oscillating and sets the mixing restart step if oscillation is detected. This is used to increase the precision of magnetization calculation.
| iter | The current iteration number (1-indexed). |
| drho | The current charge density difference. |
| p_chgmix | Pointer to the Charge_Mixing object. |
| inp | The input parameters. |
Return if DeltaSpin is not enabled
Get the singleton instance of SpinConstrain
Check if higher magnetization precision is needed
Detect SCF oscillation
If oscillation detected, set mixing restart step for next iteration
| void pw::check_td_input | ( | const Input_para & | input, |
| const UnitCell & | cell, | ||
| int | xc_type, | ||
| bool | cal_exx ) |
Check PW propagation restrictions after resolving the XC functional and EXX configuration.
| double pw::compute_pot_onsite_scalar | ( | std::complex< double > * | pot_onsite, |
| const double * | occ, | ||
| double | u_value, | ||
| double | diag_coeff, | ||
| double | weight_eu, | ||
| int | m_size ) |
compute pot_onsite and energy contribution for one atom, one spin channel (nspin==1 or nspin==2). Returns the energy_u increment.
pot_onsite: pointer to the spin channel's pot_onsite block (size m_size * m_size) occ: pointer to occ_mat[iat][target_l][is].c for this channel
| double pw::compute_pot_onsite_spinor | ( | std::complex< double > * | pot_onsite, |
| const double * | occ, | ||
| double | u_value, | ||
| double | diag_coeff, | ||
| double | weight_eu, | ||
| int | m_size ) |
compute pot_onsite and energy contribution for one atom (nspin==4, spinor).
Writes 4 Pauli blocks of pot_onsite into pot_onsite (size 4 * m_size * m_size) and returns the energy_u increment. Internally calls pauli_to_spin_basis to convert pot_onsite to spin basis in-place.
pot_onsite: pointer to uterm_mat[uterm_mat_index[iat]] occ: pointer to occ_mat[iat][target_l][0].c (4 Pauli blocks packed)
| void pw::compute_pot_uterm_and_energy | ( | const UnitCell & | cell, |
| const int | nspin, | ||
| const std::vector< double > & | u_current, | ||
| const std::vector< int > & | l_channel, | ||
| const std::vector< int > & | uterm_mat_index, | ||
| const OccupationMatrix & | occmat, | ||
| std::vector< std::complex< double > > & | uterm_mat, | ||
| double & | energy_u ) |
compute effective potential pot_onsite and DFT+U energy from occ_mat.
Preconditions:
Outputs:
| void pw::ensure_td_vnl | ( | const UnitCell & | cell, |
| const double | unshifted_bound, | ||
| const ModuleBase::Vector3< double > & | A_right_ha, | ||
| const ModuleBase::Vector3< double > & | A_prop_ha, | ||
| pseudopot_cell_vnl * | projectors ) |
Extend the projector table to cover both endpoint and propagation fields in Hartree atomic units.
| template std::unique_ptr< TDPropPW< std::complex< float >, base_device::DEVICE_CPU > > pw::make_td_prop | ( | const ModulePW::PW_Basis_K & | , |
| const Input_para & | , | ||
| int | , | ||
| const std::vector< int > & | , | ||
| const hsolver::diag_comm_info & | , | ||
| std::ostream & | ) |
| std::unique_ptr< TDPropPW< T, Device > > pw::make_td_prop | ( | const ModulePW::PW_Basis_K & | basis, |
| const Input_para & | input, | ||
| int | npol, | ||
| const std::vector< int > & | global_k, | ||
| const hsolver::diag_comm_info & | comm, | ||
| std::ostream & | log ) |
Resolve input controls and construct only the selected propagation method.
| template void pw::orth_init_pw | ( | hsolver::TDOrbOps< std::complex< double >, base_device::DEVICE_CPU > & | , |
| hsolver::HSOperator< std::complex< double >, base_device::DEVICE_CPU > & | , | ||
| psi::Psi< std::complex< double >, base_device::DEVICE_CPU > & | , | ||
| elecstate::ElecStatePW< std::complex< double >, base_device::DEVICE_CPU > & | , | ||
| Charge & | , | ||
| UnitCell & | , | ||
| const ModulePW::PW_Basis & | , | ||
| int | , | ||
| int | , | ||
| int | , | ||
| bool | ) |
| template void pw::orth_init_pw | ( | hsolver::TDOrbOps< std::complex< float >, base_device::DEVICE_CPU > & | , |
| hsolver::HSOperator< std::complex< float >, base_device::DEVICE_CPU > & | , | ||
| psi::Psi< std::complex< float >, base_device::DEVICE_CPU > & | , | ||
| elecstate::ElecStatePW< std::complex< float >, base_device::DEVICE_CPU > & | , | ||
| Charge & | , | ||
| UnitCell & | , | ||
| const ModulePW::PW_Basis & | , | ||
| int | , | ||
| int | , | ||
| int | , | ||
| bool | ) |
| void pw::orth_init_pw | ( | hsolver::TDOrbOps< T, Device > & | orbitals, |
| hsolver::HSOperator< T, Device > & | op, | ||
| psi::Psi< T, Device > & | current, | ||
| elecstate::ElecStatePW< T, Device > & | estate, | ||
| Charge & | charge, | ||
| UnitCell & | cell, | ||
| const ModulePW::PW_Basis & | rhod, | ||
| int | nspin, | ||
| int | nbands, | ||
| int | iter, | ||
| bool | do_orth ) |
Clean initial orbitals and rebuild occupations and density if orthogonalization changes them.
| void pw::pauli_to_spin_basis | ( | std::complex< double > * | pot_onsite, |
| int | m_size ) |
transform pot_onsite from Pauli basis to spin basis (in-place, nspin==4 only).
pot_onsite points to the per-atom pot_onsite block of size 4 * m_size * m_size, storing 4 contiguous Pauli blocks (is=0 charge, is=1 sigma_x, is=2 sigma_y, is=3 sigma_z). After the transform, the same memory holds the spin representation: pot_onsite[0] <- 0.5 * (pot_onsite_pauli[0] + pot_onsite_pauli[3]) pot_onsite[3*size] <- 0.5 * (pot_onsite_pauli[0] - pot_onsite_pauli[3]) pot_onsite[size] <- 0.5 * (pot_onsite_pauli[1] + i * pot_onsite_pauli[2]) pot_onsite[2*size] <- 0.5 * (pot_onsite_pauli[1] - i * pot_onsite_pauli[2])
| void pw::prepare_exx_nscf | ( | const Input_para & | inp, |
| const UnitCell & | ucell, | ||
| const ModulePW::PW_Basis_K * | pw_wfc, | ||
| hamilt::OperatorEXXPW< T, Device > & | op_exx, | ||
| const std::string & | readin_dir ) |
| pw::ExxSourceHeader pw::read_exx_source_header | ( | std::istream & | in | ) |
| void pw::read_exx_source_occupations | ( | std::istream & | in, |
| const std::vector< ExxSourceHeader > & | headers, | ||
| int | nspin, | ||
| ModuleBase::matrix & | weights ) |
| template void pw::rebuild_td_end | ( | psi::Psi< std::complex< double >, base_device::DEVICE_CPU > & | , |
| elecstate::ElecStatePW< std::complex< double >, base_device::DEVICE_CPU > & | , | ||
| Charge & | , | ||
| UnitCell & | , | ||
| hamilt::HamiltPW< std::complex< double >, base_device::DEVICE_CPU > & | , | ||
| hsolver::TDOrbOps< std::complex< double >, base_device::DEVICE_CPU > & | , | ||
| const ModulePW::PW_Basis_K & | , | ||
| const ModulePW::PW_Basis & | , | ||
| const ModuleBase::Vector3< double > & | , | ||
| int | , | ||
| int | , | ||
| bool | , | ||
| int | , | ||
| const std::string & | ) |
| template void pw::rebuild_td_end | ( | psi::Psi< std::complex< float >, base_device::DEVICE_CPU > & | , |
| elecstate::ElecStatePW< std::complex< float >, base_device::DEVICE_CPU > & | , | ||
| Charge & | , | ||
| UnitCell & | , | ||
| hamilt::HamiltPW< std::complex< float >, base_device::DEVICE_CPU > & | , | ||
| hsolver::TDOrbOps< std::complex< float >, base_device::DEVICE_CPU > & | , | ||
| const ModulePW::PW_Basis_K & | , | ||
| const ModulePW::PW_Basis & | , | ||
| const ModuleBase::Vector3< double > & | , | ||
| int | , | ||
| int | , | ||
| bool | , | ||
| int | , | ||
| const std::string & | ) |
| void pw::rebuild_td_end | ( | psi::Psi< T, Device > & | current, |
| elecstate::ElecStatePW< T, Device > & | estate, | ||
| Charge & | charge, | ||
| UnitCell & | cell, | ||
| hamilt::HamiltPW< T, Device > & | hamilt, | ||
| hsolver::TDOrbOps< T, Device > & | orbitals, | ||
| const ModulePW::PW_Basis_K & | basis, | ||
| const ModulePW::PW_Basis & | rhod, | ||
| const ModuleBase::Vector3< double > & | vecpot, | ||
| int | nspin, | ||
| int | imp_sol, | ||
| bool | sc_mag, | ||
| int | dft_u, | ||
| const std::string & | assume_iso ) |
Rebuild an accepted endpoint from its orbitals while retaining all occupations.
| void pw::reduce_occ_mat | ( | const UnitCell & | cell, |
| const int | nspin, | ||
| const int | kpar, | ||
| const std::vector< int > & | l_channel, | ||
| OccupationMatrix & | occmat ) |
reduce occ_mat across all k-pools (per-atom, nspin-aware).
Each k-pool only accumulates occ_mat contributions from the k-points it owns; this sums them across pools so occmat holds the full result. nspin=1: single channel, size elements nspin=2: two channels (spin-up/down) reduced separately nspin=4: 4 Pauli blocks packed contiguously, reduced in one shot
| std::string pw::resolve_source_file | ( | const std::vector< std::string > & | directories, |
| const std::string & | fixed_name, | ||
| const std::string & | tail, | ||
| const bool | allow_electronic_suffix, | ||
| int * | ionic_step = nullptr, | ||
| int * | electronic_step = nullptr ) |
Locate the EXX source file written by the latest output step.
The fixed file name is preferred (modes 0 and 1). When it does not exist, the highest g{ionic step} variant is selected, and within that step the highest e{electronic iteration} variant. This is the rule used for mode-2 output directories, where every ionic step gets its own file.
| directories | Candidate directories, tried in order. |
| fixed_name | File name without the directory, e.g. "wfk1s1_pw.dat". |
| tail | Fixed suffix that follows the optional step tokens, e.g. "_pw.dat" or ".txt". |
| allow_electronic_suffix | Whether g{step}e{iter} names are accepted. |
| ionic_step | When non-null, receives the parsed one-based ionic step, or -1 for a fixed (step-less) file name. |
| electronic_step | When non-null, receives the parsed one-based electronic iteration, or -1. |
| std::runtime_error | When no candidate exists. |
| void pw::restore_td | ( | const TDElecSnap & | state, |
| elecstate::fenergy & | energy, | ||
| ModuleBase::matrix & | eigenvalues, | ||
| Charge & | charge ) |
Restore electronic data on the unchanged density grid and refresh its mixing backup.
| bool pw::run_deltaspin_lambda_loop | ( | const int | iter, |
| const double | drho, | ||
| const Input_para & | inp, | ||
| std::ostream & | ofs_running ) |
Run the inner lambda loop for DeltaSpin method to constrain atomic magnetic moments.
This function is used in the PW basis SCF iteration to optimize lambda parameters for constraining atomic magnetic moments to target values using the DeltaSpin method.
| iter | The current iteration number (0-indexed). |
| drho | The current charge density difference. |
| inp | The input parameters. |
| ofs_running | The output stream for running log (e.g. running_scf.log). |
Return false if DeltaSpin is not enabled
Get the singleton instance of SpinConstrain
Case 0: linear_scan strategy - sweep lambda values for energy landscape mapping This is a diagnostic/debugging mode that does NOT optimize lambda, only records Mi vs lambda to lambda_scan_results.dat.
Case 1: Magnetic moments not yet converged and SCF is close to convergence. This is the first time we enter the lambda loop after SCF is nearly converged.
Optimize lambda to get target magnetic moments
Case 2: Magnetic moments already converged in previous iteration. Re-run the lambda loop to update psi and charge density with current lambda.
Default: run the normal solver
| void pw::setup_pot | ( | const int | istep, |
| UnitCell & | ucell, | ||
| const K_Vectors & | kv, | ||
| Structure_Factor & | sf, | ||
| elecstate::ElecState * | pelec, | ||
| const Parallel_Grid & | para_grid, | ||
| const Charge & | chr, | ||
| pseudopot_cell_vl & | locpp, | ||
| pseudopot_cell_vnl & | ppcell, | ||
| VSep * | vsep_cell, | ||
| psi::Psi< T, Device > * | kspw_psi, | ||
| psi::Psi< std::complex< double >, Device > * | onsite_psi, | ||
| hamilt::HamiltBase * | p_hamilt, | ||
| ModulePW::PW_Basis_K * | pw_wfc, | ||
| const ModulePW::PW_Basis * | pw_rhod, | ||
| const std::string & | out_dir, | ||
| const Input_para & | inp ) |
0) DFT-1/2 calculations, sep potential need to generate
1) Renew local pseudopotential
2) Symmetrize the charge density (rho)
Density symmetrization should be behind init_scf, because charge should be initialized first. liuyu comment: it should be located between init_rho and v_of_rho?
3) Calculate the effective potential with rho
liuyu move here 2023-10-09 D in uspp need vloc, thus behind init_scf() calculate the effective coefficient matrix for non-local pseudopotential projectors
4) Onsite projectors
5) Spin-constrained algorithms
| void pw::setup_pwrho | ( | UnitCell & | ucell, |
| const bool | double_grid, | ||
| bool & | pw_rho_flag, | ||
| ModulePW::PW_Basis *& | pw_rho, | ||
| ModulePW::PW_Basis *& | pw_rhod, | ||
| ModulePW::PW_Basis_Big *& | pw_big, | ||
| const std::string & | classname, | ||
| const Input_para & | inp ) |
initialie the plane wave basis for rho
for OFDFT calculations
initialize the FFT grid
initialize the double grid (for uspp) if necessary
| void pw::setup_pwwfc | ( | const Input_para & | inp, |
| const UnitCell & | ucell, | ||
| const ModulePW::PW_Basis & | pw_rho, | ||
| K_Vectors & | kv, | ||
| ModulePW::PW_Basis_K *& | pw_wfc ) |
setup pw_wfc
new plane wave basis, fft grids, etc.
initialize the number of plane waves for each k point
| double pw::td_momentum_bound | ( | const ModulePW::PW_Basis_K & | basis, |
| const double | tpiba ) |
Return the global unshifted momentum bound after updating the distributed basis.
| std::vector< int > pw::td_voronoi_pw | ( | const UnitCell & | cell, |
| const ModulePW::PW_Basis & | grid ) |
Periodic nearest-atom labels on the local charge grid, in global atom order.
| void pw::teardown_pwrho | ( | bool & | pw_rho_flag, |
| const bool | double_grid, | ||
| ModulePW::PW_Basis *& | pw_rho, | ||
| ModulePW::PW_Basis *& | pw_rhod ) |
| void pw::teardown_pwwfc | ( | ModulePW::PW_Basis_K *& | pw_wfc | ) |
| void pw::update_cell_pw | ( | const UnitCell & | ucell, |
| pseudopot_cell_vnl & | ppcell, | ||
| const K_Vectors & | kv, | ||
| ModulePW::PW_Basis_K * | pw_wfc, | ||
| const Input_para & | inp ) |
| void pw::validate_hybrid_nscf | ( | const Input_para & | inp, |
| const General_Exx_Info & | info ) |
| void pw::validate_uspp_support | ( | bool | use_uspp, |
| const std::string & | basis_type, | ||
| const std::string & | esolver_type, | ||
| int | nspin, | ||
| int | xc_func_type, | ||
| bool | berry_phase, | ||
| bool | towannier90, | ||
| bool | cal_cond ) |
Validate that a calculation using ultrasoft pseudopotentials stays within the currently reviewed support boundary.