diff --git a/docs/advanced/input_files/input-main.md b/docs/advanced/input_files/input-main.md index eb464e088e..e400d317cb 100644 --- a/docs/advanced/input_files/input-main.md +++ b/docs/advanced/input_files/input-main.md @@ -3,7 +3,6 @@ - [Full List of INPUT Keywords](#full-list-of-input-keywords) - [System variables](#system-variables) - [suffix](#suffix) - - [ntype](#ntype) - [calculation](#calculation) - [esolver\_type](#esolver_type) - [symmetry](#symmetry) @@ -16,13 +15,6 @@ - [init\_wfc](#init_wfc) - [init\_chg](#init_chg) - [init\_vel](#init_vel) - - [nelec](#nelec) - - [nelec\_delta](#nelec_delta) - - [nupdown](#nupdown) - - [dft\_functional](#dft_functional) - - [xc\_temperature](#xc_temperature) - - [pseudo\_rcut](#pseudo_rcut) - - [pseudo\_mesh](#pseudo_mesh) - [mem\_saver](#mem_saver) - [diago\_proc](#diago_proc) - [nbspline](#nbspline) @@ -30,13 +22,13 @@ - [min\_dist\_coef](#min_dist_coef) - [device](#device) - [precision](#precision) - - [elpa\_num\_thread](#elpa_num_thread) - [Variables related to input files](#variables-related-to-input-files) - [stru\_file](#stru_file) - [kpoint\_file](#kpoint_file) - [pseudo\_dir](#pseudo_dir) - [orbital\_dir](#orbital_dir) - [read\_file\_dir](#read_file_dir) + - [restart\_load](#restart_load) - [wannier\_card](#wannier_card) - [Plane wave related variables](#plane-wave-related-variables) - [ecutwfc](#ecutwfc) @@ -62,11 +54,19 @@ - [search\_radius](#search_radius) - [search\_pbc](#search_pbc) - [bx, by, bz](#bx-by-bz) + - [elpa\_num\_thread](#elpa_num_thread) - [num\_stream](#num_stream) - [Electronic structure](#electronic-structure) - [basis\_type](#basis_type) - [ks\_solver](#ks_solver) - [nbands](#nbands) + - [nelec](#nelec) + - [nelec\_delta](#nelec_delta) + - [nupdown](#nupdown) + - [dft\_functional](#dft_functional) + - [xc\_temperature](#xc_temperature) + - [pseudo\_rcut](#pseudo_rcut) + - [pseudo\_mesh](#pseudo_mesh) - [nspin](#nspin) - [smearing\_method](#smearing_method) - [smearing\_sigma](#smearing_sigma) @@ -154,7 +154,6 @@ - [out\_interval](#out_interval) - [out\_element\_info](#out_element_info) - [restart\_save](#restart_save) - - [restart\_load](#restart_load) - [rpa](#rpa) - [nbands\_istate](#nbands_istate) - [bands\_to\_print](#bands_to_print) @@ -434,12 +433,6 @@ These variables are used to control general system parameters. - **Description**: In each run, ABACUS will generate a subdirectory in the working directory. This subdirectory contains all the information of the run. The subdirectory name has the format: OUT.suffix, where the `suffix` is the name you can pick up for your convenience. - **Default**: ABACUS -### ntype - -- **Type**: Integer -- **Description**: Number of different atom species in this calculation. If this value is not equal to the atom species in the STRU file, ABACUS will stop and quit. If not set or set to 0, ABACUS will automatically set it to the atom species in the STRU file. -- **Default**: 0 - ### calculation - **Type**: String @@ -585,63 +578,6 @@ These variables are used to control general system parameters. - False: assign value to atom velocity using Gaussian distributed random numbers. - **Default**: False -### nelec - -- **Type**: Real -- **Description**: - - - 0.0: the total number of electrons will be calculated by the sum of valence electrons (i.e. assuming neutral system). - - `>0.0`: this denotes the total number of electrons in the system. Must be less than 2*nbands. -- **Default**: 0.0 - -### nelec_delta - -- **Type**: Real -- **Description**: - the total number of electrons will be calculated by `nelec`+`nelec_delta`. -- **Default**: 0.0 - -### nupdown - -- **Type**: Real -- **Description**: - - 0.0: no constrain apply to system. - - `>0.0`: this denotes the difference number of electrons between spin-up and spin-down in the system. The range of value must in [-nelec ~ nelec]. It is one method of constraint DFT, the fermi energy level will separate to E_Fermi_up and E_Fermi_down. -- **Default**: 0.0 - -### dft_functional - -- **Type**: String -- **Description**: In our package, the XC functional can either be set explicitly using the `dft_functional` keyword in `INPUT` file. If `dft_functional` is not specified, ABACUS will use the xc functional indicated in the pseudopotential file. - On the other hand, if dft_functional is specified, it will overwrite the functional from pseudopotentials and performs calculation with whichever functional the user prefers. We further offer two ways of supplying exchange-correlation functional. The first is using 'short-hand' names such as 'LDA', 'PBE', 'SCAN'. A complete list of 'short-hand' expressions can be found in [the source code](../../../source/module_hamilt_general/module_xc/xc_functional.cpp). The other way is only available when ***compiling with LIBXC***, and it allows for supplying exchange-correlation functionals as combinations of LIBXC keywords for functional components, joined by a plus sign, for example, 'dft_functional='LDA_X_1D_EXPONENTIAL+LDA_C_1D_CSC'. The list of LIBXC keywords can be found on its [website](https://www.tddft.org/programs/libxc/functionals/). In this way, **we support all the LDA,GGA and mGGA functionals provided by LIBXC**. - - Furthermore, the old INPUT parameter exx_hybrid_type for hybrid functionals has been absorbed into dft_functional. Options are `hf` (pure Hartree-Fock), `pbe0`(PBE0), `hse` (Note: in order to use HSE functional, LIBXC is required). Note also that HSE has been tested while PBE0 has NOT been fully tested yet, and the maximum CPU cores for running exx in parallel is $N(N+1)/2$, with N being the number of atoms. And forces for hybrid functionals are not supported yet. - - If set to `opt_orb`, the program will not perform hybrid functional calculation. Instead, it is going to generate opt-ABFs as discussed in this [article](https://pubs.acs.org/doi/abs/10.1021/acs.jpclett.0c00481). -- **Default**: same as UPF file. - -### xc_temperature - -- **Type**: Real -- **Description**: specifies temperature when using temperature-dependent XC functionals (KSDT and so on). -- **Default** : 0.0 -- **Unit**: Ry - -### pseudo_rcut - -- **Type**: Real -- **Description**: Cut-off of radial integration for pseudopotentials -- **Default**: 15 -- **Unit**: Bohr - -### pseudo_mesh - -- **Type**: Integer -- **Description**: - - 0: use our own mesh for radial integration of pseudopotentials - - 1: use the mesh that is consistent with quantum espresso -- **Default**: 0 - ### mem_saver - **Type**: Boolean @@ -712,14 +648,6 @@ If only one value is set (such as `kspacing 0.5`), then kspacing values of a/b/c - cg/bpcg/dav ks_solver: required by the `single` precision options - **Default**: double -### elpa_num_thread - -- **Type**: int -- **Description**: Number of threads used in one elpa calculation. - - If the number is below 0 or 0 or beyond the max number of threads, all elpa calculation will be using all mpi threads -- **Default**: -1 - [back to top](#full-list-of-input-keywords) ## Variables related to input files @@ -766,6 +694,15 @@ These variables are used to control parameters related to input files. - Example: './' implies the files to be read are located in the working directory. - **Default**: OUT.$suffix +### restart_load + +- **Type**: Boolean +- **Availability**: Numerical atomic orbital basis +- **Description**: If [restart_save](#restart_save) is set to true and an electronic iteration is finished, calculations can be restarted from the charge density file, which are saved in the former calculation. Please ensure [read_file_dir](#read_file_dir) is correct, and the charge density file exist. + + If EXX(exact exchange) is calculated (i.e. *[dft_fuctional](#dft_functional)==hse/hf/pbe0/scan0/opt_orb* or *[rpa](#rpa)==True*), the Hexx(R) files in the same folder for each processor will also be read. +- **Default**: False + ### wannier_card - **Type**: String @@ -938,6 +875,14 @@ These variables are used to control the numerical atomic orbitals related parame - **Description**: In the matrix operation of grid integral, bx/by/bz grids (in x, y, z directions) are treated as a whole as a matrix element. A different value will affect the calculation speed. The default is 0, which means abacus will automatically calculate these values. - **Default**: 0 +### elpa_num_thread + +- **Type**: int +- **Description**: Number of threads used in one elpa calculation. + + If the number is below 0 or 0 or beyond the max number of threads, all elpa calculation will be using all mpi threads +- **Default**: -1 + ### num_stream - **Type** :int @@ -998,6 +943,63 @@ calculations. - nspin=2: max(1.2\*nelec_spin, nelec_spin + 10), in which nelec_spin = max(nelec_spin_up, nelec_spin_down) - nspin=4: max(1.2\*nelec, nelec + 20) +### nelec + +- **Type**: Real +- **Description**: + + - 0.0: the total number of electrons will be calculated by the sum of valence electrons (i.e. assuming neutral system). + - `>0.0`: this denotes the total number of electrons in the system. Must be less than 2*nbands. +- **Default**: 0.0 + +### nelec_delta + +- **Type**: Real +- **Description**: + the total number of electrons will be calculated by `nelec`+`nelec_delta`. +- **Default**: 0.0 + +### nupdown + +- **Type**: Real +- **Description**: + - 0.0: no constrain apply to system. + - `>0.0`: this denotes the difference number of electrons between spin-up and spin-down in the system. The range of value must in [-nelec ~ nelec]. It is one method of constraint DFT, the fermi energy level will separate to E_Fermi_up and E_Fermi_down. +- **Default**: 0.0 + +### dft_functional + +- **Type**: String +- **Description**: In our package, the XC functional can either be set explicitly using the `dft_functional` keyword in `INPUT` file. If `dft_functional` is not specified, ABACUS will use the xc functional indicated in the pseudopotential file. + On the other hand, if dft_functional is specified, it will overwrite the functional from pseudopotentials and performs calculation with whichever functional the user prefers. We further offer two ways of supplying exchange-correlation functional. The first is using 'short-hand' names such as 'LDA', 'PBE', 'SCAN'. A complete list of 'short-hand' expressions can be found in [the source code](../../../source/module_hamilt_general/module_xc/xc_functional.cpp). The other way is only available when ***compiling with LIBXC***, and it allows for supplying exchange-correlation functionals as combinations of LIBXC keywords for functional components, joined by a plus sign, for example, 'dft_functional='LDA_X_1D_EXPONENTIAL+LDA_C_1D_CSC'. The list of LIBXC keywords can be found on its [website](https://www.tddft.org/programs/libxc/functionals/). In this way, **we support all the LDA,GGA and mGGA functionals provided by LIBXC**. + + Furthermore, the old INPUT parameter exx_hybrid_type for hybrid functionals has been absorbed into dft_functional. Options are `hf` (pure Hartree-Fock), `pbe0`(PBE0), `hse` (Note: in order to use HSE functional, LIBXC is required). Note also that HSE has been tested while PBE0 has NOT been fully tested yet, and the maximum CPU cores for running exx in parallel is $N(N+1)/2$, with N being the number of atoms. And forces for hybrid functionals are not supported yet. + + If set to `opt_orb`, the program will not perform hybrid functional calculation. Instead, it is going to generate opt-ABFs as discussed in this [article](https://pubs.acs.org/doi/abs/10.1021/acs.jpclett.0c00481). +- **Default**: same as UPF file. + +### xc_temperature + +- **Type**: Real +- **Description**: specifies temperature when using temperature-dependent XC functionals (KSDT and so on). +- **Default** : 0.0 +- **Unit**: Ry + +### pseudo_rcut + +- **Type**: Real +- **Description**: Cut-off of radial integration for pseudopotentials +- **Default**: 15 +- **Unit**: Bohr + +### pseudo_mesh + +- **Type**: Integer +- **Description**: + - 0: use our own mesh for radial integration of pseudopotentials + - 1: use the mesh that is consistent with quantum espresso +- **Default**: 0 + ### nspin - **Type**: Integer @@ -1735,15 +1737,6 @@ The band (KS orbital) energy for each (k-point, spin, band) will be printed in t If EXX(exact exchange) is calculated (i.e. *[dft_fuctional](#dft_functional)==hse/hf/pbe0/scan0/opt_orb* or *[rpa](#rpa)==True*), the Hexx(R) files for each processor will also be saved in the above folder, which can be read in EXX calculation with *[restart_load](#restart_load)==True*. - **Default**: False -### restart_load - -- **Type**: Boolean -- **Availability**: Numerical atomic orbital basis -- **Description**: If [restart_save](#restart_save) is set to true and an electronic iteration is finished, calculations can be restarted from the charge density file, which are saved in the former calculation. Please ensure [read_file_dir](#read_file_dir) is correct, and the charge density file exist. - - If EXX(exact exchange) is calculated (i.e. *[dft_fuctional](#dft_functional)==hse/hf/pbe0/scan0/opt_orb* or *[rpa](#rpa)==True*), the Hexx(R) files in the same folder for each processor will also be read. -- **Default**: False - ### rpa - **Type**: Boolean diff --git a/source/Makefile.Objects b/source/Makefile.Objects index 5577eac06c..8a3cb88425 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -496,14 +496,19 @@ OBJS_IO=input.o\ output_info.o\ parse_args.o\ read_input.o\ - read_input_item_general.o\ - read_input_item_pw.o\ - read_input_item_sdft.o\ + read_input_item_system.o\ + read_input_item_elec_stru.o\ read_input_item_relax.o\ - read_input_item_lcao.o\ - read_input_item_postprocess.o\ read_input_item_md.o\ + read_input_item_ofdft.o\ + read_input_item_sdft.o\ + read_input_item_tddft.o\ + read_input_item_deepks.o\ + read_input_item_model.o\ + read_input_item_postprocess.o\ + read_input_item_exx_dftu.o\ read_input_item_other.o\ + read_input_item_output.o\ bcast_globalv.o OBJS_IO_LCAO=cal_r_overlap_R.o\ diff --git a/source/module_cell/unitcell.cpp b/source/module_cell/unitcell.cpp index 8eb6db6d11..e60822ee6f 100644 --- a/source/module_cell/unitcell.cpp +++ b/source/module_cell/unitcell.cpp @@ -28,8 +28,9 @@ #endif UnitCell::UnitCell() { - if (GlobalV::test_unitcell) + if (GlobalV::test_unitcell) { ModuleBase::TITLE("unitcell", "Constructor"); +} Coordinate = "Direct"; latName = "none"; lat0 = 0.0; @@ -87,8 +88,9 @@ UnitCell::~UnitCell() { #include "module_base/parallel_common.h" #ifdef __MPI void UnitCell::bcast_unitcell() { - if (GlobalV::test_unitcell) + if (GlobalV::test_unitcell) { ModuleBase::TITLE("UnitCell", "bcast_unitcell"); +} Parallel_Common::bcast_string(Coordinate); Parallel_Common::bcast_int(nat); @@ -167,8 +169,9 @@ void UnitCell::bcast_unitcell2() { #endif void UnitCell::print_cell(std::ofstream& ofs) const { - if (GlobalV::test_unitcell) + if (GlobalV::test_unitcell) { ModuleBase::TITLE("UnitCell", "print_cell"); +} ModuleBase::GlobalFunc::OUT(ofs, "print_unitcell()"); @@ -380,18 +383,24 @@ void UnitCell::periodic_boundary_adjustment() { Atom* atom = &this->atoms[it]; for (int ia = 0; ia < atom->na; ia++) { // mohan update 2011-03-21 - if (atom->taud[ia].x < 0) + if (atom->taud[ia].x < 0) { atom->taud[ia].x += 1.0; - if (atom->taud[ia].y < 0) +} + if (atom->taud[ia].y < 0) { atom->taud[ia].y += 1.0; - if (atom->taud[ia].z < 0) +} + if (atom->taud[ia].z < 0) { atom->taud[ia].z += 1.0; - if (atom->taud[ia].x >= 1.0) +} + if (atom->taud[ia].x >= 1.0) { atom->taud[ia].x -= 1.0; - if (atom->taud[ia].y >= 1.0) +} + if (atom->taud[ia].y >= 1.0) { atom->taud[ia].y -= 1.0; - if (atom->taud[ia].z >= 1.0) +} + if (atom->taud[ia].z >= 1.0) { atom->taud[ia].z -= 1.0; +} if (atom->taud[ia].x < 0 || atom->taud[ia].y < 0 || atom->taud[ia].z < 0 || atom->taud[ia].x >= 1.0 @@ -445,8 +454,9 @@ void UnitCell::cal_ux() { break; } } - if (magnet.lsign_) + if (magnet.lsign_) { break; +} } // whether the initial magnetizations is parallel for (int it = starting_it; it < ntype; it++) { @@ -789,8 +799,9 @@ void UnitCell::read_pseudo(std::ofstream& ofs) { break; } } - if (cut_mesh % 2 == 0) + if (cut_mesh % 2 == 0) { ++cut_mesh; +} ofs << std::setw(10) << cut_mesh << "\t" << "the number of mesh points." << std::endl; @@ -1084,8 +1095,9 @@ void UnitCell::set_iat2iwt(const int& npol_in) { // Demand : atoms[].msh //====================== void UnitCell::cal_meshx() { - if (GlobalV::test_pseudo_cell) + if (GlobalV::test_pseudo_cell) { ModuleBase::TITLE("UnitCell", "cal_meshx"); +} this->meshx = 0; for (int it = 0; it < this->ntype; it++) { const int mesh = this->atoms[it].ncpp.msh; @@ -1104,8 +1116,9 @@ void UnitCell::cal_meshx() { // atoms[].na //========================= void UnitCell::cal_natomwfc(std::ofstream& log) { - if (GlobalV::test_pseudo_cell) + if (GlobalV::test_pseudo_cell) { ModuleBase::TITLE("UnitCell", "cal_natomwfc"); +} this->natomwfc = 0; for (int it = 0; it < ntype; it++) { @@ -1120,13 +1133,15 @@ void UnitCell::cal_natomwfc(std::ofstream& log) { tmp += 2 * atoms[it].ncpp.lchi[l]; if (fabs(atoms[it].ncpp.jchi[l] - atoms[it].ncpp.lchi[l] - 0.5) - < 1e-6) + < 1e-6) { tmp += 2; +} } else { tmp += 2 * (2 * atoms[it].ncpp.lchi[l] + 1); } - } else + } else { tmp += 2 * atoms[it].ncpp.lchi[l] + 1; +} } } natomwfc += tmp * atoms[it].na; @@ -1208,8 +1223,9 @@ bool UnitCell::if_atoms_can_move() const { for (int it = 0; it < this->ntype; it++) { Atom* atom = &atoms[it]; for (int ia = 0; ia < atom->na; ia++) { - if (atom->mbl[ia].x || atom->mbl[ia].y || atom->mbl[ia].z) + if (atom->mbl[ia].x || atom->mbl[ia].y || atom->mbl[ia].z) { return true; +} } } return false; diff --git a/source/module_esolver/esolver_ks_pw.cpp b/source/module_esolver/esolver_ks_pw.cpp index ececc08116..6a5dba53fa 100644 --- a/source/module_esolver/esolver_ks_pw.cpp +++ b/source/module_esolver/esolver_ks_pw.cpp @@ -1030,7 +1030,7 @@ void ESolver_KS_PW::after_all_runners() { this->kv, this->pw_wfc, GlobalC::ucell, - PARAM.inp.bessel_nao_rcuts[i]); + i); } ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "BASIS OVERLAP (Q and S) GENERATION."); diff --git a/source/module_io/CMakeLists.txt b/source/module_io/CMakeLists.txt index 8c8f0a9c1a..d74e529eb6 100644 --- a/source/module_io/CMakeLists.txt +++ b/source/module_io/CMakeLists.txt @@ -81,14 +81,19 @@ endif() add_library( io_input OBJECT - read_input_item_other.cpp - read_input_item_general.cpp - read_input_item_pw.cpp - read_input_item_sdft.cpp + read_input_item_system.cpp + read_input_item_elec_stru.cpp read_input_item_relax.cpp - read_input_item_lcao.cpp - read_input_item_postprocess.cpp read_input_item_md.cpp + read_input_item_ofdft.cpp + read_input_item_sdft.cpp + read_input_item_tddft.cpp + read_input_item_deepks.cpp + read_input_item_model.cpp + read_input_item_postprocess.cpp + read_input_item_exx_dftu.cpp + read_input_item_other.cpp + read_input_item_output.cpp read_input.cpp bcast_globalv.cpp ) diff --git a/source/module_io/bcast_globalv.cpp b/source/module_io/bcast_globalv.cpp index 88c90e18a9..3a9def3e0f 100644 --- a/source/module_io/bcast_globalv.cpp +++ b/source/module_io/bcast_globalv.cpp @@ -5,8 +5,6 @@ namespace ModuleIO void ReadInput::set_globalv_bcast() { add_bool_bcast(sys.two_fermi); - add_int_bcast(sys.nrcut); - add_double_bcast(sys.bessel_nao_rcut); add_bool_bcast(sys.dos_setemin); add_bool_bcast(sys.dos_setemax); add_int_bcast(sys.ncx); diff --git a/source/module_io/input.h b/source/module_io/input.h index 2bd77b14a5..99d4393775 100644 --- a/source/module_io/input.h +++ b/source/module_io/input.h @@ -22,7 +22,6 @@ class Input int cond_dtbatch; int nche_sto; double md_tfirst; - double bessel_nao_rcut; // radial cutoff for spherical bessel functions(a.u.) MD_para mdp; int* orbital_corr = nullptr; ///< which correlated orbitals need corrected ; double* hubbard_u = nullptr; ///< Hubbard Coulomb interaction parameter U(ev) diff --git a/source/module_io/input_conv_tmp.cpp b/source/module_io/input_conv_tmp.cpp index 47c8419af5..af3cd1cb0e 100644 --- a/source/module_io/input_conv_tmp.cpp +++ b/source/module_io/input_conv_tmp.cpp @@ -8,7 +8,6 @@ void Input_Conv::tmp_convert() { INPUT.stru_file = PARAM.inp.stru_file; - INPUT.bessel_nao_rcut = PARAM.globalv.bessel_nao_rcut; INPUT.cond_dtbatch = PARAM.inp.cond_dtbatch; INPUT.nche_sto = PARAM.inp.nche_sto; INPUT.mdp = PARAM.mdp; diff --git a/source/module_io/numerical_basis.cpp b/source/module_io/numerical_basis.cpp index 76f9501a11..f02048990e 100644 --- a/source/module_io/numerical_basis.cpp +++ b/source/module_io/numerical_basis.cpp @@ -39,37 +39,34 @@ Numerical_Basis::~Numerical_Basis() // to generate TableOne // Secondly output overlap, use psi(evc) and jlq3d. //============================================================ -void Numerical_Basis::start_from_file_k(const int& ik, - ModuleBase::ComplexMatrix& psi, - const Structure_Factor& sf, - const ModulePW::PW_Basis_K* wfcpw, - const UnitCell& ucell, - const double& beseel_nao_rcut) -{ - ModuleBase::TITLE("Numerical_Basis", "start_from_file_k"); - - if (!this->init_label) - { - // true stands for : start_from_file - this->bessel_basis.init(true, std::stod(PARAM.inp.bessel_nao_ecut), ucell.ntype, ucell.lmax, - PARAM.inp.bessel_nao_smooth, PARAM.inp.bessel_nao_sigma, beseel_nao_rcut, - PARAM.inp.bessel_nao_tolerence, ucell); - this->mu_index = this->init_mu_index(ucell); - this->init_label = true; - } - this->numerical_atomic_wfc(ik, wfcpw, psi, sf, ucell); -} +// void Numerical_Basis::start_from_file_k(const int& ik, ModuleBase::ComplexMatrix& psi, const Structure_Factor& sf, +// const ModulePW::PW_Basis_K* wfcpw, const UnitCell& ucell) +// { +// ModuleBase::TITLE("Numerical_Basis", "start_from_file_k"); + +// if (!this->init_label) +// { +// // true stands for : start_from_file +// this->bessel_basis.init(true, std::stod(PARAM.inp.bessel_nao_ecut), ucell.ntype, ucell.lmax, +// PARAM.inp.bessel_nao_smooth, PARAM.inp.bessel_nao_sigma, PARAM.globalv.bessel_nao_rcut, +// PARAM.inp.bessel_nao_tolerence, ucell); +// this->mu_index = this->init_mu_index(ucell); +// this->init_label = true; +// } +// this->numerical_atomic_wfc(ik, wfcpw, psi, sf, ucell); +// } // The function is called in run_fp.cpp. -void Numerical_Basis::output_overlap(const psi::Psi>& psi, +void Numerical_Basis::output_overlap(const psi::Psi>& psi, const Structure_Factor& sf, - const K_Vectors& kv, - const ModulePW::PW_Basis_K* wfcpw, + const K_Vectors& kv, + const ModulePW::PW_Basis_K* wfcpw, const UnitCell& ucell, - const double& bessel_nao_rcut) + const int& index) { ModuleBase::TITLE("Numerical_Basis", "output_overlap"); ModuleBase::GlobalFunc::NEW_PART("Overlap Data For Spillage Minimization"); + const double bessel_nao_rcut = PARAM.inp.bessel_nao_rcuts[index]; //--------------------------------------------------------- // if the numerical_basis hasn't been initialized yet, @@ -181,37 +178,43 @@ void Numerical_Basis::output_overlap(const psi::Psi>& psi, Parallel_Reduce::reduce_pool(overlap_V.c, overlap_V.nr * overlap_V.nc); // Peize Lin add 2020.04.23 #endif // exception handling following, for FileNotOpenFailure - if (ofs.good()) + if (ofs.good()) { this->output_info(ofs, bessel_basis, kv, ucell); // header of orb_matrix* file - else + } else { ModuleBase::WARNING_QUIT("Numerical_Basis", "Failed to open file for writing the overlap matrix."); +} // because one stage of file io complete, re-check the file status. - if (ofs.good()) + if (ofs.good()) { this->output_k(ofs, kv); // ... - else + } else { ModuleBase::WARNING_QUIT("Numerical_Basis", "Failed to write k-points to file."); +} // because one stage of file io complete, re-check the file status. - if (ofs.good()) + if (ofs.good()) { this->output_overlap_Q(ofs, overlap_Q, kv); // ... - else + } else { ModuleBase::WARNING_QUIT("Numerical_Basis", "Failed to write overlap Q to file."); +} // because one stage of file io complete, re-check the file status. if (winput::out_spillage == 2) { // caution: this is the largest matrix to be output, always flush - if (ofs.good()) + if (ofs.good()) { this->output_overlap_Sq(ss.str(), ofs, overlap_Sq, kv); // ... - else + } else { ModuleBase::WARNING_QUIT("Numerical_Basis", "Failed to write overlap S to file."); +} } // because one stage of file io complete, re-check the file status. - if (ofs.good()) + if (ofs.good()) { this->output_overlap_V(ofs, overlap_V); // ... // Peize Lin add 2020.04.23 - else + } else { ModuleBase::WARNING_QUIT("Numerical_Basis", "Failed to write overlap V to file."); - if (GlobalV::MY_RANK == 0) +} + if (GlobalV::MY_RANK == 0) { ofs.close(); +} } return; } @@ -312,8 +315,9 @@ ModuleBase::ComplexArray Numerical_Basis::cal_overlap_Sq(const int& ik, const in = (4 * ModuleBase::PI) * (4 * ModuleBase::PI) / ucell.omega; // Peize Lin add normalization 2015-12-29 std::vector> gk(np); - for (int ig = 0; ig < np; ig++) + for (int ig = 0; ig < np; ig++) { gk[ig] = wfcpw->getgpluskcar(ik, ig) * ucell.tpiba; +} const std::vector gpow = Numerical_Basis::cal_gpow(gk, derivative_order); @@ -357,9 +361,10 @@ ModuleBase::ComplexArray Numerical_Basis::cal_overlap_Sq(const int& ik, const in const int iwt1 = this->mu_index[T1](I1, l1, ic1, m1); std::vector> about_ig1(np, std::complex(0.0, 0.0)); - for (int ig = 0; ig < np; ig++) + for (int ig = 0; ig < np; ig++) { about_ig1[ig] = conj(lphase1 * sk1[ig] * ylm(lm1, ig)) * gpow[ig]; // Peize Lin add for dpsi 2020.04.23 +} for (int m2 = 0; m2 < 2 * l2 + 1; m2++) // 2.6 { @@ -368,8 +373,9 @@ ModuleBase::ComplexArray Numerical_Basis::cal_overlap_Sq(const int& ik, const in std::vector> about_ig2(np, std::complex(0.0, 0.0)); - for (int ig = 0; ig < np; ++ig) + for (int ig = 0; ig < np; ++ig) { about_ig2[ig] = lphase2 * sk2[ig] * ylm(lm2, ig) * about_ig1[ig]; +} /* same as: for (int ig=0; ig>()); +} BlasConnector::gemm('N', 'T', enumber, enumber, np, 1.0, about_ig3_1.c, np, about_ig3_2.c, np, 1.0, &overlap_Sq(iwt1, iwt2, 0, 0), @@ -420,14 +427,17 @@ ModuleBase::matrix Numerical_Basis::cal_overlap_V(const ModulePW::PW_Basis_K* wf for (int ik = 0; ik < kv.get_nks(); ++ik) { std::vector> gk(kv.ngk[ik]); - for (int ig = 0; ig < gk.size(); ig++) + for (int ig = 0; ig < gk.size(); ig++) { gk[ig] = wfcpw->getgpluskcar(ik, ig) * tpiba; +} const std::vector gpow = Numerical_Basis::cal_gpow(gk, derivative_order); - for (int ib = 0; ib < GlobalV::NBANDS; ++ib) - for (int ig = 0; ig < kv.ngk[ik]; ++ig) + for (int ib = 0; ib < GlobalV::NBANDS; ++ib) { + for (int ig = 0; ig < kv.ngk[ik]; ++ig) { overlap_V(ik, ib) += norm(psi(ik, ib, ig)) * gpow[ig]; +} +} } return overlap_V; } @@ -474,8 +484,9 @@ std::vector Numerical_Basis::cal_gpow(const std::vector= thr) + if (gk[ig].norm2() >= thr) { gpow[ig] = std::pow(gk[ig].norm2(), derivative_order); +} } } return gpow; @@ -524,8 +535,9 @@ void Numerical_Basis::numerical_atomic_wfc(const int& ik, const ModulePW::PW_Bas ModuleBase::TITLE("Numerical_Basis", "numerical_atomic_wfc"); const int np = wfcpw->npwk[ik]; std::vector> gk(np); - for (int ig = 0; ig < np; ig++) + for (int ig = 0; ig < np; ig++) { gk[ig] = wfcpw->getgpluskcar(ik, ig); +} const int total_lm = (ucell.lmax + 1) * (ucell.lmax + 1); ModuleBase::matrix ylm(total_lm, np); @@ -640,8 +652,9 @@ void Numerical_Basis::output_k(std::ofstream& ofs, const K_Vectors& kv) #ifdef __MPI // temprary restrict kpar=1 for NSPIN=2 case for generating_orbitals int pool = 0; - if (GlobalV::NSPIN != 2) + if (GlobalV::NSPIN != 2) { pool = GlobalC::Pkpoints.whichpool[ik]; +} const int iknow = ik - GlobalC::Pkpoints.startk_pool[GlobalV::MY_POOL]; if (GlobalV::RANK_IN_POOL == 0) { @@ -749,8 +762,9 @@ void Numerical_Basis::output_overlap_Q(std::ofstream& ofs, const std::vector>& psi, - const Structure_Factor& sf, - const K_Vectors& kv, - const ModulePW::PW_Basis_K* wfcpw, + // void start_from_file_k(const int& ik, ModuleBase::ComplexMatrix& psi, const Structure_Factor& sf, const ModulePW::PW_Basis_K* wfcpw, const UnitCell& ucell); + void output_overlap(const psi::Psi>& psi, + const Structure_Factor& sf, + const K_Vectors& kv, + const ModulePW::PW_Basis_K* wfcpw, const UnitCell& ucell, - const double& beseel_nao_rcut); + const int& index); private: bool init_label = false; diff --git a/source/module_io/read_input.cpp b/source/module_io/read_input.cpp index 9c9e801958..6ffd98648a 100644 --- a/source/module_io/read_input.cpp +++ b/source/module_io/read_input.cpp @@ -116,13 +116,21 @@ ReadInput::ReadInput(const int& rank) { this->rank = rank; this->set_globalv_bcast(); - this->item_general(); - this->item_pw(); - this->item_sdft(); + // add items + this->item_system(); + this->item_elec_stru(); this->item_relax(); - this->item_lcao(); - this->item_postprocess(); this->item_md(); + this->item_ofdft(); + this->item_sdft(); + this->item_deepks(); + this->item_rt_tddft(); + this->item_lr_tddft(); + this->item_output(); + this->item_postprocess(); + this->item_model(); + this->item_exx(); + this->item_dftu(); this->item_others(); } @@ -325,7 +333,7 @@ void ReadInput::write_txt_input(const Parameter& param, const std::string& filen ofs << "INPUT_PARAMETERS" << std::endl; ofs << std::setiosflags(std::ios::left); - ofs << "#Parameters (1.General)" << std::endl; + ofs << "#Parameters (1.System)" << std::endl; for (auto& item: this->input_lists) { Input_Item* p_item = &(item.second); @@ -333,94 +341,83 @@ void ReadInput::write_txt_input(const Parameter& param, const std::string& filen continue; } p_item->get_final_value(*p_item, param); - if (p_item->label == "ecutwfc") + if (p_item->label == "ks_solver") { - ofs << "\n#Parameters (2.PW)" << std::endl; + ofs << "\n#Parameters (2.Electronic structure)" << std::endl; } - else if (p_item->label == "method_sto") + else if (p_item->label == "nb2d") { - ofs << "\n#Parameters (3.Stochastic DFT)" << std::endl; + ofs << "\n#Parameters (3.LCAO)" << std::endl; } - else if (p_item->label == "ks_solver") + else if (p_item->label == "relax_method") { ofs << "\n#Parameters (4.Relaxation)" << std::endl; } - else if (p_item->label == "basis_type") - { - ofs << "\n#Parameters (5.LCAO)" << std::endl; - } - else if (p_item->label == "smearing_method") - { - ofs << "\n#Parameters (6.Smearing)" << std::endl; - } - else if (p_item->label == "mixing_type") - { - ofs << "\n#Parameters (7.Charge Mixing)" << std::endl; - } - else if (p_item->label == "dos_emin_ev") - { - ofs << "\n#Parameters (8.DOS)" << std::endl; - } else if (p_item->label == "md_type") { - ofs << "\n#Parameters (9.Molecular dynamics)" << std::endl; + ofs << "\n#Parameters (5.Molecular dynamics)" << std::endl; } - else if (p_item->label == "efield_flag") + else if (p_item->label == "of_kinetic") { - ofs << "\n#Parameters (10.Electric field and dipole correction)" << std::endl; + ofs << "\n#Parameters (6.orbital free density functional theory)" << std::endl; } - else if (p_item->label == "gate_flag") + else if (p_item->label == "method_sto") { - ofs << "\n#Parameters (11.Gate field)" << std::endl; + ofs << "\n#Parameters (7.Stochastic DFT)" << std::endl; } - else if (p_item->label == "out_alllog") + else if (p_item->label == "deepks_out_labels") { - ofs << "\n#Parameters (12.Test)" << std::endl; + ofs << "\n#Parameters (8.DeepKS)" << std::endl; } - else if (p_item->label == "vdw_method") + else if (p_item->label == "td_force_dt") { - ofs << "\n#Parameters (13.vdW Correction)" << std::endl; + ofs << "\n#Parameters (9.rt-tddft)" << std::endl; } - else if (p_item->label == "exx_hybrid_alpha") + else if (p_item->label == "lr_nstates") { - ofs << "\n#Parameters (14.exx)" << std::endl; + ofs << "\n#Parameters (10.lr-tddft)" << std::endl; } - else if (p_item->label == "td_force_dt") + else if (p_item->label == "out_stru") { - ofs << "\n#Parameters (16.tddft)" << std::endl; + ofs << "\n#Parameters (11.Output)" << std::endl; } - else if (p_item->label == "berry_phase") + else if (p_item->label == "dos_emin_ev") { - ofs << "\n#Parameters (17.berry_wannier)" << std::endl; + ofs << "\n#Parameters (12.Postprocess)" << std::endl; } - else if (p_item->label == "imp_sol") + else if (p_item->label == "efield_flag") { - ofs << "\n#Parameters (18.implicit_solvation)" << std::endl; + ofs << "\n#Parameters (13.Model)" << std::endl; } - else if (p_item->label == "of_kinetic") + else if (p_item->label == "vdw_method") { - ofs << "\n#Parameters (19.orbital free density functional theory)" << std::endl; + ofs << "\n#Parameters (14.vdW Correction)" << std::endl; } - else if (p_item->label == "dft_plus_u") + else if (p_item->label == "exx_hybrid_alpha") { - ofs << "\n#Parameters (20.dft+u)" << std::endl; + ofs << "\n#Parameters (15.exx)" << std::endl; } - else if (p_item->label == "bessel_nao_ecut") + else if (p_item->label == "dft_plus_u") { - ofs << "\n#Parameters (21.spherical bessel)" << std::endl; + ofs << "\n#Parameters (16.dft+u)" << std::endl; } else if (p_item->label == "sc_mag_switch") { - ofs << "\n#Parameters (22.non-collinear spin-constrained DFT)" << std::endl; + ofs << "\n#Parameters (17.non-collinear spin-constrained DFT)" << std::endl; } else if (p_item->label == "qo_switch") { - ofs << "\n#Parameters (23.Quasiatomic Orbital analysis)" << std::endl; + ofs << "\n#Parameters (18.Quasiatomic Orbital analysis)" << std::endl; } else if (p_item->label == "pexsi_npole") { - ofs << "\n#Parameters (24.PEXSI)" << std::endl; + ofs << "\n#Parameters (19.PEXSI)" << std::endl; } + else if (p_item->label == "out_alllog") + { + ofs << "\n#Parameters (20.Test)" << std::endl; + } + ModuleBase::GlobalFunc::OUTP(ofs, p_item->label, p_item->final_value.str(), p_item->annotation); } } diff --git a/source/module_io/read_input.h b/source/module_io/read_input.h index 54577d1499..71e8a553ce 100644 --- a/source/module_io/read_input.h +++ b/source/module_io/read_input.h @@ -1,11 +1,11 @@ #ifndef READ_INPUT_H #define READ_INPUT_H -#include - #include "input_item.h" #include "module_parameter/parameter.h" +#include + namespace ModuleIO { class ReadInput @@ -78,21 +78,37 @@ class ReadInput void add_item(const Input_Item& item); // add bcast functions for global values void set_globalv_bcast(); - // general items - void item_general(); - // items for pw - void item_pw(); - // items for sdft - void item_sdft(); - // items for relax - void item_relax(); + // system items + void item_system(); + // items for electronic structure + void item_elec_stru(); // items for lcao void item_lcao(); - // items for postprocess - void item_postprocess(); + // items for relax + void item_relax(); // items for md void item_md(); - // items for others + // items for ofdft + void item_ofdft(); + // items for sdft + void item_sdft(); + // items for deepks + void item_deepks(); + // items for real time tddft + void item_rt_tddft(); + // items for linear response tddft + void item_lr_tddft(); + // items for output + void item_output(); + // items for postprocess + void item_postprocess(); + // items for some models + void item_model(); + // items for exx + void item_exx(); + // items for dft+u + void item_dftu(); + // items for other void item_others(); private: diff --git a/source/module_io/read_input_item_deepks.cpp b/source/module_io/read_input_item_deepks.cpp new file mode 100644 index 0000000000..a64372036d --- /dev/null +++ b/source/module_io/read_input_item_deepks.cpp @@ -0,0 +1,107 @@ +#include "module_base/constants.h" +#include "module_base/tool_quit.h" +#include "read_input.h" +#include "read_input_tool.h" +namespace ModuleIO +{ +void ReadInput::item_deepks() +{ + { + Input_Item item("deepks_out_labels"); + item.annotation = ">0 compute descriptor for deepks"; + read_sync_bool(input.deepks_out_labels); + this->add_item(item); + } + { + Input_Item item("deepks_scf"); + item.annotation = ">0 add V_delta to Hamiltonian"; + read_sync_bool(input.deepks_scf); + this->add_item(item); + } + { + Input_Item item("deepks_equiv"); + item.annotation = "whether to use equivariant version of DeePKS"; + read_sync_bool(input.deepks_equiv); + this->add_item(item); + } + { + Input_Item item("deepks_bandgap"); + item.annotation = ">0 for bandgap label"; + read_sync_bool(input.deepks_bandgap); + this->add_item(item); + } + { + Input_Item item("deepks_v_delta"); + item.annotation = ">0 for v_delta label. when output, 1 for v_delta_precalc, 2 for psialpha and grad_evdm ( can save memory )"; + read_sync_int(input.deepks_v_delta); + this->add_item(item); + } + { + Input_Item item("deepks_out_unittest"); + item.annotation = "if set 1, prints intermediate quantities that shall " + "be used for making unit test"; + read_sync_bool(input.deepks_out_unittest); + this->add_item(item); + } + { + Input_Item item("deepks_model"); + item.annotation = "file dir of traced pytorch model: 'model.ptg"; + read_sync_string(input.deepks_model); + this->add_item(item); + } + { + Input_Item item("bessel_descriptor_lmax"); + item.annotation = "lmax used in generating spherical bessel functions"; + read_sync_int(input.bessel_descriptor_lmax); + this->add_item(item); + } + { + Input_Item item("bessel_descriptor_ecut"); + item.annotation = "energy cutoff for spherical bessel functions(Ry)"; + read_sync_string(input.bessel_descriptor_ecut); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.bessel_descriptor_ecut == "default") + { + para.input.bessel_descriptor_ecut = std::to_string(para.input.ecutwfc); + } + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (std::stod(para.input.bessel_descriptor_ecut) < 0) + { + ModuleBase::WARNING_QUIT("ReadInput", "bessel_descriptor_ecut must >= 0"); + } + }; + this->add_item(item); + } + { + Input_Item item("bessel_descriptor_tolerence"); + item.annotation = "tolerence for spherical bessel root"; + read_sync_double(input.bessel_descriptor_tolerence); + this->add_item(item); + } + { + Input_Item item("bessel_descriptor_rcut"); + item.annotation = "radial cutoff for spherical bessel functions(a.u.)"; + read_sync_double(input.bessel_descriptor_rcut); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.bessel_descriptor_rcut < 0) + { + ModuleBase::WARNING_QUIT("ReadInput", "bessel_descriptor_rcut must >= 0"); + } + }; + this->add_item(item); + } + { + Input_Item item("bessel_descriptor_smooth"); + item.annotation = "spherical bessel smooth or not"; + read_sync_bool(input.bessel_descriptor_smooth); + this->add_item(item); + } + { + Input_Item item("bessel_descriptor_sigma"); + item.annotation = "sphereical bessel smearing_sigma"; + read_sync_double(input.bessel_descriptor_sigma); + this->add_item(item); + } +} +} // namespace ModuleIO \ No newline at end of file diff --git a/source/module_io/read_input_item_elec_stru.cpp b/source/module_io/read_input_item_elec_stru.cpp new file mode 100644 index 0000000000..bc1d7d356a --- /dev/null +++ b/source/module_io/read_input_item_elec_stru.cpp @@ -0,0 +1,742 @@ +#include "module_base/global_function.h" +#include "module_base/tool_quit.h" +#include "read_input.h" +#include "read_input_tool.h" + +namespace ModuleIO +{ +void ReadInput::item_elec_stru() +{ + // Electronic Structure + { + Input_Item item("ks_solver"); + item.annotation = "cg; dav; lapack; genelpa; scalapack_gvx; cusolver"; + read_sync_string(input.ks_solver); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.ks_solver == "default") + { + if (para.input.basis_type == "pw") + { + para.input.ks_solver = "cg"; + ModuleBase::GlobalFunc::AUTO_SET("ks_solver", "cg"); + } + else if (para.input.basis_type == "lcao") + { + if (para.input.device == "gpu") + { + para.input.ks_solver = "cusolver"; + ModuleBase::GlobalFunc::AUTO_SET("ks_solver", "cusolver"); + } + else + { +#ifdef __ELPA + para.input.ks_solver = "genelpa"; + ModuleBase::GlobalFunc::AUTO_SET("ks_solver", "genelpa"); +#else +#ifdef __MPI + para.input.ks_solver = "scalapack_gvx"; + ModuleBase::GlobalFunc::AUTO_SET("ks_solver", "scalapack_gvx"); +#else + para.input.ks_solver = "lapack"; + ModuleBase::GlobalFunc::AUTO_SET("ks_solver", "lapack"); +#endif +#endif + } + } + } + if (para.input.towannier90) + { + if (para.input.basis_type == "lcao_in_pw") + { +#ifdef __ELPA + para.input.ks_solver = "genelpa"; +#else +#ifdef __MPI + para.input.ks_solver = "scalapack_gvx"; +#else + para.input.ks_solver = "lapack"; +#endif +#endif + } + }; + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + const std::string& ks_solver = para.input.ks_solver; + const std::vector pw_solvers = {"cg", "dav", "bpcg", "dav_subspace"}; + const std::vector lcao_solvers = { + "genelpa", + "lapack", + "scalapack_gvx", + "cusolver", + "pexsi", + "cg_in_lcao", + }; + + if (para.input.basis_type == "pw") + { + if (!find_str(pw_solvers, ks_solver)) + { + ModuleBase::WARNING_QUIT("ReadInput", + "ks_solver must be cg, dav, bpcg " + "or dav_subspace for pw basis."); + } + } + else if (para.input.basis_type == "lcao") + { + if (!find_str(lcao_solvers, ks_solver)) + { + ModuleBase::WARNING_QUIT("ReadInput", + "ks_solver must be genelpa, lapack, scalapack_gvx, " + "cusolver, pexsi or " + "cg_in_lcao for lcao basis."); + } + if (ks_solver == "cg_in_lcao") + { + GlobalV::ofs_warning << "cg_in_lcao is under testing" << std::endl; + } + else if (ks_solver == "genelpa") + { +#ifndef __ELPA + ModuleBase::WARNING_QUIT("Input", + "Can not use genelpa if abacus is not compiled with " + "ELPA. Please change " + "ks_solver to scalapack_gvx."); +#endif + } + else if (ks_solver == "scalapack_gvx") + { +#ifdef __MPI + GlobalV::ofs_warning << "scalapack_gvx is under testing" << std::endl; +#else + ModuleBase::WARNING_QUIT("ReadInput", "scalapack_gvx can not be used for series version."); +#endif + } + else if (ks_solver == "cusolver" || ks_solver == "cusolvermp") + { +#ifndef __MPI + ModuleBase::WARNING_QUIT("ReadInput", "Cusolver can not be used for series version."); +#endif + } + else if (ks_solver == "pexsi") + { +#ifdef __PEXSI + GlobalV::ofs_warning << " It's ok to use pexsi." << std::endl; +#else + ModuleBase::WARNING_QUIT("ReadInput", + "Can not use PEXSI if abacus is not compiled with " + "PEXSI. Please change " + "ks_solver to scalapack_gvx."); +#endif + } + } + else if (para.input.basis_type == "lcao_in_pw") + { + if (ks_solver != "lapack") + { + ModuleBase::WARNING_QUIT("ReadInput", "LCAO in plane wave can only done with lapack."); + } + } + }; + this->add_item(item); + } + { + Input_Item item("basis_type"); + item.annotation = "PW; LCAO in pw; LCAO"; + read_sync_string(input.basis_type); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.towannier90) + { + if (para.input.basis_type == "lcao_in_pw") + { + para.input.basis_type = "lcao"; + } + } + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + const std::vector basis_types = {"pw", "lcao_in_pw", "lcao"}; + if (!find_str(basis_types, para.input.basis_type)) + { + ModuleBase::WARNING_QUIT("ReadInput", "basis_type should be pw, lcao_in_pw, or lcao"); + } + }; + this->add_item(item); + } + { + Input_Item item("use_paw"); + item.annotation = "whether to use PAW in pw calculation"; + read_sync_bool(input.use_paw); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.use_paw) + { +#ifndef USE_PAW + ModuleBase::WARNING_QUIT("ReadInput", "to use PAW, compile with USE_PAW"); +#endif + if (para.input.basis_type != "pw") + { + ModuleBase::WARNING_QUIT("ReadInput", "PAW is for pw basis only"); + } + if (para.input.dft_functional == "default") + { + ModuleBase::WARNING_QUIT("ReadInput", "dft_functional must be set when use_paw is true"); + } + } + }; + this->add_item(item); + } + { + Input_Item item("nbands"); + item.annotation = "number of bands"; + read_sync_int(input.nbands); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.nbands < 0) + { + ModuleBase::WARNING_QUIT("ReadInput", "nbands should be greater than 0."); + } + }; + this->add_item(item); + } + { + Input_Item item("nelec"); + item.annotation = "input number of electrons"; + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.nelec < 0) + { + ModuleBase::WARNING_QUIT("ReadInput", "nelec should be greater than 0."); + } + if (para.input.nelec > 0 && para.input.nbands > 0 && para.input.nelec > 2 * para.input.nbands) + { + ModuleBase::WARNING_QUIT("ReadInput", "nelec > 2*nbnd , bands not enough!"); + } + }; + read_sync_double(input.nelec); + this->add_item(item); + } + { + Input_Item item("nelec_delta"); + item.annotation = "change in the number of total electrons"; + read_sync_double(input.nelec_delta); + this->add_item(item); + } + { + Input_Item item("nupdown"); + item.annotation = "the difference number of electrons between spin-up " + "and spin-down"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.nupdown = doublevalue; + para.sys.two_fermi = true; + }; + + sync_double(input.nupdown); + this->add_item(item); + } + { + Input_Item item("dft_functional"); + item.annotation = "exchange correlation functional"; + read_sync_string(input.dft_functional); + this->add_item(item); + } + { + Input_Item item("xc_temperature"); + item.annotation = "temperature for finite temperature functionals"; + read_sync_double(input.xc_temperature); + this->add_item(item); + } + { + Input_Item item("pseudo_rcut"); + item.annotation = "default #exchange correlation functional"; + read_sync_double(input.pseudo_rcut); + this->add_item(item); + } + { + Input_Item item("pseudo_mesh"); + item.annotation = "0: use our own mesh to do radial renormalization; " + "1: use mesh as in QE"; + read_sync_bool(input.pseudo_mesh); + this->add_item(item); + } + { + Input_Item item("nspin"); + item.annotation = "1: single spin; 2: up and down spin; 4: noncollinear spin"; + read_sync_int(input.nspin); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.noncolin || para.input.lspinorb) + { + para.input.nspin = 4; + } + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.nspin != 1 && para.input.nspin != 2 && para.input.nspin != 4) + { + ModuleBase::WARNING_QUIT("ReadInput", "nspin should be 1, 2 or 4."); + } + }; + this->add_item(item); + } + { + Input_Item item("pw_diag_nmax"); + item.annotation = "max iteration number for cg"; + read_sync_int(input.pw_diag_nmax); + this->add_item(item); + } + { + Input_Item item("pw_diag_thr"); + item.annotation = "threshold for eigenvalues is cg electron iterations"; + read_sync_double(input.pw_diag_thr); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.calculation == "get_S" && para.input.basis_type == "pw") + { + if (para.input.pw_diag_thr > 1.0e-3) + { + para.input.pw_diag_thr = 1.0e-5; + } + } + }; + this->add_item(item); + } + { + Input_Item item("pw_diag_ndim"); + item.annotation = "dimension of workspace for Davidson diagonalization"; + read_sync_int(input.pw_diag_ndim); + this->add_item(item); + } + { + Input_Item item("diago_cg_prec"); + item.annotation = "diago_cg_prec"; + read_sync_int(input.diago_cg_prec); + this->add_item(item); + } + { + Input_Item item("smearing_method"); + item.annotation = "type of smearing_method: gauss; fd; fixed; mp; mp2; mv"; + read_sync_string(input.smearing_method); + this->add_item(item); + } + { + Input_Item item("smearing_sigma"); + item.annotation = "energy range for smearing"; + read_sync_double(input.smearing_sigma); + this->add_item(item); + } + { + // Energy range for smearing, + //`smearing_sigma` = 1/2 *kB* `smearing_sigma_temp`. + Input_Item tmp_item("smearing_sigma_temp"); + tmp_item.read_value + = [](const Input_Item& item, Parameter& para) { para.input.smearing_sigma = 3.166815e-6 * doublevalue; }; + // only to set smearing_sigma, so no need to write to output INPUT file + // or bcast. + this->add_item(tmp_item); + } + { + Input_Item item("mixing_type"); + item.annotation = "plain; pulay; broyden"; + read_sync_string(input.mixing_mode); + this->add_item(item); + } + { + Input_Item item("mixing_beta"); + item.annotation = "mixing parameter: 0 means no new charge"; + read_sync_double(input.mixing_beta); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.mixing_beta < 0.0) + { + if (para.input.nspin == 1) + { + para.input.mixing_beta = 0.8; + } + else if (para.input.nspin == 2) + { + para.input.mixing_beta = 0.4; + para.input.mixing_beta_mag = 1.6; + para.input.mixing_gg0_mag = 0.0; + } + else if (para.input.nspin == 4) // I will add this + { + para.input.mixing_beta = 0.4; + para.input.mixing_beta_mag = 1.6; + para.input.mixing_gg0_mag = 0.0; + } + } + }; + this->add_item(item); + } + { + Input_Item item("mixing_ndim"); + item.annotation = "mixing dimension in pulay or broyden"; + read_sync_int(input.mixing_ndim); + this->add_item(item); + } + { + Input_Item item("mixing_restart"); + item.annotation = "threshold to restart mixing during SCF"; + read_sync_double(input.mixing_restart); + this->add_item(item); + } + { + Input_Item item("mixing_gg0"); + item.annotation = "mixing parameter in kerker"; + read_sync_double(input.mixing_gg0); + this->add_item(item); + } + { + Input_Item item("mixing_beta_mag"); + item.annotation = "mixing parameter for magnetic density"; + read_sync_double(input.mixing_beta_mag); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.mixing_beta_mag < 0.0) + { + if (para.input.nspin == 2 || para.input.nspin == 4) + { + if (para.input.mixing_beta <= 0.4) + { + para.input.mixing_beta_mag = 4 * para.input.mixing_beta; + } + else + { + para.input.mixing_beta_mag = 1.6; // 1.6 can be discussed + } + } + } + }; + this->add_item(item); + } + { + Input_Item item("mixing_gg0_mag"); + item.annotation = "mixing parameter in kerker"; + read_sync_double(input.mixing_gg0_mag); + this->add_item(item); + } + { + Input_Item item("mixing_gg0_min"); + item.annotation = "the minimum kerker coefficient"; + read_sync_double(input.mixing_gg0_min); + this->add_item(item); + } + { + Input_Item item("mixing_angle"); + item.annotation = "angle mixing parameter for non-colinear calculations"; + read_sync_double(input.mixing_angle); + this->add_item(item); + } + { + Input_Item item("mixing_tau"); + item.annotation = "whether to mix tau in mGGA calculation"; + read_sync_bool(input.mixing_tau); + this->add_item(item); + } + { + Input_Item item("mixing_dftu"); + item.annotation = "whether to mix locale in DFT+U calculation"; + read_sync_bool(input.mixing_dftu); + this->add_item(item); + } + { + Input_Item item("mixing_dmr"); + item.annotation = "whether to mix real-space density matrix"; + read_sync_bool(input.mixing_dmr); + this->add_item(item); + } + { + Input_Item item("gamma_only"); + item.annotation = "Only for localized orbitals set and gamma point. If " + "set to 1, a fast algorithm is used"; + read_sync_bool(input.gamma_only); + item.reset_value = [](const Input_Item& item, Parameter& para) { + Input_para& input = para.input; + std::string& basis_type = input.basis_type; + bool& gamma_only = input.gamma_only; + if (basis_type == "pw" && gamma_only) // pengfei Li add 2015-1-31 + { + gamma_only = false; + GlobalV::ofs_warning << " WARNING : gamma_only has not been " + "implemented for pw yet" + << std::endl; + GlobalV::ofs_warning << " the INPUT parameter gamma_only has been reset to 0" << std::endl; + GlobalV::ofs_warning << " and a new KPT is generated with " + "gamma point as the only k point" + << std::endl; + + GlobalV::ofs_warning << " Auto generating k-points file: " << input.kpoint_file << std::endl; + std::ofstream ofs(input.kpoint_file.c_str()); + ofs << "K_POINTS" << std::endl; + ofs << "0" << std::endl; + ofs << "Gamma" << std::endl; + ofs << "1 1 1 0 0 0" << std::endl; + ofs.close(); + } + else if (basis_type == "lcao" && gamma_only == 1) + { + para.sys.gamma_only_local = true; + // std::cout << "gamma_only_local =" << gamma_only_local << + // std::endl; + if (input.esolver_type == "tddft") + { + GlobalV::ofs_running << " WARNING : gamma_only is not applicable for tddft" << std::endl; + para.sys.gamma_only_local = false; + } + } + + if ((input.out_mat_r || input.out_mat_hs2 || input.out_mat_t || input.out_mat_dh || input.out_hr_npz + || input.out_dm_npz || input.dm_to_rho) + && para.sys.gamma_only_local) + { + ModuleBase::WARNING_QUIT("ReadInput", + "output of r(R)/H(R)/S(R)/T(R)/dH(R)/DM(R) is not " + "available for gamma only calculations"); + } + }; + this->add_item(item); + } + { + Input_Item item("scf_nmax"); + item.annotation = "number of electron iterations"; + read_sync_int(input.scf_nmax); + this->add_item(item); + } + { + Input_Item item("scf_thr"); + item.annotation = "charge density error"; + read_sync_double(input.scf_thr); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.scf_thr == -1.0) + { + if (para.input.basis_type == "lcao" || para.input.basis_type == "lcao_in_pw") + { + para.input.scf_thr = 1.0e-7; + } + else if (para.input.basis_type == "pw" && para.input.calculation != "nscf") + { + para.input.scf_thr = 1.0e-9; + } + else if (para.input.basis_type == "pw" && para.input.calculation == "nscf") + { + para.input.scf_thr = 1.0e-6; + // In NSCF calculation, the diagonalization threshold is set + // to 0.1*scf/nelec. In other words, the scf_thr is used to + // control diagonalization convergence threthod in NSCF. In + // this case, the default 1.0e-9 is too strict. renxi + // 20230908 + } + } + }; + this->add_item(item); + } + { + Input_Item item("scf_thr_type"); + item.annotation = "type of the criterion of scf_thr, 1: reci drho for " + "pw, 2: real drho for lcao"; + read_sync_int(input.scf_thr_type); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.scf_thr_type == -1) + { + if (para.input.basis_type == "lcao" || para.input.basis_type == "lcao_in_pw") + { + para.input.scf_thr_type = 2; + } + else if (para.input.basis_type == "pw") + { + para.input.scf_thr_type = 1; + } + } + }; + this->add_item(item); + } + { + Input_Item item("lspinorb"); + item.annotation = "consider the spin-orbit interaction"; + read_sync_bool(input.lspinorb); + this->add_item(item); + } + { + Input_Item item("noncolin"); + item.annotation = "using non-collinear-spin"; + read_sync_bool(input.noncolin); + this->add_item(item); + } + { + Input_Item item("soc_lambda"); + item.annotation = "The fraction of averaged SOC pseudopotential is " + "given by (1-soc_lambda)"; + read_sync_double(input.soc_lambda); + this->add_item(item); + } + + // LCAO + { + Input_Item item("nb2d"); + item.annotation = "matrix 2d division"; + read_sync_int(input.nb2d); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.nb2d < 0) + { + ModuleBase::WARNING_QUIT("ReadInput", "nb2d should be greater than 0"); + } + }; + this->add_item(item); + } + { + Input_Item item("lmaxmax"); + item.annotation = "maximum of l channels used"; + read_sync_int(input.lmaxmax); + this->add_item(item); + } + { + Input_Item item("lcao_ecut"); + item.annotation = "energy cutoff for LCAO"; + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.lcao_ecut == 0 && para.input.basis_type == "lcao") + { + para.input.lcao_ecut = para.input.ecutwfc; + ModuleBase::GlobalFunc::AUTO_SET("lcao_ecut", para.input.ecutwfc); + } + }; + read_sync_double(input.lcao_ecut); + this->add_item(item); + } + { + Input_Item item("lcao_dk"); + item.annotation = "delta k for 1D integration in LCAO"; + read_sync_double(input.lcao_dk); + this->add_item(item); + } + { + Input_Item item("lcao_dr"); + item.annotation = "delta r for 1D integration in LCAO"; + read_sync_double(input.lcao_dr); + this->add_item(item); + } + { + Input_Item item("lcao_rmax"); + item.annotation = "max R for 1D two-center integration table"; + read_sync_double(input.lcao_rmax); + this->add_item(item); + } + { + Input_Item item("search_radius"); + item.annotation = "input search radius (Bohr)"; + read_sync_double(input.search_radius); + this->add_item(item); + } + { + Input_Item item("search_pbc"); + item.annotation = "input periodic boundary condition"; + read_sync_bool(input.search_pbc); + this->add_item(item); + } + { + Input_Item item("bx"); + item.annotation = "division of an element grid in FFT grid along x"; + read_sync_int(input.bx); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.bx > 10) + { + ModuleBase::WARNING_QUIT("ReadInput", "bx should be no more than 10"); + } + }; + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.basis_type == "pw" || para.input.basis_type == "lcao_in_pw" + || para.input.calculation == "get_wf") + { + para.input.bx = 1; + para.input.by = 1; + para.input.bz = 1; + } + }; + this->add_item(item); + } + { + Input_Item item("by"); + item.annotation = "division of an element grid in FFT grid along y"; + read_sync_int(input.by); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.by > 10) + { + ModuleBase::WARNING_QUIT("ReadInput", "by should be no more than 10"); + } + }; + this->add_item(item); + } + { + Input_Item item("bz"); + item.annotation = "division of an element grid in FFT grid along z"; + read_sync_int(input.bz); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.bz > 10) + { + ModuleBase::WARNING_QUIT("ReadInput", "bz should be no more than 10"); + } + }; + this->add_item(item); + } + { + Input_Item item("elpa_num_thread"); + item.annotation = "Number of threads need to use in elpa"; + read_sync_int(input.elpa_num_thread); + this->add_item(item); + } + { + Input_Item item("num_stream"); + item.annotation = "the nstream in compute the LCAO with CUDA"; + read_sync_int(input.nstream); + this->add_item(item); + } + { + Input_Item item("bessel_nao_ecut"); + item.annotation = "energy cutoff for spherical bessel functions(Ry)"; + read_sync_string(input.bessel_nao_ecut); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.bessel_nao_ecut == "default") + { + para.input.bessel_nao_ecut = std::to_string(para.input.ecutwfc); + } + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (std::stod(para.input.bessel_nao_ecut) < 0) + { + ModuleBase::WARNING_QUIT("ReadInput", "bessel_nao_ecut must >= 0"); + } + }; + this->add_item(item); + } + { + Input_Item item("bessel_nao_tolerence"); + item.annotation = "tolerence for spherical bessel root"; + read_sync_double(input.bessel_nao_tolerence); + this->add_item(item); + } + { + Input_Item item("bessel_nao_rcut"); + item.annotation = "radial cutoff for spherical bessel functions(a.u.)"; + item.read_value = [](const Input_Item& item, Parameter& para) { + size_t count = item.get_size(); + for (int i = 0; i < count; i++) + { + para.input.bessel_nao_rcuts.push_back(std::stod(item.str_values[i])); + } + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + for(auto rcut: para.input.bessel_nao_rcuts) + { + if (rcut < 0) + { + ModuleBase::WARNING_QUIT("ReadInput", "bessel_nao_rcut must >= 0"); + } + } + }; + sync_doublevec(input.bessel_nao_rcuts, para.input.bessel_nao_rcuts.size(), 0.0); + this->add_item(item); + } + { + Input_Item item("bessel_nao_smooth"); + item.annotation = "spherical bessel smooth or not"; + read_sync_bool(input.bessel_nao_smooth); + this->add_item(item); + } + { + Input_Item item("bessel_nao_sigma"); + item.annotation = "spherical bessel smearing_sigma"; + read_sync_double(input.bessel_nao_sigma); + this->add_item(item); + } +} +} // namespace ModuleIO diff --git a/source/module_io/read_input_item_exx_dftu.cpp b/source/module_io/read_input_item_exx_dftu.cpp new file mode 100644 index 0000000000..4763138da1 --- /dev/null +++ b/source/module_io/read_input_item_exx_dftu.cpp @@ -0,0 +1,451 @@ +#include "module_base/constants.h" +#include "module_base/tool_quit.h" +#include "read_input.h" +#include "read_input_tool.h" +namespace ModuleIO +{ +void ReadInput::item_exx() +{ + // EXX + { + Input_Item item("exx_hybrid_alpha"); + item.annotation = "fraction of Fock exchange in hybrid functionals"; + read_sync_string(input.exx_hybrid_alpha); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.exx_hybrid_alpha == "default") + { + std::string& dft_functional = para.input.dft_functional; + std::string dft_functional_lower = dft_functional; + std::transform(dft_functional.begin(), dft_functional.end(), dft_functional_lower.begin(), tolower); + if (dft_functional_lower == "hf") + { + para.input.exx_hybrid_alpha = "1"; + } + else if (dft_functional_lower == "pbe0" || dft_functional_lower == "hse" + || dft_functional_lower == "scan0") + { + para.input.exx_hybrid_alpha = "0.25"; + } + else + { // no exx in scf, but will change to non-zero in + // postprocess like rpa + para.input.exx_hybrid_alpha = "0"; + } + } + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + const double exx_hybrid_alpha_value = std::stod(para.input.exx_hybrid_alpha); + if (exx_hybrid_alpha_value < 0 || exx_hybrid_alpha_value > 1) + { + ModuleBase::WARNING_QUIT("ReadInput", "must 0 <= exx_hybrid_alpha <= 1"); + } + }; + this->add_item(item); + } + { + Input_Item item("exx_hse_omega"); + item.annotation = "range-separation parameter in HSE functional"; + read_sync_double(input.exx_hse_omega); + this->add_item(item); + } + { + Input_Item item("exx_separate_loop"); + item.annotation = "if 1, a two-step method is employed, else it will " + "start with a GGA-Loop, and then Hybrid-Loop"; + read_sync_bool(input.exx_separate_loop); + this->add_item(item); + } + { + Input_Item item("exx_hybrid_step"); + item.annotation = "the maximal electronic iteration number in the " + "evaluation of Fock exchange"; + read_sync_int(input.exx_hybrid_step); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.exx_hybrid_step <= 0) + { + ModuleBase::WARNING_QUIT("ReadInput", "exx_hybrid_step must > 0"); + } + }; + this->add_item(item); + } + { + Input_Item item("exx_mixing_beta"); + item.annotation = "mixing_beta for outer-loop when exx_separate_loop=1"; + read_sync_double(input.exx_mixing_beta); + this->add_item(item); + } + { + Input_Item item("exx_lambda"); + item.annotation = "used to compensate for divergence points at G=0 in " + "the evaluation of Fock exchange using " + "lcao_in_pw method"; + read_sync_double(input.exx_lambda); + this->add_item(item); + } + { + Input_Item item("exx_real_number"); + item.annotation = "exx calculated in real or complex"; + read_sync_string(input.exx_real_number); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.exx_real_number == "default") + { + if (para.input.gamma_only) + { + para.input.exx_real_number = "1"; + } + else + { + para.input.exx_real_number = "0"; + } + } + }; + this->add_item(item); + } + { + Input_Item item("exx_pca_threshold"); + item.annotation = "threshold to screen on-site ABFs in exx"; + read_sync_double(input.exx_pca_threshold); + this->add_item(item); + } + { + Input_Item item("exx_c_threshold"); + item.annotation = "threshold to screen C matrix in exx"; + read_sync_double(input.exx_c_threshold); + this->add_item(item); + } + { + Input_Item item("exx_v_threshold"); + item.annotation = "threshold to screen C matrix in exx"; + read_sync_double(input.exx_v_threshold); + this->add_item(item); + } + { + Input_Item item("exx_dm_threshold"); + item.annotation = "threshold to screen density matrix in exx"; + read_sync_double(input.exx_dm_threshold); + this->add_item(item); + } + { + Input_Item item("exx_schwarz_threshold"); + item.annotation = "threshold to screen exx using Cauchy-Schwartz inequality"; + read_sync_double(input.exx_schwarz_threshold); + this->add_item(item); + } + { + Input_Item item("exx_cauchy_threshold"); + item.annotation = "threshold to screen exx using Cauchy-Schwartz inequality"; + read_sync_double(input.exx_cauchy_threshold); + this->add_item(item); + } + { + Input_Item item("exx_c_grad_threshold"); + item.annotation = "threshold to screen nabla C matrix in exx"; + read_sync_double(input.exx_c_grad_threshold); + this->add_item(item); + } + { + Input_Item item("exx_v_grad_threshold"); + item.annotation = "threshold to screen nabla V matrix in exx"; + read_sync_double(input.exx_v_grad_threshold); + this->add_item(item); + } + { + Input_Item item("exx_cauchy_force_threshold"); + item.annotation = "threshold to screen exx force using Cauchy-Schwartz inequality"; + read_sync_double(input.exx_cauchy_force_threshold); + this->add_item(item); + } + { + Input_Item item("exx_cauchy_stress_threshold"); + item.annotation = "threshold to screen exx stress using Cauchy-Schwartz inequality"; + read_sync_double(input.exx_cauchy_stress_threshold); + this->add_item(item); + } + { + Input_Item item("exx_ccp_rmesh_times"); + item.annotation = "how many times larger the radial mesh required for " + "calculating Columb potential is to that " + "of atomic orbitals"; + read_sync_string(input.exx_ccp_rmesh_times); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.exx_ccp_rmesh_times == "default") + { + std::string& dft_functional = para.input.dft_functional; + std::string dft_functional_lower = dft_functional; + std::transform(dft_functional.begin(), dft_functional.end(), dft_functional_lower.begin(), tolower); + if (dft_functional_lower == "hf" || dft_functional_lower == "pbe0" || dft_functional_lower == "scan0") + { + para.input.exx_ccp_rmesh_times = "5"; + } + else if (dft_functional_lower == "hse") + { + para.input.exx_ccp_rmesh_times = "1.5"; + } + else + { // no exx in scf + para.input.exx_ccp_rmesh_times = "1"; + } + } + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (std::stod(para.input.exx_ccp_rmesh_times) < 1) + { + ModuleBase::WARNING_QUIT("ReadInput", "exx_ccp_rmesh_times must >= 1"); + } + }; + this->add_item(item); + } + { + Input_Item item("exx_distribute_type"); + item.annotation = "exx_distribute_type"; + read_sync_string(input.exx_distribute_type); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.exx_distribute_type != "htime" && para.input.exx_distribute_type != "kmeans2" + && para.input.exx_distribute_type != "kmeans1" && para.input.exx_distribute_type != "order") + { + ModuleBase::WARNING_QUIT("ReadInput", + "exx_distribute_type must be htime or " + "kmeans2 or kmeans1 or order"); + } + }; + this->add_item(item); + } + { + Input_Item item("exx_opt_orb_lmax"); + item.annotation = "the maximum l of the spherical Bessel functions for opt ABFs"; + read_sync_int(input.exx_opt_orb_lmax); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.exx_opt_orb_lmax < 0) + { + ModuleBase::WARNING_QUIT("ReadInput", "exx_opt_orb_lmax must >= 0"); + } + }; + this->add_item(item); + } + { + Input_Item item("exx_opt_orb_ecut"); + item.annotation = "the cut-off of plane wave expansion for opt ABFs"; + read_sync_double(input.exx_opt_orb_ecut); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.exx_opt_orb_ecut < 0) + { + ModuleBase::WARNING_QUIT("ReadInput", "exx_opt_orb_ecut must >= 0"); + } + }; + this->add_item(item); + } + { + Input_Item item("exx_opt_orb_tolerence"); + item.annotation = "the threshold when solving for the zeros of " + "spherical Bessel functions for opt ABFs"; + read_sync_double(input.exx_opt_orb_tolerence); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.exx_opt_orb_tolerence < 0) + { + ModuleBase::WARNING_QUIT("ReadInput", "exx_opt_orb_tolerence must >= 0"); + } + }; + this->add_item(item); + } + { + Input_Item item("rpa_ccp_rmesh_times"); + item.annotation = "how many times larger the radial mesh required for " + "calculating Columb potential is to that " + "of atomic orbitals"; + read_sync_double(input.rpa_ccp_rmesh_times); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.rpa_ccp_rmesh_times < 1) + { + ModuleBase::WARNING_QUIT("ReadInput", "rpa_ccp_rmesh_times must >= 1"); + } + }; + this->add_item(item); + } +} +void ReadInput::item_dftu() +{ + // dft+u + { + Input_Item item("dft_plus_u"); + item.annotation = "DFT+U correction method"; + read_sync_int(input.dft_plus_u); + item.reset_value = [](const Input_Item& item, Parameter& para) { + bool all_minus1 = true; + for (auto& val: para.input.orbital_corr) + { + if (val != -1) + { + all_minus1 = false; + break; + } + } + if (all_minus1) + { + if (para.input.dft_plus_u != 0) + { + para.input.dft_plus_u = 0; + ModuleBase::WARNING("ReadInput", "No atoms are correlated, DFT+U is closed!!!"); + } + } + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + const Input_para& input = para.input; + if (input.dft_plus_u != 0) + { + if (input.basis_type != "lcao") + { + ModuleBase::WARNING_QUIT("ReadInput", "WRONG ARGUMENTS OF basis_type, only lcao is support"); + } + if (input.ks_solver != "genelpa" && input.ks_solver != "scalapack_gvx" && input.ks_solver != "default") + { + std::cout << " You'are using " << input.ks_solver << std::endl; + ModuleBase::WARNING_QUIT("ReadInput", + "WRONG ARGUMENTS OF ks_solver in DFT+U routine, only " + "genelpa and scalapack_gvx are supported "); + } + } + }; + this->add_item(item); + } + { + Input_Item item("dft_plus_dmft"); + item.annotation = "true:DFT+DMFT; false: standard DFT calcullation(default)"; + read_sync_bool(input.dft_plus_dmft); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.basis_type != "lcao" && para.input.dft_plus_dmft) + { + ModuleBase::WARNING_QUIT("ReadInput", "DFT+DMFT is only supported for lcao calculation."); + } + }; + this->add_item(item); + } + { + Input_Item item("yukawa_lambda"); + item.annotation = "default:0.0"; + read_sync_double(input.yukawa_lambda); + this->add_item(item); + } + { + Input_Item item("yukawa_potential"); + item.annotation = "default: false"; + read_sync_bool(input.yukawa_potential); + this->add_item(item); + } + { + Input_Item item("uramping"); + item.annotation = "increasing U values during SCF"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.uramping_eV = doublevalue; + para.sys.uramping = para.input.uramping_eV / ModuleBase::Ry_to_eV; + }; + item.reset_value = [](const Input_Item& item, Parameter& para) { + bool all_minus1 = true; + for (auto& val: para.input.orbital_corr) + { + if (val != -1) + { + all_minus1 = false; + break; + } + } + if (all_minus1) + { + if (para.sys.uramping != 0.0) + { + para.sys.uramping = 0.0; + ModuleBase::WARNING("ReadInput", "No atoms are correlated, U-ramping is closed!!!"); + } + } + }; + sync_double(input.uramping_eV); + this->add_item(item); + } + { + Input_Item item("omc"); + item.annotation = "the mode of occupation matrix control"; + read_sync_int(input.omc); + this->add_item(item); + } + { + Input_Item item("onsite_radius"); + item.annotation = "radius of the sphere for onsite projection (Bohr)"; + read_sync_double(input.onsite_radius); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.dft_plus_u == 1 && para.input.onsite_radius == 0.0) + { + // autoset onsite_radius to 5.0 as default + para.input.onsite_radius = 5.0; + } + }; + this->add_item(item); + } + { + Input_Item item("hubbard_u"); + item.annotation = "Hubbard Coulomb interaction parameter U(ev)"; + item.read_value = [](const Input_Item& item, Parameter& para) { + size_t count = item.get_size(); + for (int i = 0; i < count; i++) + { + para.input.hubbard_u_eV.push_back(std::stod(item.str_values[i])); + para.sys.hubbard_u.push_back(para.input.hubbard_u_eV[i] / ModuleBase::Ry_to_eV); + } + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (!item.is_read()) + { + return; + } + if (para.sys.hubbard_u.size() != para.input.ntype) + { + ModuleBase::WARNING_QUIT("ReadInput", + "hubbard_u should have the same " + "number of elements as ntype"); + } + for (auto& value: para.sys.hubbard_u) + { + if (value < -1.0e-3) + { + ModuleBase::WARNING_QUIT("ReadInput", "WRONG ARGUMENTS OF hubbard_u"); + } + } + }; + sync_doublevec(input.hubbard_u_eV, para.input.ntype, 0.0); + add_doublevec_bcast(sys.hubbard_u, para.input.ntype, 0.0); + this->add_item(item); + } + { + Input_Item item("orbital_corr"); + item.annotation = "which correlated orbitals need corrected ; d:2 " + ",f:3, do not need correction:-1"; + item.read_value = [](const Input_Item& item, Parameter& para) { + size_t count = item.get_size(); + for (int i = 0; i < count; i++) + { + para.input.orbital_corr.push_back(std::stoi(item.str_values[i])); + } + }; + + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (!item.is_read()) + { + return; + } + if (para.input.orbital_corr.size() != para.input.ntype) + { + ModuleBase::WARNING_QUIT("ReadInput", + "orbital_corr should have the same " + "number of elements as ntype"); + } + for (auto& val: para.input.orbital_corr) + { + if (val < -1 || val > 3) + { + ModuleBase::WARNING_QUIT("ReadInput", "WRONG ARGUMENTS OF orbital_corr"); + } + } + }; + sync_intvec(input.orbital_corr, para.input.ntype, -1); + this->add_item(item); + } +} +} // namespace ModuleIO \ No newline at end of file diff --git a/source/module_io/read_input_item_lcao.cpp b/source/module_io/read_input_item_lcao.cpp deleted file mode 100644 index 2046234a86..0000000000 --- a/source/module_io/read_input_item_lcao.cpp +++ /dev/null @@ -1,350 +0,0 @@ - -#include - -#include "module_base/global_function.h" -#include "module_base/tool_quit.h" -#include "read_input.h" -#include "read_input_tool.h" -namespace ModuleIO -{ -void ReadInput::item_lcao() -{ - { - Input_Item item("basis_type"); - item.annotation = "PW; LCAO in pw; LCAO"; - read_sync_string(input.basis_type); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.towannier90) - { - if (para.input.basis_type == "lcao_in_pw") - { - para.input.basis_type = "lcao"; - } - } - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - const std::vector basis_types = {"pw", "lcao_in_pw", "lcao"}; - if (!find_str(basis_types, para.input.basis_type)) - { - ModuleBase::WARNING_QUIT("ReadInput", "basis_type should be pw, lcao_in_pw, or lcao"); - } - }; - this->add_item(item); - } - { - Input_Item item("gamma_only"); - item.annotation = "Only for localized orbitals set and gamma point. If " - "set to 1, a fast algorithm is used"; - read_sync_bool(input.gamma_only); - item.reset_value = [](const Input_Item& item, Parameter& para) { - Input_para& input = para.input; - std::string& basis_type = input.basis_type; - bool& gamma_only = input.gamma_only; - if (basis_type == "pw" && gamma_only) // pengfei Li add 2015-1-31 - { - gamma_only = false; - GlobalV::ofs_warning << " WARNING : gamma_only has not been " - "implemented for pw yet" - << std::endl; - GlobalV::ofs_warning << " the INPUT parameter gamma_only has been reset to 0" << std::endl; - GlobalV::ofs_warning << " and a new KPT is generated with " - "gamma point as the only k point" - << std::endl; - - GlobalV::ofs_warning << " Auto generating k-points file: " << input.kpoint_file << std::endl; - std::ofstream ofs(input.kpoint_file.c_str()); - ofs << "K_POINTS" << std::endl; - ofs << "0" << std::endl; - ofs << "Gamma" << std::endl; - ofs << "1 1 1 0 0 0" << std::endl; - ofs.close(); - } - else if (basis_type == "lcao" && gamma_only == 1) - { - para.sys.gamma_only_local = true; - // std::cout << "gamma_only_local =" << gamma_only_local << - // std::endl; - if (input.esolver_type == "tddft") - { - GlobalV::ofs_running << " WARNING : gamma_only is not applicable for tddft" << std::endl; - para.sys.gamma_only_local = false; - } - } - - if ((input.out_mat_r || input.out_mat_hs2 || input.out_mat_t || input.out_mat_dh || input.out_hr_npz - || input.out_dm_npz || input.dm_to_rho) - && para.sys.gamma_only_local) - { - ModuleBase::WARNING_QUIT("ReadInput", - "output of r(R)/H(R)/S(R)/T(R)/dH(R)/DM(R) is not " - "available for gamma only calculations"); - } - }; - this->add_item(item); - } - { - Input_Item item("search_radius"); - item.annotation = "input search radius (Bohr)"; - read_sync_double(input.search_radius); - this->add_item(item); - } - { - Input_Item item("search_pbc"); - item.annotation = "input periodic boundary condition"; - read_sync_bool(input.search_pbc); - this->add_item(item); - } - { - Input_Item item("lcao_ecut"); - item.annotation = "energy cutoff for LCAO"; - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.lcao_ecut == 0 && para.input.basis_type == "lcao") - { - para.input.lcao_ecut = para.input.ecutwfc; - ModuleBase::GlobalFunc::AUTO_SET("lcao_ecut", para.input.ecutwfc); - } - }; - read_sync_double(input.lcao_ecut); - this->add_item(item); - } - { - Input_Item item("lcao_dk"); - item.annotation = "delta k for 1D integration in LCAO"; - read_sync_double(input.lcao_dk); - this->add_item(item); - } - { - Input_Item item("lcao_dr"); - item.annotation = "delta r for 1D integration in LCAO"; - read_sync_double(input.lcao_dr); - this->add_item(item); - } - { - Input_Item item("lcao_rmax"); - item.annotation = "max R for 1D two-center integration table"; - read_sync_double(input.lcao_rmax); - this->add_item(item); - } - { - Input_Item item("out_mat_hs"); - item.annotation = "output H and S matrix (with precision 8)"; - item.read_value = [](const Input_Item& item, Parameter& para) { - size_t count = item.get_size(); - if (count == 1) - { - para.input.out_mat_hs[0] = std::stoi(item.str_values[0]); - para.input.out_mat_hs[1] = 8; - } - else if (count == 2) - { - para.input.out_mat_hs[0] = std::stoi(item.str_values[0]); - para.input.out_mat_hs[1] = std::stoi(item.str_values[1]); - } - else - { - ModuleBase::WARNING_QUIT("ReadInput", "out_mat_hs should have 1 or 2 values"); - } - }; - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.qo_switch) - { - para.input.out_mat_hs[0] = 1; // print H(k) and S(k) - } - }; - sync_intvec(input.out_mat_hs, 2, 0); - this->add_item(item); - } - { - Input_Item item("out_mat_hs2"); - item.annotation = "output H(R) and S(R) matrix"; - read_sync_bool(input.out_mat_hs2); - this->add_item(item); - } - { - Input_Item item("out_mat_dh"); - item.annotation = "output of derivative of H(R) matrix"; - read_sync_bool(input.out_mat_dh); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.out_mat_dh && para.input.nspin == 4) - { - ModuleBase::WARNING_QUIT("ReadInput", "out_mat_dh is not available for nspin = 4"); - } - }; - this->add_item(item); - } - { - Input_Item item("out_mat_xc"); - item.annotation = "output exchange-correlation matrix in KS-orbital representation"; - read_sync_bool(input.out_mat_xc); - this->add_item(item); - } - { - Input_Item item("out_hr_npz"); - item.annotation = "output hr(I0,JR) submatrices in npz format"; - read_sync_bool(input.out_hr_npz); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.out_hr_npz) - { -#ifndef __USECNPY - ModuleBase::WARNING_QUIT("ReadInput", - "to write in npz format, please " - "recompile with -DENABLE_CNPY=1"); -#endif - } - }; - this->add_item(item); - } - { - Input_Item item("out_dm_npz"); - item.annotation = "output dmr(I0,JR) submatrices in npz format"; - read_sync_bool(input.out_dm_npz); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.out_dm_npz) - { -#ifndef __USECNPY - ModuleBase::WARNING_QUIT("ReadInput", - "to write in npz format, please " - "recompile with -DENABLE_CNPY=1"); -#endif - } - }; - this->add_item(item); - } - { - Input_Item item("dm_to_rho"); - item.annotation = "reads dmr in npz format and calculates electron density"; - read_sync_bool(input.dm_to_rho); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.dm_to_rho && GlobalV::NPROC > 1) - { - ModuleBase::WARNING_QUIT("ReadInput", "dm_to_rho is not available for parallel calculations"); - } - if (para.input.dm_to_rho) - { -#ifndef __USECNPY - ModuleBase::WARNING_QUIT("ReadInput", - "to write in npz format, please " - "recompile with -DENABLE_CNPY=1"); -#endif - } - }; - this->add_item(item); - } - { - Input_Item item("out_interval"); - item.annotation = "interval for printing H(R) and S(R) matrix during MD"; - read_sync_int(input.out_interval); - this->add_item(item); - } - { - Input_Item item("out_app_flag"); - item.annotation = "whether output r(R), H(R), S(R), T(R), and dH(R) " - "matrices in an append manner during MD"; - read_sync_bool(input.out_app_flag); - this->add_item(item); - } - { - Input_Item item("out_ndigits"); - item.annotation = "the length of decimal part of output data"; - read_sync_int(input.out_ndigits); - this->add_item(item); - } - { - Input_Item item("out_mat_t"); - item.annotation = "output T(R) matrix"; - read_sync_bool(input.out_mat_t); - this->add_item(item); - } - { - Input_Item item("out_element_info"); - item.annotation = "output (projected) wavefunction of each element"; - read_sync_bool(input.out_element_info); - this->add_item(item); - } - { - Input_Item item("out_mat_r"); - item.annotation = "output r(R) matrix"; - read_sync_bool(input.out_mat_r); - this->add_item(item); - } - { - Input_Item item("out_wfc_lcao"); - item.annotation = "ouput LCAO wave functions, 0, no output 1: text, 2: binary"; - read_sync_int(input.out_wfc_lcao); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.qo_switch) - { - para.input.out_wfc_lcao = 1; - } - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.out_wfc_lcao < 0 || para.input.out_wfc_lcao > 2) - { - ModuleBase::WARNING_QUIT("ReadInput", "out_wfc_lcao should be 0, 1, or 2"); - } - if (para.input.basis_type != "lcao" && para.input.out_wfc_lcao != 0) - { - ModuleBase::WARNING_QUIT("ReadInput", "out_wfc_lcao is only available for basis_type = lcao"); - } - }; - this->add_item(item); - } - { - Input_Item item("bx"); - item.annotation = "division of an element grid in FFT grid along x"; - read_sync_int(input.bx); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.bx > 10) - { - ModuleBase::WARNING_QUIT("ReadInput", "bx should be no more than 10"); - } - }; - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.basis_type == "pw" || para.input.basis_type == "lcao_in_pw" - || para.input.calculation == "get_wf") - { - para.input.bx = 1; - para.input.by = 1; - para.input.bz = 1; - } - }; - this->add_item(item); - } - { - Input_Item item("by"); - item.annotation = "division of an element grid in FFT grid along y"; - read_sync_int(input.by); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.by > 10) - { - ModuleBase::WARNING_QUIT("ReadInput", "by should be no more than 10"); - } - }; - this->add_item(item); - } - { - Input_Item item("bz"); - item.annotation = "division of an element grid in FFT grid along z"; - read_sync_int(input.bz); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.bz > 10) - { - ModuleBase::WARNING_QUIT("ReadInput", "bz should be no more than 10"); - } - }; - this->add_item(item); - } - { - Input_Item item("num_stream"); - item.annotation = "the nstream in compute the LCAO with CUDA"; - read_sync_int(input.nstream); - this->add_item(item); - } - { - Input_Item item("elpa_num_thread"); - item.annotation = "Number of threads need to use in elpa"; - read_sync_int(input.elpa_num_thread); - this->add_item(item); - } -} -} // namespace ModuleIO \ No newline at end of file diff --git a/source/module_io/read_input_item_model.cpp b/source/module_io/read_input_item_model.cpp new file mode 100644 index 0000000000..964e0f2c52 --- /dev/null +++ b/source/module_io/read_input_item_model.cpp @@ -0,0 +1,375 @@ +#include "module_base/global_function.h" +#include "module_base/tool_quit.h" +#include "read_input.h" +#include "read_input_tool.h" +namespace ModuleIO +{ +void ReadInput::item_model() +{ + // Electric field and dipole correction + { + Input_Item item("efield_flag"); + item.annotation = "add electric field"; + read_sync_bool(input.efield_flag); + this->add_item(item); + } + { + Input_Item item("dip_cor_flag"); + item.annotation = "dipole correction"; + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.dip_cor_flag && !para.input.efield_flag) + { + ModuleBase::WARNING_QUIT("ReadInput", "dipole correction is not active if efield_flag=false !"); + } + }; + read_sync_bool(input.dip_cor_flag); + this->add_item(item); + } + { + Input_Item item("efield_dir"); + item.annotation = "the direction of the electric field or dipole correction"; + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.gate_flag && para.input.efield_flag && !para.input.dip_cor_flag) + { + ModuleBase::WARNING_QUIT("ReadInput", + "gate field cannot be used with " + "efield if dip_cor_flag=false !"); + } + }; + read_sync_int(input.efield_dir); + this->add_item(item); + } + { + Input_Item item("efield_pos_max"); + item.annotation = "position of the maximum of the saw-like potential " + "along crystal axis efield_dir"; + read_sync_double(input.efield_pos_max); + this->add_item(item); + } + { + Input_Item item("efield_pos_dec"); + item.annotation = "zone in the unit cell where the saw-like potential decreases"; + read_sync_double(input.efield_pos_dec); + this->add_item(item); + } + { + Input_Item item("efield_amp"); + item.annotation = "amplitude of the electric field"; + read_sync_double(input.efield_amp); + this->add_item(item); + } + + // Gate field + { + Input_Item item("gate_flag"); + item.annotation = "compensating charge or not"; + read_sync_bool(input.gate_flag); + this->add_item(item); + } + { + Input_Item item("zgate"); + item.annotation = "position of charged plate"; + read_sync_double(input.zgate); + this->add_item(item); + } + + { + Input_Item item("block"); + item.annotation = "add a block potential or not"; + read_sync_bool(input.block); + this->add_item(item); + } + { + Input_Item item("block_down"); + item.annotation = "low bound of the block"; + read_sync_double(input.block_down); + this->add_item(item); + } + { + Input_Item item("block_up"); + item.annotation = "high bound of the block"; + read_sync_double(input.block_up); + this->add_item(item); + } + { + Input_Item item("block_height"); + item.annotation = "height of the block"; + read_sync_double(input.block_height); + this->add_item(item); + } + + // imlicit_solvation + { + Input_Item item("imp_sol"); + item.annotation = "calculate implicit solvation correction or not"; + read_sync_bool(input.imp_sol); + this->add_item(item); + } + { + Input_Item item("eb_k"); + item.annotation = "the relative permittivity of the bulk solvent"; + read_sync_double(input.eb_k); + this->add_item(item); + } + { + Input_Item item("tau"); + item.annotation = "the effective surface tension parameter"; + read_sync_double(input.tau); + this->add_item(item); + } + { + Input_Item item("sigma_k"); + item.annotation = "the width of the diffuse cavity"; + read_sync_double(input.sigma_k); + this->add_item(item); + } + { + Input_Item item("nc_k"); + item.annotation = "the cut-off charge density"; + read_sync_double(input.nc_k); + this->add_item(item); + } + + // vdW Correction + { + Input_Item item("vdw_method"); + item.annotation = "the method of calculating vdw (none ; d2 ; d3_0 ; d3_bj"; + read_sync_string(input.vdw_method); + this->add_item(item); + } + { + Input_Item item("vdw_s6"); + item.annotation = "scale parameter of d2/d3_0/d3_bj"; + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.vdw_s6 == "default") + { + if (para.input.vdw_method == "d2") + { + para.input.vdw_s6 = "0.75"; + } + else if (para.input.vdw_method == "d3_0" || para.input.vdw_method == "d3_bj") + { + para.input.vdw_s6 = "1.0"; + } + } + }; + read_sync_string(input.vdw_s6); + this->add_item(item); + } + { + Input_Item item("vdw_s8"); + item.annotation = "scale parameter of d3_0/d3_bj"; + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.vdw_s8 == "default") + { + if (para.input.vdw_method == "d3_0") + { + para.input.vdw_s8 = "0.722"; + } + else if (para.input.vdw_method == "d3_bj") + { + para.input.vdw_s8 = "0.7875"; + } + } + }; + read_sync_string(input.vdw_s8); + this->add_item(item); + } + { + Input_Item item("vdw_a1"); + item.annotation = "damping parameter of d3_0/d3_bj"; + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.vdw_a1 == "default") + { + if (para.input.vdw_method == "d3_0") + { + para.input.vdw_a1 = "1.217"; + } + else if (para.input.vdw_method == "d3_bj") + { + para.input.vdw_a1 = "0.4289"; + } + } + }; + read_sync_string(input.vdw_a1); + this->add_item(item); + } + { + Input_Item item("vdw_a2"); + item.annotation = "damping parameter of d3_bj"; + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.vdw_a2 == "default") + { + if (para.input.vdw_method == "d3_0") + { + para.input.vdw_a2 = "1.0"; + } + else if (para.input.vdw_method == "d3_bj") + { + para.input.vdw_a2 = "4.4407"; + } + } + }; + read_sync_string(input.vdw_a2); + this->add_item(item); + } + { + Input_Item item("vdw_d"); + item.annotation = "damping parameter of d2"; + read_sync_double(input.vdw_d); + this->add_item(item); + } + { + Input_Item item("vdw_abc"); + item.annotation = "third-order term?"; + read_sync_bool(input.vdw_abc); + this->add_item(item); + } + { + Input_Item item("vdw_c6_file"); + item.annotation = "filename of C6"; + read_sync_string(input.vdw_C6_file); + this->add_item(item); + } + { + Input_Item item("vdw_c6_unit"); + item.annotation = "unit of C6, Jnm6/mol or eVA6"; + read_sync_string(input.vdw_C6_unit); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if ((para.input.vdw_C6_unit != "Jnm6/mol") && (para.input.vdw_C6_unit != "eVA6")) + { + ModuleBase::WARNING_QUIT("ReadInput", "vdw_C6_unit must be Jnm6/mol or eVA6"); + } + }; + this->add_item(item); + } + { + Input_Item item("vdw_r0_file"); + item.annotation = "filename of R0"; + read_sync_string(input.vdw_R0_file); + this->add_item(item); + } + { + Input_Item item("vdw_r0_unit"); + item.annotation = "unit of R0, A or Bohr"; + read_sync_string(input.vdw_R0_unit); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if ((para.input.vdw_R0_unit != "A") && (para.input.vdw_R0_unit != "Bohr")) + { + ModuleBase::WARNING_QUIT("ReadInput", "vdw_R0_unit must be A or Bohr"); + } + }; + this->add_item(item); + } + { + Input_Item item("vdw_cutoff_type"); + item.annotation = "expression model of periodic structure, radius or period"; + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.vdw_cutoff_type != "radius" && para.input.vdw_cutoff_type != "period") + { + ModuleBase::WARNING_QUIT("ReadInput", "vdw_cutoff_type must be radius or period"); + } + }; + read_sync_string(input.vdw_cutoff_type); + this->add_item(item); + } + { + Input_Item item("vdw_cutoff_radius"); + item.annotation = "radius cutoff for periodic structure"; + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.vdw_cutoff_radius == "default") + { + if (para.input.vdw_method == "d2") + { + para.input.vdw_cutoff_radius = "56.6918"; + } + else if (para.input.vdw_method == "d3_0" || para.input.vdw_method == "d3_bj") + { + para.input.vdw_cutoff_radius = "95"; + } + else + { + para.input.vdw_cutoff_radius = "0"; + } + } + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (std::stod(para.input.vdw_cutoff_radius) <= 0 && para.input.vdw_method != "none") + { + ModuleBase::WARNING_QUIT("ReadInput", "vdw_cutoff_radius <= 0 is not allowd"); + } + }; + read_sync_string(input.vdw_cutoff_radius); + this->add_item(item); + } + { + Input_Item item("vdw_radius_unit"); + item.annotation = "unit of radius cutoff for periodic structure"; + read_sync_string(input.vdw_radius_unit); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if ((para.input.vdw_radius_unit != "A") && (para.input.vdw_radius_unit != "Bohr")) + { + ModuleBase::WARNING_QUIT("ReadInput", "vdw_radius_unit must be A or Bohr"); + } + }; + this->add_item(item); + } + { + Input_Item item("vdw_cn_thr"); + item.annotation = "radius cutoff for cn"; + read_sync_double(input.vdw_cn_thr); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.vdw_cn_thr <= 0) + { + ModuleBase::WARNING_QUIT("ReadInput", "vdw_cn_thr <= 0 is not allowd"); + } + }; + this->add_item(item); + } + { + Input_Item item("vdw_cn_thr_unit"); + item.annotation = "unit of cn_thr, Bohr or Angstrom"; + read_sync_string(input.vdw_cn_thr_unit); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if ((para.input.vdw_cn_thr_unit != "A") && (para.input.vdw_cn_thr_unit != "Bohr")) + { + ModuleBase::WARNING_QUIT("ReadInput", "vdw_cn_thr_unit must be A or Bohr"); + } + }; + this->add_item(item); + } + { + Input_Item item("vdw_cutoff_period"); + item.annotation = "periods of periodic structure"; + item.read_value = [](const Input_Item& item, Parameter& para) { + size_t count = item.get_size(); + if (count == 3) + { + para.input.vdw_cutoff_period[0] = std::stoi(item.str_values[0]); + para.input.vdw_cutoff_period[1] = std::stoi(item.str_values[1]); + para.input.vdw_cutoff_period[2] = std::stoi(item.str_values[2]); + } + else + { + ModuleBase::WARNING_QUIT("ReadInput", "vdw_cutoff_period should have 3 values"); + } + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.vdw_cutoff_period[0] <= 0 || para.input.vdw_cutoff_period[1] <= 0 + || para.input.vdw_cutoff_period[2] <= 0) + { + ModuleBase::WARNING_QUIT("ReadInput", "vdw_cutoff_period should be positive"); + } + }; + item.get_final_value = [](Input_Item& item, const Parameter& para) { + item.final_value << para.input.vdw_cutoff_period[0] << " " << para.input.vdw_cutoff_period[1] << " " + << para.input.vdw_cutoff_period[2]; + }; +#ifdef __MPI + bcastfuncs.push_back( + [](Parameter& para) { Parallel_Common::bcast_int((int*)¶.input.vdw_cutoff_period, 3); }); +#endif + this->add_item(item); + } +} +} // namespace ModuleIO \ No newline at end of file diff --git a/source/module_io/read_input_item_ofdft.cpp b/source/module_io/read_input_item_ofdft.cpp new file mode 100644 index 0000000000..9d4b90268e --- /dev/null +++ b/source/module_io/read_input_item_ofdft.cpp @@ -0,0 +1,135 @@ + +#include "module_base/global_function.h" +#include "module_base/tool_quit.h" +#include "read_input.h" +#include "read_input_tool.h" +namespace ModuleIO +{ +void ReadInput::item_ofdft() +{ + { + Input_Item item("of_kinetic"); + item.annotation = "kinetic energy functional, such as tf, vw, wt"; + read_sync_string(input.of_kinetic); + this->add_item(item); + } + { + Input_Item item("of_method"); + item.annotation = "optimization method used in OFDFT, including cg1, " + "cg2, tn (default)"; + read_sync_string(input.of_method); + this->add_item(item); + } + { + Input_Item item("of_conv"); + item.annotation = "the convergence criterion, potential, energy (default), or both"; + read_sync_string(input.of_conv); + this->add_item(item); + } + { + Input_Item item("of_tole"); + item.annotation = "tolerance of the energy change (in Ry) for " + "determining the convergence, default=2e-6 Ry"; + read_sync_double(input.of_tole); + this->add_item(item); + } + { + Input_Item item("of_tolp"); + item.annotation = "tolerance of potential for determining the " + "convergence, default=1e-5 in a.u."; + read_sync_double(input.of_tolp); + this->add_item(item); + } + { + Input_Item item("of_tf_weight"); + item.annotation = "weight of TF KEDF"; + read_sync_double(input.of_tf_weight); + this->add_item(item); + } + { + Input_Item item("of_vw_weight"); + item.annotation = "weight of vW KEDF"; + read_sync_double(input.of_vw_weight); + this->add_item(item); + } + { + Input_Item item("of_wt_alpha"); + item.annotation = "parameter alpha of WT KEDF"; + read_sync_double(input.of_wt_alpha); + this->add_item(item); + } + { + Input_Item item("of_wt_beta"); + item.annotation = "parameter beta of WT KEDF"; + read_sync_double(input.of_wt_beta); + this->add_item(item); + } + { + Input_Item item("of_wt_rho0"); + item.annotation = "the average density of system, used in WT KEDF, in Bohr^-3"; + read_sync_double(input.of_wt_rho0); + this->add_item(item); + } + { + Input_Item item("of_hold_rho0"); + item.annotation = "If set to 1, the rho0 will be fixed even if the " + "volume of system has changed, it will be " + "set to 1 automaticly if of_wt_rho0 is not zero"; + read_sync_bool(input.of_hold_rho0); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.of_wt_rho0 != 0) + { + para.input.of_hold_rho0 = true; // sunliang add 2022-06-17 + } + }; + this->add_item(item); + } + { + Input_Item item("of_lkt_a"); + item.annotation = "parameter a of LKT KEDF"; + read_sync_double(input.of_lkt_a); + this->add_item(item); + } + { + Input_Item item("of_full_pw"); + item.annotation = "If set to 1, ecut will be ignored when collect " + "planewaves, so that all planewaves will be used"; + read_sync_bool(input.of_full_pw); + this->add_item(item); + } + { + Input_Item item("of_full_pw_dim"); + item.annotation = "If of_full_pw = true, dimention of FFT is " + "testricted to be (0) either odd or even; (1) odd " + "only; (2) even only"; + read_sync_int(input.of_full_pw_dim); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (!para.input.of_full_pw) + { + para.input.of_full_pw_dim = 0; // sunliang add 2022-08-31 + } + }; + this->add_item(item); + } + { + Input_Item item("of_read_kernel"); + item.annotation = "If set to 1, the kernel of WT KEDF will be filled " + "from file of_kernel_file, not from " + "formula. Only usable for WT KEDF"; + read_sync_bool(input.of_read_kernel); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.of_kinetic != "wt") + { + para.input.of_read_kernel = false; // sunliang add 2022-09-12 + } + }; + this->add_item(item); + } + { + Input_Item item("of_kernel_file"); + item.annotation = "The name of WT kernel file."; + read_sync_string(input.of_kernel_file); + this->add_item(item); + } +} +} // namespace ModuleIO \ No newline at end of file diff --git a/source/module_io/read_input_item_other.cpp b/source/module_io/read_input_item_other.cpp index f1521ea4c0..4308fc59ae 100644 --- a/source/module_io/read_input_item_other.cpp +++ b/source/module_io/read_input_item_other.cpp @@ -1,1537 +1,17 @@ -#include - -#include -#include - -#include "module_base/constants.h" -#include "module_base/tool_quit.h" -#include "read_input.h" -#include "read_input_tool.h" - -namespace ModuleIO -{ -void ReadInput::item_others() -{ - // 10. Electric field and dipole correction - { - Input_Item item("efield_flag"); - item.annotation = "add electric field"; - read_sync_bool(input.efield_flag); - this->add_item(item); - } - { - Input_Item item("dip_cor_flag"); - item.annotation = "dipole correction"; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.dip_cor_flag && !para.input.efield_flag) - { - ModuleBase::WARNING_QUIT("ReadInput", "dipole correction is not active if efield_flag=false !"); - } - }; - read_sync_bool(input.dip_cor_flag); - this->add_item(item); - } - { - Input_Item item("efield_dir"); - item.annotation = "the direction of the electric field or dipole correction"; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.gate_flag && para.input.efield_flag && !para.input.dip_cor_flag) - { - ModuleBase::WARNING_QUIT("ReadInput", - "gate field cannot be used with " - "efield if dip_cor_flag=false !"); - } - }; - read_sync_int(input.efield_dir); - this->add_item(item); - } - { - Input_Item item("efield_pos_max"); - item.annotation = "position of the maximum of the saw-like potential " - "along crystal axis efield_dir"; - read_sync_double(input.efield_pos_max); - this->add_item(item); - } - { - Input_Item item("efield_pos_dec"); - item.annotation = "zone in the unit cell where the saw-like potential decreases"; - read_sync_double(input.efield_pos_dec); - this->add_item(item); - } - { - Input_Item item("efield_amp"); - item.annotation = "amplitude of the electric field"; - read_sync_double(input.efield_amp); - this->add_item(item); - } - - // 11. Gate field - { - Input_Item item("gate_flag"); - item.annotation = "compensating charge or not"; - read_sync_bool(input.gate_flag); - this->add_item(item); - } - { - Input_Item item("zgate"); - item.annotation = "position of charged plate"; - read_sync_double(input.zgate); - this->add_item(item); - } - { - Input_Item item("relax"); - item.annotation = "allow relaxation along the specific direction"; - read_sync_bool(input.relax); - this->add_item(item); - } - { - Input_Item item("block"); - item.annotation = "add a block potential or not"; - read_sync_bool(input.block); - this->add_item(item); - } - { - Input_Item item("block_down"); - item.annotation = "low bound of the block"; - read_sync_double(input.block_down); - this->add_item(item); - } - { - Input_Item item("block_up"); - item.annotation = "high bound of the block"; - read_sync_double(input.block_up); - this->add_item(item); - } - { - Input_Item item("block_height"); - item.annotation = "height of the block"; - read_sync_double(input.block_height); - this->add_item(item); - } - - // 12. Test - { - Input_Item item("out_alllog"); - item.annotation = "output information for each processor, when parallel"; - read_sync_bool(input.out_alllog); - this->add_item(item); - } - { - Input_Item item("nurse"); - item.annotation = "for coders"; - read_sync_int(input.nurse); - this->add_item(item); - } - { - Input_Item item("colour"); - item.annotation = "for coders, make their live colourful"; - read_sync_bool(input.colour); - this->add_item(item); - } - { - Input_Item item("t_in_h"); - item.annotation = "calculate the kinetic energy or not"; - read_sync_bool(input.t_in_h); - this->add_item(item); - } - { - Input_Item item("vl_in_h"); - item.annotation = "calculate the local potential or not"; - read_sync_bool(input.vl_in_h); - this->add_item(item); - } - { - Input_Item item("vnl_in_h"); - item.annotation = "calculate the nonlocal potential or not"; - read_sync_bool(input.vnl_in_h); - this->add_item(item); - } - { - Input_Item item("vh_in_h"); - item.annotation = "calculate the hartree potential or not"; - read_sync_bool(input.vh_in_h); - this->add_item(item); - } - { - Input_Item item("vion_in_h"); - item.annotation = "calculate the local ionic potential or not"; - read_sync_bool(input.vion_in_h); - this->add_item(item); - } - { - Input_Item item("test_force"); - item.annotation = "test the force"; - read_sync_bool(input.test_force); - this->add_item(item); - } - { - Input_Item item("test_stress"); - item.annotation = "test the stress"; - read_sync_bool(input.test_stress); - this->add_item(item); - } - { - Input_Item item("test_skip_ewald"); - item.annotation = "whether to skip ewald"; - read_sync_bool(input.test_skip_ewald); - this->add_item(item); - } - - // 13. vdW Correction - { - Input_Item item("vdw_method"); - item.annotation = "the method of calculating vdw (none ; d2 ; d3_0 ; d3_bj"; - read_sync_string(input.vdw_method); - this->add_item(item); - } - { - Input_Item item("vdw_s6"); - item.annotation = "scale parameter of d2/d3_0/d3_bj"; - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.vdw_s6 == "default") - { - if (para.input.vdw_method == "d2") - { - para.input.vdw_s6 = "0.75"; - } - else if (para.input.vdw_method == "d3_0" || para.input.vdw_method == "d3_bj") - { - para.input.vdw_s6 = "1.0"; - } - } - }; - read_sync_string(input.vdw_s6); - this->add_item(item); - } - { - Input_Item item("vdw_s8"); - item.annotation = "scale parameter of d3_0/d3_bj"; - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.vdw_s8 == "default") - { - if (para.input.vdw_method == "d3_0") - { - para.input.vdw_s8 = "0.722"; - } - else if (para.input.vdw_method == "d3_bj") - { - para.input.vdw_s8 = "0.7875"; - } - } - }; - read_sync_string(input.vdw_s8); - this->add_item(item); - } - { - Input_Item item("vdw_a1"); - item.annotation = "damping parameter of d3_0/d3_bj"; - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.vdw_a1 == "default") - { - if (para.input.vdw_method == "d3_0") - { - para.input.vdw_a1 = "1.217"; - } - else if (para.input.vdw_method == "d3_bj") - { - para.input.vdw_a1 = "0.4289"; - } - } - }; - read_sync_string(input.vdw_a1); - this->add_item(item); - } - { - Input_Item item("vdw_a2"); - item.annotation = "damping parameter of d3_bj"; - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.vdw_a2 == "default") - { - if (para.input.vdw_method == "d3_0") - { - para.input.vdw_a2 = "1.0"; - } - else if (para.input.vdw_method == "d3_bj") - { - para.input.vdw_a2 = "4.4407"; - } - } - }; - read_sync_string(input.vdw_a2); - this->add_item(item); - } - { - Input_Item item("vdw_d"); - item.annotation = "damping parameter of d2"; - read_sync_double(input.vdw_d); - this->add_item(item); - } - { - Input_Item item("vdw_abc"); - item.annotation = "third-order term?"; - read_sync_bool(input.vdw_abc); - this->add_item(item); - } - { - Input_Item item("vdw_c6_file"); - item.annotation = "filename of C6"; - read_sync_string(input.vdw_C6_file); - this->add_item(item); - } - { - Input_Item item("vdw_c6_unit"); - item.annotation = "unit of C6, Jnm6/mol or eVA6"; - read_sync_string(input.vdw_C6_unit); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if ((para.input.vdw_C6_unit != "Jnm6/mol") && (para.input.vdw_C6_unit != "eVA6")) - { - ModuleBase::WARNING_QUIT("ReadInput", "vdw_C6_unit must be Jnm6/mol or eVA6"); - } - }; - this->add_item(item); - } - { - Input_Item item("vdw_r0_file"); - item.annotation = "filename of R0"; - read_sync_string(input.vdw_R0_file); - this->add_item(item); - } - { - Input_Item item("vdw_r0_unit"); - item.annotation = "unit of R0, A or Bohr"; - read_sync_string(input.vdw_R0_unit); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if ((para.input.vdw_R0_unit != "A") && (para.input.vdw_R0_unit != "Bohr")) - { - ModuleBase::WARNING_QUIT("ReadInput", "vdw_R0_unit must be A or Bohr"); - } - }; - this->add_item(item); - } - { - Input_Item item("vdw_cutoff_type"); - item.annotation = "expression model of periodic structure, radius or period"; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.vdw_cutoff_type != "radius" && para.input.vdw_cutoff_type != "period") - { - ModuleBase::WARNING_QUIT("ReadInput", "vdw_cutoff_type must be radius or period"); - } - }; - read_sync_string(input.vdw_cutoff_type); - this->add_item(item); - } - { - Input_Item item("vdw_cutoff_radius"); - item.annotation = "radius cutoff for periodic structure"; - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.vdw_cutoff_radius == "default") - { - if (para.input.vdw_method == "d2") - { - para.input.vdw_cutoff_radius = "56.6918"; - } - else if (para.input.vdw_method == "d3_0" || para.input.vdw_method == "d3_bj") - { - para.input.vdw_cutoff_radius = "95"; - } - else - { - para.input.vdw_cutoff_radius = "0"; - } - } - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (std::stod(para.input.vdw_cutoff_radius) <= 0 && para.input.vdw_method != "none") - { - ModuleBase::WARNING_QUIT("ReadInput", "vdw_cutoff_radius <= 0 is not allowd"); - } - }; - read_sync_string(input.vdw_cutoff_radius); - this->add_item(item); - } - { - Input_Item item("vdw_radius_unit"); - item.annotation = "unit of radius cutoff for periodic structure"; - read_sync_string(input.vdw_radius_unit); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if ((para.input.vdw_radius_unit != "A") && (para.input.vdw_radius_unit != "Bohr")) - { - ModuleBase::WARNING_QUIT("ReadInput", "vdw_radius_unit must be A or Bohr"); - } - }; - this->add_item(item); - } - { - Input_Item item("vdw_cn_thr"); - item.annotation = "radius cutoff for cn"; - read_sync_double(input.vdw_cn_thr); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.vdw_cn_thr <= 0) - { - ModuleBase::WARNING_QUIT("ReadInput", "vdw_cn_thr <= 0 is not allowd"); - } - }; - this->add_item(item); - } - { - Input_Item item("vdw_cn_thr_unit"); - item.annotation = "unit of cn_thr, Bohr or Angstrom"; - read_sync_string(input.vdw_cn_thr_unit); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if ((para.input.vdw_cn_thr_unit != "A") && (para.input.vdw_cn_thr_unit != "Bohr")) - { - ModuleBase::WARNING_QUIT("ReadInput", "vdw_cn_thr_unit must be A or Bohr"); - } - }; - this->add_item(item); - } - { - Input_Item item("vdw_cutoff_period"); - item.annotation = "periods of periodic structure"; - item.read_value = [](const Input_Item& item, Parameter& para) { - size_t count = item.get_size(); - if (count == 3) - { - para.input.vdw_cutoff_period[0] = std::stoi(item.str_values[0]); - para.input.vdw_cutoff_period[1] = std::stoi(item.str_values[1]); - para.input.vdw_cutoff_period[2] = std::stoi(item.str_values[2]); - } - else - { - ModuleBase::WARNING_QUIT("ReadInput", "vdw_cutoff_period should have 3 values"); - } - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.vdw_cutoff_period[0] <= 0 || para.input.vdw_cutoff_period[1] <= 0 - || para.input.vdw_cutoff_period[2] <= 0) - { - ModuleBase::WARNING_QUIT("ReadInput", "vdw_cutoff_period should be positive"); - } - }; - item.get_final_value = [](Input_Item& item, const Parameter& para) { - item.final_value << para.input.vdw_cutoff_period[0] << " " << para.input.vdw_cutoff_period[1] << " " - << para.input.vdw_cutoff_period[2]; - }; -#ifdef __MPI - bcastfuncs.push_back( - [](Parameter& para) { Parallel_Common::bcast_int((int*)¶.input.vdw_cutoff_period, 3); }); -#endif - this->add_item(item); - } - - // 14. exx - { - Input_Item item("exx_hybrid_alpha"); - item.annotation = "fraction of Fock exchange in hybrid functionals"; - read_sync_string(input.exx_hybrid_alpha); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.exx_hybrid_alpha == "default") - { - std::string& dft_functional = para.input.dft_functional; - std::string dft_functional_lower = dft_functional; - std::transform(dft_functional.begin(), dft_functional.end(), dft_functional_lower.begin(), tolower); - if (dft_functional_lower == "hf") { - para.input.exx_hybrid_alpha = "1"; - } else if (dft_functional_lower == "pbe0" || dft_functional_lower == "hse" - || dft_functional_lower == "scan0") { - para.input.exx_hybrid_alpha = "0.25"; - } else { // no exx in scf, but will change to non-zero in - // postprocess like rpa - para.input.exx_hybrid_alpha = "0"; -} - } - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - const double exx_hybrid_alpha_value = std::stod(para.input.exx_hybrid_alpha); - if (exx_hybrid_alpha_value < 0 || exx_hybrid_alpha_value > 1) - { - ModuleBase::WARNING_QUIT("ReadInput", "must 0 <= exx_hybrid_alpha <= 1"); - } - }; - this->add_item(item); - } - { - Input_Item item("exx_hse_omega"); - item.annotation = "range-separation parameter in HSE functional"; - read_sync_double(input.exx_hse_omega); - this->add_item(item); - } - { - Input_Item item("exx_separate_loop"); - item.annotation = "if 1, a two-step method is employed, else it will " - "start with a GGA-Loop, and then Hybrid-Loop"; - read_sync_bool(input.exx_separate_loop); - this->add_item(item); - } - { - Input_Item item("exx_hybrid_step"); - item.annotation = "the maximal electronic iteration number in the " - "evaluation of Fock exchange"; - read_sync_int(input.exx_hybrid_step); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.exx_hybrid_step <= 0) - { - ModuleBase::WARNING_QUIT("ReadInput", "exx_hybrid_step must > 0"); - } - }; - this->add_item(item); - } - { - Input_Item item("exx_mixing_beta"); - item.annotation = "mixing_beta for outer-loop when exx_separate_loop=1"; - read_sync_double(input.exx_mixing_beta); - this->add_item(item); - } - { - Input_Item item("exx_lambda"); - item.annotation = "used to compensate for divergence points at G=0 in " - "the evaluation of Fock exchange using " - "lcao_in_pw method"; - read_sync_double(input.exx_lambda); - this->add_item(item); - } - { - Input_Item item("exx_real_number"); - item.annotation = "exx calculated in real or complex"; - read_sync_string(input.exx_real_number); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.exx_real_number == "default") - { - if (para.input.gamma_only) { - para.input.exx_real_number = "1"; - } else { - para.input.exx_real_number = "0"; -} - } - }; - this->add_item(item); - } - { - Input_Item item("exx_pca_threshold"); - item.annotation = "threshold to screen on-site ABFs in exx"; - read_sync_double(input.exx_pca_threshold); - this->add_item(item); - } - { - Input_Item item("exx_c_threshold"); - item.annotation = "threshold to screen C matrix in exx"; - read_sync_double(input.exx_c_threshold); - this->add_item(item); - } - { - Input_Item item("exx_v_threshold"); - item.annotation = "threshold to screen C matrix in exx"; - read_sync_double(input.exx_v_threshold); - this->add_item(item); - } - { - Input_Item item("exx_dm_threshold"); - item.annotation = "threshold to screen density matrix in exx"; - read_sync_double(input.exx_dm_threshold); - this->add_item(item); - } - { - Input_Item item("exx_schwarz_threshold"); - item.annotation = "threshold to screen exx using Cauchy-Schwartz inequality"; - read_sync_double(input.exx_schwarz_threshold); - this->add_item(item); - } - { - Input_Item item("exx_cauchy_threshold"); - item.annotation = "threshold to screen exx using Cauchy-Schwartz inequality"; - read_sync_double(input.exx_cauchy_threshold); - this->add_item(item); - } - { - Input_Item item("exx_c_grad_threshold"); - item.annotation = "threshold to screen nabla C matrix in exx"; - read_sync_double(input.exx_c_grad_threshold); - this->add_item(item); - } - { - Input_Item item("exx_v_grad_threshold"); - item.annotation = "threshold to screen nabla V matrix in exx"; - read_sync_double(input.exx_v_grad_threshold); - this->add_item(item); - } - { - Input_Item item("exx_cauchy_force_threshold"); - item.annotation = "threshold to screen exx force using Cauchy-Schwartz inequality"; - read_sync_double(input.exx_cauchy_force_threshold); - this->add_item(item); - } - { - Input_Item item("exx_cauchy_stress_threshold"); - item.annotation = "threshold to screen exx stress using Cauchy-Schwartz inequality"; - read_sync_double(input.exx_cauchy_stress_threshold); - this->add_item(item); - } - { - Input_Item item("exx_ccp_rmesh_times"); - item.annotation = "how many times larger the radial mesh required for " - "calculating Columb potential is to that " - "of atomic orbitals"; - read_sync_string(input.exx_ccp_rmesh_times); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.exx_ccp_rmesh_times == "default") - { - std::string& dft_functional = para.input.dft_functional; - std::string dft_functional_lower = dft_functional; - std::transform(dft_functional.begin(), dft_functional.end(), dft_functional_lower.begin(), tolower); - if (dft_functional_lower == "hf" || dft_functional_lower == "pbe0" || dft_functional_lower == "scan0") { - para.input.exx_ccp_rmesh_times = "5"; - } else if (dft_functional_lower == "hse") { - para.input.exx_ccp_rmesh_times = "1.5"; - } else { // no exx in scf - para.input.exx_ccp_rmesh_times = "1"; -} - } - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (std::stod(para.input.exx_ccp_rmesh_times) < 1) - { - ModuleBase::WARNING_QUIT("ReadInput", "exx_ccp_rmesh_times must >= 1"); - } - }; - this->add_item(item); - } - { - Input_Item item("exx_distribute_type"); - item.annotation = "exx_distribute_type"; - read_sync_string(input.exx_distribute_type); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.exx_distribute_type != "htime" && para.input.exx_distribute_type != "kmeans2" - && para.input.exx_distribute_type != "kmeans1" && para.input.exx_distribute_type != "order") - { - ModuleBase::WARNING_QUIT("ReadInput", - "exx_distribute_type must be htime or " - "kmeans2 or kmeans1 or order"); - } - }; - this->add_item(item); - } - { - Input_Item item("exx_opt_orb_lmax"); - item.annotation = "the maximum l of the spherical Bessel functions for opt ABFs"; - read_sync_int(input.exx_opt_orb_lmax); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.exx_opt_orb_lmax < 0) - { - ModuleBase::WARNING_QUIT("ReadInput", "exx_opt_orb_lmax must >= 0"); - } - }; - this->add_item(item); - } - { - Input_Item item("exx_opt_orb_ecut"); - item.annotation = "the cut-off of plane wave expansion for opt ABFs"; - read_sync_double(input.exx_opt_orb_ecut); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.exx_opt_orb_ecut < 0) - { - ModuleBase::WARNING_QUIT("ReadInput", "exx_opt_orb_ecut must >= 0"); - } - }; - this->add_item(item); - } - { - Input_Item item("exx_opt_orb_tolerence"); - item.annotation = "the threshold when solving for the zeros of " - "spherical Bessel functions for opt ABFs"; - read_sync_double(input.exx_opt_orb_tolerence); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.exx_opt_orb_tolerence < 0) - { - ModuleBase::WARNING_QUIT("ReadInput", "exx_opt_orb_tolerence must >= 0"); - } - }; - this->add_item(item); - } - { - Input_Item item("rpa_ccp_rmesh_times"); - item.annotation = "how many times larger the radial mesh required for " - "calculating Columb potential is to that " - "of atomic orbitals"; - read_sync_double(input.rpa_ccp_rmesh_times); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.rpa_ccp_rmesh_times < 1) - { - ModuleBase::WARNING_QUIT("ReadInput", "rpa_ccp_rmesh_times must >= 1"); - } - }; - this->add_item(item); - } - - // 16. tddft - { - Input_Item item("td_force_dt"); - item.annotation = "time of force change"; - read_sync_double(input.td_force_dt); - this->add_item(item); - } - { - Input_Item item("td_vext"); - item.annotation = "add extern potential or not"; - read_sync_bool(input.td_vext); - this->add_item(item); - } - { - Input_Item item("td_vext_dire"); - item.annotation = "extern potential direction"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.td_vext_dire = longstring(item.str_values); - }; - sync_string(input.td_vext_dire); - this->add_item(item); - } - { - Input_Item item("out_dipole"); - item.annotation = "output dipole or not"; - read_sync_bool(input.out_dipole); - this->add_item(item); - } - { - Input_Item item("out_efield"); - item.annotation = "output dipole or not"; - read_sync_bool(input.out_efield); - this->add_item(item); - } - { - Input_Item item("out_current"); - item.annotation = "output current or not"; - read_sync_bool(input.out_current); - this->add_item(item); - } - { - Input_Item item("out_current_k"); - item.annotation = "output current for each k"; - read_sync_bool(input.out_current_k); - this->add_item(item); - } - { - Input_Item item("out_vecpot"); - item.annotation = "output TDDFT vector potential or not"; - read_sync_bool(input.out_vecpot); - this->add_item(item); - } - { - Input_Item item("init_vecpot_file"); - item.annotation = "init vector potential through file or not"; - read_sync_bool(input.init_vecpot_file); - this->add_item(item); - } - { - Input_Item item("td_print_eij"); - item.annotation = "print eij or not"; - read_sync_double(input.td_print_eij); - this->add_item(item); - } - { - Input_Item item("td_edm"); - item.annotation = "the method to calculate the energy density matrix"; - read_sync_int(input.td_edm); - this->add_item(item); - } - { - Input_Item item("td_propagator"); - item.annotation = "method of propagator"; - read_sync_int(input.propagator); - this->add_item(item); - } - { - Input_Item item("td_stype"); - item.annotation = "type of electric field in space domain"; - read_sync_int(input.td_stype); - this->add_item(item); - } - { - Input_Item item("td_ttype"); - item.annotation = "type of electric field in time domain"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.td_ttype = longstring(item.str_values); - }; - sync_string(input.td_ttype); - this->add_item(item); - } - { - Input_Item item("td_tstart"); - item.annotation = " number of steps where electric field starts"; - read_sync_int(input.td_tstart); - this->add_item(item); - } - { - Input_Item item("td_tend"); - item.annotation = "number of steps where electric field ends"; - read_sync_int(input.td_tend); - this->add_item(item); - } - { - Input_Item item("td_lcut1"); - item.annotation = "cut1 of interval in length gauge"; - read_sync_double(input.td_lcut1); - this->add_item(item); - } - { - Input_Item item("td_lcut2"); - item.annotation = "cut2 of interval in length gauge"; - read_sync_double(input.td_lcut2); - this->add_item(item); - } - { - Input_Item item("td_gauss_freq"); - item.annotation = "frequency (freq) of Gauss type electric field"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.td_gauss_freq = longstring(item.str_values); - }; - sync_string(input.td_gauss_freq); - this->add_item(item); - } - { - Input_Item item("td_gauss_phase"); - item.annotation = "phase of Gauss type electric field"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.td_gauss_phase = longstring(item.str_values); - }; - sync_string(input.td_gauss_phase); - this->add_item(item); - } - { - Input_Item item("td_gauss_sigma"); - item.annotation = "sigma of Gauss type electric field"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.td_gauss_sigma = longstring(item.str_values); - }; - sync_string(input.td_gauss_sigma); - this->add_item(item); - } - { - Input_Item item("td_gauss_t0"); - item.annotation = "step number of time center (t0) of Gauss type electric field"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.td_gauss_t0 = longstring(item.str_values); - }; - sync_string(input.td_gauss_t0); - this->add_item(item); - } - { - Input_Item item("td_gauss_amp"); - item.annotation = "amplitude of Gauss type electric field"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.td_gauss_amp = longstring(item.str_values); - }; - sync_string(input.td_gauss_amp); - this->add_item(item); - } - { - Input_Item item("td_trape_freq"); - item.annotation = "frequency of Trapezoid type electric field"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.td_trape_freq = longstring(item.str_values); - }; - sync_string(input.td_trape_freq); - this->add_item(item); - } - { - Input_Item item("td_trape_phase"); - item.annotation = "phase of Trapezoid type electric field"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.td_trape_phase = longstring(item.str_values); - }; - sync_string(input.td_trape_phase); - this->add_item(item); - } - { - Input_Item item("td_trape_t1"); - item.annotation = "t1 of Trapezoid type electric field"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.td_trape_t1 = longstring(item.str_values); - }; - sync_string(input.td_trape_t1); - this->add_item(item); - } - { - Input_Item item("td_trape_t2"); - item.annotation = "t2 of Trapezoid type electric field"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.td_trape_t2 = longstring(item.str_values); - }; - sync_string(input.td_trape_t2); - this->add_item(item); - } - { - Input_Item item("td_trape_t3"); - item.annotation = "t3 of Trapezoid type electric field"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.td_trape_t3 = longstring(item.str_values); - }; - sync_string(input.td_trape_t3); - this->add_item(item); - } - { - Input_Item item("td_trape_amp"); - item.annotation = "amplitude of Trapezoid type electric field"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.td_trape_amp = longstring(item.str_values); - }; - sync_string(input.td_trape_amp); - this->add_item(item); - } - { - Input_Item item("td_trigo_freq1"); - item.annotation = "frequency 1 of Trigonometric type electric field"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.td_trigo_freq1 = longstring(item.str_values); - }; - sync_string(input.td_trigo_freq1); - this->add_item(item); - } - { - Input_Item item("td_trigo_freq2"); - item.annotation = "frequency 2 of Trigonometric type electric field"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.td_trigo_freq2 = longstring(item.str_values); - }; - sync_string(input.td_trigo_freq2); - this->add_item(item); - } - { - Input_Item item("td_trigo_phase1"); - item.annotation = "phase 1 of Trigonometric type electric field"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.td_trigo_phase1 = longstring(item.str_values); - }; - sync_string(input.td_trigo_phase1); - this->add_item(item); - } - { - Input_Item item("td_trigo_phase2"); - item.annotation = "phase 2 of Trigonometric type electric field"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.td_trigo_phase2 = longstring(item.str_values); - }; - sync_string(input.td_trigo_phase2); - this->add_item(item); - } - { - Input_Item item("td_trigo_amp"); - item.annotation = "amplitude of Trigonometric type electric field"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.td_trigo_amp = longstring(item.str_values); - }; - sync_string(input.td_trigo_amp); - this->add_item(item); - } - { - Input_Item item("td_heavi_t0"); - item.annotation = "t0 of Heaviside type electric field"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.td_heavi_t0 = longstring(item.str_values); - }; - sync_string(input.td_heavi_t0); - this->add_item(item); - } - { - Input_Item item("td_heavi_amp"); - item.annotation = "amplitude of Heaviside type electric field"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.td_heavi_amp = longstring(item.str_values); - }; - sync_string(input.td_heavi_amp); - this->add_item(item); - } - { - Input_Item item("ocp"); - item.annotation = "change occupation or not"; - read_sync_bool(input.ocp); - this->add_item(item); - } - { - Input_Item item("ocp_set"); - item.annotation = "set occupation"; - item.read_value = [](const Input_Item& item, Parameter& para) { - parse_expression(item.str_values, para.input.ocp_kb); - }; - item.get_final_value = [](Input_Item& item, const Parameter& para) { - if(item.is_read()) - { - item.final_value.str(longstring(item.str_values)); - } - }; - add_doublevec_bcast(input.ocp_kb, para.input.ocp_kb.size(), 0.0); - this->add_item(item); - } - - // 17. berry_wannier - { - Input_Item item("berry_phase"); - item.annotation = "calculate berry phase or not"; - read_sync_bool(input.berry_phase); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.berry_phase) - { - if (para.input.basis_type != "pw" && para.input.basis_type != "lcao") - { - ModuleBase::WARNING_QUIT("ReadInput", - "calculate berry phase, please " - "set basis_type = pw or lcao"); - } - if (para.input.calculation != "nscf") - { - ModuleBase::WARNING_QUIT("ReadInput", "calculate berry phase, please set calculation = nscf"); - } - if (!(para.input.gdir == 1 || para.input.gdir == 2 || para.input.gdir == 3)) - { - ModuleBase::WARNING_QUIT("ReadInput", "calculate berry phase, please set gdir = 1 or 2 or 3"); - } - } - }; - this->add_item(item); - } - { - Input_Item item("gdir"); - item.annotation = "calculate the polarization in the direction of the " - "lattice vector"; - read_sync_int(input.gdir); - this->add_item(item); - } - { - Input_Item item("towannier90"); - item.annotation = "use wannier90 code interface or not"; - read_sync_bool(input.towannier90); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.towannier90) - { - if (para.input.calculation != "nscf") - { - ModuleBase::WARNING_QUIT("ReadInput", "to use towannier90, please set calculation = nscf"); - } - if (para.input.nspin == 2) - { - if (para.input.wannier_spin != "up" && para.input.wannier_spin != "down") - { - ModuleBase::WARNING_QUIT("ReadInput", - "to use towannier90, please set wannier_spin = up " - "or down"); - } - } - } - }; - this->add_item(item); - } - { - Input_Item item("nnkpfile"); - item.annotation = "the wannier90 code nnkp file name"; - read_sync_string(input.nnkpfile); - this->add_item(item); - } - { - Input_Item item("wannier_spin"); - item.annotation = "calculate spin in wannier90 code interface"; - read_sync_string(input.wannier_spin); - this->add_item(item); - } - { - Input_Item item("wannier_method"); - item.annotation = "different implementation methods under Lcao basis set"; - item.reset_value = [](const Input_Item& item, Parameter& para) { - /* - Developer's notes: on the repair of lcao_in_pw - - lcao_in_pw is a special basis_type, for scf calculation, - it follows workflow of pw, but for nscf the toWannier90 - calculation, the interface is in ESolver_KS_LCAO_elec, - therefore lcao_in_pw for towannier90 calculation follows - lcao. - - In the future lcao_in_pw will have its own ESolver. - - 2023/12/22 use new psi_initializer to expand numerical - atomic orbitals, ykhuang - */ - if (para.input.towannier90 && para.input.basis_type == "lcao_in_pw") - { - para.input.wannier_method = 1; - } - }; - read_sync_int(input.wannier_method); - this->add_item(item); - } - { - Input_Item item("out_wannier_mmn"); - item.annotation = "output .mmn file or not"; - read_sync_bool(input.out_wannier_mmn); - this->add_item(item); - } - { - Input_Item item("out_wannier_amn"); - item.annotation = "output .amn file or not"; - read_sync_bool(input.out_wannier_amn); - this->add_item(item); - } - { - Input_Item item("out_wannier_unk"); - item.annotation = "output UNK. file or not"; - read_sync_bool(input.out_wannier_unk); - this->add_item(item); - } - { - Input_Item item("out_wannier_eig"); - item.annotation = "output .eig file or not"; - read_sync_bool(input.out_wannier_eig); - this->add_item(item); - } - { - Input_Item item("out_wannier_wvfn_formatted"); - item.annotation = "output UNK. file in text format or in binary format"; - read_sync_bool(input.out_wannier_wvfn_formatted); - this->add_item(item); - } - - // 18. imlicit_solvation - { - Input_Item item("imp_sol"); - item.annotation = "calculate implicit solvation correction or not"; - read_sync_bool(input.imp_sol); - this->add_item(item); - } - { - Input_Item item("eb_k"); - item.annotation = "the relative permittivity of the bulk solvent"; - read_sync_double(input.eb_k); - this->add_item(item); - } - { - Input_Item item("tau"); - item.annotation = "the effective surface tension parameter"; - read_sync_double(input.tau); - this->add_item(item); - } - { - Input_Item item("sigma_k"); - item.annotation = "the width of the diffuse cavity"; - read_sync_double(input.sigma_k); - this->add_item(item); - } - { - Input_Item item("nc_k"); - item.annotation = "the cut-off charge density"; - read_sync_double(input.nc_k); - this->add_item(item); - } - - // 19. OFDFT - { - Input_Item item("of_kinetic"); - item.annotation = "kinetic energy functional, such as tf, vw, wt"; - read_sync_string(input.of_kinetic); - this->add_item(item); - } - { - Input_Item item("of_method"); - item.annotation = "optimization method used in OFDFT, including cg1, " - "cg2, tn (default)"; - read_sync_string(input.of_method); - this->add_item(item); - } - { - Input_Item item("of_conv"); - item.annotation = "the convergence criterion, potential, energy (default), or both"; - read_sync_string(input.of_conv); - this->add_item(item); - } - { - Input_Item item("of_tole"); - item.annotation = "tolerance of the energy change (in Ry) for " - "determining the convergence, default=2e-6 Ry"; - read_sync_double(input.of_tole); - this->add_item(item); - } - { - Input_Item item("of_tolp"); - item.annotation = "tolerance of potential for determining the " - "convergence, default=1e-5 in a.u."; - read_sync_double(input.of_tolp); - this->add_item(item); - } - { - Input_Item item("of_tf_weight"); - item.annotation = "weight of TF KEDF"; - read_sync_double(input.of_tf_weight); - this->add_item(item); - } - { - Input_Item item("of_vw_weight"); - item.annotation = "weight of vW KEDF"; - read_sync_double(input.of_vw_weight); - this->add_item(item); - } - { - Input_Item item("of_wt_alpha"); - item.annotation = "parameter alpha of WT KEDF"; - read_sync_double(input.of_wt_alpha); - this->add_item(item); - } - { - Input_Item item("of_wt_beta"); - item.annotation = "parameter beta of WT KEDF"; - read_sync_double(input.of_wt_beta); - this->add_item(item); - } - { - Input_Item item("of_wt_rho0"); - item.annotation = "the average density of system, used in WT KEDF, in Bohr^-3"; - read_sync_double(input.of_wt_rho0); - this->add_item(item); - } - { - Input_Item item("of_hold_rho0"); - item.annotation = "If set to 1, the rho0 will be fixed even if the " - "volume of system has changed, it will be " - "set to 1 automaticly if of_wt_rho0 is not zero"; - read_sync_bool(input.of_hold_rho0); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.of_wt_rho0 != 0) - { - para.input.of_hold_rho0 = true; // sunliang add 2022-06-17 - } - }; - this->add_item(item); - } - { - Input_Item item("of_lkt_a"); - item.annotation = "parameter a of LKT KEDF"; - read_sync_double(input.of_lkt_a); - this->add_item(item); - } - { - Input_Item item("of_full_pw"); - item.annotation = "If set to 1, ecut will be ignored when collect " - "planewaves, so that all planewaves will be used"; - read_sync_bool(input.of_full_pw); - this->add_item(item); - } - { - Input_Item item("of_full_pw_dim"); - item.annotation = "If of_full_pw = true, dimention of FFT is " - "testricted to be (0) either odd or even; (1) odd " - "only; (2) even only"; - read_sync_int(input.of_full_pw_dim); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (!para.input.of_full_pw) - { - para.input.of_full_pw_dim = 0; // sunliang add 2022-08-31 - } - }; - this->add_item(item); - } - { - Input_Item item("of_read_kernel"); - item.annotation = "If set to 1, the kernel of WT KEDF will be filled " - "from file of_kernel_file, not from " - "formula. Only usable for WT KEDF"; - read_sync_bool(input.of_read_kernel); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.of_kinetic != "wt") - { - para.input.of_read_kernel = false; // sunliang add 2022-09-12 - } - }; - this->add_item(item); - } - { - Input_Item item("of_kernel_file"); - item.annotation = "The name of WT kernel file."; - read_sync_string(input.of_kernel_file); - this->add_item(item); - } - - // 20. dft+u - { - Input_Item item("dft_plus_u"); - item.annotation = "DFT+U correction method"; - read_sync_int(input.dft_plus_u); - item.reset_value = [](const Input_Item& item, Parameter& para) { - bool all_minus1 = true; - for (auto& val: para.input.orbital_corr) - { - if (val != -1) - { - all_minus1 = false; - break; - } - } - if (all_minus1) - { - if (para.input.dft_plus_u != 0) - { - para.input.dft_plus_u = 0; - ModuleBase::WARNING("ReadInput", "No atoms are correlated, DFT+U is closed!!!"); - } - } - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - const Input_para& input = para.input; - if (input.dft_plus_u != 0) - { - if (input.basis_type != "lcao") - { - ModuleBase::WARNING_QUIT("ReadInput", "WRONG ARGUMENTS OF basis_type, only lcao is support"); - } - if (input.ks_solver != "genelpa" && input.ks_solver != "scalapack_gvx" && input.ks_solver != "default") - { - std::cout << " You'are using " << input.ks_solver << std::endl; - ModuleBase::WARNING_QUIT("ReadInput", - "WRONG ARGUMENTS OF ks_solver in DFT+U routine, only " - "genelpa and scalapack_gvx are supported "); - } - } - }; - this->add_item(item); - } - { - Input_Item item("yukawa_lambda"); - item.annotation = "default:0.0"; - read_sync_double(input.yukawa_lambda); - this->add_item(item); - } - { - Input_Item item("yukawa_potential"); - item.annotation = "default: false"; - read_sync_bool(input.yukawa_potential); - this->add_item(item); - } - { - Input_Item item("uramping"); - item.annotation = "increasing U values during SCF"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.uramping_eV = doublevalue; - para.sys.uramping = para.input.uramping_eV / ModuleBase::Ry_to_eV; - }; - item.reset_value = [](const Input_Item& item, Parameter& para) { - bool all_minus1 = true; - for (auto& val: para.input.orbital_corr) - { - if (val != -1) - { - all_minus1 = false; - break; - } - } - if (all_minus1) - { - if (para.sys.uramping != 0.0) - { - para.sys.uramping = 0.0; - ModuleBase::WARNING("ReadInput", "No atoms are correlated, U-ramping is closed!!!"); - } - } - }; - sync_double(input.uramping_eV); - this->add_item(item); - } - { - Input_Item item("omc"); - item.annotation = "the mode of occupation matrix control"; - read_sync_int(input.omc); - this->add_item(item); - } - { - Input_Item item("onsite_radius"); - item.annotation = "radius of the sphere for onsite projection (Bohr)"; - read_sync_double(input.onsite_radius); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.dft_plus_u == 1 && para.input.onsite_radius == 0.0) - { - // autoset onsite_radius to 5.0 as default - para.input.onsite_radius = 5.0; - } - }; - this->add_item(item); - } - { - Input_Item item("hubbard_u"); - item.annotation = "Hubbard Coulomb interaction parameter U(ev)"; - item.read_value = [](const Input_Item& item, Parameter& para) { - size_t count = item.get_size(); - for (int i = 0; i < count; i++) - { - para.input.hubbard_u_eV.push_back(std::stod(item.str_values[i])); - para.sys.hubbard_u.push_back(para.input.hubbard_u_eV[i] / ModuleBase::Ry_to_eV); - } - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (!item.is_read()) { - return; -} - if (para.sys.hubbard_u.size() != para.input.ntype) - { - ModuleBase::WARNING_QUIT("ReadInput", - "hubbard_u should have the same " - "number of elements as ntype"); - } - for (auto& value: para.sys.hubbard_u) - { - if (value < -1.0e-3) - { - ModuleBase::WARNING_QUIT("ReadInput", "WRONG ARGUMENTS OF hubbard_u"); - } - } - }; - sync_doublevec(input.hubbard_u_eV, para.input.ntype, 0.0); - add_doublevec_bcast(sys.hubbard_u, para.input.ntype, 0.0); - this->add_item(item); - } - { - Input_Item item("orbital_corr"); - item.annotation = "which correlated orbitals need corrected ; d:2 " - ",f:3, do not need correction:-1"; - item.read_value = [](const Input_Item& item, Parameter& para) { - size_t count = item.get_size(); - for (int i = 0; i < count; i++) - { - para.input.orbital_corr.push_back(std::stoi(item.str_values[i])); - } - }; - - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (!item.is_read()) { - return; -} - if (para.input.orbital_corr.size() != para.input.ntype) - { - ModuleBase::WARNING_QUIT("ReadInput", - "orbital_corr should have the same " - "number of elements as ntype"); - } - for (auto& val: para.input.orbital_corr) - { - if (val < -1 || val > 3) - { - ModuleBase::WARNING_QUIT("ReadInput", "WRONG ARGUMENTS OF orbital_corr"); - } - } - }; - sync_intvec(input.orbital_corr, para.input.ntype, -1); - this->add_item(item); - } +#include "module_base/global_function.h" +#include "module_base/tool_quit.h" +#include "read_input.h" +#include "read_input_tool.h" - // 21. spherical bessel - { - Input_Item item("bessel_nao_ecut"); - item.annotation = "energy cutoff for spherical bessel functions(Ry)"; - read_sync_string(input.bessel_nao_ecut); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.bessel_nao_ecut == "default") - { - para.input.bessel_nao_ecut = std::to_string(para.input.ecutwfc); - } - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (std::stod(para.input.bessel_nao_ecut) < 0) - { - ModuleBase::WARNING_QUIT("ReadInput", "bessel_nao_ecut must >= 0"); - } - }; - this->add_item(item); - } - { - Input_Item item("bessel_nao_tolerence"); - item.annotation = "tolerence for spherical bessel root"; - read_sync_double(input.bessel_nao_tolerence); - this->add_item(item); - } - { - Input_Item item("bessel_nao_rcut"); - item.annotation = "radial cutoff for spherical bessel functions(a.u.)"; - item.read_value = [](const Input_Item& item, Parameter& para) { - size_t count = item.get_size(); - for (int i = 0; i < count; i++) - { - para.input.bessel_nao_rcuts.push_back(std::stod(item.str_values[i])); - } - if (count > 0) { - para.sys.bessel_nao_rcut = para.input.bessel_nao_rcuts[0]; // also compatible with -} - // old input file - para.sys.nrcut = count; - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.sys.bessel_nao_rcut < 0) - { - ModuleBase::WARNING_QUIT("ReadInput", "bessel_nao_rcut must >= 0"); - } - }; - sync_doublevec(input.bessel_nao_rcuts, para.sys.nrcut, 0.0); - this->add_item(item); - } - { - Input_Item item("bessel_nao_smooth"); - item.annotation = "spherical bessel smooth or not"; - read_sync_bool(input.bessel_nao_smooth); - this->add_item(item); - } - { - Input_Item item("bessel_nao_sigma"); - item.annotation = "spherical bessel smearing_sigma"; - read_sync_double(input.bessel_nao_sigma); - this->add_item(item); - } - { - Input_Item item("bessel_descriptor_lmax"); - item.annotation = "lmax used in generating spherical bessel functions"; - read_sync_int(input.bessel_descriptor_lmax); - this->add_item(item); - } - { - Input_Item item("bessel_descriptor_ecut"); - item.annotation = "energy cutoff for spherical bessel functions(Ry)"; - read_sync_string(input.bessel_descriptor_ecut); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.bessel_descriptor_ecut == "default") - { - para.input.bessel_descriptor_ecut = std::to_string(para.input.ecutwfc); - } - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (std::stod(para.input.bessel_descriptor_ecut) < 0) - { - ModuleBase::WARNING_QUIT("ReadInput", "bessel_descriptor_ecut must >= 0"); - } - }; - this->add_item(item); - } - { - Input_Item item("bessel_descriptor_tolerence"); - item.annotation = "tolerence for spherical bessel root"; - read_sync_double(input.bessel_descriptor_tolerence); - this->add_item(item); - } - { - Input_Item item("bessel_descriptor_rcut"); - item.annotation = "radial cutoff for spherical bessel functions(a.u.)"; - read_sync_double(input.bessel_descriptor_rcut); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.bessel_descriptor_rcut < 0) - { - ModuleBase::WARNING_QUIT("ReadInput", "bessel_descriptor_rcut must >= 0"); - } - }; - this->add_item(item); - } - { - Input_Item item("bessel_descriptor_smooth"); - item.annotation = "spherical bessel smooth or not"; - read_sync_bool(input.bessel_descriptor_smooth); - this->add_item(item); - } - { - Input_Item item("bessel_descriptor_sigma"); - item.annotation = "sphereical bessel smearing_sigma"; - read_sync_double(input.bessel_descriptor_sigma); - this->add_item(item); - } +#include +#include +#include - // 22. non-collinear spin-constrained +namespace ModuleIO +{ +void ReadInput::item_others() +{ + // non-collinear spin-constrained { Input_Item item("sc_mag_switch"); item.annotation = "switch to control spin-constrained DFT"; @@ -1659,7 +139,7 @@ void ReadInput::item_others() this->add_item(item); } - // 23. Quasiatomic Orbital analysis + // Quasiatomic Orbital analysis { Input_Item item("qo_switch"); item.annotation = "switch to control quasiatomic orbital analysis"; @@ -1707,11 +187,15 @@ void ReadInput::item_others() else { std::string default_strategy; - if (para.input.qo_basis == "hydrogen") { + if (para.input.qo_basis == "hydrogen") + { default_strategy = "energy-valence"; - } else if ((para.input.qo_basis == "pswfc") || (para.input.qo_basis == "szv")) { + } + else if ((para.input.qo_basis == "pswfc") || (para.input.qo_basis == "szv")) + { default_strategy = "all"; - } else + } + else { ModuleBase::WARNING_QUIT("ReadInput", "When setting default values for qo_strategy, " @@ -1736,9 +220,10 @@ void ReadInput::item_others() } }; item.reset_value = [](const Input_Item& item, Parameter& para) { - if (!item.is_read()) { + if (!item.is_read()) + { return; -} + } if (para.input.qo_screening_coeff.size() != para.input.ntype) { if (para.input.qo_basis == "pswfc") @@ -1776,7 +261,7 @@ void ReadInput::item_others() this->add_item(item); } - // 24. PEXSI + // PEXSI { Input_Item item("pexsi_npole"); item.annotation = "Number of poles in expansion"; @@ -1928,74 +413,71 @@ void ReadInput::item_others() this->add_item(item); } - // 25. Linear Response + // Only for Test { - Input_Item item("lr_nstates"); - item.annotation = "the number of 2-particle states to be solved"; - read_sync_int(input.lr_nstates); + Input_Item item("out_alllog"); + item.annotation = "output information for each processor, when parallel"; + read_sync_bool(input.out_alllog); this->add_item(item); } { - Input_Item item("nocc"); - item.annotation = "the number of occupied orbitals to form the 2-particle basis ( <= nelec/2)"; - read_sync_int(input.nocc); - item.reset_value = [](const Input_Item& item, Parameter& para) { - const int nocc_default = std::max(static_cast(para.input.nelec + 1) / 2, para.input.nbands); - if (para.input.nocc <= 0 || para.input.nocc > nocc_default) { para.input.nocc = nocc_default; } - }; + Input_Item item("nurse"); + item.annotation = "for coders"; + read_sync_int(input.nurse); + this->add_item(item); + } + { + Input_Item item("colour"); + item.annotation = "for coders, make their live colourful"; + read_sync_bool(input.colour); + this->add_item(item); + } + { + Input_Item item("t_in_h"); + item.annotation = "calculate the kinetic energy or not"; + read_sync_bool(input.t_in_h); this->add_item(item); } { - Input_Item item("nvirt"); - item.annotation = "the number of virtual orbitals to form the 2-particle basis (nocc + nvirt <= nbands)"; - read_sync_int(input.nvirt); + Input_Item item("vl_in_h"); + item.annotation = "calculate the local potential or not"; + read_sync_bool(input.vl_in_h); this->add_item(item); } { - Input_Item item("xc_kernel"); - item.annotation = "exchange correlation (XC) kernel for LR-TDDFT"; - read_sync_string(input.xc_kernel); + Input_Item item("vnl_in_h"); + item.annotation = "calculate the nonlocal potential or not"; + read_sync_bool(input.vnl_in_h); this->add_item(item); } { - Input_Item item("lr_solver"); - item.annotation = "the eigensolver for LR-TDDFT"; - read_sync_string(input.lr_solver); + Input_Item item("vh_in_h"); + item.annotation = "calculate the hartree potential or not"; + read_sync_bool(input.vh_in_h); this->add_item(item); } { - Input_Item item("lr_thr"); - item.annotation = "convergence threshold of the LR-TDDFT eigensolver"; - read_sync_double(input.lr_thr); + Input_Item item("vion_in_h"); + item.annotation = "calculate the local ionic potential or not"; + read_sync_bool(input.vion_in_h); this->add_item(item); } { - Input_Item item("out_wfc_lr"); - item.annotation = "whether to output the eigenvectors (excitation amplitudes) in the particle-hole basis"; - read_sync_bool(input.out_wfc_lr); + Input_Item item("test_force"); + item.annotation = "test the force"; + read_sync_bool(input.test_force); this->add_item(item); } { - Input_Item item("abs_wavelen_range"); - item.annotation = "the range of wavelength(nm) to output the absorption spectrum "; - item.read_value = [](const Input_Item& item, Parameter& para) { - size_t count = item.get_size(); - for (int i = 0; i < count; i++) - { - para.input.abs_wavelen_range.push_back(std::stod(item.str_values[i])); - } - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - auto& awr = para.input.abs_wavelen_range; - if (awr.size() < 2) { ModuleBase::WARNING_QUIT("ReadInput", "abs_wavelen_range must have two values"); } - }; - sync_doublevec(input.abs_wavelen_range, 2, 0.0); + Input_Item item("test_stress"); + item.annotation = "test the stress"; + read_sync_bool(input.test_stress); this->add_item(item); } { - Input_Item item("abs_broadening"); - item.annotation = "the broadening (eta) for LR-TDDFT absorption spectrum"; - read_sync_double(input.abs_broadening); + Input_Item item("test_skip_ewald"); + item.annotation = "whether to skip ewald"; + read_sync_bool(input.test_skip_ewald); this->add_item(item); } } diff --git a/source/module_io/read_input_item_output.cpp b/source/module_io/read_input_item_output.cpp new file mode 100644 index 0000000000..e57d81eaae --- /dev/null +++ b/source/module_io/read_input_item_output.cpp @@ -0,0 +1,433 @@ +#include "module_base/global_function.h" +#include "module_base/tool_quit.h" +#include "read_input.h" +#include "read_input_tool.h" +namespace ModuleIO +{ +void ReadInput::item_output() +{ + { + Input_Item item("out_stru"); + item.annotation = "output the structure files after each ion step"; + item.reset_value = [](const Input_Item& item, Parameter& para) { + const std::vector offlist = {"nscf", "get_S", "get_pchg", "get_wf"}; + if (find_str(offlist, para.input.calculation)) + { + para.input.out_stru = false; + } + }; + read_sync_bool(input.out_stru); + this->add_item(item); + } + { + Input_Item item("out_freq_elec"); + item.annotation = "the frequency ( >= 0) of electronic iter to output " + "charge density and wavefunction. 0: " + "output only when converged"; + read_sync_int(input.out_freq_elec); + this->add_item(item); + } + { + Input_Item item("out_freq_ion"); + item.annotation = "the frequency ( >= 0 ) of ionic step to output " + "charge density and wavefunction. 0: output " + "only when ion steps are finished"; + read_sync_int(input.out_freq_ion); + this->add_item(item); + } + { + Input_Item item("out_chg"); + item.annotation = ">0 output charge density for selected electron steps"; + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.calculation == "get_wf" || para.input.calculation == "get_pchg") + { + para.input.out_chg = 1; + } + }; + read_sync_int(input.out_chg); + this->add_item(item); + } + { + Input_Item item("out_pot"); + item.annotation = "output realspace potential"; + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.calculation == "get_wf" || para.input.calculation == "get_pchg") + { + para.input.out_pot = 0; + } + }; + read_sync_int(input.out_pot); + this->add_item(item); + } + { + Input_Item item("out_wfc_pw"); + item.annotation = "output wave functions"; + read_sync_int(input.out_wfc_pw); + this->add_item(item); + } + { + Input_Item item("out_wfc_r"); + item.annotation = "output wave functions in realspace"; + read_sync_bool(input.out_wfc_r); + this->add_item(item); + } + { + Input_Item item("printe"); + item.annotation = "Print out energy for each band for every printe steps"; + read_sync_int(input.printe); + this->add_item(item); + } + { + Input_Item item("out_band"); + item.annotation = "output energy and band structure (with precision 8)"; + item.read_value = [](const Input_Item& item, Parameter& para) { + size_t count = item.get_size(); + if (count == 1) + { + para.input.out_band[0] = std::stoi(item.str_values[0]); + para.input.out_band[1] = 8; + } + else if (count == 2) + { + para.input.out_band[0] = std::stoi(item.str_values[0]); + para.input.out_band[1] = std::stoi(item.str_values[1]); + } + else + { + ModuleBase::WARNING_QUIT("ReadInput", "out_band should have 1 or 2 values"); + } + }; + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.calculation == "get_wf" || para.input.calculation == "get_pchg") + { + para.input.out_band[0] = 0; + } + }; + sync_intvec(input.out_band, 2, 0); + this->add_item(item); + } + { + Input_Item item("out_dos"); + item.annotation = "output energy and dos"; + read_sync_int(input.out_dos); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.calculation == "get_wf" || para.input.calculation == "get_pchg") + { + para.input.out_dos = 0; + } + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.out_dos == 3 && para.input.symmetry == "1") + { + ModuleBase::WARNING_QUIT("ReadInput", + "symmetry can't be used for out_dos==3(Fermi Surface " + "Plotting) by now."); + } + if (para.input.basis_type == "pw" && para.input.out_dos == 3) + { + ModuleBase::WARNING_QUIT("ReadInput", + "Fermi Surface Plotting not " + "implemented for plane wave now."); + } + }; + this->add_item(item); + } + { + Input_Item item("out_mul"); + item.annotation = "mulliken charge or not"; + read_sync_bool(input.out_mul); + this->add_item(item); + } + { + Input_Item item("out_proj_band"); + item.annotation = "output projected band structure"; + read_sync_bool(input.out_proj_band); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.calculation == "get_wf" || para.input.calculation == "get_pchg") + { + para.input.out_proj_band = false; + } + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.basis_type == "pw" && para.input.out_proj_band) + { + ModuleBase::WARNING_QUIT("ReadInput", "out_proj_band is only for lcao"); + } + }; + this->add_item(item); + } + { + Input_Item item("out_level"); + item.annotation = "ie(for electrons); i(for ions);"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.out_level = strvalue; + para.sys.out_md_control = true; + }; + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (!para.sys.out_md_control && para.input.calculation == "md") + { + para.input.out_level = "m"; // zhengdy add 2019-04-07 + } + }; + sync_string(input.out_level); + this->add_item(item); + } + { + Input_Item item("out_dm"); + item.annotation = ">0 output density matrix"; + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.calculation == "get_pchg" || para.input.calculation == "get_wf") + { + para.input.out_dm = false; + } + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.sys.gamma_only_local == false && para.input.out_dm) + { + ModuleBase::WARNING_QUIT("ReadInput", "out_dm with k-point algorithm is not implemented yet."); + } + }; + read_sync_bool(input.out_dm); + this->add_item(item); + } + { + Input_Item item("out_dm1"); + item.annotation = ">0 output density matrix (multi-k points)"; + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.calculation == "get_pchg" || para.input.calculation == "get_wf") + { + para.input.out_dm1 = false; + } + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.sys.gamma_only_local == true && para.input.out_dm1) + { + ModuleBase::WARNING_QUIT("ReadInput", "out_dm1 is only for multi-k"); + } + }; + read_sync_bool(input.out_dm1); + this->add_item(item); + } + { + Input_Item item("out_bandgap"); + item.annotation = "if true, print out bandgap"; + read_sync_bool(input.out_bandgap); + this->add_item(item); + } + { + Input_Item item("out_mat_hs"); + item.annotation = "output H and S matrix (with precision 8)"; + item.read_value = [](const Input_Item& item, Parameter& para) { + size_t count = item.get_size(); + if (count == 1) + { + para.input.out_mat_hs[0] = std::stoi(item.str_values[0]); + para.input.out_mat_hs[1] = 8; + } + else if (count == 2) + { + para.input.out_mat_hs[0] = std::stoi(item.str_values[0]); + para.input.out_mat_hs[1] = std::stoi(item.str_values[1]); + } + else + { + ModuleBase::WARNING_QUIT("ReadInput", "out_mat_hs should have 1 or 2 values"); + } + }; + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.qo_switch) + { + para.input.out_mat_hs[0] = 1; // print H(k) and S(k) + } + }; + sync_intvec(input.out_mat_hs, 2, 0); + this->add_item(item); + } + { + Input_Item item("out_mat_hs2"); + item.annotation = "output H(R) and S(R) matrix"; + read_sync_bool(input.out_mat_hs2); + this->add_item(item); + } + { + Input_Item item("out_mat_dh"); + item.annotation = "output of derivative of H(R) matrix"; + read_sync_bool(input.out_mat_dh); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.out_mat_dh && para.input.nspin == 4) + { + ModuleBase::WARNING_QUIT("ReadInput", "out_mat_dh is not available for nspin = 4"); + } + }; + this->add_item(item); + } + { + Input_Item item("out_mat_xc"); + item.annotation = "output exchange-correlation matrix in KS-orbital representation"; + read_sync_bool(input.out_mat_xc); + this->add_item(item); + } + { + Input_Item item("out_hr_npz"); + item.annotation = "output hr(I0,JR) submatrices in npz format"; + read_sync_bool(input.out_hr_npz); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.out_hr_npz) + { +#ifndef __USECNPY + ModuleBase::WARNING_QUIT("ReadInput", + "to write in npz format, please " + "recompile with -DENABLE_CNPY=1"); +#endif + } + }; + this->add_item(item); + } + { + Input_Item item("out_dm_npz"); + item.annotation = "output dmr(I0,JR) submatrices in npz format"; + read_sync_bool(input.out_dm_npz); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.out_dm_npz) + { +#ifndef __USECNPY + ModuleBase::WARNING_QUIT("ReadInput", + "to write in npz format, please " + "recompile with -DENABLE_CNPY=1"); +#endif + } + }; + this->add_item(item); + } + { + Input_Item item("out_interval"); + item.annotation = "interval for printing H(R) and S(R) matrix during MD"; + read_sync_int(input.out_interval); + this->add_item(item); + } + { + Input_Item item("out_app_flag"); + item.annotation = "whether output r(R), H(R), S(R), T(R), and dH(R) " + "matrices in an append manner during MD"; + read_sync_bool(input.out_app_flag); + this->add_item(item); + } + { + Input_Item item("out_ndigits"); + item.annotation = "the length of decimal part of output data"; + read_sync_int(input.out_ndigits); + this->add_item(item); + } + { + Input_Item item("out_mat_t"); + item.annotation = "output T(R) matrix"; + read_sync_bool(input.out_mat_t); + this->add_item(item); + } + { + Input_Item item("out_element_info"); + item.annotation = "output (projected) wavefunction of each element"; + read_sync_bool(input.out_element_info); + this->add_item(item); + } + { + Input_Item item("out_mat_r"); + item.annotation = "output r(R) matrix"; + read_sync_bool(input.out_mat_r); + this->add_item(item); + } + { + Input_Item item("out_wfc_lcao"); + item.annotation = "ouput LCAO wave functions, 0, no output 1: text, 2: binary"; + read_sync_int(input.out_wfc_lcao); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.qo_switch) + { + para.input.out_wfc_lcao = 1; + } + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.out_wfc_lcao < 0 || para.input.out_wfc_lcao > 2) + { + ModuleBase::WARNING_QUIT("ReadInput", "out_wfc_lcao should be 0, 1, or 2"); + } + if (para.input.basis_type != "lcao" && para.input.out_wfc_lcao != 0) + { + ModuleBase::WARNING_QUIT("ReadInput", "out_wfc_lcao is only available for basis_type = lcao"); + } + }; + this->add_item(item); + } + { + Input_Item item("out_dipole"); + item.annotation = "output dipole or not"; + read_sync_bool(input.out_dipole); + this->add_item(item); + } + { + Input_Item item("out_efield"); + item.annotation = "output dipole or not"; + read_sync_bool(input.out_efield); + this->add_item(item); + } + { + Input_Item item("out_current"); + item.annotation = "output current or not"; + read_sync_bool(input.out_current); + this->add_item(item); + } + { + Input_Item item("out_current_k"); + item.annotation = "output current for each k"; + read_sync_bool(input.out_current_k); + this->add_item(item); + } + { + Input_Item item("out_vecpot"); + item.annotation = "output TDDFT vector potential or not"; + read_sync_bool(input.out_vecpot); + this->add_item(item); + } + { + Input_Item item("restart_save"); + item.annotation = "print to disk every step for restart"; + read_sync_bool(input.restart_save); + this->add_item(item); + } + { + Input_Item item("rpa"); + item.annotation = "true:generate output files used in rpa calculation; " + "false:(default)"; + read_sync_bool(input.rpa); + this->add_item(item); + } + { + Input_Item item("nbands_istate"); + item.annotation = "number of bands around Fermi level for get_wf and get_pchg calulation"; + read_sync_int(input.nbands_istate); + this->add_item(item); + } + { + Input_Item item("bands_to_print"); + item.annotation = "specify the bands to be calculated in get_wf and get_pchg calculation"; + item.read_value = [](const Input_Item& item, Parameter& para) { + parse_expression(item.str_values, para.input.bands_to_print); + }; + item.get_final_value = [](Input_Item& item, const Parameter& para) { + if (item.is_read()) + { + item.final_value.str(longstring(item.str_values)); + } + }; + add_intvec_bcast(input.bands_to_print, para.input.bands_to_print.size(), 0); + this->add_item(item); + } + { + Input_Item item("if_separate_k"); + item.annotation = "specify whether to write the partial charge densities for all k-points to individual files " + "or merge them"; + read_sync_bool(input.if_separate_k); + this->add_item(item); + } +} +} // namespace ModuleIO \ No newline at end of file diff --git a/source/module_io/read_input_item_postprocess.cpp b/source/module_io/read_input_item_postprocess.cpp index c84bce571c..411214fe6c 100644 --- a/source/module_io/read_input_item_postprocess.cpp +++ b/source/module_io/read_input_item_postprocess.cpp @@ -1,3 +1,4 @@ +#include "module_base/global_function.h" #include "module_base/tool_quit.h" #include "read_input.h" #include "read_input_tool.h" @@ -5,184 +6,231 @@ namespace ModuleIO { void ReadInput::item_postprocess() { - // 6. Smearing + // DOS { - Input_Item item("smearing_method"); - item.annotation = "type of smearing_method: gauss; fd; fixed; mp; mp2; mv"; - read_sync_string(input.smearing_method); + Input_Item item("dos_emin_ev"); + item.annotation = "minimal range for dos"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.dos_emin_ev = doublevalue; + para.sys.dos_setemin = true; + }; + sync_double(input.dos_emin_ev); this->add_item(item); } { - Input_Item item("smearing_sigma"); - item.annotation = "energy range for smearing"; - read_sync_double(input.smearing_sigma); + Input_Item item("dos_emax_ev"); + item.annotation = "maximal range for dos"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.dos_emax_ev = doublevalue; + para.sys.dos_setemax = true; + }; + sync_double(input.dos_emax_ev); this->add_item(item); } { - // Energy range for smearing, - //`smearing_sigma` = 1/2 *kB* `smearing_sigma_temp`. - Input_Item tmp_item("smearing_sigma_temp"); - tmp_item.read_value - = [](const Input_Item& item, Parameter& para) { para.input.smearing_sigma = 3.166815e-6 * doublevalue; }; - // only to set smearing_sigma, so no need to write to output INPUT file - // or bcast. - this->add_item(tmp_item); + Input_Item item("dos_edelta_ev"); + item.annotation = "delta energy for dos"; + read_sync_double(input.dos_edelta_ev); + this->add_item(item); } - - // 7. Charge Mixing { - Input_Item item("mixing_type"); - item.annotation = "plain; pulay; broyden"; - read_sync_string(input.mixing_mode); + Input_Item item("dos_scale"); + item.annotation = "scale dos range by"; + read_sync_double(input.dos_scale); this->add_item(item); } { - Input_Item item("mixing_beta"); - item.annotation = "mixing parameter: 0 means no new charge"; - read_sync_double(input.mixing_beta); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.mixing_beta < 0.0) - { - if (para.input.nspin == 1) - { - para.input.mixing_beta = 0.8; - } - else if (para.input.nspin == 2) - { - para.input.mixing_beta = 0.4; - para.input.mixing_beta_mag = 1.6; - para.input.mixing_gg0_mag = 0.0; - } - else if (para.input.nspin == 4) // I will add this - { - para.input.mixing_beta = 0.4; - para.input.mixing_beta_mag = 1.6; - para.input.mixing_gg0_mag = 0.0; - } - } - }; + Input_Item item("dos_sigma"); + item.annotation = "gauss b coefficeinet(default=0.07)"; + read_sync_double(input.dos_sigma); this->add_item(item); } { - Input_Item item("mixing_ndim"); - item.annotation = "mixing dimension in pulay or broyden"; - read_sync_int(input.mixing_ndim); + Input_Item item("dos_nche"); + item.annotation = "orders of Chebyshev expansions for dos"; + read_sync_int(input.dos_nche); this->add_item(item); } + + // Electronic Conductivity { - Input_Item item("mixing_restart"); - item.annotation = "threshold to restart mixing during SCF"; - read_sync_double(input.mixing_restart); + Input_Item item("cal_cond"); + item.annotation = "calculate electronic conductivities"; + read_sync_bool(input.cal_cond); this->add_item(item); } { - Input_Item item("mixing_gg0"); - item.annotation = "mixing parameter in kerker"; - read_sync_double(input.mixing_gg0); + Input_Item item("cond_che_thr"); + item.annotation = "control the error of Chebyshev expansions for conductivities"; + read_sync_double(input.cond_che_thr); this->add_item(item); } { - Input_Item item("mixing_beta_mag"); - item.annotation = "mixing parameter for magnetic density"; - read_sync_double(input.mixing_beta_mag); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.mixing_beta_mag < 0.0) - { - if (para.input.nspin == 2 || para.input.nspin == 4) - { - if (para.input.mixing_beta <= 0.4) - { - para.input.mixing_beta_mag = 4 * para.input.mixing_beta; - } - else - { - para.input.mixing_beta_mag = 1.6; // 1.6 can be discussed - } - } - } - }; + Input_Item item("cond_dw"); + item.annotation = "frequency interval for conductivities"; + read_sync_double(input.cond_dw); this->add_item(item); } { - Input_Item item("mixing_gg0_mag"); - item.annotation = "mixing parameter in kerker"; - read_sync_double(input.mixing_gg0_mag); + Input_Item item("cond_wcut"); + item.annotation = "cutoff frequency (omega) for conductivities"; + read_sync_double(input.cond_wcut); this->add_item(item); } { - Input_Item item("mixing_gg0_min"); - item.annotation = "the minimum kerker coefficient"; - read_sync_double(input.mixing_gg0_min); + Input_Item item("cond_dt"); + item.annotation = "t interval to integrate Onsager coefficiencies"; + read_sync_double(input.cond_dt); this->add_item(item); } { - Input_Item item("mixing_angle"); - item.annotation = "angle mixing parameter for non-colinear calculations"; - read_sync_double(input.mixing_angle); + Input_Item item("cond_dtbatch"); + item.annotation = "exp(iH*dt*cond_dtbatch) is expanded with Chebyshev expansion"; + read_sync_int(input.cond_dtbatch); this->add_item(item); } { - Input_Item item("mixing_tau"); - item.annotation = "whether to mix tau in mGGA calculation"; - read_sync_bool(input.mixing_tau); + Input_Item item("cond_smear"); + item.annotation = "Smearing method for conductivities"; + read_sync_int(input.cond_smear); this->add_item(item); } { - Input_Item item("mixing_dftu"); - item.annotation = "whether to mix locale in DFT+U calculation"; - read_sync_bool(input.mixing_dftu); + Input_Item item("cond_fwhm"); + item.annotation = "FWHM for conductivities"; + read_sync_double(input.cond_fwhm); this->add_item(item); } { - Input_Item item("mixing_dmr"); - item.annotation = "whether to mix real-space density matrix"; - read_sync_bool(input.mixing_dmr); + Input_Item item("cond_nonlocal"); + item.annotation = "Nonlocal effects for conductivities"; + read_sync_bool(input.cond_nonlocal); this->add_item(item); } - // 8. DOS + // berry_wannier { - Input_Item item("dos_emin_ev"); - item.annotation = "minimal range for dos"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.dos_emin_ev = doublevalue; - para.sys.dos_setemin = true; + Input_Item item("berry_phase"); + item.annotation = "calculate berry phase or not"; + read_sync_bool(input.berry_phase); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.berry_phase) + { + if (para.input.basis_type != "pw" && para.input.basis_type != "lcao") + { + ModuleBase::WARNING_QUIT("ReadInput", + "calculate berry phase, please " + "set basis_type = pw or lcao"); + } + if (para.input.calculation != "nscf") + { + ModuleBase::WARNING_QUIT("ReadInput", "calculate berry phase, please set calculation = nscf"); + } + if (!(para.input.gdir == 1 || para.input.gdir == 2 || para.input.gdir == 3)) + { + ModuleBase::WARNING_QUIT("ReadInput", "calculate berry phase, please set gdir = 1 or 2 or 3"); + } + } }; - sync_double(input.dos_emin_ev); this->add_item(item); } { - Input_Item item("dos_emax_ev"); - item.annotation = "maximal range for dos"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.dos_emax_ev = doublevalue; - para.sys.dos_setemax = true; + Input_Item item("gdir"); + item.annotation = "calculate the polarization in the direction of the " + "lattice vector"; + read_sync_int(input.gdir); + this->add_item(item); + } + { + Input_Item item("towannier90"); + item.annotation = "use wannier90 code interface or not"; + read_sync_bool(input.towannier90); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.towannier90) + { + if (para.input.calculation != "nscf") + { + ModuleBase::WARNING_QUIT("ReadInput", "to use towannier90, please set calculation = nscf"); + } + if (para.input.nspin == 2) + { + if (para.input.wannier_spin != "up" && para.input.wannier_spin != "down") + { + ModuleBase::WARNING_QUIT("ReadInput", + "to use towannier90, please set wannier_spin = up " + "or down"); + } + } + } }; - sync_double(input.dos_emax_ev); this->add_item(item); } { - Input_Item item("dos_edelta_ev"); - item.annotation = "delta energy for dos"; - read_sync_double(input.dos_edelta_ev); + Input_Item item("nnkpfile"); + item.annotation = "the wannier90 code nnkp file name"; + read_sync_string(input.nnkpfile); this->add_item(item); } { - Input_Item item("dos_scale"); - item.annotation = "scale dos range by"; - read_sync_double(input.dos_scale); + Input_Item item("wannier_spin"); + item.annotation = "calculate spin in wannier90 code interface"; + read_sync_string(input.wannier_spin); this->add_item(item); } { - Input_Item item("dos_sigma"); - item.annotation = "gauss b coefficeinet(default=0.07)"; - read_sync_double(input.dos_sigma); + Input_Item item("wannier_method"); + item.annotation = "different implementation methods under Lcao basis set"; + item.reset_value = [](const Input_Item& item, Parameter& para) { + /* + Developer's notes: on the repair of lcao_in_pw + + lcao_in_pw is a special basis_type, for scf calculation, + it follows workflow of pw, but for nscf the toWannier90 + calculation, the interface is in ESolver_KS_LCAO_elec, + therefore lcao_in_pw for towannier90 calculation follows + lcao. + + In the future lcao_in_pw will have its own ESolver. + + 2023/12/22 use new psi_initializer to expand numerical + atomic orbitals, ykhuang + */ + if (para.input.towannier90 && para.input.basis_type == "lcao_in_pw") + { + para.input.wannier_method = 1; + } + }; + read_sync_int(input.wannier_method); this->add_item(item); } { - Input_Item item("dos_nche"); - item.annotation = "orders of Chebyshev expansions for dos"; - read_sync_int(input.dos_nche); + Input_Item item("out_wannier_mmn"); + item.annotation = "output .mmn file or not"; + read_sync_bool(input.out_wannier_mmn); + this->add_item(item); + } + { + Input_Item item("out_wannier_amn"); + item.annotation = "output .amn file or not"; + read_sync_bool(input.out_wannier_amn); + this->add_item(item); + } + { + Input_Item item("out_wannier_unk"); + item.annotation = "output UNK. file or not"; + read_sync_bool(input.out_wannier_unk); + this->add_item(item); + } + { + Input_Item item("out_wannier_eig"); + item.annotation = "output .eig file or not"; + read_sync_bool(input.out_wannier_eig); + this->add_item(item); + } + { + Input_Item item("out_wannier_wvfn_formatted"); + item.annotation = "output UNK. file in text format or in binary format"; + read_sync_bool(input.out_wannier_wvfn_formatted); this->add_item(item); } } diff --git a/source/module_io/read_input_item_pw.cpp b/source/module_io/read_input_item_pw.cpp deleted file mode 100644 index eabffe7430..0000000000 --- a/source/module_io/read_input_item_pw.cpp +++ /dev/null @@ -1,522 +0,0 @@ -#include "module_base/global_function.h" -#include "module_base/tool_quit.h" -#include "read_input.h" -#include "read_input_tool.h" - -namespace ModuleIO -{ -void ReadInput::item_pw() -{ - { - Input_Item item("ecutwfc"); - item.annotation = "energy cutoff for wave functions"; - read_sync_double(input.ecutwfc); - this->add_item(item); - } - { - Input_Item item("ecutrho"); - item.annotation = "energy cutoff for charge density and potential"; - read_sync_double(input.ecutrho); - item.reset_value = [](const Input_Item& item, Parameter& para) { - Input_para& input = para.input; - if (input.ecutrho <= 0.0) - { - input.ecutrho = 4.0 * input.ecutwfc; - } - if (input.nx * input.ny * input.nz == 0 && input.ecutrho / input.ecutwfc > 4 + 1e-8) - { - para.sys.double_grid = true; - } - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.ecutrho / para.input.ecutwfc < 4 - 1e-8) - { - ModuleBase::WARNING_QUIT("ReadInput", "ecutrho/ecutwfc must >= 4"); - } - }; - this->add_item(item); - } - { - Input_Item item("erf_ecut"); - item.annotation = "the value of the constant energy cutoff"; - read_sync_double(input.erf_ecut); - this->add_item(item); - } - { - Input_Item item("erf_height"); - item.annotation = "the height of the energy step for reciprocal vectors"; - read_sync_double(input.erf_height); - this->add_item(item); - } - { - Input_Item item("erf_sigma"); - item.annotation = "the width of the energy step for reciprocal vectors"; - read_sync_double(input.erf_sigma); - this->add_item(item); - } - { - Input_Item item("fft_mode"); - item.annotation = "mode of FFTW"; - read_sync_int(input.fft_mode); - this->add_item(item); - } - { - Input_Item item("pw_diag_nmax"); - item.annotation = "max iteration number for cg"; - read_sync_int(input.pw_diag_nmax); - this->add_item(item); - } - { - Input_Item item("diago_cg_prec"); - item.annotation = "diago_cg_prec"; - read_sync_int(input.diago_cg_prec); - this->add_item(item); - } - { - Input_Item item("pw_diag_ndim"); - item.annotation = "dimension of workspace for Davidson diagonalization"; - read_sync_int(input.pw_diag_ndim); - this->add_item(item); - } - { - Input_Item item("diago_full_acc"); - item.annotation = "all the empty states are diagonalized"; - read_sync_bool(input.diago_full_acc); - this->add_item(item); - } - { - Input_Item item("pw_diag_thr"); - item.annotation = "threshold for eigenvalues is cg electron iterations"; - read_sync_double(input.pw_diag_thr); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.calculation == "get_S" && para.input.basis_type == "pw") - { - if (para.input.pw_diag_thr > 1.0e-3) { - para.input.pw_diag_thr = 1.0e-5; -} - } - }; - this->add_item(item); - } - { - Input_Item item("nb2d"); - item.annotation = "matrix 2d division"; - read_sync_int(input.nb2d); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.nb2d < 0) - { - ModuleBase::WARNING_QUIT("ReadInput", "nb2d should be greater than 0"); - } - }; - this->add_item(item); - } - { - Input_Item item("scf_thr"); - item.annotation = "charge density error"; - read_sync_double(input.scf_thr); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.scf_thr == -1.0) - { - if (para.input.basis_type == "lcao" || para.input.basis_type == "lcao_in_pw") - { - para.input.scf_thr = 1.0e-7; - } - else if (para.input.basis_type == "pw" && para.input.calculation != "nscf") - { - para.input.scf_thr = 1.0e-9; - } - else if (para.input.basis_type == "pw" && para.input.calculation == "nscf") - { - para.input.scf_thr = 1.0e-6; - // In NSCF calculation, the diagonalization threshold is set - // to 0.1*scf/nelec. In other words, the scf_thr is used to - // control diagonalization convergence threthod in NSCF. In - // this case, the default 1.0e-9 is too strict. renxi - // 20230908 - } - } - }; - this->add_item(item); - } - { - Input_Item item("scf_thr_type"); - item.annotation = "type of the criterion of scf_thr, 1: reci drho for " - "pw, 2: real drho for lcao"; - read_sync_int(input.scf_thr_type); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.scf_thr_type == -1) - { - if (para.input.basis_type == "lcao" || para.input.basis_type == "lcao_in_pw") - { - para.input.scf_thr_type = 2; - } - else if (para.input.basis_type == "pw") - { - para.input.scf_thr_type = 1; - } - } - }; - this->add_item(item); - } - { - Input_Item item("init_wfc"); - item.annotation = "start wave functions are from 'atomic', " - "'atomic+random', 'random' or"; - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.calculation == "get_pchg" || para.input.calculation == "get_wf") - { - para.input.init_wfc = "file"; - } - if (para.input.basis_type == "lcao_in_pw") - { - if (para.input.init_wfc != "nao") - { - para.input.init_wfc = "nao"; - GlobalV::ofs_warning << "init_wfc is set to nao when " - "basis_type is lcao_in_pw" - << std::endl; - } - } - }; - read_sync_string(input.init_wfc); - this->add_item(item); - } - { - Input_Item item("psi_initializer"); - item.annotation = "whether to use psi_initializer"; - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.basis_type == "lcao_in_pw") - { - para.input.psi_initializer = true; - } - }; - read_sync_bool(input.psi_initializer); - this->add_item(item); - } - { - Input_Item item("init_chg"); - item.annotation = "start charge is from 'atomic' or file"; - read_sync_string(input.init_chg); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.calculation == "get_pchg" || para.input.calculation == "get_wf") - { - para.input.init_chg = "atomic"; - } - if (para.input.calculation == "nscf" || para.input.calculation == "get_S") - { - if (para.input.init_chg != "file") - { - ModuleBase::GlobalFunc::AUTO_SET("init_chg", para.input.init_chg); - } - para.input.init_chg = "file"; - } - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.init_chg != "atomic" && para.input.init_chg != "file" && para.input.init_chg != "auto") - { - ModuleBase::WARNING_QUIT("ReadInput", "init_chg should be 'atomic', 'file' or 'auto'"); - } - }; - this->add_item(item); - } - { - Input_Item item("chg_extrap"); - item.annotation = "atomic; first-order; second-order; dm:coefficients of SIA"; - read_sync_string(input.chg_extrap); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.chg_extrap == "default" && para.input.calculation == "md") - { - para.input.chg_extrap = "second-order"; - } - else if (para.input.chg_extrap == "default" - && (para.input.calculation == "relax" || para.input.calculation == "cell-relax")) - { - para.input.chg_extrap = "first-order"; - } - else if (para.input.chg_extrap == "default") - { - para.input.chg_extrap = "atomic"; - } - if (para.input.calculation == "get_wf" || para.input.calculation == "get_pchg") - { - para.input.chg_extrap = "atomic"; - } - }; - this->add_item(item); - } - { - Input_Item item("out_chg"); - item.annotation = ">0 output charge density for selected electron steps"; - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.calculation == "get_wf" || para.input.calculation == "get_pchg") { - para.input.out_chg = 1; -} - }; - read_sync_int(input.out_chg); - this->add_item(item); - } - { - Input_Item item("out_pot"); - item.annotation = "output realspace potential"; - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.calculation == "get_wf" || para.input.calculation == "get_pchg") { - para.input.out_pot = 0; -} - }; - read_sync_int(input.out_pot); - this->add_item(item); - } - { - Input_Item item("out_wfc_pw"); - item.annotation = "output wave functions"; - read_sync_int(input.out_wfc_pw); - this->add_item(item); - } - { - Input_Item item("out_wfc_r"); - item.annotation = "output wave functions in realspace"; - read_sync_bool(input.out_wfc_r); - this->add_item(item); - } - { - Input_Item item("out_dos"); - item.annotation = "output energy and dos"; - read_sync_int(input.out_dos); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.calculation == "get_wf" || para.input.calculation == "get_pchg") { - para.input.out_dos = 0; -} - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.out_dos == 3 && para.input.symmetry == "1") - { - ModuleBase::WARNING_QUIT("ReadInput", - "symmetry can't be used for out_dos==3(Fermi Surface " - "Plotting) by now."); - } - if (para.input.basis_type == "pw" && para.input.out_dos == 3) - { - ModuleBase::WARNING_QUIT("ReadInput", - "Fermi Surface Plotting not " - "implemented for plane wave now."); - } - }; - this->add_item(item); - } - { - Input_Item item("out_band"); - item.annotation = "output energy and band structure (with precision 8)"; - item.read_value = [](const Input_Item& item, Parameter& para) { - size_t count = item.get_size(); - if (count == 1) - { - para.input.out_band[0] = std::stoi(item.str_values[0]); - para.input.out_band[1] = 8; - } - else if (count == 2) - { - para.input.out_band[0] = std::stoi(item.str_values[0]); - para.input.out_band[1] = std::stoi(item.str_values[1]); - } - else - { - ModuleBase::WARNING_QUIT("ReadInput", "out_band should have 1 or 2 values"); - } - }; - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.calculation == "get_wf" || para.input.calculation == "get_pchg") { - para.input.out_band[0] = 0; -} - }; - sync_intvec(input.out_band, 2, 0); - this->add_item(item); - } - { - Input_Item item("out_proj_band"); - item.annotation = "output projected band structure"; - read_sync_bool(input.out_proj_band); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.calculation == "get_wf" || para.input.calculation == "get_pchg") { - para.input.out_proj_band = false; -} - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.basis_type == "pw" && para.input.out_proj_band) - { - ModuleBase::WARNING_QUIT("ReadInput", "out_proj_band is only for lcao"); - } - }; - this->add_item(item); - } - { - Input_Item item("restart_save"); - item.annotation = "print to disk every step for restart"; - read_sync_bool(input.restart_save); - this->add_item(item); - } - { - Input_Item item("restart_load"); - item.annotation = "restart from disk"; - read_sync_bool(input.restart_load); - this->add_item(item); - } - { - Input_Item item("read_file_dir"); - item.annotation = "directory of files for reading"; - read_sync_string(input.read_file_dir); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.read_file_dir == "auto") - { - para.input.read_file_dir = "OUT." + para.input.suffix; - } - else - { - para.input.read_file_dir = para.input.read_file_dir; - } - para.input.read_file_dir = to_dir(para.input.read_file_dir); - }; - this->add_item(item); - } - { - Input_Item item("nx"); - item.annotation = "number of points along x axis for FFT grid"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.nx = intvalue; - para.sys.ncx = intvalue; - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.nx * para.input.ny * para.input.nz == 0 && para.input.nx != 0) - { - ModuleBase::WARNING_QUIT("ReadInput", "nx, ny, nz should be all set to non-zero"); - } - }; - sync_int(input.nx); - this->add_item(item); - } - { - Input_Item item("ny"); - item.annotation = "number of points along y axis for FFT grid"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.ny = intvalue; - para.sys.ncy = intvalue; - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.nx * para.input.ny * para.input.nz == 0 && para.input.ny != 0) - { - ModuleBase::WARNING_QUIT("ReadInput", "nx, ny, nz should be all set to non-zero"); - } - }; - sync_int(input.ny); - this->add_item(item); - } - { - Input_Item item("nz"); - item.annotation = "number of points along z axis for FFT grid"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.nz = intvalue; - para.sys.ncz = intvalue; - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.nx * para.input.ny * para.input.nz == 0 && para.input.nz != 0) - { - ModuleBase::WARNING_QUIT("ReadInput", "nx, ny, nz should be all set to non-zero"); - } - }; - sync_int(input.nz); - this->add_item(item); - } - { - Input_Item item("ndx"); - item.annotation = "number of points along x axis for FFT smooth grid"; - read_sync_int(input.ndx); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.ndx > para.input.nx) - { - para.sys.double_grid = true; - } - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (!item.is_read()) { - return; -} - if (para.input.ndx * para.input.ndy * para.input.ndz == 0 && para.input.ndx != 0) - { - ModuleBase::WARNING_QUIT("ReadInput", "ndx, ndy, ndz should be all set to non-zero"); - } - if (para.input.ndx < para.input.nx) - { - ModuleBase::WARNING_QUIT("ReadInput", "ndx should be greater than or equal to nx"); - } - }; - this->add_item(item); - } - { - Input_Item item("ndy"); - item.annotation = "number of points along y axis for FFT smooth grid"; - read_sync_int(input.ndy); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.ndy > para.input.ny) - { - para.sys.double_grid = true; - } - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (!item.is_read()) { - return; -} - if (para.input.ndx * para.input.ndy * para.input.ndz == 0 && para.input.ndy != 0) - { - ModuleBase::WARNING_QUIT("ReadInput", "ndx, ndy, ndz should be all set to non-zero"); - } - if (para.input.ndy < para.input.ny) - { - ModuleBase::WARNING_QUIT("ReadInput", "ndy should be greater than or equal to ny"); - } - }; - this->add_item(item); - } - { - Input_Item item("ndz"); - item.annotation = "number of points along z axis for FFT smooth grid"; - read_sync_int(input.ndz); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.ndy > para.input.ny) - { - para.sys.double_grid = true; - } - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (!item.is_read()) { - return; -} - if (para.input.ndx * para.input.ndy * para.input.ndz == 0 && para.input.ndz != 0) - { - ModuleBase::WARNING_QUIT("ReadInput", "ndx, ndy, ndz should be all set to non-zero"); - } - if (para.input.ndz < para.input.nz) - { - ModuleBase::WARNING_QUIT("ReadInput", "ndz should be greater than or equal to nz"); - } - }; - this->add_item(item); - } - { - Input_Item item("cell_factor"); - item.annotation = "used in the construction of the pseudopotential tables"; - read_sync_double(input.cell_factor); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.calculation == "cell-relax" && para.input.cell_factor < 2.0) - { - para.input.cell_factor = 2.0; // follows QE - } - }; - this->add_item(item); - } - { - Input_Item item("pw_seed"); - item.annotation = "random seed for initializing wave functions"; - read_sync_int(input.pw_seed); - this->add_item(item); - } -} -} // namespace ModuleIO diff --git a/source/module_io/read_input_item_relax.cpp b/source/module_io/read_input_item_relax.cpp index ede0587189..cfd2f22772 100644 --- a/source/module_io/read_input_item_relax.cpp +++ b/source/module_io/read_input_item_relax.cpp @@ -8,140 +8,40 @@ namespace ModuleIO void ReadInput::item_relax() { { - Input_Item item("ks_solver"); - item.annotation = "cg; dav; lapack; genelpa; scalapack_gvx; cusolver"; - read_sync_string(input.ks_solver); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.ks_solver == "default") - { - if (para.input.basis_type == "pw") - { - para.input.ks_solver = "cg"; - ModuleBase::GlobalFunc::AUTO_SET("ks_solver", "cg"); - } - else if (para.input.basis_type == "lcao") - { - if (para.input.device == "gpu") - { - para.input.ks_solver = "cusolver"; - ModuleBase::GlobalFunc::AUTO_SET("ks_solver", "cusolver"); - } - else - { -#ifdef __ELPA - para.input.ks_solver = "genelpa"; - ModuleBase::GlobalFunc::AUTO_SET("ks_solver", "genelpa"); -#else -#ifdef __MPI - para.input.ks_solver = "scalapack_gvx"; - ModuleBase::GlobalFunc::AUTO_SET("ks_solver", "scalapack_gvx"); -#else - para.input.ks_solver = "lapack"; - ModuleBase::GlobalFunc::AUTO_SET("ks_solver", "lapack"); -#endif -#endif - } - } - } - if (para.input.towannier90) - { - if (para.input.basis_type == "lcao_in_pw") - { -#ifdef __ELPA - para.input.ks_solver = "genelpa"; -#else -#ifdef __MPI - para.input.ks_solver = "scalapack_gvx"; -#else - para.input.ks_solver = "lapack"; -#endif -#endif - } - }; - }; + Input_Item item("relax_method"); + item.annotation = "cg; bfgs; sd; cg; cg_bfgs;"; + read_sync_string(input.relax_method); item.check_value = [](const Input_Item& item, const Parameter& para) { - const std::string& ks_solver = para.input.ks_solver; - const std::vector pw_solvers = {"cg", "dav", "bpcg", "dav_subspace"}; - const std::vector lcao_solvers = { - "genelpa", - "lapack", - "scalapack_gvx", - "cusolver", - "pexsi", - "cg_in_lcao", - }; - - if (para.input.basis_type == "pw") - { - if (!find_str(pw_solvers, ks_solver)) - { - ModuleBase::WARNING_QUIT("ReadInput", - "ks_solver must be cg, dav, bpcg " - "or dav_subspace for pw basis."); - } - } - else if (para.input.basis_type == "lcao") + const std::vector relax_methods = {"cg", "bfgs", "sd", "cg_bfgs"}; + if (!find_str(relax_methods, para.input.relax_method)) { - if (!find_str(lcao_solvers, ks_solver)) - { - ModuleBase::WARNING_QUIT("ReadInput", - "ks_solver must be genelpa, lapack, scalapack_gvx, " - "cusolver, pexsi or " - "cg_in_lcao for lcao basis."); - } - if (ks_solver == "cg_in_lcao") - { - GlobalV::ofs_warning << "cg_in_lcao is under testing" << std::endl; - } - else if (ks_solver == "genelpa") - { -#ifndef __ELPA - ModuleBase::WARNING_QUIT("Input", - "Can not use genelpa if abacus is not compiled with " - "ELPA. Please change " - "ks_solver to scalapack_gvx."); -#endif - } - else if (ks_solver == "scalapack_gvx") - { -#ifdef __MPI - GlobalV::ofs_warning << "scalapack_gvx is under testing" << std::endl; -#else - ModuleBase::WARNING_QUIT("ReadInput", "scalapack_gvx can not be used for series version."); -#endif - } - else if (ks_solver == "cusolver" || ks_solver == "cusolvermp") - { -#ifndef __MPI - ModuleBase::WARNING_QUIT("ReadInput", "Cusolver can not be used for series version."); -#endif - } - else if (ks_solver == "pexsi") - { -#ifdef __PEXSI - GlobalV::ofs_warning << " It's ok to use pexsi." << std::endl; -#else - ModuleBase::WARNING_QUIT("ReadInput", - "Can not use PEXSI if abacus is not compiled with " - "PEXSI. Please change " - "ks_solver to scalapack_gvx."); -#endif - } + ModuleBase::WARNING_QUIT("ReadInput", "relax_method must be cg, bfgs, sd or cg_bfgs."); } - else if (para.input.basis_type == "lcao_in_pw") + }; + this->add_item(item); + } + { + Input_Item item("relax_new"); + item.annotation = "whether to use the new relaxation method"; + read_sync_bool(input.relax_new); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.relax_new && para.input.relax_method != "cg") { - if (ks_solver != "lapack") - { - ModuleBase::WARNING_QUIT("ReadInput", "LCAO in plane wave can only done with lapack."); - } + para.input.relax_new = false; } }; this->add_item(item); } { - Input_Item item("scf_nmax"); - item.annotation = "number of electron iterations"; - read_sync_int(input.scf_nmax); + Input_Item item("relax"); + item.annotation = "allow relaxation along the specific direction"; + read_sync_bool(input.relax); + this->add_item(item); + } + { + Input_Item item("relax_scale_force"); + item.annotation = "controls the size of the first CG step if relax_new is true"; + read_sync_double(input.relax_scale_force); this->add_item(item); } { @@ -167,16 +67,9 @@ void ReadInput::item_relax() this->add_item(item); } { - Input_Item item("out_stru"); - item.annotation = "output the structure files after each ion step"; - item.reset_value = [](const Input_Item& item, Parameter& para) { - const std::vector offlist = {"nscf", "get_S", "get_pchg", "get_wf"}; - if (find_str(offlist, para.input.calculation)) - { - para.input.out_stru = false; - } - }; - read_sync_bool(input.out_stru); + Input_Item item("relax_cg_thr"); + item.annotation = "threshold for switching from cg to bfgs, unit: eV/Angstrom"; + read_sync_double(input.relax_cg_thr); this->add_item(item); } { @@ -219,12 +112,6 @@ void ReadInput::item_relax() read_sync_double(input.force_thr_ev2); this->add_item(item); } - { - Input_Item item("relax_cg_thr"); - item.annotation = "threshold for switching from cg to bfgs, unit: eV/Angstrom"; - read_sync_double(input.relax_cg_thr); - this->add_item(item); - } { Input_Item item("stress_thr"); item.annotation = "stress threshold"; @@ -279,28 +166,6 @@ void ReadInput::item_relax() read_sync_double(input.relax_bfgs_init); this->add_item(item); } - { - Input_Item item("cal_stress"); - item.annotation = "calculate the stress or not"; - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.calculation == "md") - { - if (para.input.esolver_type == "lj" || para.input.esolver_type == "dp" - || para.input.mdp.md_type == "msst" || para.input.mdp.md_type == "npt") - { - para.input.cal_stress = true; - } - } - else if (para.input.calculation == "cell-relax") - { - para.input.cal_stress = true; - } - para.input.mdp.cal_stress = para.input.cal_stress; // temperaory - }; - read_sync_bool(input.cal_stress); - add_bool_bcast(input.mdp.cal_stress); - this->add_item(item); - } { Input_Item item("fixed_axes"); item.annotation = "which axes are fixed"; @@ -342,159 +207,5 @@ void ReadInput::item_relax() }; this->add_item(item); } - { - Input_Item item("relax_method"); - item.annotation = "cg; bfgs; sd; cg; cg_bfgs;"; - read_sync_string(input.relax_method); - item.check_value = [](const Input_Item& item, const Parameter& para) { - const std::vector relax_methods = {"cg", "bfgs", "sd", "cg_bfgs"}; - if (!find_str(relax_methods, para.input.relax_method)) - { - ModuleBase::WARNING_QUIT("ReadInput", "relax_method must be cg, bfgs, sd or cg_bfgs."); - } - }; - this->add_item(item); - } - { - Input_Item item("relax_new"); - item.annotation = "whether to use the new relaxation method"; - read_sync_bool(input.relax_new); - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.relax_new && para.input.relax_method != "cg") - { - para.input.relax_new = false; - } - }; - this->add_item(item); - } - { - Input_Item item("relax_scale_force"); - item.annotation = "controls the size of the first CG step if relax_new is true"; - read_sync_double(input.relax_scale_force); - this->add_item(item); - } - { - Input_Item item("out_level"); - item.annotation = "ie(for electrons); i(for ions);"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.out_level = strvalue; - para.sys.out_md_control = true; - }; - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (!para.sys.out_md_control && para.input.calculation == "md") - { - para.input.out_level = "m"; // zhengdy add 2019-04-07 - } - }; - sync_string(input.out_level); - this->add_item(item); - } - { - Input_Item item("out_dm"); - item.annotation = ">0 output density matrix"; - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.calculation == "get_pchg" || para.input.calculation == "get_wf") - { - para.input.out_dm = false; - } - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.sys.gamma_only_local == false && para.input.out_dm) - { - ModuleBase::WARNING_QUIT("ReadInput", "out_dm with k-point algorithm is not implemented yet."); - } - }; - read_sync_bool(input.out_dm); - this->add_item(item); - } - { - Input_Item item("out_dm1"); - item.annotation = ">0 output density matrix (multi-k points)"; - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.calculation == "get_pchg" || para.input.calculation == "get_wf") - { - para.input.out_dm1 = false; - } - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.sys.gamma_only_local == true && para.input.out_dm1) - { - ModuleBase::WARNING_QUIT("ReadInput", "out_dm1 is only for multi-k"); - } - }; - read_sync_bool(input.out_dm1); - this->add_item(item); - } - { - Input_Item item("out_bandgap"); - item.annotation = "if true, print out bandgap"; - read_sync_bool(input.out_bandgap); - this->add_item(item); - } - { - Input_Item item("use_paw"); - item.annotation = "whether to use PAW in pw calculation"; - read_sync_bool(input.use_paw); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.use_paw) - { -#ifndef USE_PAW - ModuleBase::WARNING_QUIT("ReadInput", "to use PAW, compile with USE_PAW"); -#endif - if (para.input.basis_type != "pw") - { - ModuleBase::WARNING_QUIT("ReadInput", "PAW is for pw basis only"); - } - if (para.input.dft_functional == "default") - { - ModuleBase::WARNING_QUIT("ReadInput", "dft_functional must be set when use_paw is true"); - } - } - }; - this->add_item(item); - } - { - Input_Item item("deepks_out_labels"); - item.annotation = ">0 compute descriptor for deepks"; - read_sync_bool(input.deepks_out_labels); - this->add_item(item); - } - { - Input_Item item("deepks_scf"); - item.annotation = ">0 add V_delta to Hamiltonian"; - read_sync_bool(input.deepks_scf); - this->add_item(item); - } - { - Input_Item item("deepks_equiv"); - item.annotation = "whether to use equivariant version of DeePKS"; - read_sync_bool(input.deepks_equiv); - this->add_item(item); - } - { - Input_Item item("deepks_bandgap"); - item.annotation = ">0 for bandgap label"; - read_sync_bool(input.deepks_bandgap); - this->add_item(item); - } - { - Input_Item item("deepks_v_delta"); - item.annotation = ">0 for v_delta label. when output, 1 for v_delta_precalc, 2 for psialpha and grad_evdm ( can save memory )"; - read_sync_int(input.deepks_v_delta); - this->add_item(item); - } - { - Input_Item item("deepks_out_unittest"); - item.annotation = "if set 1, prints intermediate quantities that shall " - "be used for making unit test"; - read_sync_bool(input.deepks_out_unittest); - this->add_item(item); - } - { - Input_Item item("deepks_model"); - item.annotation = "file dir of traced pytorch model: 'model.ptg"; - read_sync_string(input.deepks_model); - this->add_item(item); - } } } // namespace ModuleIO \ No newline at end of file diff --git a/source/module_io/read_input_item_sdft.cpp b/source/module_io/read_input_item_sdft.cpp index 69db574320..2f532680b1 100644 --- a/source/module_io/read_input_item_sdft.cpp +++ b/source/module_io/read_input_item_sdft.cpp @@ -107,59 +107,5 @@ void ReadInput::item_sdft() read_sync_int(input.initsto_freq); this->add_item(item); } - { - Input_Item item("cal_cond"); - item.annotation = "calculate electronic conductivities"; - read_sync_bool(input.cal_cond); - this->add_item(item); - } - { - Input_Item item("cond_che_thr"); - item.annotation = "control the error of Chebyshev expansions for conductivities"; - read_sync_double(input.cond_che_thr); - this->add_item(item); - } - { - Input_Item item("cond_dw"); - item.annotation = "frequency interval for conductivities"; - read_sync_double(input.cond_dw); - this->add_item(item); - } - { - Input_Item item("cond_wcut"); - item.annotation = "cutoff frequency (omega) for conductivities"; - read_sync_double(input.cond_wcut); - this->add_item(item); - } - { - Input_Item item("cond_dt"); - item.annotation = "t interval to integrate Onsager coefficiencies"; - read_sync_double(input.cond_dt); - this->add_item(item); - } - { - Input_Item item("cond_dtbatch"); - item.annotation = "exp(iH*dt*cond_dtbatch) is expanded with Chebyshev expansion"; - read_sync_int(input.cond_dtbatch); - this->add_item(item); - } - { - Input_Item item("cond_smear"); - item.annotation = "Smearing method for conductivities"; - read_sync_int(input.cond_smear); - this->add_item(item); - } - { - Input_Item item("cond_fwhm"); - item.annotation = "FWHM for conductivities"; - read_sync_double(input.cond_fwhm); - this->add_item(item); - } - { - Input_Item item("cond_nonlocal"); - item.annotation = "Nonlocal effects for conductivities"; - read_sync_bool(input.cond_nonlocal); - this->add_item(item); - } } } // namespace ModuleIO \ No newline at end of file diff --git a/source/module_io/read_input_item_general.cpp b/source/module_io/read_input_item_system.cpp similarity index 58% rename from source/module_io/read_input_item_general.cpp rename to source/module_io/read_input_item_system.cpp index 3d2c2ce000..b3fb68f8f9 100644 --- a/source/module_io/read_input_item_general.cpp +++ b/source/module_io/read_input_item_system.cpp @@ -44,7 +44,7 @@ namespace ModuleIO // add_doublevec_bcast(&Parameter::PARAMETER, N); // this->add_item(item); // } -void ReadInput::item_general() +void ReadInput::item_system() { { Input_Item item("suffix"); @@ -53,70 +53,10 @@ void ReadInput::item_general() this->add_item(item); } { - Input_Item item("latname"); - item.annotation = "the name of lattice name"; - read_sync_string(input.latname); - this->add_item(item); - } - { - Input_Item item("stru_file"); - item.annotation = "the filename of file containing atom positions"; - read_sync_string(input.stru_file); - this->add_item(item); - } - { - Input_Item item("kpoint_file"); - item.annotation = "the name of file containing k points"; - read_sync_string(input.kpoint_file); - this->add_item(item); - } - { - Input_Item item("pseudo_dir"); - item.annotation = "the directory containing pseudo files"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.pseudo_dir = to_dir(strvalue); - }; - sync_string(input.pseudo_dir); - this->add_item(item); - } - { - Input_Item item("orbital_dir"); - item.annotation = "the directory containing orbital files"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.orbital_dir = to_dir(strvalue); - }; - sync_string(input.orbital_dir); - this->add_item(item); - } - { - Input_Item item("pseudo_rcut"); - item.annotation = "default #exchange correlation functional"; - read_sync_double(input.pseudo_rcut); - this->add_item(item); - } - { - Input_Item item("pseudo_mesh"); - item.annotation = "0: use our own mesh to do radial renormalization; " - "1: use mesh as in QE"; - read_sync_bool(input.pseudo_mesh); - this->add_item(item); - } - { - Input_Item item("lmaxmax"); - item.annotation = "maximum of l channels used"; - read_sync_int(input.lmaxmax); - this->add_item(item); - } - { - Input_Item item("dft_functional"); - item.annotation = "exchange correlation functional"; - read_sync_string(input.dft_functional); - this->add_item(item); - } - { - Input_Item item("xc_temperature"); - item.annotation = "temperature for finite temperature functionals"; - read_sync_double(input.xc_temperature); + Input_Item item("ntype"); + item.annotation = "atom species number"; + // check of ntype is done in check_ntype + read_sync_int(input.ntype); this->add_item(item); } { @@ -192,294 +132,514 @@ void ReadInput::item_general() this->add_item(item); } { - Input_Item item("ntype"); - item.annotation = "atom species number"; - // check of ntype is done in check_ntype - read_sync_int(input.ntype); + Input_Item item("symmetry"); + item.annotation = "the control of symmetry"; + read_sync_string(input.symmetry); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.symmetry == "default") + { + if (para.input.gamma_only || para.input.calculation == "nscf" || para.input.calculation == "get_S" + || para.input.calculation == "get_pchg" || para.input.calculation == "get_wf") + { + para.input.symmetry = "0"; // if md or exx, symmetry will be + // force-set to 0 or -1 later + } + else + { + para.input.symmetry = "1"; + } + } + if (para.input.calculation == "md") + { + para.input.symmetry = "0"; + } + if (para.input.efield_flag) + { + para.input.symmetry = "0"; + } + if (para.input.qo_switch) + { + para.input.symmetry = "-1"; // disable kpoint reduce + } + }; + this->add_item(item); + } + { + Input_Item item("symmetry_prec"); + item.annotation = "accuracy for symmetry"; + read_sync_double(input.symmetry_prec); this->add_item(item); } { - Input_Item item("nspin"); - item.annotation = "1: single spin; 2: up and down spin; 4: noncollinear spin"; - read_sync_int(input.nspin); + Input_Item item("symmetry_autoclose"); + item.annotation = "whether to close symmetry automatically when error " + "occurs in symmetry analysis"; + read_sync_bool(input.symmetry_autoclose); + this->add_item(item); + } + { + Input_Item item("cal_stress"); + item.annotation = "calculate the stress or not"; item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.noncolin || para.input.lspinorb) + if (para.input.calculation == "md") { - para.input.nspin = 4; + if (para.input.esolver_type == "lj" || para.input.esolver_type == "dp" + || para.input.mdp.md_type == "msst" || para.input.mdp.md_type == "npt") + { + para.input.cal_stress = true; + } } - }; - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.nspin != 1 && para.input.nspin != 2 && para.input.nspin != 4) + else if (para.input.calculation == "cell-relax") { - ModuleBase::WARNING_QUIT("ReadInput", "nspin should be 1, 2 or 4."); + para.input.cal_stress = true; } + para.input.mdp.cal_stress = para.input.cal_stress; // temperaory }; + read_sync_bool(input.cal_stress); + add_bool_bcast(input.mdp.cal_stress); this->add_item(item); } { - Input_Item item("kspacing"); - item.annotation = "unit in 1/bohr, should be > 0, default is 0 which " - "means read KPT file"; - item.read_value = [](const Input_Item& item, Parameter& para) { - size_t count = item.get_size(); - if (count == 1) + Input_Item item("cal_force"); + item.annotation = "if calculate the force at the end of the electronic iteration"; + item.reset_value = [](const Input_Item& item, Parameter& para) { + std::vector use_force = {"cell-relax", "relax", "md"}; + std::vector not_use_force = {"get_wf", "get_pchg", "nscf", "get_S"}; + if (find_str(use_force, para.input.calculation)) { - para.input.kspacing[0] = para.input.kspacing[1] = para.input.kspacing[2] = doublevalue; + if (!para.input.cal_force) + { + ModuleBase::GlobalFunc::AUTO_SET("cal_force", "true"); + } + para.input.cal_force = true; } - else if (count == 3) + else if (find_str(not_use_force, para.input.calculation)) { - para.input.kspacing[0] = std::stod(item.str_values[0]); - para.input.kspacing[1] = std::stod(item.str_values[1]); - para.input.kspacing[2] = std::stod(item.str_values[2]); + if (para.input.cal_force) + { + ModuleBase::GlobalFunc::AUTO_SET("cal_force", "false"); + } + para.input.cal_force = false; } - else + }; + read_sync_bool(input.cal_force); + this->add_item(item); + } + { + Input_Item item("kpar"); + item.annotation = "devide all processors into kpar groups and k points " + "will be distributed among"; + read_sync_int(input.kpar); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.basis_type == "lcao" && para.input.kpar > 1) { - ModuleBase::WARNING_QUIT("ReadInput", "kspacing can only accept one or three values."); + ModuleBase::WARNING("ReadInput", "kpar > 1 has not been supported for lcao calculation."); } }; - sync_doublevec(input.kspacing, 3, 0.0); - item.check_value = [](const Input_Item& item, const Parameter& para) { - int kspacing_zero_num = 0; - const std::vector& kspacing = para.input.kspacing; - for (int i = 0; i < 3; i++) + this->add_item(item); + } + { + Input_Item item("bndpar"); + item.annotation = "devide all processors into bndpar groups and bands " + "will be distributed among each group"; + read_sync_int(input.bndpar); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.esolver_type != "sdft") { - if (kspacing[i] < 0.0) - { - ModuleBase::WARNING_QUIT("ReadInput", "kspacing must > 0"); - } - else if (kspacing[i] == 0.0) - { - kspacing_zero_num++; - } + para.input.bndpar = 1; } - if (kspacing_zero_num > 0 && kspacing_zero_num < 3) + if (para.input.bndpar > GlobalV::NPROC) { - std::cout << "kspacing: " << kspacing[0] << " " << kspacing[1] << " " << kspacing[2] << std::endl; - ModuleBase::WARNING_QUIT("ReadInput", "kspacing must > 0"); + para.input.bndpar = GlobalV::NPROC; } }; this->add_item(item); } { - Input_Item item("min_dist_coef"); - item.annotation = "factor related to the allowed minimum distance " - "between two atoms"; - read_sync_double(input.min_dist_coef); + Input_Item item("latname"); + item.annotation = "the name of lattice name"; + read_sync_string(input.latname); this->add_item(item); } { - Input_Item item("nbands"); - item.annotation = "number of bands"; - read_sync_int(input.nbands); + Input_Item item("ecutwfc"); + item.annotation = "energy cutoff for wave functions"; + read_sync_double(input.ecutwfc); + this->add_item(item); + } + { + Input_Item item("ecutrho"); + item.annotation = "energy cutoff for charge density and potential"; + read_sync_double(input.ecutrho); + item.reset_value = [](const Input_Item& item, Parameter& para) { + Input_para& input = para.input; + if (input.ecutrho <= 0.0) + { + input.ecutrho = 4.0 * input.ecutwfc; + } + if (input.nx * input.ny * input.nz == 0 && input.ecutrho / input.ecutwfc > 4 + 1e-8) + { + para.sys.double_grid = true; + } + }; item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.nbands < 0) + if (para.input.ecutrho / para.input.ecutwfc < 4 - 1e-8) { - ModuleBase::WARNING_QUIT("ReadInput", "nbands should be greater than 0."); + ModuleBase::WARNING_QUIT("ReadInput", "ecutrho/ecutwfc must >= 4"); } }; this->add_item(item); } { - Input_Item item("nbands_istate"); - item.annotation = "number of bands around Fermi level for get_wf and get_pchg calulation"; - read_sync_int(input.nbands_istate); + Input_Item item("nx"); + item.annotation = "number of points along x axis for FFT grid"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.nx = intvalue; + para.sys.ncx = intvalue; + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.nx * para.input.ny * para.input.nz == 0 && para.input.nx != 0) + { + ModuleBase::WARNING_QUIT("ReadInput", "nx, ny, nz should be all set to non-zero"); + } + }; + sync_int(input.nx); this->add_item(item); } { - Input_Item item("bands_to_print"); - item.annotation = "specify the bands to be calculated in get_wf and get_pchg calculation"; + Input_Item item("ny"); + item.annotation = "number of points along y axis for FFT grid"; item.read_value = [](const Input_Item& item, Parameter& para) { - parse_expression(item.str_values, para.input.bands_to_print); + para.input.ny = intvalue; + para.sys.ncy = intvalue; }; - item.get_final_value = [](Input_Item& item, const Parameter& para) { - if(item.is_read()) + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.nx * para.input.ny * para.input.nz == 0 && para.input.ny != 0) { - item.final_value.str(longstring(item.str_values)); + ModuleBase::WARNING_QUIT("ReadInput", "nx, ny, nz should be all set to non-zero"); } }; - add_intvec_bcast(input.bands_to_print, para.input.bands_to_print.size(), 0); + sync_int(input.ny); this->add_item(item); } { - Input_Item item("if_separate_k"); - item.annotation = "specify whether to write the partial charge densities for all k-points to individual files or merge them"; - read_sync_bool(input.if_separate_k); + Input_Item item("nz"); + item.annotation = "number of points along z axis for FFT grid"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.nz = intvalue; + para.sys.ncz = intvalue; + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.nx * para.input.ny * para.input.nz == 0 && para.input.nz != 0) + { + ModuleBase::WARNING_QUIT("ReadInput", "nx, ny, nz should be all set to non-zero"); + } + }; + sync_int(input.nz); this->add_item(item); } { - Input_Item item("symmetry"); - item.annotation = "the control of symmetry"; - read_sync_string(input.symmetry); + Input_Item item("ndx"); + item.annotation = "number of points along x axis for FFT smooth grid"; + read_sync_int(input.ndx); item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.symmetry == "default") + if (para.input.ndx > para.input.nx) { - if (para.input.gamma_only || para.input.calculation == "nscf" || para.input.calculation == "get_S" - || para.input.calculation == "get_pchg" || para.input.calculation == "get_wf") - { - para.input.symmetry = "0"; // if md or exx, symmetry will be - // force-set to 0 or -1 later - } - else - { - para.input.symmetry = "1"; - } + para.sys.double_grid = true; } - if (para.input.calculation == "md") + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (!item.is_read()) { - para.input.symmetry = "0"; + return; } - if (para.input.efield_flag) + if (para.input.ndx * para.input.ndy * para.input.ndz == 0 && para.input.ndx != 0) { - para.input.symmetry = "0"; + ModuleBase::WARNING_QUIT("ReadInput", "ndx, ndy, ndz should be all set to non-zero"); } - if (para.input.qo_switch) + if (para.input.ndx < para.input.nx) { - para.input.symmetry = "-1"; // disable kpoint reduce + ModuleBase::WARNING_QUIT("ReadInput", "ndx should be greater than or equal to nx"); } }; this->add_item(item); } { - Input_Item item("init_vel"); - item.annotation = "read velocity from STRU or not"; + Input_Item item("ndy"); + item.annotation = "number of points along y axis for FFT smooth grid"; + read_sync_int(input.ndy); item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.calculation == "md") + if (para.input.ndy > para.input.ny) { - if (para.input.mdp.md_tfirst < 0 || para.input.mdp.md_restart) - { - para.input.init_vel = true; - } + para.sys.double_grid = true; + } + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (!item.is_read()) { + return; +} + if (para.input.ndx * para.input.ndy * para.input.ndz == 0 && para.input.ndy != 0) + { + ModuleBase::WARNING_QUIT("ReadInput", "ndx, ndy, ndz should be all set to non-zero"); + } + if (para.input.ndy < para.input.ny) + { + ModuleBase::WARNING_QUIT("ReadInput", "ndy should be greater than or equal to ny"); } }; - read_sync_bool(input.init_vel); - this->add_item(item); - } - { - Input_Item item("symmetry_prec"); - item.annotation = "accuracy for symmetry"; - read_sync_double(input.symmetry_prec); - this->add_item(item); - } - { - Input_Item item("symmetry_autoclose"); - item.annotation = "whether to close symmetry automatically when error " - "occurs in symmetry analysis"; - read_sync_bool(input.symmetry_autoclose); this->add_item(item); } { - Input_Item item("nelec"); - item.annotation = "input number of electrons"; + Input_Item item("ndz"); + item.annotation = "number of points along z axis for FFT smooth grid"; + read_sync_int(input.ndz); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.ndy > para.input.ny) + { + para.sys.double_grid = true; + } + }; item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.nelec < 0) + if (!item.is_read()) { + return; +} + if (para.input.ndx * para.input.ndy * para.input.ndz == 0 && para.input.ndz != 0) { - ModuleBase::WARNING_QUIT("ReadInput", "nelec should be greater than 0."); + ModuleBase::WARNING_QUIT("ReadInput", "ndx, ndy, ndz should be all set to non-zero"); } - if (para.input.nelec > 0 && para.input.nbands > 0 && para.input.nelec > 2 * para.input.nbands) + if (para.input.ndz < para.input.nz) { - ModuleBase::WARNING_QUIT("ReadInput", "nelec > 2*nbnd , bands not enough!"); + ModuleBase::WARNING_QUIT("ReadInput", "ndz should be greater than or equal to nz"); } }; - read_sync_double(input.nelec); this->add_item(item); } { - Input_Item item("nelec_delta"); - item.annotation = "change in the number of total electrons"; - read_sync_double(input.nelec_delta); + Input_Item item("cell_factor"); + item.annotation = "used in the construction of the pseudopotential tables"; + read_sync_double(input.cell_factor); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.calculation == "cell-relax" && para.input.cell_factor < 2.0) + { + para.input.cell_factor = 2.0; // follows QE + } + }; this->add_item(item); } { - Input_Item item("nupdown"); - item.annotation = "the difference number of electrons between spin-up " - "and spin-down"; - item.read_value = [](const Input_Item& item, Parameter& para) { - para.input.nupdown = doublevalue; - para.sys.two_fermi = true; + Input_Item item("erf_ecut"); + item.annotation = "the value of the constant energy cutoff"; + read_sync_double(input.erf_ecut); + this->add_item(item); + } + { + Input_Item item("erf_height"); + item.annotation = "the height of the energy step for reciprocal vectors"; + read_sync_double(input.erf_height); + this->add_item(item); + } + { + Input_Item item("erf_sigma"); + item.annotation = "the width of the energy step for reciprocal vectors"; + read_sync_double(input.erf_sigma); + this->add_item(item); + } + { + Input_Item item("fft_mode"); + item.annotation = "mode of FFTW"; + read_sync_int(input.fft_mode); + this->add_item(item); + } + { + Input_Item item("diago_full_acc"); + item.annotation = "all the empty states are diagonalized"; + read_sync_bool(input.diago_full_acc); + this->add_item(item); + } + { + Input_Item item("init_wfc"); + item.annotation = "start wave functions are from 'atomic', " + "'atomic+random', 'random' or"; + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.calculation == "get_pchg" || para.input.calculation == "get_wf") + { + para.input.init_wfc = "file"; + } + if (para.input.basis_type == "lcao_in_pw") + { + if (para.input.init_wfc != "nao") + { + para.input.init_wfc = "nao"; + GlobalV::ofs_warning << "init_wfc is set to nao when " + "basis_type is lcao_in_pw" + << std::endl; + } + } }; - - sync_double(input.nupdown); + read_sync_string(input.init_wfc); this->add_item(item); } { - Input_Item item("out_mul"); - item.annotation = "mulliken charge or not"; - read_sync_bool(input.out_mul); + Input_Item item("psi_initializer"); + item.annotation = "whether to use psi_initializer"; + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.basis_type == "lcao_in_pw") + { + para.input.psi_initializer = true; + } + }; + read_sync_bool(input.psi_initializer); this->add_item(item); } { - Input_Item item("noncolin"); - item.annotation = "using non-collinear-spin"; - read_sync_bool(input.noncolin); + Input_Item item("pw_seed"); + item.annotation = "random seed for initializing wave functions"; + read_sync_int(input.pw_seed); this->add_item(item); } { - Input_Item item("lspinorb"); - item.annotation = "consider the spin-orbit interaction"; - read_sync_bool(input.lspinorb); + Input_Item item("init_chg"); + item.annotation = "start charge is from 'atomic' or file"; + read_sync_string(input.init_chg); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.calculation == "get_pchg" || para.input.calculation == "get_wf") + { + para.input.init_chg = "atomic"; + } + if (para.input.calculation == "nscf" || para.input.calculation == "get_S") + { + if (para.input.init_chg != "file") + { + ModuleBase::GlobalFunc::AUTO_SET("init_chg", para.input.init_chg); + } + para.input.init_chg = "file"; + } + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.init_chg != "atomic" && para.input.init_chg != "file" && para.input.init_chg != "auto") + { + ModuleBase::WARNING_QUIT("ReadInput", "init_chg should be 'atomic', 'file' or 'auto'"); + } + }; this->add_item(item); } { - Input_Item item("kpar"); - item.annotation = "devide all processors into kpar groups and k points " - "will be distributed among"; - read_sync_int(input.kpar); + Input_Item item("dm_to_rho"); + item.annotation = "reads dmr in npz format and calculates electron density"; + read_sync_bool(input.dm_to_rho); item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.basis_type == "lcao" && para.input.kpar > 1) + if (para.input.dm_to_rho && GlobalV::NPROC > 1) { - ModuleBase::WARNING("ReadInput", "kpar > 1 has not been supported for lcao calculation."); + ModuleBase::WARNING_QUIT("ReadInput", "dm_to_rho is not available for parallel calculations"); + } + if (para.input.dm_to_rho) + { +#ifndef __USECNPY + ModuleBase::WARNING_QUIT("ReadInput", + "to write in npz format, please " + "recompile with -DENABLE_CNPY=1"); +#endif } }; this->add_item(item); } { - Input_Item item("bndpar"); - item.annotation = "devide all processors into bndpar groups and bands " - "will be distributed among each group"; - read_sync_int(input.bndpar); + Input_Item item("chg_extrap"); + item.annotation = "atomic; first-order; second-order; dm:coefficients of SIA"; + read_sync_string(input.chg_extrap); item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.esolver_type != "sdft") + if (para.input.chg_extrap == "default" && para.input.calculation == "md") { - para.input.bndpar = 1; + para.input.chg_extrap = "second-order"; } - if (para.input.bndpar > GlobalV::NPROC) + else if (para.input.chg_extrap == "default" + && (para.input.calculation == "relax" || para.input.calculation == "cell-relax")) { - para.input.bndpar = GlobalV::NPROC; + para.input.chg_extrap = "first-order"; + } + else if (para.input.chg_extrap == "default") + { + para.input.chg_extrap = "atomic"; + } + if (para.input.calculation == "get_wf" || para.input.calculation == "get_pchg") + { + para.input.chg_extrap = "atomic"; + } + }; + this->add_item(item); + } + { + Input_Item item("init_vel"); + item.annotation = "read velocity from STRU or not"; + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.calculation == "md") + { + if (para.input.mdp.md_tfirst < 0 || para.input.mdp.md_restart) + { + para.input.init_vel = true; + } } }; + read_sync_bool(input.init_vel); + this->add_item(item); + } + { + Input_Item item("stru_file"); + item.annotation = "the filename of file containing atom positions"; + read_sync_string(input.stru_file); this->add_item(item); } { - Input_Item item("out_freq_elec"); - item.annotation = "the frequency ( >= 0) of electronic iter to output " - "charge density and wavefunction. 0: " - "output only when converged"; - read_sync_int(input.out_freq_elec); + Input_Item item("kpoint_file"); + item.annotation = "the name of file containing k points"; + read_sync_string(input.kpoint_file); this->add_item(item); } { - Input_Item item("dft_plus_dmft"); - item.annotation = "true:DFT+DMFT; false: standard DFT calcullation(default)"; - read_sync_bool(input.dft_plus_dmft); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.basis_type != "lcao" && para.input.dft_plus_dmft) + Input_Item item("pseudo_dir"); + item.annotation = "the directory containing pseudo files"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.pseudo_dir = to_dir(strvalue); + }; + sync_string(input.pseudo_dir); + this->add_item(item); + } + { + Input_Item item("orbital_dir"); + item.annotation = "the directory containing orbital files"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.orbital_dir = to_dir(strvalue); + }; + sync_string(input.orbital_dir); + this->add_item(item); + } + { + Input_Item item("read_file_dir"); + item.annotation = "directory of files for reading"; + read_sync_string(input.read_file_dir); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.read_file_dir == "auto") { - ModuleBase::WARNING_QUIT("ReadInput", "DFT+DMFT is only supported for lcao calculation."); + para.input.read_file_dir = "OUT." + para.input.suffix; } + else + { + para.input.read_file_dir = para.input.read_file_dir; + } + para.input.read_file_dir = to_dir(para.input.read_file_dir); }; this->add_item(item); } { - Input_Item item("rpa"); - item.annotation = "true:generate output files used in rpa calculation; " - "false:(default)"; - read_sync_bool(input.rpa); + Input_Item item("restart_load"); + item.annotation = "restart from disk"; + read_sync_bool(input.restart_load); this->add_item(item); } { - Input_Item item("printe"); - item.annotation = "Print out energy for each band for every printe steps"; - read_sync_int(input.printe); + Input_Item item("wannier_card"); + item.annotation = "input card for wannier functions"; + read_sync_string(input.wannier_card); this->add_item(item); } { @@ -519,50 +679,54 @@ void ReadInput::item_general() this->add_item(item); } { - Input_Item item("wannier_card"); - item.annotation = "input card for wannier functions"; - read_sync_string(input.wannier_card); - this->add_item(item); - } - { - Input_Item item("soc_lambda"); - item.annotation = "The fraction of averaged SOC pseudopotential is " - "given by (1-soc_lambda)"; - read_sync_double(input.soc_lambda); - this->add_item(item); - } - { - Input_Item item("cal_force"); - item.annotation = "if calculate the force at the end of the electronic iteration"; - item.reset_value = [](const Input_Item& item, Parameter& para) { - std::vector use_force = {"cell-relax", "relax", "md"}; - std::vector not_use_force = {"get_wf", "get_pchg", "nscf", "get_S"}; - if (find_str(use_force, para.input.calculation)) + Input_Item item("kspacing"); + item.annotation = "unit in 1/bohr, should be > 0, default is 0 which " + "means read KPT file"; + item.read_value = [](const Input_Item& item, Parameter& para) { + size_t count = item.get_size(); + if (count == 1) { - if (!para.input.cal_force) - { - ModuleBase::GlobalFunc::AUTO_SET("cal_force", "true"); - } - para.input.cal_force = true; + para.input.kspacing[0] = para.input.kspacing[1] = para.input.kspacing[2] = doublevalue; } - else if (find_str(not_use_force, para.input.calculation)) + else if (count == 3) { - if (para.input.cal_force) + para.input.kspacing[0] = std::stod(item.str_values[0]); + para.input.kspacing[1] = std::stod(item.str_values[1]); + para.input.kspacing[2] = std::stod(item.str_values[2]); + } + else + { + ModuleBase::WARNING_QUIT("ReadInput", "kspacing can only accept one or three values."); + } + }; + sync_doublevec(input.kspacing, 3, 0.0); + item.check_value = [](const Input_Item& item, const Parameter& para) { + int kspacing_zero_num = 0; + const std::vector& kspacing = para.input.kspacing; + for (int i = 0; i < 3; i++) + { + if (kspacing[i] < 0.0) { - ModuleBase::GlobalFunc::AUTO_SET("cal_force", "false"); + ModuleBase::WARNING_QUIT("ReadInput", "kspacing must > 0"); + } + else if (kspacing[i] == 0.0) + { + kspacing_zero_num++; } - para.input.cal_force = false; + } + if (kspacing_zero_num > 0 && kspacing_zero_num < 3) + { + std::cout << "kspacing: " << kspacing[0] << " " << kspacing[1] << " " << kspacing[2] << std::endl; + ModuleBase::WARNING_QUIT("ReadInput", "kspacing must > 0"); } }; - read_sync_bool(input.cal_force); this->add_item(item); } { - Input_Item item("out_freq_ion"); - item.annotation = "the frequency ( >= 0 ) of ionic step to output " - "charge density and wavefunction. 0: output " - "only when ion steps are finished"; - read_sync_int(input.out_freq_ion); + Input_Item item("min_dist_coef"); + item.annotation = "factor related to the allowed minimum distance " + "between two atoms"; + read_sync_double(input.min_dist_coef); this->add_item(item); } { diff --git a/source/module_io/read_input_item_tddft.cpp b/source/module_io/read_input_item_tddft.cpp new file mode 100644 index 0000000000..544fe00ebb --- /dev/null +++ b/source/module_io/read_input_item_tddft.cpp @@ -0,0 +1,354 @@ +#include "module_base/constants.h" +#include "module_base/tool_quit.h" +#include "read_input.h" +#include "read_input_tool.h" + +namespace ModuleIO +{ +void ReadInput::item_rt_tddft() +{ + // real time TDDFT + { + Input_Item item("td_force_dt"); + item.annotation = "time of force change"; + read_sync_double(input.td_force_dt); + this->add_item(item); + } + { + Input_Item item("td_vext"); + item.annotation = "add extern potential or not"; + read_sync_bool(input.td_vext); + this->add_item(item); + } + { + Input_Item item("td_vext_dire"); + item.annotation = "extern potential direction"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.td_vext_dire = longstring(item.str_values); + }; + sync_string(input.td_vext_dire); + this->add_item(item); + } + { + Input_Item item("init_vecpot_file"); + item.annotation = "init vector potential through file or not"; + read_sync_bool(input.init_vecpot_file); + this->add_item(item); + } + { + Input_Item item("td_print_eij"); + item.annotation = "print eij or not"; + read_sync_double(input.td_print_eij); + this->add_item(item); + } + { + Input_Item item("td_edm"); + item.annotation = "the method to calculate the energy density matrix"; + read_sync_int(input.td_edm); + this->add_item(item); + } + { + Input_Item item("td_propagator"); + item.annotation = "method of propagator"; + read_sync_int(input.propagator); + this->add_item(item); + } + { + Input_Item item("td_stype"); + item.annotation = "type of electric field in space domain"; + read_sync_int(input.td_stype); + this->add_item(item); + } + { + Input_Item item("td_ttype"); + item.annotation = "type of electric field in time domain"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.td_ttype = longstring(item.str_values); + }; + sync_string(input.td_ttype); + this->add_item(item); + } + { + Input_Item item("td_tstart"); + item.annotation = " number of steps where electric field starts"; + read_sync_int(input.td_tstart); + this->add_item(item); + } + { + Input_Item item("td_tend"); + item.annotation = "number of steps where electric field ends"; + read_sync_int(input.td_tend); + this->add_item(item); + } + { + Input_Item item("td_lcut1"); + item.annotation = "cut1 of interval in length gauge"; + read_sync_double(input.td_lcut1); + this->add_item(item); + } + { + Input_Item item("td_lcut2"); + item.annotation = "cut2 of interval in length gauge"; + read_sync_double(input.td_lcut2); + this->add_item(item); + } + { + Input_Item item("td_gauss_freq"); + item.annotation = "frequency (freq) of Gauss type electric field"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.td_gauss_freq = longstring(item.str_values); + }; + sync_string(input.td_gauss_freq); + this->add_item(item); + } + { + Input_Item item("td_gauss_phase"); + item.annotation = "phase of Gauss type electric field"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.td_gauss_phase = longstring(item.str_values); + }; + sync_string(input.td_gauss_phase); + this->add_item(item); + } + { + Input_Item item("td_gauss_sigma"); + item.annotation = "sigma of Gauss type electric field"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.td_gauss_sigma = longstring(item.str_values); + }; + sync_string(input.td_gauss_sigma); + this->add_item(item); + } + { + Input_Item item("td_gauss_t0"); + item.annotation = "step number of time center (t0) of Gauss type electric field"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.td_gauss_t0 = longstring(item.str_values); + }; + sync_string(input.td_gauss_t0); + this->add_item(item); + } + { + Input_Item item("td_gauss_amp"); + item.annotation = "amplitude of Gauss type electric field"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.td_gauss_amp = longstring(item.str_values); + }; + sync_string(input.td_gauss_amp); + this->add_item(item); + } + { + Input_Item item("td_trape_freq"); + item.annotation = "frequency of Trapezoid type electric field"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.td_trape_freq = longstring(item.str_values); + }; + sync_string(input.td_trape_freq); + this->add_item(item); + } + { + Input_Item item("td_trape_phase"); + item.annotation = "phase of Trapezoid type electric field"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.td_trape_phase = longstring(item.str_values); + }; + sync_string(input.td_trape_phase); + this->add_item(item); + } + { + Input_Item item("td_trape_t1"); + item.annotation = "t1 of Trapezoid type electric field"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.td_trape_t1 = longstring(item.str_values); + }; + sync_string(input.td_trape_t1); + this->add_item(item); + } + { + Input_Item item("td_trape_t2"); + item.annotation = "t2 of Trapezoid type electric field"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.td_trape_t2 = longstring(item.str_values); + }; + sync_string(input.td_trape_t2); + this->add_item(item); + } + { + Input_Item item("td_trape_t3"); + item.annotation = "t3 of Trapezoid type electric field"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.td_trape_t3 = longstring(item.str_values); + }; + sync_string(input.td_trape_t3); + this->add_item(item); + } + { + Input_Item item("td_trape_amp"); + item.annotation = "amplitude of Trapezoid type electric field"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.td_trape_amp = longstring(item.str_values); + }; + sync_string(input.td_trape_amp); + this->add_item(item); + } + { + Input_Item item("td_trigo_freq1"); + item.annotation = "frequency 1 of Trigonometric type electric field"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.td_trigo_freq1 = longstring(item.str_values); + }; + sync_string(input.td_trigo_freq1); + this->add_item(item); + } + { + Input_Item item("td_trigo_freq2"); + item.annotation = "frequency 2 of Trigonometric type electric field"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.td_trigo_freq2 = longstring(item.str_values); + }; + sync_string(input.td_trigo_freq2); + this->add_item(item); + } + { + Input_Item item("td_trigo_phase1"); + item.annotation = "phase 1 of Trigonometric type electric field"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.td_trigo_phase1 = longstring(item.str_values); + }; + sync_string(input.td_trigo_phase1); + this->add_item(item); + } + { + Input_Item item("td_trigo_phase2"); + item.annotation = "phase 2 of Trigonometric type electric field"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.td_trigo_phase2 = longstring(item.str_values); + }; + sync_string(input.td_trigo_phase2); + this->add_item(item); + } + { + Input_Item item("td_trigo_amp"); + item.annotation = "amplitude of Trigonometric type electric field"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.td_trigo_amp = longstring(item.str_values); + }; + sync_string(input.td_trigo_amp); + this->add_item(item); + } + { + Input_Item item("td_heavi_t0"); + item.annotation = "t0 of Heaviside type electric field"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.td_heavi_t0 = longstring(item.str_values); + }; + sync_string(input.td_heavi_t0); + this->add_item(item); + } + { + Input_Item item("td_heavi_amp"); + item.annotation = "amplitude of Heaviside type electric field"; + item.read_value = [](const Input_Item& item, Parameter& para) { + para.input.td_heavi_amp = longstring(item.str_values); + }; + sync_string(input.td_heavi_amp); + this->add_item(item); + } + { + Input_Item item("ocp"); + item.annotation = "change occupation or not"; + read_sync_bool(input.ocp); + this->add_item(item); + } + { + Input_Item item("ocp_set"); + item.annotation = "set occupation"; + item.read_value = [](const Input_Item& item, Parameter& para) { + parse_expression(item.str_values, para.input.ocp_kb); + }; + item.get_final_value = [](Input_Item& item, const Parameter& para) { + if(item.is_read()) + { + item.final_value.str(longstring(item.str_values)); + } + }; + add_doublevec_bcast(input.ocp_kb, para.input.ocp_kb.size(), 0.0); + this->add_item(item); + } + + +} +void ReadInput::item_lr_tddft() +{ + // Linear Responce TDDFT + { + Input_Item item("lr_nstates"); + item.annotation = "the number of 2-particle states to be solved"; + read_sync_int(input.lr_nstates); + this->add_item(item); + } + { + Input_Item item("nocc"); + item.annotation = "the number of occupied orbitals to form the 2-particle basis ( <= nelec/2)"; + read_sync_int(input.nocc); + item.reset_value = [](const Input_Item& item, Parameter& para) { + const int nocc_default = std::max(static_cast(para.input.nelec + 1) / 2, para.input.nbands); + if (para.input.nocc <= 0 || para.input.nocc > nocc_default) { para.input.nocc = nocc_default; } + }; + this->add_item(item); + } + { + Input_Item item("nvirt"); + item.annotation = "the number of virtual orbitals to form the 2-particle basis (nocc + nvirt <= nbands)"; + read_sync_int(input.nvirt); + this->add_item(item); + } + { + Input_Item item("xc_kernel"); + item.annotation = "exchange correlation (XC) kernel for LR-TDDFT"; + read_sync_string(input.xc_kernel); + this->add_item(item); + } + { + Input_Item item("lr_solver"); + item.annotation = "the eigensolver for LR-TDDFT"; + read_sync_string(input.lr_solver); + this->add_item(item); + } + { + Input_Item item("lr_thr"); + item.annotation = "convergence threshold of the LR-TDDFT eigensolver"; + read_sync_double(input.lr_thr); + this->add_item(item); + } + { + Input_Item item("out_wfc_lr"); + item.annotation = "whether to output the eigenvectors (excitation amplitudes) in the particle-hole basis"; + read_sync_bool(input.out_wfc_lr); + this->add_item(item); + } + { + Input_Item item("abs_wavelen_range"); + item.annotation = "the range of wavelength(nm) to output the absorption spectrum "; + item.read_value = [](const Input_Item& item, Parameter& para) { + size_t count = item.get_size(); + for (int i = 0; i < count; i++) + { + para.input.abs_wavelen_range.push_back(std::stod(item.str_values[i])); + } + }; + item.check_value = [](const Input_Item& item, const Parameter& para) { + auto& awr = para.input.abs_wavelen_range; + if (awr.size() < 2) { ModuleBase::WARNING_QUIT("ReadInput", "abs_wavelen_range must have two values"); } + }; + sync_doublevec(input.abs_wavelen_range, 2, 0.0); + this->add_item(item); + } + { + Input_Item item("abs_broadening"); + item.annotation = "the broadening (eta) for LR-TDDFT absorption spectrum"; + read_sync_double(input.abs_broadening); + this->add_item(item); + } +} +} \ No newline at end of file diff --git a/source/module_io/test/input_test.cpp b/source/module_io/test/input_test.cpp deleted file mode 100644 index 3a02741c6c..0000000000 --- a/source/module_io/test/input_test.cpp +++ /dev/null @@ -1,1843 +0,0 @@ -#include "gtest/gtest.h" -#include "gmock/gmock.h" -#include "module_base/global_variable.h" -#include "module_base/tool_quit.h" -/************************************************ - * unit test of input.cpp - ***********************************************/ - -/** - * - Tested Functions: - * - Default() - * - set default value of input parameters - * - Read() - * - read input parameters from input files - */ - -#define private public -#include "module_io/input.h" - -class InputTest : public testing::Test -{ -protected: - std::string output; -}; - -TEST_F(InputTest, Default) -{ - INPUT.Default(); - EXPECT_EQ(INPUT.suffix,"ABACUS"); - EXPECT_EQ(INPUT.stru_file,""); - EXPECT_EQ(INPUT.kpoint_file,""); - EXPECT_EQ(INPUT.pseudo_dir,""); - EXPECT_EQ(INPUT.orbital_dir,""); - EXPECT_EQ(INPUT.read_file_dir,"auto"); - EXPECT_EQ(INPUT.wannier_card,"none"); - EXPECT_EQ(INPUT.latname,"none"); - EXPECT_EQ(INPUT.calculation,"scf"); - EXPECT_EQ(INPUT.esolver_type,"ksdft"); - EXPECT_DOUBLE_EQ(INPUT.pseudo_rcut,15.0); - EXPECT_FALSE(INPUT.pseudo_mesh); - EXPECT_EQ(INPUT.ntype,0); - EXPECT_EQ(INPUT.nbands,0); - EXPECT_EQ(INPUT.nbands_sto,256); - EXPECT_EQ(INPUT.nbands_istate,5); - EXPECT_EQ(INPUT.pw_seed,1); - EXPECT_EQ(INPUT.emin_sto,0.0); - EXPECT_EQ(INPUT.emax_sto,0.0); - EXPECT_EQ(INPUT.nche_sto,100); - EXPECT_EQ(INPUT.seed_sto,0); - EXPECT_EQ(INPUT.initsto_ecut,0.0); - EXPECT_EQ(INPUT.bndpar,1); - EXPECT_EQ(INPUT.kpar,1); - EXPECT_EQ(INPUT.initsto_freq,0); - EXPECT_EQ(INPUT.method_sto,2); - EXPECT_EQ(INPUT.npart_sto,1); - EXPECT_FALSE(INPUT.cal_cond); - EXPECT_EQ(INPUT.dos_nche,100); - EXPECT_DOUBLE_EQ(INPUT.cond_che_thr,1e-8); - EXPECT_DOUBLE_EQ(INPUT.cond_dw,0.1); - EXPECT_DOUBLE_EQ(INPUT.cond_wcut,10); - EXPECT_EQ(INPUT.cond_dt,0.02); - EXPECT_EQ(INPUT.cond_dtbatch,0); - EXPECT_EQ(INPUT.cond_smear,1); - EXPECT_DOUBLE_EQ(INPUT.cond_fwhm,0.4); - EXPECT_TRUE(INPUT.cond_nonlocal); - EXPECT_FALSE(INPUT.berry_phase); - EXPECT_EQ(INPUT.gdir,3); - EXPECT_FALSE(INPUT.towannier90); - EXPECT_EQ(INPUT.nnkpfile,"seedname.nnkp"); - EXPECT_EQ(INPUT.wannier_spin,"up"); - EXPECT_EQ(INPUT.wannier_method,1); - EXPECT_TRUE(INPUT.out_wannier_amn); - EXPECT_TRUE(INPUT.out_wannier_mmn); - EXPECT_FALSE(INPUT.out_wannier_unk); - EXPECT_TRUE(INPUT.out_wannier_eig); - EXPECT_TRUE(INPUT.out_wannier_wvfn_formatted); - EXPECT_DOUBLE_EQ(INPUT.kspacing[0], 0.0); - EXPECT_DOUBLE_EQ(INPUT.kspacing[1],0.0); - EXPECT_DOUBLE_EQ(INPUT.kspacing[2],0.0); - EXPECT_DOUBLE_EQ(INPUT.min_dist_coef,0.2); - EXPECT_EQ(INPUT.dft_functional,"default"); - EXPECT_DOUBLE_EQ(INPUT.xc_temperature,0.0); - EXPECT_EQ(INPUT.nspin,1); - EXPECT_DOUBLE_EQ(INPUT.nelec,0.0); - EXPECT_EQ(INPUT.lmaxmax,2); - EXPECT_EQ(INPUT.basis_type,"pw"); - EXPECT_EQ(INPUT.ks_solver,"default"); - EXPECT_DOUBLE_EQ(INPUT.search_radius,-1.0); - EXPECT_TRUE(INPUT.search_pbc); - EXPECT_EQ(INPUT.symmetry,"default"); - EXPECT_FALSE(INPUT.init_vel); - EXPECT_DOUBLE_EQ(INPUT.ref_cell_factor,1.0); - EXPECT_DOUBLE_EQ(INPUT.symmetry_prec, 1.0e-6); - EXPECT_TRUE(INPUT.symmetry_autoclose); - EXPECT_EQ(INPUT.cal_force, 0); - EXPECT_DOUBLE_EQ(INPUT.force_thr,1.0e-3); - EXPECT_DOUBLE_EQ(INPUT.force_thr_ev2,0); - EXPECT_DOUBLE_EQ(INPUT.stress_thr, 0.5); - EXPECT_DOUBLE_EQ(INPUT.press1,0.0); - EXPECT_DOUBLE_EQ(INPUT.press2,0.0); - EXPECT_DOUBLE_EQ(INPUT.press3,0.0); - EXPECT_FALSE(INPUT.cal_stress); - EXPECT_EQ(INPUT.fixed_axes,"None"); - EXPECT_FALSE(INPUT.fixed_ibrav); - EXPECT_FALSE(INPUT.fixed_atoms); - EXPECT_EQ(INPUT.relax_method,"cg"); - EXPECT_DOUBLE_EQ(INPUT.relax_cg_thr,0.5); - EXPECT_EQ(INPUT.out_level,"ie"); - EXPECT_FALSE(INPUT.out_md_control); - EXPECT_TRUE(INPUT.relax_new); - EXPECT_DOUBLE_EQ(INPUT.relax_bfgs_w1,0.01); - EXPECT_DOUBLE_EQ(INPUT.relax_bfgs_w2,0.5); - EXPECT_DOUBLE_EQ(INPUT.relax_bfgs_rmax,0.8); - EXPECT_DOUBLE_EQ(INPUT.relax_bfgs_rmin,1e-5); - EXPECT_DOUBLE_EQ(INPUT.relax_bfgs_init,0.5); - EXPECT_DOUBLE_EQ(INPUT.relax_scale_force,0.5); - EXPECT_EQ(INPUT.nbspline,-1); - EXPECT_FALSE(INPUT.gamma_only); - EXPECT_FALSE(INPUT.gamma_only_local); - EXPECT_DOUBLE_EQ(INPUT.ecutwfc,50.0); - EXPECT_DOUBLE_EQ(INPUT.erf_ecut, 0.0); - EXPECT_DOUBLE_EQ(INPUT.erf_height, 0.0); - EXPECT_DOUBLE_EQ(INPUT.erf_sigma, 0.1); - EXPECT_EQ(INPUT.fft_mode,0); - EXPECT_EQ(INPUT.nx,0); - EXPECT_EQ(INPUT.ny,0); - EXPECT_EQ(INPUT.nz,0); - EXPECT_EQ(INPUT.bx,0); - EXPECT_EQ(INPUT.by,0); - EXPECT_EQ(INPUT.bz,0); - EXPECT_EQ(INPUT.ndx, 0); - EXPECT_EQ(INPUT.ndy, 0); - EXPECT_EQ(INPUT.ndz, 0); - EXPECT_EQ(INPUT.diago_proc,0); - EXPECT_EQ(INPUT.pw_diag_nmax,50); - EXPECT_EQ(INPUT.diago_cg_prec,1); - EXPECT_EQ(INPUT.pw_diag_ndim,4); - EXPECT_DOUBLE_EQ(INPUT.pw_diag_thr,1.0e-2); - EXPECT_EQ(INPUT.nb2d,0); - EXPECT_EQ(INPUT.nurse,0); - EXPECT_EQ(INPUT.colour,0); - EXPECT_EQ(INPUT.t_in_h,1); - EXPECT_EQ(INPUT.vl_in_h,1); - EXPECT_EQ(INPUT.vnl_in_h,1); - EXPECT_EQ(INPUT.vh_in_h,1); - EXPECT_EQ(INPUT.vion_in_h,1); - EXPECT_EQ(INPUT.test_force,0); - EXPECT_EQ(INPUT.test_stress,0); - EXPECT_DOUBLE_EQ(INPUT.scf_thr,-1.0); - EXPECT_EQ(INPUT.scf_thr_type,-1); - EXPECT_EQ(INPUT.scf_nmax,100); - EXPECT_EQ(INPUT.relax_nmax,0); - EXPECT_EQ(INPUT.out_stru,0); - EXPECT_EQ(INPUT.occupations,"smearing"); - EXPECT_EQ(INPUT.smearing_method,"gauss"); - EXPECT_DOUBLE_EQ(INPUT.smearing_sigma,0.015); - EXPECT_EQ(INPUT.mixing_mode,"broyden"); - EXPECT_DOUBLE_EQ(INPUT.mixing_beta,-10.0); - EXPECT_EQ(INPUT.mixing_ndim,8); - EXPECT_DOUBLE_EQ(INPUT.mixing_gg0,1.00); - EXPECT_EQ(INPUT.init_wfc,"atomic"); - EXPECT_EQ(INPUT.mem_saver,0); - EXPECT_EQ(INPUT.printe,100); - EXPECT_EQ(INPUT.init_chg,"atomic"); - EXPECT_EQ(INPUT.chg_extrap, "default"); - EXPECT_EQ(INPUT.out_freq_elec,0); - EXPECT_EQ(INPUT.out_freq_ion,0); - EXPECT_EQ(INPUT.out_chg,0); - EXPECT_EQ(INPUT.out_dm,0); - EXPECT_EQ(INPUT.out_dm1,0); - EXPECT_EQ(INPUT.deepks_out_labels,0); - EXPECT_EQ(INPUT.deepks_scf,0); - EXPECT_EQ(INPUT.deepks_equiv,0); - EXPECT_EQ(INPUT.deepks_bandgap,0); - EXPECT_EQ(INPUT.deepks_out_unittest,0); - EXPECT_EQ(INPUT.out_pot,0); - EXPECT_EQ(INPUT.out_wfc_pw,0); - EXPECT_EQ(INPUT.out_wfc_r,0); - EXPECT_EQ(INPUT.out_dos,0); - EXPECT_EQ(INPUT.out_band[0],0); - EXPECT_EQ(INPUT.out_band[1],8); - EXPECT_EQ(INPUT.out_proj_band,0); - EXPECT_EQ(INPUT.out_mat_hs[0],0); - EXPECT_EQ(INPUT.out_mat_hs[1],8); - EXPECT_EQ(INPUT.out_mat_hs2,0); - EXPECT_EQ(INPUT.out_mat_xc, 0); - EXPECT_EQ(INPUT.out_interval,1); - EXPECT_EQ(INPUT.out_app_flag,1); - EXPECT_EQ(INPUT.out_mat_r,0); - EXPECT_EQ(INPUT.out_wfc_lcao,0); - EXPECT_FALSE(INPUT.out_alllog); - EXPECT_DOUBLE_EQ(INPUT.dos_emin_ev,-15); - EXPECT_DOUBLE_EQ(INPUT.dos_emax_ev,15); - EXPECT_DOUBLE_EQ(INPUT.dos_edelta_ev,0.01); - EXPECT_DOUBLE_EQ(INPUT.dos_scale,0.01); - EXPECT_DOUBLE_EQ(INPUT.dos_sigma,0.07); - EXPECT_FALSE(INPUT.out_element_info); - EXPECT_DOUBLE_EQ(INPUT.lcao_ecut,0); - EXPECT_DOUBLE_EQ(INPUT.lcao_dk,0.01); - EXPECT_DOUBLE_EQ(INPUT.lcao_dr,0.01); - EXPECT_DOUBLE_EQ(INPUT.lcao_rmax,30); - EXPECT_TRUE(INPUT.bessel_nao_smooth); - EXPECT_DOUBLE_EQ(INPUT.bessel_nao_sigma, 0.1); - EXPECT_EQ(INPUT.bessel_nao_ecut, "default"); - EXPECT_DOUBLE_EQ(INPUT.bessel_nao_rcut, 6.0); - EXPECT_DOUBLE_EQ(INPUT.bessel_nao_tolerence, 1E-12); - EXPECT_EQ(INPUT.bessel_descriptor_lmax, 2); - EXPECT_TRUE(INPUT.bessel_descriptor_smooth); - EXPECT_DOUBLE_EQ(INPUT.bessel_descriptor_sigma, 0.1); - EXPECT_EQ(INPUT.bessel_descriptor_ecut, "default"); - EXPECT_DOUBLE_EQ(INPUT.bessel_descriptor_rcut, 6.0); - EXPECT_DOUBLE_EQ(INPUT.bessel_descriptor_tolerence, 1E-12); - - EXPECT_FALSE(INPUT.efield_flag); - EXPECT_FALSE(INPUT.dip_cor_flag); - EXPECT_EQ(INPUT.efield_dir,2); - EXPECT_DOUBLE_EQ(INPUT.efield_pos_max, -1.0); - EXPECT_DOUBLE_EQ(INPUT.efield_pos_dec, -1.0); - EXPECT_DOUBLE_EQ(INPUT.efield_amp ,0.0); - EXPECT_FALSE(INPUT.gate_flag); - EXPECT_DOUBLE_EQ(INPUT.zgate,0.5); - EXPECT_FALSE(INPUT.relax); - EXPECT_FALSE(INPUT.block); - EXPECT_DOUBLE_EQ(INPUT.block_down,0.45); - EXPECT_DOUBLE_EQ(INPUT.block_up,0.55); - EXPECT_DOUBLE_EQ(INPUT.block_height,0.1); - EXPECT_EQ(INPUT.vdw_method,"none"); - EXPECT_EQ(INPUT.vdw_s6,"default"); - EXPECT_EQ(INPUT.vdw_s8,"default"); - EXPECT_EQ(INPUT.vdw_a1,"default"); - EXPECT_EQ(INPUT.vdw_a2,"default"); - EXPECT_DOUBLE_EQ(INPUT.vdw_d,20); - EXPECT_FALSE(INPUT.vdw_abc); - EXPECT_EQ(INPUT.vdw_cutoff_radius,"default"); - EXPECT_EQ(INPUT.vdw_radius_unit,"Bohr"); - EXPECT_DOUBLE_EQ(INPUT.vdw_cn_thr,40.0); - EXPECT_EQ(INPUT.vdw_cn_thr_unit,"Bohr"); - EXPECT_EQ(INPUT.vdw_C6_file,"default"); - EXPECT_EQ(INPUT.vdw_C6_unit,"Jnm6/mol"); - EXPECT_EQ(INPUT.vdw_R0_file,"default"); - EXPECT_EQ(INPUT.vdw_R0_unit,"A"); - EXPECT_EQ(INPUT.vdw_cutoff_type,"radius"); - EXPECT_EQ(INPUT.vdw_cutoff_period[0],3); - EXPECT_EQ(INPUT.vdw_cutoff_period[1],3); - EXPECT_EQ(INPUT.vdw_cutoff_period[2],3); - EXPECT_EQ(INPUT.exx_hybrid_alpha,"default"); - EXPECT_EQ(INPUT.exx_real_number,"default"); - EXPECT_DOUBLE_EQ(INPUT.exx_hse_omega,0.11); - EXPECT_TRUE(INPUT.exx_separate_loop); - EXPECT_EQ(INPUT.exx_hybrid_step,100); - EXPECT_DOUBLE_EQ(INPUT.exx_lambda,0.3); - EXPECT_DOUBLE_EQ(INPUT.exx_mixing_beta,1.0); - EXPECT_DOUBLE_EQ(INPUT.exx_pca_threshold,1E-4); - EXPECT_DOUBLE_EQ(INPUT.exx_c_threshold,1E-4); - EXPECT_DOUBLE_EQ(INPUT.exx_v_threshold,1E-1); - EXPECT_DOUBLE_EQ(INPUT.exx_dm_threshold,1E-4); - EXPECT_DOUBLE_EQ(INPUT.exx_schwarz_threshold,0); - EXPECT_DOUBLE_EQ(INPUT.exx_cauchy_threshold,1E-7); - EXPECT_DOUBLE_EQ(INPUT.exx_c_grad_threshold,1E-4); - EXPECT_DOUBLE_EQ(INPUT.exx_v_grad_threshold,1E-1); - EXPECT_DOUBLE_EQ(INPUT.exx_cauchy_force_threshold,1E-7); - EXPECT_DOUBLE_EQ(INPUT.exx_cauchy_stress_threshold,1E-7); - EXPECT_DOUBLE_EQ(INPUT.exx_ccp_threshold,1E-8); - EXPECT_EQ(INPUT.exx_ccp_rmesh_times, "default"); - EXPECT_DOUBLE_EQ(INPUT.rpa_ccp_rmesh_times, 10.0); - EXPECT_EQ(INPUT.exx_distribute_type, "htime"); - EXPECT_EQ(INPUT.exx_opt_orb_lmax,0); - EXPECT_DOUBLE_EQ(INPUT.exx_opt_orb_ecut,0.0); - EXPECT_DOUBLE_EQ(INPUT.exx_opt_orb_tolerence,0.0); - EXPECT_FALSE(INPUT.noncolin); - EXPECT_FALSE(INPUT.lspinorb); - EXPECT_DOUBLE_EQ(INPUT.soc_lambda,1.0); - EXPECT_EQ(INPUT.input_error,0); - EXPECT_DOUBLE_EQ(INPUT.td_force_dt,0.02); - EXPECT_FALSE(INPUT.td_vext); - EXPECT_EQ(INPUT.td_vext_dire,"1"); - EXPECT_EQ(INPUT.propagator,0); - EXPECT_EQ(INPUT.td_stype,0); - EXPECT_EQ(INPUT.td_ttype,"0"); - EXPECT_EQ(INPUT.td_tstart,1); - EXPECT_EQ(INPUT.td_tend,1000); - EXPECT_EQ(INPUT.td_lcut1,0.05); - EXPECT_EQ(INPUT.td_lcut2,0.95); - EXPECT_EQ(INPUT.td_gauss_amp,"0.25"); - EXPECT_EQ(INPUT.td_gauss_freq,"22.13"); - EXPECT_EQ(INPUT.td_gauss_phase,"0.0"); - EXPECT_EQ(INPUT.td_gauss_t0,"100.0"); - EXPECT_EQ(INPUT.td_gauss_sigma,"30.0"); - EXPECT_EQ(INPUT.td_trape_amp,"2.74"); - EXPECT_EQ(INPUT.td_trape_freq,"1.60"); - EXPECT_EQ(INPUT.td_trape_phase,"0.0"); - EXPECT_EQ(INPUT.td_trape_t1,"1875"); - EXPECT_EQ(INPUT.td_trape_t2,"5625"); - EXPECT_EQ(INPUT.td_trape_t3,"7500"); - EXPECT_EQ(INPUT.td_trigo_freq1,"1.164656"); - EXPECT_EQ(INPUT.td_trigo_freq2,"0.029116"); - EXPECT_EQ(INPUT.td_trigo_phase1,"0.0"); - EXPECT_EQ(INPUT.td_trigo_phase2,"0.0"); - EXPECT_EQ(INPUT.td_trigo_amp,"2.74"); - EXPECT_EQ(INPUT.td_heavi_t0,"100"); - EXPECT_EQ(INPUT.td_heavi_amp,"1.0"); - EXPECT_EQ(INPUT.out_dipole,0); - EXPECT_EQ(INPUT.out_efield,0); - EXPECT_EQ(INPUT.td_print_eij,-1.0); - EXPECT_EQ(INPUT.td_edm,0); - EXPECT_DOUBLE_EQ(INPUT.cell_factor,1.2); - EXPECT_EQ(INPUT.out_mul,0); - EXPECT_FALSE(INPUT.restart_save); - EXPECT_FALSE(INPUT.restart_load); - EXPECT_FALSE(INPUT.test_skip_ewald); - EXPECT_EQ(INPUT.dft_plus_u, 0); - EXPECT_FALSE(INPUT.yukawa_potential); - EXPECT_DOUBLE_EQ(INPUT.yukawa_lambda,-1.0); - EXPECT_EQ(INPUT.onsite_radius, 0.0); - EXPECT_EQ(INPUT.omc,0); - EXPECT_FALSE(INPUT.dft_plus_dmft); - EXPECT_FALSE(INPUT.rpa); - EXPECT_EQ(INPUT.coulomb_type,"full"); - EXPECT_EQ(INPUT.imp_sol,0); - EXPECT_DOUBLE_EQ(INPUT.eb_k,80.0); - EXPECT_DOUBLE_EQ(INPUT.tau,1.0798 * 1e-5); - EXPECT_DOUBLE_EQ(INPUT.sigma_k,0.6); - EXPECT_DOUBLE_EQ(INPUT.nc_k,0.00037); - EXPECT_EQ(INPUT.of_kinetic,"wt"); - EXPECT_EQ(INPUT.of_method,"tn"); - EXPECT_EQ(INPUT.of_conv,"energy"); - EXPECT_DOUBLE_EQ(INPUT.of_tole,1e-6); - EXPECT_DOUBLE_EQ(INPUT.of_tolp,1e-5); - EXPECT_DOUBLE_EQ(INPUT.of_tf_weight,1.); - EXPECT_DOUBLE_EQ(INPUT.of_vw_weight,1.); - EXPECT_DOUBLE_EQ(INPUT.of_wt_alpha,5./6.); - EXPECT_DOUBLE_EQ(INPUT.of_wt_beta,5./6.); - EXPECT_DOUBLE_EQ(INPUT.of_wt_rho0,0.); - EXPECT_FALSE(INPUT.of_hold_rho0); - EXPECT_DOUBLE_EQ(INPUT.of_lkt_a,1.3); - EXPECT_TRUE(INPUT.of_full_pw); - EXPECT_EQ(INPUT.of_full_pw_dim,0); - EXPECT_FALSE(INPUT.of_read_kernel); - EXPECT_EQ(INPUT.of_kernel_file,"WTkernel.txt"); - EXPECT_EQ(INPUT.device,"cpu"); - EXPECT_DOUBLE_EQ(INPUT.ecutrho,0.0); - EXPECT_EQ(INPUT.ncx,0); - EXPECT_EQ(INPUT.ncy,0); - EXPECT_EQ(INPUT.ncz,0); - EXPECT_NEAR(INPUT.mdp.lj_epsilon,0.01032,1e-7); - EXPECT_NEAR(INPUT.mdp.lj_rcut,8.5,1e-7); - EXPECT_NEAR(INPUT.mdp.lj_sigma,3.405,1e-7); - EXPECT_EQ(INPUT.mdp.md_damp,1); - EXPECT_EQ(INPUT.mdp.md_dt,1); - EXPECT_EQ(INPUT.mdp.md_dumpfreq,1); - EXPECT_EQ(INPUT.mdp.md_nraise,1); - EXPECT_EQ(INPUT.cal_syns,0); - EXPECT_EQ(INPUT.dmax,0.01); - EXPECT_EQ(INPUT.mdp.md_nstep,10); - EXPECT_EQ(INPUT.mdp.md_pchain,1); - EXPECT_EQ(INPUT.mdp.md_pcouple,"none"); - EXPECT_DOUBLE_EQ(INPUT.mdp.md_pfirst,-1); - EXPECT_DOUBLE_EQ(INPUT.mdp.md_pfreq,0); - EXPECT_DOUBLE_EQ(INPUT.mdp.md_plast,-1); - EXPECT_EQ(INPUT.mdp.md_pmode,"iso"); - EXPECT_EQ(INPUT.mdp.md_restart,0); - EXPECT_EQ(INPUT.mdp.md_restartfreq,5); - EXPECT_EQ(INPUT.mdp.md_seed,-1); - EXPECT_EQ(INPUT.mdp.md_prec_level,0); - EXPECT_EQ(INPUT.mdp.md_tchain,1); - EXPECT_DOUBLE_EQ(INPUT.mdp.md_tfirst,-1); - EXPECT_DOUBLE_EQ(INPUT.mdp.md_tfreq,0); - EXPECT_EQ(INPUT.mdp.md_thermostat,"nhc"); - EXPECT_DOUBLE_EQ(INPUT.mdp.md_tlast,-1); - EXPECT_DOUBLE_EQ(INPUT.mdp.md_tolerance,100); - EXPECT_EQ(INPUT.mdp.md_type,"nvt"); - EXPECT_EQ(INPUT.mdp.msst_direction,2); - EXPECT_DOUBLE_EQ(INPUT.mdp.msst_qmass,-1); - EXPECT_DOUBLE_EQ(INPUT.mdp.msst_tscale,0.01); - EXPECT_DOUBLE_EQ(INPUT.mdp.msst_vel,0); - EXPECT_DOUBLE_EQ(INPUT.mdp.msst_vis,0); - EXPECT_EQ(INPUT.mdp.pot_file,"graph.pb"); - EXPECT_TRUE(INPUT.mdp.dump_force); - EXPECT_TRUE(INPUT.mdp.dump_vel); - EXPECT_TRUE(INPUT.mdp.dump_virial); - EXPECT_EQ(INPUT.sc_mag_switch,0); - EXPECT_FALSE(INPUT.decay_grad_switch); - EXPECT_DOUBLE_EQ(INPUT.sc_thr, 1e-6); - EXPECT_EQ(INPUT.nsc, 100); - EXPECT_EQ(INPUT.nsc_min, 2); - EXPECT_EQ(INPUT.sc_scf_nmin, 2); - EXPECT_DOUBLE_EQ(INPUT.alpha_trial, 0.01); - EXPECT_DOUBLE_EQ(INPUT.sccut, 3.0); - EXPECT_EQ(INPUT.sc_file, "none"); -} - -TEST_F(InputTest, Read) -{ - std::string input_file = "./support/INPUT"; - INPUT.Read(input_file); - EXPECT_EQ(INPUT.suffix,"autotest"); - EXPECT_EQ(INPUT.stru_file,"./support/STRU"); - EXPECT_EQ(INPUT.kpoint_file,"KPT"); - EXPECT_EQ(INPUT.pseudo_dir,"../../PP_ORB/"); - EXPECT_EQ(INPUT.orbital_dir,"../../PP_ORB/"); - EXPECT_EQ(INPUT.read_file_dir,"auto"); - EXPECT_EQ(INPUT.wannier_card,"none"); - EXPECT_EQ(INPUT.latname,"none"); - EXPECT_EQ(INPUT.calculation,"scf"); - EXPECT_EQ(INPUT.esolver_type,"ksdft"); - EXPECT_DOUBLE_EQ(INPUT.pseudo_rcut,15.0); - EXPECT_FALSE(INPUT.pseudo_mesh); - EXPECT_EQ(INPUT.ntype,1); - EXPECT_EQ(INPUT.nbands,8); - EXPECT_EQ(INPUT.nbands_sto,256); - EXPECT_EQ(INPUT.nbands_istate,5); - EXPECT_EQ(INPUT.pw_seed,1); - EXPECT_EQ(INPUT.emin_sto,0.0); - EXPECT_EQ(INPUT.emax_sto,0.0); - EXPECT_EQ(INPUT.nche_sto,100); - EXPECT_EQ(INPUT.seed_sto,0); - EXPECT_EQ(INPUT.initsto_ecut,0.0); - EXPECT_EQ(INPUT.bndpar,1); - EXPECT_EQ(INPUT.kpar,1); - EXPECT_EQ(INPUT.initsto_freq,0); - EXPECT_EQ(INPUT.method_sto,3); - EXPECT_EQ(INPUT.npart_sto,1); - EXPECT_FALSE(INPUT.cal_cond); - EXPECT_EQ(INPUT.dos_nche,100); - EXPECT_DOUBLE_EQ(INPUT.cond_che_thr,1e-8); - EXPECT_DOUBLE_EQ(INPUT.cond_dw,0.1); - EXPECT_DOUBLE_EQ(INPUT.cond_wcut,10); - EXPECT_EQ(INPUT.cond_dt,0.07); - EXPECT_EQ(INPUT.cond_dtbatch,2); - EXPECT_DOUBLE_EQ(INPUT.cond_fwhm,0.3); - EXPECT_TRUE(INPUT.cond_nonlocal); - EXPECT_FALSE(INPUT.berry_phase); - EXPECT_EQ(INPUT.gdir,3); - EXPECT_FALSE(INPUT.towannier90); - EXPECT_EQ(INPUT.nnkpfile,"seedname.nnkp"); - EXPECT_EQ(INPUT.wannier_spin,"up"); - EXPECT_EQ(INPUT.wannier_method,1); - EXPECT_TRUE(INPUT.out_wannier_amn); - EXPECT_TRUE(INPUT.out_wannier_mmn); - EXPECT_TRUE(INPUT.out_wannier_unk); - EXPECT_TRUE(INPUT.out_wannier_eig); - EXPECT_TRUE(INPUT.out_wannier_wvfn_formatted); - EXPECT_DOUBLE_EQ(INPUT.kspacing[0], 0.0); - EXPECT_DOUBLE_EQ(INPUT.kspacing[1],0.0); - EXPECT_DOUBLE_EQ(INPUT.kspacing[2],0.0); - EXPECT_DOUBLE_EQ(INPUT.min_dist_coef,0.2); - EXPECT_EQ(INPUT.dft_functional,"hse"); - EXPECT_DOUBLE_EQ(INPUT.xc_temperature,0.0); - EXPECT_EQ(INPUT.nspin,1); - EXPECT_DOUBLE_EQ(INPUT.nelec,0.0); - EXPECT_EQ(INPUT.lmaxmax,2); - EXPECT_EQ(INPUT.basis_type,"lcao"); - EXPECT_EQ(INPUT.ks_solver,"genelpa"); - EXPECT_DOUBLE_EQ(INPUT.search_radius,-1.0); - EXPECT_TRUE(INPUT.search_pbc); - EXPECT_EQ(INPUT.symmetry,"1"); - EXPECT_FALSE(INPUT.init_vel); - EXPECT_DOUBLE_EQ(INPUT.symmetry_prec, 1.0e-6); - EXPECT_TRUE(INPUT.symmetry_autoclose); - EXPECT_EQ(INPUT.cal_force, 0); - EXPECT_NEAR(INPUT.force_thr,1.0e-3,1.0e-7); - EXPECT_DOUBLE_EQ(INPUT.force_thr_ev2,0); - EXPECT_DOUBLE_EQ(INPUT.stress_thr,1.0e-2); - EXPECT_DOUBLE_EQ(INPUT.press1,0.0); - EXPECT_DOUBLE_EQ(INPUT.press2,0.0); - EXPECT_DOUBLE_EQ(INPUT.press3,0.0); - EXPECT_FALSE(INPUT.cal_stress); - EXPECT_EQ(INPUT.fixed_axes,"None"); - EXPECT_FALSE(INPUT.fixed_ibrav); - EXPECT_FALSE(INPUT.fixed_atoms); - EXPECT_EQ(INPUT.relax_method,"cg"); - EXPECT_DOUBLE_EQ(INPUT.relax_cg_thr,0.5); - EXPECT_EQ(INPUT.out_level,"ie"); - EXPECT_TRUE(INPUT.out_md_control); - EXPECT_TRUE(INPUT.relax_new); - EXPECT_DOUBLE_EQ(INPUT.relax_bfgs_w1,0.01); - EXPECT_DOUBLE_EQ(INPUT.relax_bfgs_w2,0.5); - EXPECT_DOUBLE_EQ(INPUT.relax_bfgs_rmax,0.8); - EXPECT_DOUBLE_EQ(INPUT.relax_bfgs_rmin,1e-5); - EXPECT_DOUBLE_EQ(INPUT.relax_bfgs_init,0.5); - EXPECT_DOUBLE_EQ(INPUT.relax_scale_force,0.5); - EXPECT_EQ(INPUT.nbspline,-1); - EXPECT_TRUE(INPUT.gamma_only); - EXPECT_TRUE(INPUT.gamma_only_local); - EXPECT_DOUBLE_EQ(INPUT.ecutwfc,20.0); - EXPECT_DOUBLE_EQ(INPUT.erf_ecut, 20.0); - EXPECT_DOUBLE_EQ(INPUT.erf_height, 20.0); - EXPECT_DOUBLE_EQ(INPUT.erf_sigma, 4.0); - EXPECT_DOUBLE_EQ(INPUT.ecutrho, 0.0); - EXPECT_EQ(INPUT.fft_mode,0); - EXPECT_EQ(INPUT.ncx,0); - EXPECT_EQ(INPUT.ncy,0); - EXPECT_EQ(INPUT.ncz,0); - EXPECT_EQ(INPUT.nx,0); - EXPECT_EQ(INPUT.ny,0); - EXPECT_EQ(INPUT.nz,0); - EXPECT_EQ(INPUT.bx,2); - EXPECT_EQ(INPUT.by,2); - EXPECT_EQ(INPUT.bz,2); - EXPECT_EQ(INPUT.ndx, 0); - EXPECT_EQ(INPUT.ndy, 0); - EXPECT_EQ(INPUT.ndz, 0); - EXPECT_EQ(INPUT.diago_proc,4); - EXPECT_EQ(INPUT.pw_diag_nmax,50); - EXPECT_EQ(INPUT.diago_cg_prec,1); - EXPECT_EQ(INPUT.pw_diag_ndim,4); - EXPECT_DOUBLE_EQ(INPUT.pw_diag_thr,1.0e-2); - EXPECT_EQ(INPUT.nb2d,0); - EXPECT_EQ(INPUT.nurse,0); - EXPECT_EQ(INPUT.colour,0); - EXPECT_EQ(INPUT.t_in_h,1); - EXPECT_EQ(INPUT.vl_in_h,1); - EXPECT_EQ(INPUT.vnl_in_h,1); - EXPECT_EQ(INPUT.vh_in_h,1); - EXPECT_EQ(INPUT.vion_in_h,1); - EXPECT_EQ(INPUT.test_force,0); - EXPECT_EQ(INPUT.test_stress,0); - EXPECT_NEAR(INPUT.scf_thr,1.0e-8,1.0e-15); - EXPECT_EQ(INPUT.scf_nmax,50); - EXPECT_EQ(INPUT.relax_nmax,1); - EXPECT_EQ(INPUT.out_stru,0); - EXPECT_EQ(INPUT.occupations,"smearing"); - EXPECT_EQ(INPUT.smearing_method,"gauss"); - EXPECT_DOUBLE_EQ(INPUT.smearing_sigma,0.002); - EXPECT_EQ(INPUT.mixing_mode,"broyden"); - EXPECT_DOUBLE_EQ(INPUT.mixing_beta,0.7); - EXPECT_EQ(INPUT.mixing_ndim,8); - EXPECT_DOUBLE_EQ(INPUT.mixing_gg0,0.00); - EXPECT_EQ(INPUT.init_wfc,"atomic"); - EXPECT_EQ(INPUT.mem_saver,0); - EXPECT_EQ(INPUT.printe,100); - EXPECT_EQ(INPUT.init_chg,"atomic"); - EXPECT_EQ(INPUT.chg_extrap,"atomic"); - EXPECT_EQ(INPUT.out_freq_elec,0); - EXPECT_EQ(INPUT.out_freq_ion,0); - EXPECT_EQ(INPUT.out_chg,0); - EXPECT_EQ(INPUT.out_dm,0); - EXPECT_EQ(INPUT.out_dm1,0); - EXPECT_EQ(INPUT.deepks_out_labels,0); - EXPECT_EQ(INPUT.deepks_scf,0); - EXPECT_EQ(INPUT.deepks_equiv,0); - EXPECT_EQ(INPUT.deepks_bandgap,0); - EXPECT_EQ(INPUT.deepks_out_unittest,0); - EXPECT_EQ(INPUT.out_pot,2); - EXPECT_EQ(INPUT.out_wfc_pw,0); - EXPECT_EQ(INPUT.out_wfc_r,0); - EXPECT_EQ(INPUT.out_dos,0); - EXPECT_EQ(INPUT.out_band[0],0); - EXPECT_EQ(INPUT.out_band[1],8); - EXPECT_EQ(INPUT.out_proj_band,0); - EXPECT_EQ(INPUT.out_mat_hs[0],0); - EXPECT_EQ(INPUT.out_mat_hs[1],8); - EXPECT_EQ(INPUT.out_mat_hs2,0); - EXPECT_EQ(INPUT.out_mat_xc, 0); - EXPECT_EQ(INPUT.out_interval,1); - EXPECT_EQ(INPUT.out_app_flag,0); - EXPECT_EQ(INPUT.out_mat_r,0); - EXPECT_FALSE(INPUT.out_wfc_lcao); - EXPECT_FALSE(INPUT.out_alllog); - EXPECT_DOUBLE_EQ(INPUT.dos_emin_ev,-15); - EXPECT_DOUBLE_EQ(INPUT.dos_emax_ev,15); - EXPECT_DOUBLE_EQ(INPUT.dos_edelta_ev,0.01); - EXPECT_DOUBLE_EQ(INPUT.dos_scale,0.01); - EXPECT_DOUBLE_EQ(INPUT.dos_sigma,0.07); - EXPECT_FALSE(INPUT.out_element_info); - EXPECT_DOUBLE_EQ(INPUT.lcao_ecut,20); - EXPECT_DOUBLE_EQ(INPUT.lcao_dk,0.01); - EXPECT_DOUBLE_EQ(INPUT.lcao_dr,0.01); - EXPECT_DOUBLE_EQ(INPUT.lcao_rmax,30); - EXPECT_TRUE(INPUT.bessel_nao_smooth); - EXPECT_DOUBLE_EQ(INPUT.bessel_nao_sigma, 0.1); - EXPECT_EQ(INPUT.bessel_nao_ecut, "default"); - EXPECT_DOUBLE_EQ(INPUT.bessel_nao_rcut, 6.0); - EXPECT_DOUBLE_EQ(INPUT.bessel_nao_tolerence, 1E-12); - EXPECT_EQ(INPUT.bessel_descriptor_lmax, 2); - EXPECT_TRUE(INPUT.bessel_descriptor_smooth); - EXPECT_DOUBLE_EQ(INPUT.bessel_descriptor_sigma, 0.1); - EXPECT_EQ(INPUT.bessel_descriptor_ecut, "default"); - EXPECT_DOUBLE_EQ(INPUT.bessel_descriptor_rcut, 6.0); - EXPECT_DOUBLE_EQ(INPUT.bessel_descriptor_tolerence, 1E-12); - EXPECT_FALSE(INPUT.efield_flag); - EXPECT_FALSE(INPUT.dip_cor_flag); - EXPECT_EQ(INPUT.efield_dir,2); - EXPECT_DOUBLE_EQ(INPUT.efield_pos_max,0.5); - EXPECT_DOUBLE_EQ(INPUT.efield_pos_dec,0.1); - EXPECT_DOUBLE_EQ(INPUT.efield_amp ,0.0); - EXPECT_FALSE(INPUT.gate_flag); - EXPECT_DOUBLE_EQ(INPUT.zgate,0.5); - EXPECT_FALSE(INPUT.relax); - EXPECT_FALSE(INPUT.block); - EXPECT_DOUBLE_EQ(INPUT.block_down,0.45); - EXPECT_DOUBLE_EQ(INPUT.block_up,0.55); - EXPECT_DOUBLE_EQ(INPUT.block_height,0.1); - EXPECT_EQ(INPUT.vdw_method,"d2"); - EXPECT_EQ(INPUT.vdw_s6,"default"); - EXPECT_EQ(INPUT.vdw_s8,"default"); - EXPECT_EQ(INPUT.vdw_a1,"default"); - EXPECT_EQ(INPUT.vdw_a2,"default"); - EXPECT_DOUBLE_EQ(INPUT.vdw_d,20); - EXPECT_FALSE(INPUT.vdw_abc); - EXPECT_EQ(INPUT.vdw_cutoff_radius,"default"); - EXPECT_EQ(INPUT.vdw_radius_unit,"Bohr"); - EXPECT_DOUBLE_EQ(INPUT.vdw_cn_thr,40.0); - EXPECT_EQ(INPUT.vdw_cn_thr_unit,"Bohr"); - EXPECT_EQ(INPUT.vdw_C6_file,"default"); - EXPECT_EQ(INPUT.vdw_C6_unit,"Jnm6/mol"); - EXPECT_EQ(INPUT.vdw_R0_file,"default"); - EXPECT_EQ(INPUT.vdw_R0_unit,"A"); - EXPECT_EQ(INPUT.vdw_cutoff_type,"radius"); - EXPECT_EQ(INPUT.vdw_cutoff_period[0],3); - EXPECT_EQ(INPUT.vdw_cutoff_period[1],3); - EXPECT_EQ(INPUT.vdw_cutoff_period[2],3); - EXPECT_EQ(INPUT.exx_hybrid_alpha,"default"); - EXPECT_EQ(INPUT.exx_real_number,"default"); - EXPECT_DOUBLE_EQ(INPUT.exx_hse_omega,0.11); - EXPECT_TRUE(INPUT.exx_separate_loop); - EXPECT_EQ(INPUT.exx_hybrid_step,100); - EXPECT_DOUBLE_EQ(INPUT.exx_lambda,0.3); - EXPECT_DOUBLE_EQ(INPUT.exx_mixing_beta,1.0); - EXPECT_DOUBLE_EQ(INPUT.exx_pca_threshold,0); - EXPECT_DOUBLE_EQ(INPUT.exx_c_threshold,0); - EXPECT_DOUBLE_EQ(INPUT.exx_v_threshold,0); - EXPECT_DOUBLE_EQ(INPUT.exx_dm_threshold,0); - EXPECT_DOUBLE_EQ(INPUT.exx_schwarz_threshold,0); - EXPECT_DOUBLE_EQ(INPUT.exx_cauchy_threshold,0); - EXPECT_DOUBLE_EQ(INPUT.exx_c_grad_threshold,0); - EXPECT_DOUBLE_EQ(INPUT.exx_v_grad_threshold,0); - EXPECT_DOUBLE_EQ(INPUT.exx_cauchy_force_threshold,0); - EXPECT_DOUBLE_EQ(INPUT.exx_cauchy_stress_threshold,0); - EXPECT_DOUBLE_EQ(INPUT.exx_ccp_threshold,1E-8); - EXPECT_EQ(INPUT.exx_ccp_rmesh_times, "default"); - EXPECT_DOUBLE_EQ(INPUT.rpa_ccp_rmesh_times, 10.0); - EXPECT_EQ(INPUT.exx_distribute_type, "htime"); - EXPECT_EQ(INPUT.exx_opt_orb_lmax,0); - EXPECT_DOUBLE_EQ(INPUT.exx_opt_orb_ecut,0.0); - EXPECT_DOUBLE_EQ(INPUT.exx_opt_orb_tolerence,0.0); - EXPECT_FALSE(INPUT.noncolin); - EXPECT_FALSE(INPUT.lspinorb); - EXPECT_DOUBLE_EQ(INPUT.soc_lambda,1.0); - EXPECT_EQ(INPUT.input_error,0); - EXPECT_DOUBLE_EQ(INPUT.td_force_dt,0.02); - EXPECT_EQ(INPUT.td_vext,0); - // EXPECT_EQ(INPUT.td_vext_dire,"1"); - EXPECT_EQ(INPUT.propagator,0); - EXPECT_EQ(INPUT.td_stype,0); - // EXPECT_EQ(INPUT.td_ttype,"0"); - EXPECT_EQ(INPUT.td_tstart,1); - EXPECT_EQ(INPUT.td_tend,1000); - EXPECT_EQ(INPUT.td_lcut1,0.05); - EXPECT_EQ(INPUT.td_lcut2,0.95); - // EXPECT_EQ(INPUT.td_gauss_amp,"0.25"); - // EXPECT_EQ(INPUT.td_gauss_freq,"22.13"); - // EXPECT_EQ(INPUT.td_gauss_phase,"0.0"); - // EXPECT_EQ(INPUT.td_gauss_t0,"100.0"); - // EXPECT_EQ(INPUT.td_gauss_sigma,"30.0"); - // EXPECT_EQ(INPUT.td_trape_amp,"2.74"); - // EXPECT_EQ(INPUT.td_trape_freq,"1.60"); - // EXPECT_EQ(INPUT.td_trape_phase,"0.0"); - // EXPECT_EQ(INPUT.td_trape_t1,"1875"); - // EXPECT_EQ(INPUT.td_trape_t2,"5625"); - // EXPECT_EQ(INPUT.td_trape_t3,"7500"); - // EXPECT_EQ(INPUT.td_trigo_freq1,"1.164656"); - // EXPECT_EQ(INPUT.td_trigo_freq2,"0.029116"); - // EXPECT_EQ(INPUT.td_trigo_phase1,"0.0"); - // EXPECT_EQ(INPUT.td_trigo_phase2,"0.0"); - // EXPECT_EQ(INPUT.td_trigo_amp,"2.74"); - // EXPECT_EQ(INPUT.td_heavi_t0,"100"); - // EXPECT_EQ(INPUT.td_heavi_amp,"1.0"); - EXPECT_EQ(INPUT.out_dipole,0); - EXPECT_EQ(INPUT.out_efield,0); - EXPECT_EQ(INPUT.td_print_eij,-1.0); - EXPECT_EQ(INPUT.td_edm,0); - EXPECT_DOUBLE_EQ(INPUT.cell_factor,1.2); - EXPECT_EQ(INPUT.out_mul,0); - EXPECT_FALSE(INPUT.restart_save); - EXPECT_FALSE(INPUT.restart_load); - EXPECT_FALSE(INPUT.test_skip_ewald); - EXPECT_EQ(INPUT.dft_plus_u, 0); - EXPECT_FALSE(INPUT.yukawa_potential); - EXPECT_DOUBLE_EQ(INPUT.yukawa_lambda,-1.0); - EXPECT_EQ(INPUT.onsite_radius, 0.0); - EXPECT_EQ(INPUT.omc,0); - EXPECT_FALSE(INPUT.dft_plus_dmft); - EXPECT_FALSE(INPUT.rpa); - EXPECT_EQ(INPUT.coulomb_type,"full"); - EXPECT_EQ(INPUT.imp_sol,0); - EXPECT_DOUBLE_EQ(INPUT.eb_k,80.0); - EXPECT_DOUBLE_EQ(INPUT.tau,1.0798 * 1e-5); - EXPECT_DOUBLE_EQ(INPUT.sigma_k,0.6); - EXPECT_DOUBLE_EQ(INPUT.nc_k,0.00037); - EXPECT_EQ(INPUT.of_kinetic,"vw"); - EXPECT_EQ(INPUT.of_method,"tn"); - EXPECT_EQ(INPUT.of_conv,"energy"); - EXPECT_DOUBLE_EQ(INPUT.of_tole,1e-6); - EXPECT_DOUBLE_EQ(INPUT.of_tolp,1e-5); - EXPECT_DOUBLE_EQ(INPUT.of_tf_weight,1.); - EXPECT_DOUBLE_EQ(INPUT.of_vw_weight,1.); - EXPECT_DOUBLE_EQ(INPUT.of_wt_alpha,0.833333); - EXPECT_DOUBLE_EQ(INPUT.of_wt_beta,0.833333); - EXPECT_DOUBLE_EQ(INPUT.of_wt_rho0,1.); - EXPECT_FALSE(INPUT.of_hold_rho0); - EXPECT_DOUBLE_EQ(INPUT.of_lkt_a, 1.3); - EXPECT_FALSE(INPUT.of_full_pw); - EXPECT_EQ(INPUT.of_full_pw_dim,0); - EXPECT_FALSE(INPUT.of_read_kernel); - EXPECT_EQ(INPUT.of_kernel_file,"WTkernel.txt"); - EXPECT_EQ(INPUT.device, "cpu"); - EXPECT_EQ(INPUT.ncx,0); - EXPECT_EQ(INPUT.ncy,0); - EXPECT_EQ(INPUT.ncz,0); - //EXPECT_NEAR(INPUT.force_thr_ev,0.0257112,1e-8); - EXPECT_DOUBLE_EQ(INPUT.hubbard_u[0],0); - EXPECT_EQ(INPUT.orbital_corr[0],-1); - EXPECT_NEAR(INPUT.mdp.lj_epsilon,0.01032,1e-7); - EXPECT_NEAR(INPUT.mdp.lj_rcut,8.5,1e-7); - EXPECT_NEAR(INPUT.mdp.lj_sigma,3.405,1e-7); - EXPECT_EQ(INPUT.mdp.md_damp,1); - EXPECT_EQ(INPUT.mdp.md_dt,1); - EXPECT_EQ(INPUT.mdp.md_dumpfreq,1); - EXPECT_EQ(INPUT.mdp.md_nraise,1); - EXPECT_EQ(INPUT.cal_syns,0); - EXPECT_EQ(INPUT.dmax,0.01); - EXPECT_EQ(INPUT.mdp.md_nstep,10); - EXPECT_EQ(INPUT.mdp.md_pchain,1); - EXPECT_EQ(INPUT.mdp.md_pcouple,"none"); - EXPECT_DOUBLE_EQ(INPUT.mdp.md_pfirst,-1); - EXPECT_DOUBLE_EQ(INPUT.mdp.md_pfreq,0); - EXPECT_DOUBLE_EQ(INPUT.mdp.md_plast,-1); - EXPECT_EQ(INPUT.mdp.md_pmode,"iso"); - EXPECT_EQ(INPUT.mdp.md_restart,0); - EXPECT_EQ(INPUT.mdp.md_restartfreq,5); - EXPECT_EQ(INPUT.mdp.md_seed,-1); - EXPECT_EQ(INPUT.mdp.md_prec_level, 2); - EXPECT_DOUBLE_EQ(INPUT.ref_cell_factor,1.2); - EXPECT_EQ(INPUT.mdp.md_tchain,1); - EXPECT_DOUBLE_EQ(INPUT.mdp.md_tfirst,-1); - EXPECT_DOUBLE_EQ(INPUT.mdp.md_tfreq,0); - EXPECT_EQ(INPUT.mdp.md_thermostat,"nhc"); - EXPECT_DOUBLE_EQ(INPUT.mdp.md_tlast,-1); - EXPECT_DOUBLE_EQ(INPUT.mdp.md_tolerance,100); - EXPECT_EQ(INPUT.mdp.md_type,"nvt"); - EXPECT_EQ(INPUT.mdp.msst_direction,2); - EXPECT_DOUBLE_EQ(INPUT.mdp.msst_qmass,-1); - EXPECT_DOUBLE_EQ(INPUT.mdp.msst_tscale,0.01); - EXPECT_DOUBLE_EQ(INPUT.mdp.msst_vel,0); - EXPECT_DOUBLE_EQ(INPUT.mdp.msst_vis,0); - EXPECT_EQ(INPUT.mdp.pot_file,"graph.pb"); - EXPECT_FALSE(INPUT.mdp.dump_force); - EXPECT_FALSE(INPUT.mdp.dump_vel); - EXPECT_FALSE(INPUT.mdp.dump_virial); - EXPECT_EQ(INPUT.sc_mag_switch, 0); - EXPECT_TRUE(INPUT.decay_grad_switch); - EXPECT_DOUBLE_EQ(INPUT.sc_thr, 1e-4); - EXPECT_EQ(INPUT.nsc, 50); - EXPECT_EQ(INPUT.nsc_min, 4); - EXPECT_EQ(INPUT.sc_scf_nmin, 4); - EXPECT_DOUBLE_EQ(INPUT.alpha_trial, 0.02); - EXPECT_DOUBLE_EQ(INPUT.sccut, 4.0); - EXPECT_EQ(INPUT.sc_file, "sc.json"); -} - -TEST_F(InputTest, Default_2) -{ - //================================================== - // prepare default parameters for the 1st calling - EXPECT_EQ(INPUT.vdw_method,"d2"); - EXPECT_EQ(INPUT.vdw_s6,"default"); - EXPECT_EQ(INPUT.vdw_s8,"default"); - EXPECT_EQ(INPUT.vdw_a1,"default"); - EXPECT_EQ(INPUT.vdw_a2,"default"); - EXPECT_EQ(INPUT.vdw_cutoff_radius,"default"); - EXPECT_NE(INPUT.esolver_type,"sdft"); - EXPECT_NE(INPUT.method_sto,1); - EXPECT_NE(INPUT.method_sto,2); - EXPECT_NE(INPUT.of_wt_rho0,0.0); - EXPECT_EQ(INPUT.exx_hybrid_alpha,"default"); - EXPECT_EQ(INPUT.dft_functional,"hse"); - EXPECT_EQ(INPUT.exx_real_number,"default"); - EXPECT_TRUE(INPUT.gamma_only); - EXPECT_EQ(INPUT.exx_ccp_rmesh_times,"default"); - EXPECT_EQ(INPUT.diago_proc,4); - EXPECT_EQ(GlobalV::NPROC,1); - EXPECT_EQ(INPUT.calculation,"scf"); - EXPECT_EQ(INPUT.basis_type,"lcao"); - INPUT.ks_solver = "default"; - INPUT.lcao_ecut = 0; - INPUT.scf_thr = -1.0; - INPUT.scf_thr_type = -1; - EXPECT_DOUBLE_EQ(INPUT.ecutwfc, 20.0); - EXPECT_DOUBLE_EQ(INPUT.erf_ecut, 20.0); - EXPECT_DOUBLE_EQ(INPUT.erf_height, 20.0); - EXPECT_DOUBLE_EQ(INPUT.erf_sigma, 4.0); - INPUT.nbndsto_str = "all"; - INPUT.nx = INPUT.ny = INPUT.nz = 4; - INPUT.ndx = INPUT.ndy = INPUT.ndz = 0; - // the 1st calling - INPUT.Default_2(); - // ^^^^^^^^^^^^^^ - EXPECT_EQ(INPUT.ndx, 4); - EXPECT_EQ(INPUT.ndy, 4); - EXPECT_EQ(INPUT.ndz, 4); - EXPECT_FALSE(GlobalV::double_grid); - EXPECT_DOUBLE_EQ(INPUT.ecutrho, 80.0); - EXPECT_EQ(INPUT.vdw_s6, "0.75"); - EXPECT_EQ(INPUT.vdw_cutoff_radius, "56.6918"); - EXPECT_EQ(INPUT.bndpar,1); - EXPECT_EQ(INPUT.method_sto,2); - EXPECT_TRUE(INPUT.of_hold_rho0); - EXPECT_EQ(INPUT.of_full_pw_dim,0); - EXPECT_EQ(INPUT.exx_hybrid_alpha,"0.25"); - EXPECT_EQ(INPUT.exx_real_number,"1"); - EXPECT_EQ(INPUT.exx_ccp_rmesh_times,"1.5"); - EXPECT_EQ(INPUT.diago_proc,1); - EXPECT_EQ(INPUT.mem_saver,0); - EXPECT_EQ(INPUT.relax_nmax,1); - EXPECT_DOUBLE_EQ(INPUT.scf_thr,1.0e-7); - EXPECT_EQ(INPUT.scf_thr_type,2); -#ifdef __ELPA - EXPECT_EQ(INPUT.ks_solver,"genelpa"); -#else - EXPECT_EQ(INPUT.ks_solver,"scalapack_gvx"); -#endif - EXPECT_DOUBLE_EQ(INPUT.lcao_ecut,20.0); - EXPECT_EQ(INPUT.nbands_sto, 0); - //================================================== - // prepare default parameters for the 2nd calling - INPUT.vdw_method = "d3_0"; - INPUT.vdw_s6 = "default"; - INPUT.vdw_s8 = "default"; - INPUT.vdw_a1 = "default"; - INPUT.vdw_a2 = "default"; - INPUT.vdw_cutoff_radius = "default"; - INPUT.exx_hybrid_alpha = "default"; - INPUT.dft_functional = "hf"; - INPUT.exx_real_number = "default"; - INPUT.gamma_only = 0; - INPUT.exx_ccp_rmesh_times = "default"; - INPUT.diago_proc = 0; - INPUT.calculation = "relax"; - INPUT.chg_extrap = "default"; - INPUT.relax_nmax = 0; - INPUT.basis_type = "pw"; - INPUT.ks_solver = "default"; - INPUT.gamma_only_local = 1; - INPUT.scf_thr = -1.0; - INPUT.scf_thr_type = -1; - INPUT.nbndsto_str = "0"; - INPUT.esolver_type = "sdft"; - INPUT.nx = INPUT.ny = INPUT.nz = 0; - INPUT.ndx = INPUT.ndy = INPUT.ndz = 4; - // the 2nd calling - INPUT.Default_2(); - // ^^^^^^^^^^^^^^ - EXPECT_EQ(INPUT.nx, 4); - EXPECT_EQ(INPUT.ny, 4); - EXPECT_EQ(INPUT.nz, 4); - EXPECT_FALSE(GlobalV::double_grid); - EXPECT_EQ(INPUT.chg_extrap, "first-order"); - EXPECT_EQ(INPUT.vdw_s6, "1.0"); - EXPECT_EQ(INPUT.vdw_s8, "0.722"); - EXPECT_EQ(INPUT.vdw_a1, "1.217"); - EXPECT_EQ(INPUT.vdw_a2,"1.0"); - EXPECT_EQ(INPUT.vdw_cutoff_radius,"95"); - EXPECT_EQ(INPUT.exx_hybrid_alpha,"1"); - EXPECT_EQ(INPUT.exx_real_number,"0"); - EXPECT_EQ(INPUT.exx_ccp_rmesh_times,"5"); - EXPECT_EQ(INPUT.diago_proc,1); - EXPECT_EQ(INPUT.mem_saver,0); - EXPECT_EQ(INPUT.cal_force,1); - EXPECT_EQ(INPUT.relax_nmax,50); - EXPECT_EQ(INPUT.ks_solver,"cg"); - EXPECT_EQ(INPUT.gamma_only_local,0); - EXPECT_EQ(INPUT.bx,1); - EXPECT_EQ(INPUT.by,1); - EXPECT_EQ(INPUT.bz,1); - EXPECT_DOUBLE_EQ(INPUT.scf_thr,1.0e-9); - EXPECT_EQ(INPUT.scf_thr_type,1); - EXPECT_EQ(INPUT.esolver_type, "ksdft"); - //================================================== - // prepare default parameters for the 3rd calling - INPUT.vdw_method = "d3_bj"; - INPUT.vdw_s6 = "default"; - INPUT.vdw_s8 = "default"; - INPUT.vdw_a1 = "default"; - INPUT.vdw_a2 = "default"; - INPUT.vdw_cutoff_radius = "default"; - INPUT.calculation = "get_S"; - INPUT.chg_extrap = "default"; - INPUT.basis_type = "pw"; - INPUT.pw_diag_thr = 1.0e-2; - INPUT.cal_force = 1; - INPUT.init_chg = "atomic"; - INPUT.basis_type = "pw"; - INPUT.ks_solver = "cg"; - GlobalV::NPROC = 8; - INPUT.diago_proc = 1; - INPUT.nx = INPUT.ny = INPUT.nz = 4; - INPUT.ndx = INPUT.ndy = INPUT.ndz = 6; - // the 3rd calling - INPUT.Default_2(); - // ^^^^^^^^^^^^^^ - EXPECT_TRUE(GlobalV::double_grid); - EXPECT_EQ(INPUT.chg_extrap, "atomic"); - EXPECT_EQ(INPUT.vdw_s6, "1.0"); - EXPECT_EQ(INPUT.vdw_s8, "0.7875"); - EXPECT_EQ(INPUT.vdw_a1,"0.4289"); - EXPECT_EQ(INPUT.vdw_a2,"4.4407"); - EXPECT_EQ(INPUT.vdw_cutoff_radius,"95"); - EXPECT_EQ(GlobalV::CALCULATION,"nscf"); - EXPECT_EQ(INPUT.relax_nmax,1); - EXPECT_EQ(INPUT.out_stru,0); - EXPECT_DOUBLE_EQ(INPUT.pw_diag_thr,1.0e-5); - EXPECT_FALSE(INPUT.cal_force); - EXPECT_EQ(INPUT.init_chg,"file"); - EXPECT_EQ(INPUT.diago_proc,8); - //================================================== - // prepare default parameters for the 4th calling - INPUT.calculation = "get_pchg"; - INPUT.chg_extrap = "default"; - INPUT.symmetry = "default"; - INPUT.ecutwfc = 10; - INPUT.ecutrho = 100; - INPUT.nx = INPUT.ny = INPUT.nz = 0; - INPUT.ndx = INPUT.ndy = INPUT.ndz = 0; - GlobalV::double_grid = false; - // the 4th calling - INPUT.Default_2(); - // ^^^^^^^^^^^^^^ - EXPECT_TRUE(GlobalV::double_grid); - EXPECT_EQ(GlobalV::CALCULATION, "get_pchg"); - EXPECT_EQ(INPUT.relax_nmax, 1); - EXPECT_EQ(INPUT.out_stru, 0); - EXPECT_EQ(INPUT.symmetry, "0"); - EXPECT_EQ(INPUT.out_band[0],0); - EXPECT_EQ(INPUT.out_band[1],8); - EXPECT_EQ(INPUT.out_proj_band,0); - EXPECT_EQ(INPUT.cal_force,0); - EXPECT_EQ(INPUT.init_wfc,"file"); - EXPECT_EQ(INPUT.init_chg,"atomic"); - EXPECT_EQ(INPUT.chg_extrap,"atomic"); - EXPECT_EQ(INPUT.out_chg,1); - EXPECT_EQ(INPUT.out_dm,0); - EXPECT_EQ(INPUT.out_dm1,0); - EXPECT_EQ(INPUT.out_pot,0); - //================================================== - // prepare default parameters for the 5th calling - INPUT.calculation = "get_wf"; - INPUT.symmetry = "default"; - INPUT.chg_extrap = "default"; - // the 5th calling - INPUT.Default_2(); - // ^^^^^^^^^^^^^^ - EXPECT_EQ(GlobalV::CALCULATION,"get_wf"); - EXPECT_EQ(INPUT.relax_nmax, 1); - EXPECT_EQ(INPUT.symmetry, "0"); - EXPECT_EQ(INPUT.out_stru, 0); - EXPECT_EQ(INPUT.out_band[0],0); - EXPECT_EQ(INPUT.out_band[1],8); - EXPECT_EQ(INPUT.out_proj_band,0); - EXPECT_EQ(INPUT.cal_force,0); - EXPECT_EQ(INPUT.init_wfc,"file"); - EXPECT_EQ(INPUT.init_chg,"atomic"); - EXPECT_EQ(INPUT.chg_extrap,"atomic"); - EXPECT_EQ(INPUT.out_chg,1); - EXPECT_EQ(INPUT.out_dm,0); - EXPECT_EQ(INPUT.out_dm1,0); - EXPECT_EQ(INPUT.out_pot,0); - //================================================== - // prepare default parameters for the 6th calling - INPUT.calculation = "md"; - INPUT.chg_extrap = "default"; - INPUT.mdp.md_nstep = 0; - INPUT.out_md_control = 0; - INPUT.mdp.md_tlast = -1.0; - INPUT.mdp.md_plast = -1.0; - INPUT.mdp.md_tfreq = 0; - INPUT.mdp.md_pfreq = 0; - INPUT.mdp.md_restart = 1; - INPUT.mdp.md_type = "npt"; - INPUT.mdp.md_pmode = "iso"; - // the 6th calling - INPUT.Default_2(); - // ^^^^^^^^^^^^^^ - EXPECT_EQ(GlobalV::CALCULATION,"md"); - EXPECT_EQ(INPUT.chg_extrap, "second-order"); - EXPECT_EQ(INPUT.symmetry, "0"); - EXPECT_EQ(INPUT.cal_force, 1); - EXPECT_EQ(INPUT.mdp.md_nstep,50); - EXPECT_EQ(INPUT.out_level, "m"); - EXPECT_DOUBLE_EQ(INPUT.mdp.md_plast, INPUT.mdp.md_pfirst); - EXPECT_DOUBLE_EQ(INPUT.mdp.md_tfreq,1.0/40/INPUT.mdp.md_dt); - EXPECT_DOUBLE_EQ(INPUT.mdp.md_pfreq,1.0/400/INPUT.mdp.md_dt); - EXPECT_EQ(INPUT.init_vel,1); - EXPECT_EQ(INPUT.cal_stress,1); - //================================================== - // prepare default parameters for the 7th calling - INPUT.calculation = "cell-relax"; - INPUT.chg_extrap = "default"; - INPUT.relax_nmax = 0; - // the 7th calling - INPUT.Default_2(); - // ^^^^^^^^^^^^^^ - EXPECT_EQ(INPUT.chg_extrap, "first-order"); - EXPECT_EQ(INPUT.cal_force, 1); - EXPECT_EQ(INPUT.cal_stress,1); - EXPECT_EQ(INPUT.relax_nmax,50); - //================================================== - // prepare default parameters for the 8th calling - INPUT.calculation = "test_memory"; - INPUT.chg_extrap = "default"; - // the 8th calling - INPUT.Default_2(); - // ^^^^^^^^^^^^^^ - EXPECT_EQ(INPUT.chg_extrap, "atomic"); - EXPECT_EQ(INPUT.relax_nmax,1); - //================================================== - // prepare default parameters for the 9th calling - INPUT.calculation = "test_neighbour"; - INPUT.chg_extrap = "default"; - // the 9th calling - INPUT.Default_2(); - // ^^^^^^^^^^^^^^ - EXPECT_EQ(INPUT.chg_extrap, "atomic"); - EXPECT_EQ(INPUT.relax_nmax,1); - //================================================== - // prepare default parameters for the 10th calling - INPUT.calculation = "gen_bessel"; - INPUT.chg_extrap = "default"; - // the 10th calling - INPUT.Default_2(); - // ^^^^^^^^^^^^^^ - EXPECT_EQ(INPUT.chg_extrap, "atomic"); - EXPECT_EQ(INPUT.relax_nmax,1); - //================================================== - remove("INPUT"); - remove("STRU"); -} - -TEST_F(InputTest, Check) -{ - INPUT.ecutwfc = 20.0; - INPUT.ecutrho = 10; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(), ::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output, testing::HasSubstr("ecutrho/ecutwfc must >= 4")); - INPUT.ecutrho = 100.0; - INPUT.nx = INPUT.ny = INPUT.nz = 10; - INPUT.ndx = INPUT.ndy = INPUT.ndz = 8; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(), ::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output, testing::HasSubstr("smooth grids is denser than dense grids")); - INPUT.ndx = INPUT.ndy = INPUT.ndz = 11; - // - INPUT.nbands = -1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("NBANDS must >= 0")); - INPUT.nbands = 2; - // - INPUT.nb2d = -1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("nb2d must > 0")); - INPUT.nb2d = 1; - // - INPUT.ntype = -1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("ntype must > 0")); - INPUT.ntype = 1; - // - INPUT.basis_type = "lcao"; - INPUT.diago_proc = 2; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("please don't set diago_proc with lcao base")); - INPUT.diago_proc = 1; - // - INPUT.kspacing[0] = -1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("kspacing must > 0")); - INPUT.kspacing[0] = INPUT.kspacing[1] = INPUT.kspacing[2] = 0.8; - // - INPUT.nelec = -1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("nelec < 0 is not allowed !")); - INPUT.nelec = 100; - // - INPUT.efield_flag = 0; - INPUT.dip_cor_flag = 1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("dipole correction is not active if efield_flag=false !")); - INPUT.dip_cor_flag = 0; - // - INPUT.efield_flag = 1; - INPUT.gate_flag = 1; - INPUT.dip_cor_flag = 0; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("gate field cannot be used with efield if dip_cor_flag=false !")); - INPUT.gate_flag = 0; - // - INPUT.calculation = "nscf"; - INPUT.out_dos = 3; - INPUT.symmetry = "1"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("symmetry can't be used for out_dos==3(Fermi Surface Plotting) by now.")); - INPUT.symmetry = "0"; - INPUT.out_dos = 0; - // - INPUT.calculation = "get_pchg"; - INPUT.basis_type = "pw"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("calculate = get_pchg is only availble for LCAO")); - INPUT.basis_type = "lcao"; - // - INPUT.calculation = "get_wf"; - INPUT.basis_type = "pw"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("calculate = get_wf is only availble for LCAO")); - INPUT.basis_type = "lcao"; - // - INPUT.calculation = "md"; - INPUT.mdp.md_dt = -1.0; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("time interval of MD calculation should be set!")); - INPUT.mdp.md_dt = 1.0; - // - INPUT.mdp.md_type = "msst"; - INPUT.mdp.msst_qmass = -1.0; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("msst_qmass must be greater than 0!")); - INPUT.mdp.msst_qmass = 1.0; - // - INPUT.esolver_type = "dp"; - INPUT.mdp.pot_file = "graph.pb"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("Can not find DP model !")); - INPUT.esolver_type = "ksdft"; - // - INPUT.calculation = "gen_bessel"; - INPUT.basis_type = "lcao"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("to generate descriptors, please use pw basis")); - INPUT.basis_type = "pw"; - // - INPUT.calculation = "arbitrary"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("check 'calculation' !")); - INPUT.calculation = "scf"; - // - INPUT.init_chg = "arbitrary"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("wrong 'init_chg',not 'atomic', 'file',please check")); - INPUT.init_chg = "atomic"; - // - INPUT.gamma_only_local = 0; - INPUT.out_dm = 1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("out_dm with k-point algorithm is not implemented yet.")); - INPUT.out_dm = 0; - // - INPUT.gamma_only_local = 1; - INPUT.out_dm1 = 1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("out_dm1 is only for multi-k")); - INPUT.gamma_only_local = 0; - INPUT.out_dm1 = 0; - // - INPUT.nbands = 100001; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("nbnd >100000, out of range")); - INPUT.nbands = 100; - // - INPUT.nelec = 2*INPUT.nbands + 1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("nelec > 2*nbnd , bands not enough!")); - INPUT.nelec = INPUT.nbands; - // - INPUT.nspin = 3; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("nspin does not equal to 1, 2, or 4!")); - INPUT.nspin = 1; - // - INPUT.basis_type = "pw"; - INPUT.ks_solver = "genelpa"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("genelpa can not be used with plane wave basis.")); - // - INPUT.basis_type = "pw"; - INPUT.ks_solver = "scalapack_gvx"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("scalapack_gvx can not be used with plane wave basis.")); - // - INPUT.basis_type = "pw"; - INPUT.ks_solver = "lapack"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("lapack can not be used with plane wave basis.")); - // - INPUT.basis_type = "pw"; - INPUT.ks_solver = "arbitrary"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("please check the ks_solver parameter!")); - INPUT.ks_solver = "cg"; - // - INPUT.basis_type = "pw"; - INPUT.gamma_only = 1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("gamma_only not implemented for plane wave now.")); - INPUT.gamma_only = 0; - // - INPUT.basis_type = "pw"; - INPUT.out_proj_band = 1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("out_proj_band not implemented for plane wave now.")); - INPUT.out_proj_band = 0; - // - INPUT.basis_type = "pw"; - INPUT.out_dos = 3; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("Fermi Surface Plotting not implemented for plane wave now.")); - INPUT.out_dos = 0; - // - INPUT.basis_type = "pw"; - INPUT.sc_mag_switch = 3; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("Non-colliner Spin-constrained DFT not implemented for plane wave now.")); - INPUT.sc_mag_switch = 0; - // - INPUT.basis_type = "lcao"; - INPUT.ks_solver = "cg"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("not ready for cg method in lcao .")); - // - INPUT.basis_type = "lcao"; - INPUT.ks_solver = "genelpa"; -#ifndef __MPI - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("genelpa can not be used for series version.")); -#endif -#ifndef __ELPA - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("Can not use genelpa if abacus is not compiled with ELPA. Please change ks_solver to scalapack_gvx.")); -#endif - // - INPUT.basis_type = "lcao"; - INPUT.ks_solver = "scalapack_gvx"; -#ifndef __MPI - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("scalapack_gvx can not be used for series version.")); -#endif - // - INPUT.basis_type = "lcao"; - INPUT.ks_solver = "lapack"; -#ifdef __MPI - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("ks_solver=lapack is not an option for parallel version of ABACUS (try genelpa)")); -#endif - // - INPUT.basis_type = "lcao"; - INPUT.ks_solver = "cusolver"; -#ifndef __MPI - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("Cusolver can not be used for series version.")); -#endif - // - INPUT.basis_type = "lcao"; - INPUT.ks_solver = "arbitrary"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("please check the ks_solver parameter!")); - INPUT.ks_solver = "genelpa"; - // - INPUT.basis_type = "lcao"; - INPUT.out_wfc_lcao = 3; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("out_wfc_lcao must be 0, 1, or 2")); - INPUT.out_wfc_lcao = 0; - // - INPUT.basis_type = "lcao_in_pw"; - INPUT.ks_solver = "arbitrary"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("LCAO in plane wave can only done with lapack.")); - INPUT.ks_solver = "default"; - // - INPUT.basis_type = "arbitrary"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("please check the basis_type parameter!")); - INPUT.basis_type = "pw"; - // - INPUT.relax_method = "arbitrary"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("relax_method can only be sd, cg, bfgs or cg_bfgs.")); - INPUT.relax_method = "cg"; - // - INPUT.bx = 11; INPUT.by = 1; INPUT.bz = 1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("bx, or by, or bz is larger than 10!")); - INPUT.bx = 1; - // - INPUT.vdw_method = "d2"; - INPUT.vdw_C6_unit = "arbitrary"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("vdw_C6_unit must be Jnm6/mol or eVA6")); - INPUT.vdw_C6_unit = "eVA6"; - // - INPUT.vdw_R0_unit = "arbitrary"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("vdw_R0_unit must be A or Bohr")); - INPUT.vdw_R0_unit = "A"; - // - INPUT.vdw_cutoff_type = "arbitrary"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("vdw_cutoff_type must be radius or period")); - INPUT.vdw_cutoff_type = "radius"; - // - INPUT.vdw_cutoff_period.x = 0; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("vdw_cutoff_period <= 0 is not allowd")); - INPUT.vdw_cutoff_period.x = 3; - // - INPUT.vdw_cutoff_radius = "0"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("vdw_cutoff_radius <= 0 is not allowd")); - INPUT.vdw_cutoff_radius = "1.0"; - // - INPUT.vdw_radius_unit = "arbitrary"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("vdw_radius_unit must be A or Bohr")); - INPUT.vdw_radius_unit = "A"; - // - INPUT.vdw_cn_thr = 0; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("vdw_cn_thr <= 0 is not allowd")); - INPUT.vdw_cn_thr = 1.0; - // - INPUT.vdw_cn_thr_unit = "arbitrary"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("vdw_cn_thr_unit must be A or Bohr")); - INPUT.vdw_cn_thr_unit = "A"; - // - INPUT.dft_functional = "scan0"; - INPUT.exx_hybrid_alpha = "1.25"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("must 0 <= exx_hybrid_alpha <= 1")); - INPUT.exx_hybrid_alpha = "0.25"; - // - INPUT.exx_hybrid_step = 0; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("must exx_hybrid_step > 0")); - INPUT.exx_hybrid_step = 1; - // - INPUT.exx_ccp_rmesh_times = "-1"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("must exx_ccp_rmesh_times >= 1")); - INPUT.exx_ccp_rmesh_times = "1.5"; - // - INPUT.rpa = true; - INPUT.rpa_ccp_rmesh_times = -1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(), ::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output, testing::HasSubstr("must rpa_ccp_rmesh_times >= 1")); - INPUT.rpa_ccp_rmesh_times = 10.0; - // - INPUT.exx_distribute_type = "arbitrary"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("exx_distribute_type must be htime or kmeans2 or kmeans1")); - INPUT.exx_distribute_type = "htime"; - // - INPUT.dft_functional = "opt_orb"; - INPUT.exx_opt_orb_lmax = -1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("exx_opt_orb_lmax must >=0")); - INPUT.exx_opt_orb_lmax = 0; - // - INPUT.exx_opt_orb_ecut = -1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("exx_opt_orb_ecut must >=0")); - INPUT.exx_opt_orb_ecut = 0; - // - INPUT.exx_opt_orb_tolerence = -1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("exx_opt_orb_tolerence must >=0")); - INPUT.exx_opt_orb_tolerence = 0; - // - INPUT.berry_phase = 1; - INPUT.basis_type = "lcao_in_pw"; - INPUT.ks_solver = "lapack"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("calculate berry phase, please set basis_type = pw or lcao")); - INPUT.basis_type = "pw"; - INPUT.ks_solver = "cg"; - // - INPUT.calculation = "scf"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("calculate berry phase, please set calculation = nscf")); - INPUT.calculation = "nscf"; - // - INPUT.gdir = 4; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("calculate berry phase, please set gdir = 1 or 2 or 3")); - INPUT.gdir = 3; - INPUT.berry_phase = 0; - // - INPUT.towannier90 = 1; - // due to the repair of lcao_in_pw, original warning has been deprecated, 2023/12/23, ykhuang - // INPUT.basis_type = "lcao_in_pw"; - // INPUT.ks_solver = "lapack"; - // testing::internal::CaptureStdout(); - // EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - // output = testing::internal::GetCapturedStdout(); - // EXPECT_THAT(output,testing::HasSubstr("to use towannier90, please set basis_type = pw or lcao")); - INPUT.basis_type = "pw"; - INPUT.ks_solver = "cg"; - // - INPUT.calculation = "scf"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("to use towannier90, please set calculation = nscf")); - INPUT.calculation = "nscf"; - // - INPUT.nspin = 2; - INPUT.wannier_spin = "arbitrary"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("to use towannier90, please set wannier_spin = up or down")); - INPUT.wannier_spin = "up"; - INPUT.towannier90 = 0; - // - INPUT.read_file_dir = "arbitrary"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("please set right files directory for reading in.")); - INPUT.read_file_dir = "auto"; - /* - // Start to check deltaspin parameters - INPUT.sc_mag_switch = 1; - INPUT.sc_file = "none"; - INPUT.basis_type = "lcao"; - INPUT.ks_solver = "genelpa"; - // warning 1 of Deltaspin - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("sc_file (json format) must be set when sc_mag_switch > 0")); - // warning 2 of Deltaspin - INPUT.sc_file = "sc.json"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("sc_file does not exist")); - INPUT.sc_file = "./support/sc.json"; - // warning 3 of Deltaspin - INPUT.nspin = 1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("nspin must be 2 or 4 when sc_mag_switch > 0")); - INPUT.nspin = 4; - // warning 4 of Deltaspin - INPUT.calculation = "nscf"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("calculation must be scf when sc_mag_switch > 0")); - INPUT.calculation = "scf"; - // warning 5 of Deltaspin - INPUT.sc_thr = -1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("sc_thr must > 0")); - INPUT.sc_thr = 1e-6; - // warning 6 of Deltaspin - INPUT.nsc = -1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("nsc must > 0")); - INPUT.nsc = 100; - // warning 7 of Deltaspin - INPUT.nsc_min = -1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("nsc_min must > 0")); - INPUT.nsc_min = 2; - // warning 8 of Deltapsin - INPUT.alpha_trial = -1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("alpha_trial must > 0")); - INPUT.alpha_trial = 0.01; - // warning 9 of Deltapsin - INPUT.sccut = -1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("sccut must > 0")); - INPUT.sccut = 3.0; - // warning 10 of Deltaspin - INPUT.sc_scf_nmin = -1; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("sc_scf_nmin must >= 2")); - INPUT.sc_scf_nmin = 2; - // warning 10 of Deltaspin - INPUT.nupdown = 4; - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("nupdown should not be set when sc_mag_switch > 0")); - INPUT.nupdown = 0; - // restore to default values - INPUT.nspin = 1; - INPUT.sc_file = "none"; - INPUT.sc_mag_switch = 0; - INPUT.ks_solver = "default"; - INPUT.basis_type = "pw"; - // End of checking Deltaspin parameters - */ - - /* - testing::internal::CaptureStdout(); - EXPECT_EXIT(INPUT.Check(),::testing::ExitedWithCode(0), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output,testing::HasSubstr("")); - */ -} - -bool strcmp_inbuilt(const std::string& str1, const std::string& str2) -{ - if(str1.size() != str2.size()) - return false; - for(int i=0; i value; - while(!ifs.eof()) - { - ifs >> word; - if(strcmp_inbuilt(word, "bessel_nao_rcut_case0")) - { - value.clear(); value.shrink_to_fit(); - INPUT.read_value2stdvector(ifs, value); - EXPECT_EQ(value.size(), 1); - EXPECT_EQ(value[0], 7); - } - if(strcmp_inbuilt(word, "bessel_nao_rcut_case1")) - { - value.clear(); value.shrink_to_fit(); - INPUT.read_value2stdvector(ifs, value); - EXPECT_EQ(value.size(), 1); - EXPECT_EQ(value[0], 7); - } - if(strcmp_inbuilt(word, "bessel_nao_rcut_case2")) - { - value.clear(); value.shrink_to_fit(); - INPUT.read_value2stdvector(ifs, value); - EXPECT_EQ(value.size(), 1); - EXPECT_EQ(value[0], 7); - } - if(strcmp_inbuilt(word, "bessel_nao_rcut_case3")) - { - value.clear(); value.shrink_to_fit(); - INPUT.read_value2stdvector(ifs, value); - EXPECT_EQ(value.size(), 1); - EXPECT_EQ(value[0], 7); - } - if(strcmp_inbuilt(word, "bessel_nao_rcut_case4")) - { - value.clear(); value.shrink_to_fit(); - INPUT.read_value2stdvector(ifs, value); - EXPECT_EQ(value.size(), 1); - EXPECT_EQ(value[0], 7); - } - if(strcmp_inbuilt(word, "bessel_nao_rcut_case5")) - { - value.clear(); value.shrink_to_fit(); - INPUT.read_value2stdvector(ifs, value); - EXPECT_EQ(value.size(), 4); - EXPECT_EQ(value[0], 7); - EXPECT_EQ(value[1], 8); - EXPECT_EQ(value[2], 9); - EXPECT_EQ(value[3], 10); - } - if(strcmp_inbuilt(word, "bessel_nao_rcut_case6")) - { - value.clear(); value.shrink_to_fit(); - INPUT.read_value2stdvector(ifs, value); - EXPECT_EQ(value.size(), 4); - EXPECT_EQ(value[0], 7); - EXPECT_EQ(value[1], 8); - EXPECT_EQ(value[2], 9); - EXPECT_EQ(value[3], 10); - } - if(strcmp_inbuilt(word, "bessel_nao_rcut_case7")) - { - value.clear(); value.shrink_to_fit(); - INPUT.read_value2stdvector(ifs, value); - EXPECT_EQ(value.size(), 4); - EXPECT_EQ(value[0], 7); - EXPECT_EQ(value[1], 8); - EXPECT_EQ(value[2], 9); - EXPECT_EQ(value[3], 10); - } - if(strcmp_inbuilt(word, "bessel_nao_rcut_case8")) - { - value.clear(); value.shrink_to_fit(); - INPUT.read_value2stdvector(ifs, value); - EXPECT_EQ(value.size(), 4); - EXPECT_EQ(value[0], 7); - EXPECT_EQ(value[1], 8); - EXPECT_EQ(value[2], 9); - EXPECT_EQ(value[3], 10); - } - std::vector str_value; - if(strcmp_inbuilt(word, "bessel_nao_rcut_case9")) - { - str_value.clear(); str_value.shrink_to_fit(); - INPUT.read_value2stdvector(ifs, str_value); - EXPECT_EQ(str_value.size(), 1); - EXPECT_EQ(str_value[0], "string1"); - } - if(strcmp_inbuilt(word, "bessel_nao_rcut_case10")) - { - str_value.clear(); str_value.shrink_to_fit(); - INPUT.read_value2stdvector(ifs, str_value); - EXPECT_EQ(str_value.size(), 4); - EXPECT_EQ(str_value[0], "string1"); - EXPECT_EQ(str_value[1], "string2"); - EXPECT_EQ(str_value[2], "string3"); - EXPECT_EQ(str_value[3], "string4"); - } - std::vector double_value; - if(strcmp_inbuilt(word, "bessel_nao_rcut_case11")) - { - double_value.clear(); double_value.shrink_to_fit(); - INPUT.read_value2stdvector(ifs, double_value); - EXPECT_EQ(double_value.size(), 1); - EXPECT_EQ(double_value[0], 1.23456789); - } - if(strcmp_inbuilt(word, "bessel_nao_rcut_case12")) - { - double_value.clear(); double_value.shrink_to_fit(); - INPUT.read_value2stdvector(ifs, double_value); - EXPECT_EQ(double_value.size(), 4); - EXPECT_EQ(double_value[0], -1.23456789); - EXPECT_EQ(double_value[1], 2.3456789); - EXPECT_EQ(double_value[2], -3.456789); - EXPECT_EQ(double_value[3], 4.56789); - } - } -} -#undef private - - -class ReadKSpacingTest : public ::testing::Test { -protected: - void SetUp() override - { - // create a temporary file for testing - char tmpname[] = "tmpfile.tmp"; - int fd = mkstemp(tmpname); - tmpfile = tmpname; - std::ofstream ofs(tmpfile); - ofs << "1.0"; // valid input - ofs.close(); - } - - void TearDown() override { - close(fd); - unlink(tmpfile.c_str()); - } - - std::string tmpfile; - int fd; -}; - -TEST_F(ReadKSpacingTest, ValidInputOneValue) { - std::ifstream ifs(tmpfile); - EXPECT_NO_THROW(INPUT.read_kspacing(ifs)); - EXPECT_EQ(INPUT.kspacing[0], 1.0); - EXPECT_EQ(INPUT.kspacing[1], 1.0); - EXPECT_EQ(INPUT.kspacing[2], 1.0); -} - -TEST_F(ReadKSpacingTest, ValidInputThreeValue) { - std::ofstream ofs(tmpfile); - ofs << "1.0 2.0 3.0"; // invalid input - ofs.close(); - - std::ifstream ifs(tmpfile); - EXPECT_NO_THROW(INPUT.read_kspacing(ifs)); - EXPECT_EQ(INPUT.kspacing[0], 1.0); - EXPECT_EQ(INPUT.kspacing[1], 2.0); - EXPECT_EQ(INPUT.kspacing[2], 3.0); -} - -TEST_F(ReadKSpacingTest, InvalidInput) { - std::ofstream ofs(tmpfile); - ofs << "1.0 2.0"; // invalid input - ofs.close(); - - std::ifstream ifs(tmpfile); - testing::internal::CaptureStdout(); - INPUT.read_kspacing(ifs); - std::string output; - output = testing::internal::GetCapturedStdout(); - EXPECT_TRUE(ifs.fail()); -} diff --git a/source/module_io/test/read_input_ptest.cpp b/source/module_io/test/read_input_ptest.cpp index 412d3a402a..02b90fbae2 100644 --- a/source/module_io/test/read_input_ptest.cpp +++ b/source/module_io/test/read_input_ptest.cpp @@ -215,7 +215,7 @@ TEST_F(InputParaTest, ParaRead) EXPECT_TRUE(param.inp.bessel_nao_smooth); EXPECT_DOUBLE_EQ(param.inp.bessel_nao_sigma, 0.1); EXPECT_EQ(std::stod(param.inp.bessel_nao_ecut), 20); - EXPECT_DOUBLE_EQ(param.globalv.bessel_nao_rcut, 6.0); + EXPECT_DOUBLE_EQ(param.inp.bessel_nao_rcuts[0], 6.0); EXPECT_DOUBLE_EQ(param.inp.bessel_nao_tolerence, 1E-12); EXPECT_EQ(param.inp.bessel_descriptor_lmax, 2); EXPECT_TRUE(param.inp.bessel_descriptor_smooth); diff --git a/source/module_io/test_serial/CMakeLists.txt b/source/module_io/test_serial/CMakeLists.txt index 7edcce3e38..00798fbe4a 100644 --- a/source/module_io/test_serial/CMakeLists.txt +++ b/source/module_io/test_serial/CMakeLists.txt @@ -6,14 +6,19 @@ remove_definitions(-D__MPI) add_library( io_input_serial OBJECT - ../read_input_item_other.cpp - ../read_input_item_general.cpp - ../read_input_item_pw.cpp - ../read_input_item_sdft.cpp + ../read_input_item_system.cpp + ../read_input_item_elec_stru.cpp ../read_input_item_relax.cpp - ../read_input_item_lcao.cpp - ../read_input_item_postprocess.cpp ../read_input_item_md.cpp + ../read_input_item_ofdft.cpp + ../read_input_item_sdft.cpp + ../read_input_item_tddft.cpp + ../read_input_item_deepks.cpp + ../read_input_item_model.cpp + ../read_input_item_postprocess.cpp + ../read_input_item_exx_dftu.cpp + ../read_input_item_other.cpp + ../read_input_item_output.cpp ../read_input.cpp ../bcast_globalv.cpp ) diff --git a/source/module_io/test_serial/read_input_item_test.cpp b/source/module_io/test_serial/read_input_item_test.cpp index 18a634e33d..a3165874ec 100644 --- a/source/module_io/test_serial/read_input_item_test.cpp +++ b/source/module_io/test_serial/read_input_item_test.cpp @@ -1435,7 +1435,7 @@ TEST_F(InputTest, Item_test) } { // bessel_nao_rcut auto it = find_lable("bessel_nao_rcut", readinput.input_lists); - param.sys.bessel_nao_rcut = -1; + param.input.bessel_nao_rcuts = {-1}; testing::internal::CaptureStdout(); EXPECT_EXIT(it->second.check_value(it->second, param), ::testing::ExitedWithCode(0), ""); output = testing::internal::GetCapturedStdout(); diff --git a/source/module_parameter/input_parameter.h b/source/module_parameter/input_parameter.h index 8a306fda83..75fb66dd07 100644 --- a/source/module_parameter/input_parameter.h +++ b/source/module_parameter/input_parameter.h @@ -1,11 +1,11 @@ #ifndef INPUT_PARAMETER_H #define INPUT_PARAMETER_H -#include -#include - #include "md_parameter.h" #include "module_base/vector3.h" +#include +#include + // It stores all input parameters both defined in INPUT file and not defined in // INPUT file struct Input_para @@ -13,138 +13,146 @@ struct Input_para // --------------------------------------------------------------- // -------------- INPUT Parameters ---------------- // --------------------------------------------------------------- - // ============== #Parameters (1.General) ===================== - std::string suffix = "ABACUS"; ///< suffix of out put dir - std::string latname = "none"; ///< lattice name - std::string stru_file = "STRU"; ///< file contains atomic positions -- - ///< xiaohui modify 2015-02-01 - std::string kpoint_file = "KPT"; ///< file contains k-points -- xiaohui modify 2015-02-01 - std::string pseudo_dir = "./"; ///< directory of pseudopotential - std::string orbital_dir = "./"; ///< directory of orbital file - double pseudo_rcut = 15.0; ///< cut-off radius for calculating msh - bool pseudo_mesh = false; ///< 0: use msh to normalize radial wave functions; 1: - ///< use mesh, which is used in QE. - int lmaxmax = 2; ///< maximum of l channels used - std::string dft_functional = "default"; ///< input DFT functional. - double xc_temperature = 0.0; ///< only relevant if finite temperature functional is used - std::string calculation = "scf"; ///< "scf" : self consistent calculation. - ///< "nscf" : non-self consistent calculation. - ///< "relax" : cell relaxations - std::string esolver_type = "ksdft"; ///< the energy solver: ksdft, sdft, ofdft, tddft, lj, dp - int ntype = 0; ///< number of atom types - int nspin = 1; ///< LDA ; LSDA ; non-linear spin - std::vector kspacing = {0.0, 0.0, 0.0}; ///< kspacing for k-point generation - double min_dist_coef = 0.2; ///< allowed minimum distance between two atoms - int nbands = 0; ///< number of bands - int nbands_istate = 5; ///< number of bands around fermi level for get_pchg calculation. - std::vector bands_to_print = {}; ///< specify the bands to be calculated in the get_pchg - - bool if_separate_k = false; ///< whether to write partial charge for all k-points to individual files or merge them + // ============== #Parameters (1.System) ===================== + std::string suffix = "ABACUS"; ///< suffix of out put dir + int ntype = 0; ///< number of atom types + std::string calculation = "scf"; ///< "scf" : self consistent calculation. + ///< "nscf" : non-self consistent calculation. + ///< "relax" : cell relaxations + std::string esolver_type = "ksdft"; ///< the energy solver: ksdft, sdft, ofdft, tddft, lj, dp /* symmetry level: -1, no symmetry at all; 0, only basic time reversal would be considered; 1, point group symmetry would be considered*/ std::string symmetry = "default"; - bool init_vel = false; ///< read velocity from STRU or not liuyu 2021-07-14 double symmetry_prec = 1.0e-6; ///< LiuXh add 2021-08-12, accuracy for symmetry bool symmetry_autoclose = true; ///< whether to close symmetry automatically ///< when error occurs in symmetry analysis - double nelec = 0.0; ///< total number of electrons - double nelec_delta = 0.0; ///< change in the number of total electrons - double nupdown = 0.0; - bool out_mul = false; ///< qifeng add 2019-9-10 - bool noncolin = false; ///< using non-collinear-spin - bool lspinorb = false; ///< consider the spin-orbit interaction - int kpar = 1; ///< ecch pool is for one k point - int bndpar = 1; ///< parallel for stochastic/deterministic bands - int out_freq_elec = 0; ///< the frequency ( >= 0) of electronic iter to output charge - ///< density and wavefunction. 0: output only when converged - bool dft_plus_dmft = false; ///< true:DFT+DMFT; false: standard DFT calcullation(default) - bool rpa = false; ///< rpa calculation - int printe = 100; ///< mohan add 2011-03-16 - int mem_saver = 0; ///< 1: save psi when nscf calculation. - int diago_proc = 0; ///< the number of procs used to diag. mohan add 2012-01-13 - int nbspline = -1; ///< the order of B-spline basis(>=0) if it is -1 (default) - std::string wannier_card = "none"; ///< input card for wannier functions. - double soc_lambda = 1.0; ///< The fraction of averaged SOC pseudopotential - ///< is given by (1-soc_lambda) - bool cal_force = false; ///< calculate the force - int out_freq_ion = 0; ///< the frequency ( >= 0 ) of ionic step to output charge density - ///< and wavefunction. 0: output only when ion steps are finished - int elpa_num_thread = -1; ///< Number of threads need to use in elpa - std::string device = "cpu"; - std::string precision = "double"; - - // ============== #Parameters (2.PW) =========================== - - double ecutwfc = 50; ///< energy cutoff for wavefunctions - double ecutrho = 0; ///< energy cutoff for charge/potential - double erf_ecut = 0; ///< the value of the constant energy cutoff - double erf_height = 0; ///< the height of the energy step for reciprocal vectors - double erf_sigma = 0.1; ///< the width of the energy step for reciprocal vectors - int fft_mode = 0; ///< fftw mode 0: estimate, 1: measure, 2: patient, 3: exhaustive - int pw_diag_nmax = 50; - int diago_cg_prec = 1; ///< mohan add 2012-03-31 - int pw_diag_ndim = 4; ///< dimension of workspace for Davidson diagonalization + bool cal_force = false; ///< calculate the force + bool cal_stress = false; ///< calculate the stress + int kpar = 1; ///< ecch pool is for one k point + int bndpar = 1; ///< parallel for stochastic/deterministic bands + std::string latname = "none"; ///< lattice name + double ecutwfc = 50; ///< energy cutoff for wavefunctions + double ecutrho = 0; ///< energy cutoff for charge/potential + + int nx = 0, ny = 0, nz = 0; ///< three dimension of FFT wavefunc + int ndx = 0, ndy = 0, ndz = 0; ///< three dimension of FFT smooth charge density + + double cell_factor = 1.2; ///< LiuXh add 20180619 + double erf_ecut = 0; ///< the value of the constant energy cutoff + double erf_height = 0; ///< the height of the energy step for reciprocal vectors + double erf_sigma = 0.1; ///< the width of the energy step for reciprocal vectors + int fft_mode = 0; ///< fftw mode 0: estimate, 1: measure, 2: patient, 3: exhaustive bool diago_full_acc = false; ///< all the empty states are diagonalized - double pw_diag_thr = 0.01; ///< used in cg method - int nb2d = 0; ///< matrix 2d division. - double scf_thr = -1.0; ///< \sum |rhog_out - rhog_in |^2 - int scf_thr_type = -1; ///< type of the criterion of scf_thr, 1: reci drho, 2: real drho std::string init_wfc = "atomic"; ///< "file","atomic","random" bool psi_initializer = false; ///< whether use psi_initializer to initialize wavefunctions + int pw_seed = 1; ///< random seed for initializing wave functions qianrui 2021-8-12 std::string init_chg = "atomic"; ///< "file","atomic" + bool dm_to_rho = false; ///< read density matrix from npz format and calculate charge density std::string chg_extrap = "default"; ///< xiaohui modify 2015-02-01 - int out_chg = 0; ///< output charge density. 0: no; 1: yes - int out_pot = 0; ///< yes or no - int out_wfc_pw = 0; ///< 0: no; 1: txt; 2: dat - bool out_wfc_r = false; ///< 0: no; 1: yes - int out_dos = 0; ///< dos calculation. mohan add 20090909 - std::vector out_band = {0, 8}; ///< band calculation pengfei 2014-10-13 - bool out_proj_band = false; ///< projected band structure calculation jiyy add 2022-05-11 - bool restart_save = false; ///< restart //Peize Lin add 2020-04-04 - bool restart_load = false; + bool init_vel = false; ///< read velocity from STRU or not liuyu 2021-07-14 + + std::string stru_file = "STRU"; ///< file contains atomic positions -- + ///< xiaohui modify 2015-02-01 + std::string kpoint_file = "KPT"; ///< file contains k-points -- xiaohui modify 2015-02-01 + std::string pseudo_dir = "./"; ///< directory of pseudopotential + std::string orbital_dir = "./"; ///< directory of orbital file std::string read_file_dir = "auto"; ///< directory of files for reading - int nx = 0, ny = 0, nz = 0; ///< three dimension of FFT wavefunc - int ndx = 0, ndy = 0, - ndz = 0; ///< three dimension of FFT smooth charge density - double cell_factor = 1.2; ///< LiuXh add 20180619 - int pw_seed = 1; ///< random seed for initializing wave functions qianrui 2021-8-12 - - // ============== #Parameters (3.Stochasti DFT) - // =========================== - int method_sto = 2; ///< different methods for sdft, 1: slow, less memory 2: - ///< fast, more memory - int npart_sto = 1; ///< for method_sto = 2, reduce memory - int nbands_sto = 256; ///< number of stochastic bands //qianrui 2021-2-5 - int nche_sto = 100; ///< number of orders for Chebyshev expansion in - ///< stochastic DFT ///=0) if it is -1 (default) + std::vector kspacing = {0.0, 0.0, 0.0}; ///< kspacing for k-point generation + double min_dist_coef = 0.2; ///< allowed minimum distance between two atoms - // ============== #Parameters (4.Relaxation) =========================== + std::string device = "cpu"; + std::string precision = "double"; + + // ============== #Parameters (2.Electronic structure) =========================== std::string ks_solver = "default"; ///< xiaohui add 2013-09-01 - int scf_nmax = 100; ///< number of max elec iter - int relax_nmax = 1; ///< number of max ionic iter - bool out_stru = false; ///< outut stru file each ion step - double force_thr = -1; ///< threshold of force in unit (Ry/Bohr) - double force_thr_ev = -1; ///< threshold of force in unit (eV/Angstrom) - double force_thr_ev2 = 0; ///< invalid force threshold, mohan add 2011-04-17 - double relax_cg_thr = 0.5; ///< threshold when cg to bfgs, pengfei add 2011-08-15 - double stress_thr = 0.5; ///< Pengfei Li 2017-11-01 /// bessel_nao_rcuts = {}; ///< No specific values provided for bessel_nao_rcuts + bool bessel_nao_smooth = true; ///< spherical bessel smooth or not + double bessel_nao_sigma = 0.1; ///< spherical bessel smearing_sigma + // ========================================================== + // spherical bessel Peize Lin added on 2022-12-15 + // ========================================================== + // the following are used when generating orb_matrix.dat + // int bessel_nao_lmax; ///< lmax used in descriptor + + // ============== #Parameters (4.Relaxation) =========================== + std::string relax_method = "cg"; ///< methods to move_ion: sd, bfgs, cg... + bool relax_new = true; + bool relax = false; ///< allow relaxation along the specific direction + double relax_scale_force = 0.5; + int relax_nmax = 1; ///< number of max ionic iter + double relax_cg_thr = 0.5; ///< threshold when cg to bfgs, pengfei add 2011-08-15 + double force_thr = -1; ///< threshold of force in unit (Ry/Bohr) + double force_thr_ev = -1; ///< threshold of force in unit (eV/Angstrom) + double force_thr_ev2 = 0; ///< invalid force threshold, mohan add 2011-04-17 + double stress_thr = 0.5; ///< Pengfei Li 2017-11-01 /// ocp_kb = {}; ///< OCP kb values + + // ============== #Parameters (10.lr-tddft) =========================== + int lr_nstates = 1; ///< the number of 2-particle states to be solved + int nocc = -1; ///< the number of occupied orbitals to form the 2-particle basis + int nvirt = 1; ///< the number of virtual orbitals to form the 2-particle basis (nocc + nvirt <= nbands) + std::string xc_kernel = "LDA"; ///< exchange correlation (XC) kernel for LR-TDDFT + std::string lr_solver = "dav"; ///< the eigensolver for LR-TDDFT + double lr_thr = 1e-2; ///< convergence threshold of the LR-TDDFT eigensolver + bool out_wfc_lr = false; ///< whether to output the eigenvectors (excitation amplitudes) in the particle-hole basis + std::vector abs_wavelen_range = {0., 0.}; ///< the range of wavelength(nm) to output the absorption spectrum + double abs_broadening = 0.01; ///< the broadening (eta) for LR-TDDFT absorption spectrum + + // ============== #Parameters (11.Output) =========================== + bool out_stru = false; ///< outut stru file each ion step + int out_freq_elec = 0; ///< the frequency ( >= 0) of electronic iter to output charge + ///< 0: output only when converged + int out_freq_ion = 0; ///< the frequency ( >= 0 ) of ionic step to output charge density; + ///< 0: output only when ion steps are finished + int out_chg = 0; ///< output charge density. 0: no; 1: yes + int out_pot = 0; ///< yes or no + int out_wfc_pw = 0; ///< 0: no; 1: txt; 2: dat + bool out_wfc_r = false; ///< 0: no; 1: yes + int printe = 100; ///< mohan add 2011-03-16 + std::vector out_band = {0, 8}; ///< band calculation pengfei 2014-10-13 + int out_dos = 0; ///< dos calculation. mohan add 20090909 + bool out_mul = false; ///< qifeng add 2019-9-10 + bool out_proj_band = false; ///< projected band structure calculation jiyy add 2022-05-11 + std::string out_level = "ie"; ///< control the output information. + bool out_dm = false; ///< output density matrix. (gamma point) + bool out_dm1 = false; ///< output density matrix. (multi-k points) + bool out_bandgap = false; ///< QO added for bandgap printing std::vector out_mat_hs = {0, 8}; ///< output H matrix and S matrix in local basis. bool out_mat_hs2 = false; ///< LiuXh add 2019-07-16, output H(R) matrix and ///< S(R) matrix in local basis. @@ -205,42 +331,27 @@ struct Input_para bool out_hr_npz = false; ///< output exchange-correlation matrix in ///< KS-orbital representation. bool out_dm_npz = false; - bool dm_to_rho = false; + int out_interval = 1; bool out_app_flag = true; ///< whether output r(R), H(R), S(R), T(R), and dH(R) matrices ///< in an append manner during MD liuyu 2023-03-20 int out_ndigits = 8; ///< Assuming 8 digits precision is needed for matrices output bool out_mat_t = false; - bool out_element_info = false; ///< output information of all elements - bool out_mat_r = false; ///< jingan add 2019-8-14, output r(R) matrix. - int out_wfc_lcao = 0; ///< output the wave functions in local basis. - int bx = 0, by = 0, bz = 0; ///< big mesh ball. 0: auto set bx/by/bz - int nstream = 4; ///< Number of streams in CUDA as per input data - int elpa_num_threads = -1; ///< Number of threads need to use in elpa - - // ============== #Parameters (6.Smearing) =========================== - std::string smearing_method = "gauss"; ///< "gauss", - ///< "mp","methfessel-paxton" - ///< "mv","marzari-vanderbilt","cold" - ///< "fd","fermi-dirac" - double smearing_sigma = 0.015; ///< - - // ============== #Parameters (7.Charge Mixing) ====================== - std::string mixing_mode = "broyden"; ///< "plain","broyden",... - double mixing_beta = -1.0; ///< 0 : no_mixing - int mixing_ndim = 8; ///< used in Broyden method - double mixing_restart = 0.0; ///< mixing will restart once if drho is - ///< smaller than mixing_restart - double mixing_gg0 = 1.0; ///< used in kerker method - double mixing_beta_mag = -10.0; - double mixing_gg0_mag = 0.0; - double mixing_gg0_min = 0.1; - double mixing_angle = -10.0; - bool mixing_tau = false; ///< whether to mix tau in mgga - bool mixing_dftu = false; ///< whether to mix locale in DFT+U - bool mixing_dmr = false; ///< whether to mix real space density matrix + bool out_element_info = false; ///< output information of all elements + bool out_mat_r = false; ///< jingan add 2019-8-14, output r(R) matrix. + int out_wfc_lcao = 0; ///< output the wave functions in local basis. + bool out_dipole = false; ///< output the dipole or not + bool out_efield = false; ///< output the efield or not + bool out_current = false; ///< output the current or not + bool out_current_k = false; ///< output tddft current for all k points + bool out_vecpot = false; ///< output the vector potential or not + bool restart_save = false; ///< restart //Peize Lin add 2020-04-04 + bool rpa = false; ///< rpa calculation + int nbands_istate = 5; ///< number of bands around fermi level for get_pchg calculation. + std::vector bands_to_print = {}; ///< specify the bands to be calculated in the get_pchg + bool if_separate_k = false; ///< whether to write partial charge for all k-points to individual files or merge them - // ============== #Parameters (8.DOS) =============================== + // ============== #Parameters (12.Postprocess) =========================== double dos_emin_ev = -15.0; double dos_emax_ev = 15.0; double dos_edelta_ev = 0.01; @@ -248,14 +359,38 @@ struct Input_para double dos_sigma = 0.07; ///< pengfei 2014-10-13 int dos_nche = 100; ///< orders of Chebyshev expansions for dos - // ============== #Parameters (9.Molecular dynamics) ================ - MD_para mdp; - double ref_cell_factor = 1; ///< construct a reference cell bigger than the - ///< initial cell liuyu 2023-03-21 - bool cal_syns = false; ///< calculate asynchronous S matrix to output - double dmax = 0.01; ///< maximum displacement of all atoms in one step (bohr) + bool cal_cond = false; ///< calculate electronic conductivities + double cond_che_thr = 1e-8; ///< control the error of Chebyshev expansions + ///< for conductivities + double cond_dw = 0.1; ///< d\omega for conductivities + double cond_wcut = 10; ///< cutoff \omega for conductivities + double cond_dt = 0.02; ///< dt to integrate conductivities + int cond_dtbatch = 0; ///< exp(iH*dt*cond_dtbatch) is expanded with Chebyshev expansion. + int cond_smear = 1; ///< smearing method for conductivities 1: Gaussian 2: Lorentzian + double cond_fwhm = 0.4; ///< FWHM for conductivities + bool cond_nonlocal = true; ///< if calculate nonlocal effects + + bool berry_phase = false; ///< berry phase calculation: calculate berry phase or not + int gdir = 3; ///< berry phase calculation: calculate the polarization in + ///< the direction of the lattice vector + + ///<========================================================== + ///< Wannier functions + ///<========================================================== + bool towannier90 = false; ///< add by jingan for wannier90: use wannier90 + ///< code interface or not + std::string nnkpfile = "seedname.nnkp"; ///< add by jingan for wannier90: the wannier90 code + ///< nnkp file name + std::string wannier_spin = "up"; ///< add by jingan for wannier90: calculate + ///< spin in wannier90 code interface + int wannier_method = 1; ///< different implementation methods under Lcao basis set + bool out_wannier_mmn = true; ///< add by renxi for wannier90: output .mmn file or not + bool out_wannier_amn = true; ///< output .amn file or not + bool out_wannier_unk = false; ///< output UNK. file or not + bool out_wannier_eig = true; ///< output .eig file or not + bool out_wannier_wvfn_formatted = true; ///< output UNK. file in text format or in binary format - // ======= #Parameters (10.Electric field and dipole correction) ==== + // ============== #Parameters (13.Model) =========================== // ========================================================== // efield and dipole correction // Yu Liu add 2022-05-18 @@ -268,34 +403,26 @@ struct Input_para double efield_pos_dec = -1; ///< zone in the unit cell where the saw-like potential decreases double efield_amp = 0; ///< amplitude of the electric field - // ============== #Parameters (11.Gate field) ================ // ========================================================== // gatefield (compensating charge) // Yu Liu add 2022-09-13 // ========================================================== bool gate_flag = false; ///< compensating charge or not double zgate = 0.5; ///< position of charged plate - bool relax = false; ///< allow relaxation along the specific direction bool block = false; ///< add a block potential or not double block_down = 0.45; ///< low bound of the block double block_up = 0.55; ///< high bound of the block double block_height = 0.1; ///< height of the block - // ============== #Parameters (12.Test) ==================== - bool out_alllog = false; ///< output all logs. - int nurse = 0; ///< used for debug. - bool colour = false; ///< used for fun. - bool t_in_h = true; ///< calculate the T or not. - bool vl_in_h = true; ///< calculate the vloc or not. - bool vnl_in_h = true; ///< calculate the vnl or not. - bool vh_in_h = true; ///< calculate the hartree potential or not - bool vion_in_h = true; ///< calculate the local ionic potential or not - ///< //only relevant when vl_in_h = 1 - bool test_force = false; ///< test the force. - bool test_stress = false; ///< test the stress. - bool test_skip_ewald = false; ///< variables for test only + // implicit solvation model Menglin Sun added on 2022-04-04 + bool imp_sol = false; ///< true: implicit solvation correction; false: + ///< vacuum calculation(default) + double eb_k = 80; ///< the relative permittivity of the bulk solvent + double tau = 1.0798e-05; ///< the effective surface tension parameter + double sigma_k = 0.6; ///< the width of the diffuse cavity + double nc_k = 0.00037; ///< the cut-off charge density - // ============== #Parameters (13.vdW Correction) =========== + // ============== #Parameters (14.vdW Correction) =========================== // ========================================================== // vdw // Peize Lin add 2014-03-31, jiyy update 2019-08-01 @@ -319,7 +446,7 @@ struct Input_para std::string vdw_cn_thr_unit = "Bohr"; ///< unit of cn_thr, Bohr or Angstrom ModuleBase::Vector3 vdw_cutoff_period = {3, 3, 3}; ///< periods of periodic structure - // ============== #Parameters (14.exx) ==================== + // ============== #Parameters (15.exx) ==================== // ========================================================== // exx // Peize Lin add 2018-06-20 @@ -356,133 +483,10 @@ struct Input_para ///< functions for opt ABFs double rpa_ccp_rmesh_times = 10.0; ///< how many times larger the radial mesh required for ///< calculating Columb potential is to that of atomic orbitals - - // ============== #Parameters (16.tddft) ====================== - double td_force_dt = 0.02; ///<"fs" - bool td_vext = false; ///< add extern potential or not - std::string td_vext_dire = "1"; ///< vext direction - bool out_dipole = false; ///< output the dipole or not - bool out_efield = false; ///< output the efield or not - bool out_current = false; ///< output the current or not - bool out_current_k = false; ///< output tddft current for all k points - bool out_vecpot = false; ///< output the vector potential or not - bool init_vecpot_file = false; ///< initialize the vector potential, though file or integral - double td_print_eij = -1.0; ///< threshold to output Eij elements - int td_edm = 0; ///< 0: new edm method 1: old edm method - int propagator = 0; ///< method of propagator - int td_stype = 0; ///< type of space domain 0 : length gauge 1: velocity gauge - std::string td_ttype = "0"; ///< type of time domain - ///< 0 Gauss type function. - ///< 1 trapezoid type function. - ///< 2 Trigonometric functions, sin^2. - ///< 3 heaviside function. - ///< 4 HHG function. - int td_tstart = 1; - int td_tend = 1000; - - ///< space domain parameters - ///< length gauge - double td_lcut1 = 0.05; - double td_lcut2 = 0.95; - - ///< time domain parameters - ///< Gauss - std::string td_gauss_freq = "22.13"; ///< time(fs)^-1 - std::string td_gauss_phase = "0.0"; - std::string td_gauss_sigma = "30.0"; ///< time(fs) - std::string td_gauss_t0 = "100.0"; - std::string td_gauss_amp = "0.25"; ///< V/A - - ///< trapezoid - std::string td_trape_freq = "1.60"; ///< time(fs)^-1 - // Trapezoidal - std::string td_trape_phase = "0.0"; - std::string td_trape_t1 = "1875.0"; - std::string td_trape_t2 = "5625.0"; - std::string td_trape_t3 = "7500.0"; - std::string td_trape_amp = "2.74"; // V/A - - // Trigonometric - std::string td_trigo_freq1 = "1.164656"; // time(fs)^-1 - std::string td_trigo_freq2 = "0.029116"; // time(fs)^-1 - std::string td_trigo_phase1 = "0.0"; - std::string td_trigo_phase2 = "0.0"; - std::string td_trigo_amp = "2.74"; // V/A - - // Heaviside - std::string td_heavi_t0 = "100.0"; - std::string td_heavi_amp = "1.0"; // V/A - - bool ocp = false; - // std::string ocp_set = ""; - std::vector ocp_kb = {}; ///< OCP kb values - - // ============== #Parameters (17.berry_wannier) ================ - bool berry_phase = false; ///< berry phase calculation: calculate berry phase or not - int gdir = 3; ///< berry phase calculation: calculate the polarization in - ///< the direction of the lattice vector - - ///<========================================================== - ///< Wannier functions - ///<========================================================== - bool towannier90 = false; ///< add by jingan for wannier90: use wannier90 - ///< code interface or not - std::string nnkpfile = "seedname.nnkp"; ///< add by jingan for wannier90: the wannier90 code - ///< nnkp file name - std::string wannier_spin = "up"; ///< add by jingan for wannier90: calculate - ///< spin in wannier90 code interface - int wannier_method = 1; ///< different implementation methods under Lcao basis set - bool out_wannier_mmn = true; ///< add by renxi for wannier90: output .mmn file or not - bool out_wannier_amn = true; ///< output .amn file or not - bool out_wannier_unk = false; ///< output UNK. file or not - bool out_wannier_eig = true; ///< output .eig file or not - bool out_wannier_wvfn_formatted = true; ///< output UNK. file in text format or in binary format - - // ============== #Parameters (18.implicit_solvation) ================ - // implicit solvation model Menglin Sun added on 2022-04-04 - bool imp_sol = false; ///< true: implicit solvation correction; false: - ///< vacuum calculation(default) - double eb_k = 80; ///< the relative permittivity of the bulk solvent - double tau = 1.0798e-05; ///< the effective surface tension parameter - double sigma_k = 0.6; ///< the width of the diffuse cavity - double nc_k = 0.00037; ///< the cut-off charge density - - // ============== #Parameters (19.OFDFT) ================ - // OFDFT sunliang added on 2022-05-05 - std::string of_kinetic = "wt"; ///< Kinetic energy functional, such as TF, VW, WT, TF+ - std::string of_method = "tn"; ///< optimization method, include cg1, cg2, tn (default), bfgs - std::string of_conv = "energy"; ///< select the convergence criterion, - ///< potential, energy (default), or both - double of_tole = 1e-06; ///< tolerance of the energy change (in Ry) for - ///< determining the convergence, default=2e-6 Ry - double of_tolp = 1e-05; ///< tolerance of potential for determining the - ///< convergence, default=1e-5 in a.u. - double of_tf_weight = 1.0; ///< weight of TF KEDF - double of_vw_weight = 1.0; ///< weight of vW KEDF - double of_wt_alpha = 5. / 6.; ///< parameter alpha of WT KEDF - double of_wt_beta = 5. / 6.; ///< parameter beta of WT KEDF - double of_wt_rho0 = 0.0; ///< set the average density of system, in Bohr^-3 - bool of_hold_rho0 = false; ///< If set to 1, the rho0 will be fixed even if the volume of - ///< system has changed, it will be set to 1 automatically if - ///< of_wt_rho0 is not zero. - double of_lkt_a = 1.3; ///< parameter a of LKT KEDF - bool of_full_pw = true; ///< If set to 1, ecut will be ignored while collecting - ///< planewaves, so that all planewaves will be used. - int of_full_pw_dim = 0; ///< If of_full_pw = 1, the dimension of FFT will be restricted to - ///< be (0) either odd or even; (1) odd only; (2) even only. - bool of_read_kernel = false; ///< If set to 1, the kernel of WT KEDF will be - ///< filled from file of_kernel_file, not from - ///< formula. Only usable for WT KEDF. - std::string of_kernel_file = "WTkernel.txt"; ///< The name of WT kernel file. - - ///< std::string pseudo_type; ///< the type of pseudopotential, mohan add - ///< 2013-05-20, ABACUS supports - ///< ///< UPF format (default) and vwr format. - ///< (xiaohui add 2013-06-23) - - // ============== #Parameters (19.dft+u) ================ + // ============== #Parameters (16.dft+u) ====================== // DFT+U Xin Qu added on 2020-10-29 int dft_plus_u = 0; ///< 0: standard DFT calculation (default) + bool dft_plus_dmft = false; ///< true:DFT+DMFT; false: standard DFT calcullation(default) bool yukawa_potential = false; ///< default: false double yukawa_lambda = -1.0; ///< default: -1.0, which means we calculate lambda double uramping_eV = -1.0; ///< U-Ramping method (eV) @@ -492,25 +496,7 @@ struct Input_para std::vector orbital_corr = {}; ///< which correlated orbitals need corrected ; d:2 ,f:3, do not ///< need correction:-1 - // ============== #Parameters (21.spherical bessel) ========= - // ========================================================== - // spherical bessel Peize Lin added on 2022-12-15 - // ========================================================== - // the following are used when generating orb_matrix.dat - // int bessel_nao_lmax; ///< lmax used in descriptor - std::string bessel_nao_ecut = "default"; ///< energy cutoff for spherical bessel functions(Ry) - double bessel_nao_tolerence = 1e-12; ///< tolerance for spherical bessel root - std::vector bessel_nao_rcuts = {}; ///< No specific values provided for bessel_nao_rcuts - bool bessel_nao_smooth = true; ///< spherical bessel smooth or not - double bessel_nao_sigma = 0.1; ///< spherical bessel smearing_sigma - int bessel_descriptor_lmax = 2; ///< lmax used in descriptor - std::string bessel_descriptor_ecut = "default"; ///< energy cutoff for spherical bessel functions(Ry) - double bessel_descriptor_tolerence = 1e-12; ///< tolerance for spherical bessel root - double bessel_descriptor_rcut = 6.0; ///< radial cutoff for spherical bessel functions(a.u.) - bool bessel_descriptor_smooth = true; ///< spherical bessel smooth or not - double bessel_descriptor_sigma = 0.1; ///< spherical bessel smearing_sigma - - // ======= #Parameters (22.non-collinear spin-constrained DFT) ========= + // ============== #Parameters (17.non-collinear spin-constrained DFT) ========= /** * 0: none spin-constrained DFT; * 1: constrain atomic spin; @@ -527,7 +513,7 @@ struct Input_para double sccut = 3.0; ///< restriction of step size in eV/uB std::string sc_file = "none"; ///< file name for Deltaspin (json format) - // ============== #Parameters (23.Quasiatomic Orbital analysis) ========= + // ============== #Parameters (18.Quasiatomic Orbital analysis) ========= ///<========================================================== ///< variables for Quasiatomic Orbital analysis ///<========================================================== @@ -538,7 +524,7 @@ struct Input_para std::vector qo_strategy = {}; ///< No specific values provided for qo_strategy std::vector qo_screening_coeff = {}; ///< No specific values provided for qo_screening_coeff - // ============== #Parameters (24.PEXSI) ===================== + // ============== #Parameters (19.PEXSI) ===================== int pexsi_npole = 40; bool pexsi_inertia = true; int pexsi_nmax = 80; @@ -563,15 +549,18 @@ struct Input_para double pexsi_elec_thr = 0.001; double pexsi_zero_thr = 1e-10; - // ============== #Parameters (25. Linear Response) ===================== - int lr_nstates = 1; ///< the number of 2-particle states to be solved - int nocc = -1; ///< the number of occupied orbitals to form the 2-particle basis - int nvirt = 1; ///< the number of virtual orbitals to form the 2-particle basis (nocc + nvirt <= nbands) - std::string xc_kernel = "LDA"; ///< exchange correlation (XC) kernel for LR-TDDFT - std::string lr_solver = "dav"; ///< the eigensolver for LR-TDDFT - double lr_thr = 1e-2; ///< convergence threshold of the LR-TDDFT eigensolver - bool out_wfc_lr = false; ///< whether to output the eigenvectors (excitation amplitudes) in the particle-hole basis - std::vector abs_wavelen_range = { 0., 0. }; ///< the range of wavelength(nm) to output the absorption spectrum - double abs_broadening = 0.01; ///< the broadening (eta) for LR-TDDFT absorption spectrum + // ============== #Parameters (20.Test) ==================== + bool out_alllog = false; ///< output all logs. + int nurse = 0; ///< used for debug. + bool colour = false; ///< used for fun. + bool t_in_h = true; ///< calculate the T or not. + bool vl_in_h = true; ///< calculate the vloc or not. + bool vnl_in_h = true; ///< calculate the vnl or not. + bool vh_in_h = true; ///< calculate the hartree potential or not + bool vion_in_h = true; ///< calculate the local ionic potential or not + ///< //only relevant when vl_in_h = 1 + bool test_force = false; ///< test the force. + bool test_stress = false; ///< test the stress. + bool test_skip_ewald = false; ///< variables for test only }; #endif \ No newline at end of file diff --git a/source/module_parameter/md_parameter.h b/source/module_parameter/md_parameter.h index 8c72c565bc..b23ccaa76d 100644 --- a/source/module_parameter/md_parameter.h +++ b/source/module_parameter/md_parameter.h @@ -2,6 +2,7 @@ #define MD_PARA_H #include +#include /** * @brief input parameters used in md diff --git a/source/module_parameter/system_parameter.h b/source/module_parameter/system_parameter.h index 2c40b87e05..bd0a414f67 100644 --- a/source/module_parameter/system_parameter.h +++ b/source/module_parameter/system_parameter.h @@ -21,10 +21,6 @@ struct System_para // --------------------------------------------------------------- bool two_fermi = false; ///< true if "nupdown" is set - // For parameter "bessel_nao_rcuts" - int nrcut = 0; ///< number of bessel_nao_rcuts, assuming 0 as no values provided - double bessel_nao_rcut = 6.0; ///< radial cutoff for spherical bessel functions(a.u.) - bool dos_setemin = false; ///< true: "dos_emin_ev" is set bool dos_setemax = false; ///< true: "dos_emax_ev" is set int ncx = 0, ncy = 0,