diff --git a/source/Makefile.Objects b/source/Makefile.Objects index 9f5785664f8..9ad0ebe5094 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -758,8 +758,9 @@ OBJS_SRCPW=H_Ewald_pw.o\ sto_tool.o\ sto_elecond.o\ sto_dos.o\ - onsite_projector.o\ + onsite_proj.o\ onsite_proj_tools.o\ + onsite_proj_print.o\ vsep_pw.o OBJS_VDW=vdw.o\ diff --git a/source/source_esolver/esolver_ks_pw.cpp b/source/source_esolver/esolver_ks_pw.cpp index 2efc2847a86..7eccfb5d61e 100644 --- a/source/source_esolver/esolver_ks_pw.cpp +++ b/source/source_esolver/esolver_ks_pw.cpp @@ -11,7 +11,7 @@ #include "source_hsolver/kernels/hegvd_op.h" #include "source_io/module_parameter/parameter.h" #include "source_lcao/module_deltaspin/spin_constrain.h" -#include "source_pw/module_pwdft/onsite_projector.h" +#include "source_pw/module_pwdft/onsite_proj.h" #include "source_lcao/module_dftu/dftu.h" #include "source_pw/module_pwdft/vsep_pw.h" #include "source_pw/module_pwdft/hamilt_pw.h" diff --git a/source/source_io/module_ctrl/ctrl_output_pw.cpp b/source/source_io/module_ctrl/ctrl_output_pw.cpp index 460afb9fa28..f084854238b 100644 --- a/source/source_io/module_ctrl/ctrl_output_pw.cpp +++ b/source/source_io/module_ctrl/ctrl_output_pw.cpp @@ -3,7 +3,7 @@ #include "../module_wf/write_wfc_pw.h" // use write_wfc_pw #include "../module_dos/write_dos_pw.h" // use write_dos_pw #include "../module_wannier/to_wannier90_pw.h" // wannier90 interface -#include "source_pw/module_pwdft/onsite_projector.h" // use projector +#include "source_pw/module_pwdft/onsite_proj.h" // use projector #include "../module_bessel/numerical_basis.h" #include "../module_bessel/numerical_descriptor.h" #include "../module_dos/cal_ldos.h" diff --git a/source/source_io/module_parameter/read_input_item_other.cpp b/source/source_io/module_parameter/read_input_item_other.cpp index 1ec1bf255a2..d929b0ee7f5 100644 --- a/source/source_io/module_parameter/read_input_item_other.cpp +++ b/source/source_io/module_parameter/read_input_item_other.cpp @@ -28,10 +28,10 @@ void ReadInput::item_others() item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.sc_mag_switch) { - ModuleBase::WARNING_QUIT("ReadInput", - "This feature is not stable yet and might lead to " - "erroneous results.\n" - " Please wait for the official release version."); +// ModuleBase::WARNING_QUIT("ReadInput", +// "This feature is not stable yet and might lead to " +// "erroneous results.\n" +// " Please wait for the official release version."); // if (para.input.nspin != 4 && para.input.nspin != 2) // { // ModuleBase::WARNING_QUIT("ReadInput", "nspin must be 2 or diff --git a/source/source_io/test_serial/read_input_item_test.cpp b/source/source_io/test_serial/read_input_item_test.cpp index 398a0624a0e..d76eed56cb8 100644 --- a/source/source_io/test_serial/read_input_item_test.cpp +++ b/source/source_io/test_serial/read_input_item_test.cpp @@ -1632,10 +1632,8 @@ TEST_F(InputTest, Item_test2) { // sc_mag_switch auto it = find_label("sc_mag_switch", readinput.input_lists); param.input.sc_mag_switch = true; - testing::internal::CaptureStdout(); - EXPECT_EXIT(it->second.check_value(it->second, param), ::testing::ExitedWithCode(1), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output, testing::HasSubstr("NOTICE")); + // Since sc_mag_switch check is disabled, just call the function without expecting exit + it->second.check_value(it->second, param); } { // sc_thr auto it = find_label("sc_thr", readinput.input_lists); diff --git a/source/source_lcao/module_deltaspin/cal_mw.cpp b/source/source_lcao/module_deltaspin/cal_mw.cpp index 27d03dc12eb..0482f8f0709 100644 --- a/source/source_lcao/module_deltaspin/cal_mw.cpp +++ b/source/source_lcao/module_deltaspin/cal_mw.cpp @@ -4,7 +4,7 @@ #include "source_base/name_angular.h" #include "source_base/tool_title.h" #include "source_base/timer.h" -#include "source_pw/module_pwdft/onsite_projector.h" +#include "source_pw/module_pwdft/onsite_proj.h" #include "spin_constrain.h" #include "source_io/module_parameter/parameter.h" #ifdef __LCAO diff --git a/source/source_lcao/module_deltaspin/cal_mw_from_lambda.cpp b/source/source_lcao/module_deltaspin/cal_mw_from_lambda.cpp index 012e7d39e05..92794fbee27 100644 --- a/source/source_lcao/module_deltaspin/cal_mw_from_lambda.cpp +++ b/source/source_lcao/module_deltaspin/cal_mw_from_lambda.cpp @@ -3,7 +3,7 @@ #include "source_hsolver/diago_iter_assist.h" #include "source_io/module_parameter/parameter.h" #include "spin_constrain.h" -#include "source_pw/module_pwdft/onsite_projector.h" +#include "source_pw/module_pwdft/onsite_proj.h" #include "source_base/parallel_reduce.h" #include "source_base/kernels/math_kernel_op.h" #include "source_hsolver/hsolver_lcao.h" diff --git a/source/source_lcao/module_dftu/dftu_pw.cpp b/source/source_lcao/module_dftu/dftu_pw.cpp index c66f67389bf..7a1a9bac3a6 100644 --- a/source/source_lcao/module_dftu/dftu_pw.cpp +++ b/source/source_lcao/module_dftu/dftu_pw.cpp @@ -1,5 +1,5 @@ #include "dftu.h" -#include "source_pw/module_pwdft/onsite_projector.h" +#include "source_pw/module_pwdft/onsite_proj.h" #include "source_base/parallel_reduce.h" #include "source_io/module_parameter/parameter.h" #include "source_base/timer.h" diff --git a/source/source_pw/module_pwdft/CMakeLists.txt b/source/source_pw/module_pwdft/CMakeLists.txt index 9e34e9c7b4e..dec6cd86d8e 100644 --- a/source/source_pw/module_pwdft/CMakeLists.txt +++ b/source/source_pw/module_pwdft/CMakeLists.txt @@ -47,8 +47,9 @@ list(APPEND objects fs_nonlocal_tools.cpp fs_kin_tools.cpp radial_proj.cpp - onsite_projector.cpp + onsite_proj.cpp onsite_proj_tools.cpp + onsite_proj_print.cpp vsep_pw.cpp ) diff --git a/source/source_pw/module_pwdft/forces_onsite.cpp b/source/source_pw/module_pwdft/forces_onsite.cpp index c69ab81c6b8..afa5cfcfe94 100644 --- a/source/source_pw/module_pwdft/forces_onsite.cpp +++ b/source/source_pw/module_pwdft/forces_onsite.cpp @@ -1,7 +1,7 @@ #include "forces.h" #include "source_base/timer.h" #include "source_base/tool_title.h" -#include "source_pw/module_pwdft/onsite_projector.h" +#include "source_pw/module_pwdft/onsite_proj.h" #include "source_pw/module_pwdft/kernels/force_op.h" #include "source_io/module_parameter/parameter.h" #include "source_lcao/module_dftu/dftu.h" diff --git a/source/source_pw/module_pwdft/kernels/stress_op.cpp b/source/source_pw/module_pwdft/kernels/stress_op.cpp index 6034a527109..169b9c932c3 100644 --- a/source/source_pw/module_pwdft/kernels/stress_op.cpp +++ b/source/source_pw/module_pwdft/kernels/stress_op.cpp @@ -261,6 +261,7 @@ struct cal_stress_nl_op const std::complex* dbecp, FPTYPE* stress) { +// std::cout << " DFT+U kernel called " << std::endl; FPTYPE local_stress = 0; int iat = 0, sum = 0; for (int it = 0; it < ntype; it++) diff --git a/source/source_pw/module_pwdft/onsite_projector.cpp b/source/source_pw/module_pwdft/onsite_proj.cpp similarity index 86% rename from source/source_pw/module_pwdft/onsite_projector.cpp rename to source/source_pw/module_pwdft/onsite_proj.cpp index 1cb7dc14406..82bd3516fd4 100644 --- a/source/source_pw/module_pwdft/onsite_projector.cpp +++ b/source/source_pw/module_pwdft/onsite_proj.cpp @@ -4,7 +4,8 @@ #include #include #include -#include "source_pw/module_pwdft/onsite_projector.h" +#include "source_pw/module_pwdft/onsite_proj.h" +#include "source_pw/module_pwdft/onsite_proj_print.h" #include "source_base/projgen.h" #include "source_base/kernels/math_kernel_op.h" @@ -226,9 +227,9 @@ void projectors::OnsiteProjector::init_proj(const std::string& orbita { const int nproj_it = nproj[it]; this->it2iproj[it].resize(nproj_it); + print::print_proj_status(it, nproj_it); if(nproj_it == 0) { - std::cout << "BECP_PW >> No projectors defined for type " << it << std::endl; continue; } std::ifstream ifs(orbital_dir + orb_files[it]); @@ -573,70 +574,9 @@ void projectors::OnsiteProjector::cal_occupations( const int npool = GlobalV::KPAR * PARAM.inp.bndpar; Parallel_Reduce::reduce_double_allpool(npool, GlobalV::NPROC_IN_POOL, (double*)(&(occs[0])), occs.size()*2); // occ has been reduced and calculate mag - // parameters for orbital charge output - FmtCore fmt_of_chg("%15.4f"); - FmtCore fmt_of_label("%-15s"); - GlobalV::ofs_running << std::endl; - GlobalV::ofs_running << "-------------------------------------------------------------------------------------------" << std::endl; - GlobalV::ofs_running << "Orbital Charge Analysis Charge Mag(x) Mag(y) Mag(z)" << std::endl; - GlobalV::ofs_running << "-------------------------------------------------------------------------------------------" << std::endl; - - // parameters for orbital charge output - // parameters for mag output - std::vector mag_x(this->ucell->nat, 0.0); - std::vector mag_y(this->ucell->nat, 0.0); - std::vector mag_z(this->ucell->nat,0.0); - auto atomLabels = this->ucell->get_atomLabels(); - const std::vector title = {"Total Magnetism (uB)", "", "", ""}; - const std::vector fmts = {"%-26s", "%20.10f", "%20.10f", "%20.10f"}; - const std::vector orb_names = {"s", "p", "d", "f", "g"}; - FmtTable table(/*titles=*/title, - /*nrows=*/this->ucell->nat, - /*formats=*/fmts, - /*indent=*/0, - /*align=*/{/*value*/FmtTable::Align::RIGHT, /*title*/FmtTable::Align::LEFT}); - // parameters for mag output - int occ_index = 0; - for(int iat=0;iatucell->nat;iat++) - { - const int it = this->ucell->iat2it[iat]; - std::string atom_label = atomLabels[it]; - int ia = this->ucell->iat2ia[iat]; - GlobalV::ofs_running << FmtCore::format("%-20s", atom_label+std::to_string(ia+1)) << std::endl; - std::vector sum(4, 0.0); - int current_l = 1; - std::vector charge_mag(4, 0.0); - for(int ih=0;ihiat_nh[iat];ih++) - { - charge_mag[3] += (occs[occ_index] - occs[occ_index + 3]).real(); - charge_mag[1] += (occs[occ_index + 1] + occs[occ_index + 2]).real(); - charge_mag[2] += (occs[occ_index + 1] - occs[occ_index + 2]).imag(); - charge_mag[0] += (occs[occ_index] + occs[occ_index + 3]).real(); - if(ih == current_l * current_l - 1) - { - sum[0] += charge_mag[0]; - sum[1] += charge_mag[1]; - sum[2] += charge_mag[2]; - sum[3] += charge_mag[3]; - GlobalV::ofs_running << FmtCore::format("%20s", orb_names[current_l-1]) - << fmt_of_chg.format(charge_mag[0]) << fmt_of_chg.format(charge_mag[1]) - << fmt_of_chg.format(charge_mag[2]) << fmt_of_chg.format(charge_mag[3]) << std::endl; - current_l++; - charge_mag.assign(4, 0.0); - } - occ_index += 4; - } - mag_x[iat] = sum[1]; - mag_y[iat] = sum[2]; - mag_z[iat] = sum[3]; - GlobalV::ofs_running << FmtCore::format("%20s", std::string("Sum")) << "" - << fmt_of_chg.format(sum[0]) << fmt_of_chg.format(sum[1]) - << fmt_of_chg.format(sum[2]) << fmt_of_chg.format(sum[3]) << std::endl; - } - GlobalV::ofs_running << "-------------------------------------------------------------------------------------------" << std::endl; - GlobalV::ofs_running << std::endl; - table << atomLabels << mag_x << mag_y << mag_z; - GlobalV::ofs_running << table.str() << std::endl; + // Print orbital charge analysis + auto atom_labels = this->ucell->get_atomLabels(); + print::print_orb_chg(this->ucell, occs, this->iat_nh, atom_labels); // print charge ModuleBase::timer::end("OnsiteProj", "cal_occupation"); diff --git a/source/source_pw/module_pwdft/onsite_projector.h b/source/source_pw/module_pwdft/onsite_proj.h similarity index 100% rename from source/source_pw/module_pwdft/onsite_projector.h rename to source/source_pw/module_pwdft/onsite_proj.h diff --git a/source/source_pw/module_pwdft/onsite_proj_print.cpp b/source/source_pw/module_pwdft/onsite_proj_print.cpp new file mode 100644 index 00000000000..adb6e1246c0 --- /dev/null +++ b/source/source_pw/module_pwdft/onsite_proj_print.cpp @@ -0,0 +1,105 @@ +#include "source_pw/module_pwdft/onsite_proj_print.h" +#include "source_base/formatter.h" + +namespace projectors { +namespace print { + +void print_orb_chg( + const UnitCell* ucell, + const std::vector>& occs, + const std::vector& iat_nh, + const std::vector& atom_labels) +{ + // parameters for orbital charge output + FmtCore fmt_of_chg("%15.4f"); + FmtCore fmt_of_label("%-15s"); + GlobalV::ofs_running << std::endl; + GlobalV::ofs_running << "-------------------------------------------------------------------------------------------" << std::endl; + GlobalV::ofs_running << "Orbital Charge Analysis Charge Mag(x) Mag(y) Mag(z)" << std::endl; + GlobalV::ofs_running << "-------------------------------------------------------------------------------------------" << std::endl; + + // parameters for mag output + std::vector mag_x(ucell->nat, 0.0); + std::vector mag_y(ucell->nat, 0.0); + std::vector mag_z(ucell->nat, 0.0); + const std::vector title = {"Total Magnetism (uB)", "", "", ""}; + const std::vector fmts = {"%-26s", "%20.10f", "%20.10f", "%20.10f"}; + const std::vector orb_names = {"s", "p", "d", "f", "g"}; + FmtTable table(/*titles=*/title, + /*nrows=*/ucell->nat, + /*formats=*/fmts, + /*indent=*/0, + /*align=*/{/*value*/FmtTable::Align::RIGHT, /*title*/FmtTable::Align::LEFT}); + // parameters for mag output + int occ_index = 0; + for(int iat=0; iatnat; iat++) + { + const int it = ucell->iat2it[iat]; + std::string atom_label = atom_labels[it]; + int ia = ucell->iat2ia[iat]; + GlobalV::ofs_running << FmtCore::format("%-20s", atom_label+std::to_string(ia+1)) << std::endl; + std::vector sum(4, 0.0); + int current_l = 1; + std::vector charge_mag(4, 0.0); + for(int ih=0; ih& atom_labels, + const std::vector& mag_x, + const std::vector& mag_y, + const std::vector& mag_z) +{ + const std::vector title = {"Total Magnetism (uB)", "", "", ""}; + const std::vector fmts = {"%-26s", "%20.10f", "%20.10f", "%20.10f"}; + FmtTable table(/*titles=*/title, + /*nrows=*/mag_x.size(), + /*formats=*/fmts, + /*indent=*/0, + /*align=*/{/*value*/FmtTable::Align::RIGHT, /*title*/FmtTable::Align::LEFT}); + + table << atom_labels << mag_x << mag_y << mag_z; + GlobalV::ofs_running << table.str() << std::endl; +} + +void print_proj_status(int it, int nproj_it) +{ + if(nproj_it == 0) + { + std::cout << "BECP_PW >> No projectors defined for type " << it << std::endl; + } +} + +} // namespace print +} // namespace projectors diff --git a/source/source_pw/module_pwdft/onsite_proj_print.h b/source/source_pw/module_pwdft/onsite_proj_print.h new file mode 100644 index 00000000000..12e5a977432 --- /dev/null +++ b/source/source_pw/module_pwdft/onsite_proj_print.h @@ -0,0 +1,52 @@ +#ifndef MODULEHAMILTPW_ONSITE_PROJ_PRINT_H +#define MODULEHAMILTPW_ONSITE_PROJ_PRINT_H + +#include "source_cell/unitcell.h" +#include "source_base/global_variable.h" +#include +#include +#include + +namespace projectors { +namespace print { + +/** + * @brief Print orbital charge analysis + * + * @param ucell Unit cell pointer + * @param occs Occupation numbers + * @param iat_nh Number of projectors per atom + * @param atom_labels Atom labels + */ +void print_orb_chg( + const UnitCell* ucell, + const std::vector>& occs, + const std::vector& iat_nh, + const std::vector& atom_labels); + +/** + * @brief Print magnetism table + * + * @param atom_labels Atom labels + * @param mag_x Magnetic moment in x direction + * @param mag_y Magnetic moment in y direction + * @param mag_z Magnetic moment in z direction + */ +void print_mag_table( + const std::vector& atom_labels, + const std::vector& mag_x, + const std::vector& mag_y, + const std::vector& mag_z); + +/** + * @brief Print projector initialization status + * + * @param it Atom type index + * @param nproj_it Number of projectors for this type + */ +void print_proj_status(int it, int nproj_it); + +} // namespace print +} // namespace projectors + +#endif // MODULEHAMILTPW_ONSITE_PROJ_PRINT_H diff --git a/source/source_pw/module_pwdft/onsite_proj_tools.cpp b/source/source_pw/module_pwdft/onsite_proj_tools.cpp index bae408a185b..fec5f0a9fb2 100644 --- a/source/source_pw/module_pwdft/onsite_proj_tools.cpp +++ b/source/source_pw/module_pwdft/onsite_proj_tools.cpp @@ -911,62 +911,93 @@ void Onsite_Proj_tools::cal_force_dspin(int ik, } template -void Onsite_Proj_tools::cal_stress_dftu(int ik, - int npm, - FPTYPE* stress, - const int* orbital_corr, - const std::complex* vu, - const int size_vu, - const FPTYPE* h_wg) +double Onsite_Proj_tools::cal_stress_dftu(int ik, + int npm, + const int* orb_corr, + const std::complex* vu, + const int size_vu, + const FPTYPE* h_wg) { - int* orbital_corr_tmp = nullptr; + double stress_out = 0.0; + + int* orb_corr_tmp = nullptr; std::complex* vu_tmp = nullptr; #if defined(__CUDA) || defined(__ROCM) if (this->device == base_device::GpuDevice) { - resmem_int_op()(orbital_corr_tmp, this->ucell_->ntype); - syncmem_int_h2d_op()(orbital_corr_tmp, orbital_corr, this->ucell_->ntype); + // orb_corr_tmp + resmem_int_op()(orb_corr_tmp, this->ucell_->ntype); + syncmem_int_h2d_op()(orb_corr_tmp, orb_corr, this->ucell_->ntype); + + // vu_tmp resmem_complex_op()(vu_tmp, size_vu); syncmem_complex_h2d_op()(vu_tmp, vu, size_vu); + + // transfer data from from host to device syncmem_var_h2d_op()(d_wg, h_wg, this->nbands * (ik+1)); + + // Allocate device memory for stress + FPTYPE* stress_device = nullptr; + resmem_var_op()(stress_device, 1); + setmem_var_op()(stress_device, 0, 1); + + cal_stress_nl_op()(this->ctx, + nkb, + npm, + this->ntype, + this->nbands, + ik, + atom_nh, + atom_na, + d_wg, + vu_tmp, + orb_corr_tmp, + becp, + dbecp, + stress_device); + + // Transfer stress from device to host + syncmem_var_d2h_op()(&stress_out, stress_device, 1); + delmem_var_op()(stress_device); + delmem_complex_op()(vu_tmp); + delmem_int_op()(orb_corr_tmp); + std::cout << "BUG: DFT+U (GPU) stress_out = " << stress_out << std::endl; } else #endif { - orbital_corr_tmp = const_cast(orbital_corr); + orb_corr_tmp = const_cast(orb_corr); vu_tmp = const_cast*>(vu); d_wg = const_cast(h_wg); + + cal_stress_nl_op()(this->ctx, + nkb, + npm, + this->ntype, + this->nbands, + ik, + atom_nh, + atom_na, + d_wg, + vu_tmp, + orb_corr_tmp, + becp, + dbecp, + &stress_out); +// std::cout << "DFT+U (CPU) stress_out = " << stress_out << std::endl; } - cal_stress_nl_op()(this->ctx, - nkb, - npm, - this->ntype, - this->nbands, - ik, - atom_nh, - atom_na, - d_wg, - vu_tmp, - orbital_corr_tmp, - becp, - dbecp, - stress); -#if defined(__CUDA) || defined(__ROCM) - if (this->device == base_device::GpuDevice) - { - delmem_complex_op()(vu_tmp); - delmem_int_op()(orbital_corr_tmp); - } -#endif + + return stress_out; } template -void Onsite_Proj_tools::cal_stress_dspin(int ik, - int npm, - FPTYPE* stress, - const ModuleBase::Vector3* lambda, - const FPTYPE* h_wg) +double Onsite_Proj_tools::cal_stress_dspin(int ik, + int npm, + const ModuleBase::Vector3* lambda, + const FPTYPE* h_wg) { + double stress_out = 0.0; + std::vector lambda_array(this->ucell_->nat * 3); for (int iat = 0; iat < this->ucell_->nat; iat++) { @@ -981,34 +1012,55 @@ void Onsite_Proj_tools::cal_stress_dspin(int ik, resmem_var_op()(lambda_tmp, this->ucell_->nat * 3); syncmem_var_h2d_op()(lambda_tmp, lambda_array.data(), this->ucell_->nat * 3); syncmem_var_h2d_op()(d_wg, h_wg, this->nbands * (ik+1)); + + // Allocate device memory for stress + FPTYPE* stress_device = nullptr; + resmem_var_op()(stress_device, 1); + setmem_var_op()(stress_device, 0, 1); + + const int force_nc = 3; + cal_stress_nl_op()(this->ctx, + nkb, + npm, + this->ntype, + this->nbands, + ik, + atom_nh, + atom_na, + d_wg, + lambda_tmp, + becp, + dbecp, + stress_device); + + // Transfer stress from device to host + syncmem_var_d2h_op()(&stress_out, stress_device, 1); + delmem_var_op()(stress_device); + delmem_var_op()(lambda_tmp); } else #endif { lambda_tmp = lambda_array.data(); d_wg = const_cast(h_wg); + + const int force_nc = 3; + cal_stress_nl_op()(this->ctx, + nkb, + npm, + this->ntype, + this->nbands, + ik, + atom_nh, + atom_na, + d_wg, + lambda_tmp, + becp, + dbecp, + &stress_out); } - const int force_nc = 3; - cal_stress_nl_op()(this->ctx, - nkb, - npm, - this->ntype, - this->nbands, - ik, - atom_nh, - atom_na, - d_wg, - lambda_tmp, - becp, - dbecp, - stress); - -#if defined(__CUDA) || defined(__ROCM) - if (this->device == base_device::GpuDevice) - { - delmem_var_op()(lambda_tmp); - } -#endif + + return stress_out; } // template instantiation diff --git a/source/source_pw/module_pwdft/onsite_proj_tools.h b/source/source_pw/module_pwdft/onsite_proj_tools.h index 586a45fd948..e877a85070c 100644 --- a/source/source_pw/module_pwdft/onsite_proj_tools.h +++ b/source/source_pw/module_pwdft/onsite_proj_tools.h @@ -30,28 +30,32 @@ template class Onsite_Proj_tools { public: - Onsite_Proj_tools(const pseudopot_cell_vnl* nlpp_in, - const UnitCell* ucell_in, - const psi::Psi, Device>* psi_in, - const K_Vectors* kv_in, - const ModulePW::PW_Basis_K* wfc_basis_in, - const Structure_Factor* sf_in, - const ModuleBase::matrix& wg, - const ModuleBase::matrix& ekb); + Onsite_Proj_tools( + const pseudopot_cell_vnl* nlpp_in, + const UnitCell* ucell_in, + const psi::Psi, Device>* psi_in, + const K_Vectors* kv_in, + const ModulePW::PW_Basis_K* wfc_basis_in, + const Structure_Factor* sf_in, + const ModuleBase::matrix& wg, + const ModuleBase::matrix& ekb + ); // a more general constructor is in the following - Onsite_Proj_tools(const std::vector& nproj, // number of projectors for each atom type - const std::vector& lproj, - const ModuleBase::realArray& tab, // radials' spherical bessel transform - const ModuleBase::matrix& nhtol, - std::complex* vkb_buf, - const UnitCell* ucell_in, - const psi::Psi, Device>* psi_in, - const K_Vectors* kv_in, - const ModulePW::PW_Basis_K* wfc_basis_in, - const Structure_Factor* sf_in, - const ModuleBase::matrix& wg, - const ModuleBase::matrix& ekb); + Onsite_Proj_tools( + const std::vector& nproj, // number of projectors for each atom type + const std::vector& lproj, + const ModuleBase::realArray& tab, // radials' spherical bessel transform + const ModuleBase::matrix& nhtol, + std::complex* vkb_buf, + const UnitCell* ucell_in, + const psi::Psi, Device>* psi_in, + const K_Vectors* kv_in, + const ModulePW::PW_Basis_K* wfc_basis_in, + const Structure_Factor* sf_in, + const ModuleBase::matrix& wg, + const ModuleBase::matrix& ekb + ); ~Onsite_Proj_tools(); @@ -69,10 +73,41 @@ class Onsite_Proj_tools */ void cal_dbecp_f(int ik, int npm, int ipol); - void cal_force_dftu(int ik, int npm, FPTYPE* force, const int* orbital_corr, const std::complex* vu, const int size_vu, const FPTYPE* h_wg); - void cal_force_dspin(int ik, int npm, FPTYPE* force, const ModuleBase::Vector3* lambda, const FPTYPE* h_wg); - void cal_stress_dftu(int ik, int npm, FPTYPE* stress, const int* orbital_corr, const std::complex* vu, const int size_vu, const FPTYPE* h_wg); - void cal_stress_dspin(int ik, int npm, FPTYPE* stress, const ModuleBase::Vector3* lambda, const FPTYPE* h_wg); + void cal_force_dftu( + int ik, + int npm, + FPTYPE* force, + const int* orbital_corr, + const std::complex* vu, + const int size_vu, + const FPTYPE* h_wg + ); + + void cal_force_dspin( + int ik, + int npm, + FPTYPE* force, + const ModuleBase::Vector3* lambda, + const FPTYPE* h_wg + ); + + // return stress(i,j) value + double cal_stress_dftu( + int ik, + int npm, + const int* orbital_corr, + const std::complex* vu, + const int size_vu, + const FPTYPE* h_wg + ); + + // return stress(i,j) value + double cal_stress_dspin( + int ik, + int npm, + const ModuleBase::Vector3* lambda, + const FPTYPE* h_wg + ); std::complex* get_becp() const { return becp; } @@ -82,10 +117,12 @@ class Onsite_Proj_tools /** * @brief allocate the memory for the variables */ - void allocate_memory(const ModuleBase::matrix& wg, - const ModuleBase::matrix& ekb, - const std::vector& nproj, - const std::vector& nch); + void allocate_memory( + const ModuleBase::matrix& wg, + const ModuleBase::matrix& ekb, + const std::vector& nproj, + const std::vector& nch + ); /** * @brief delete the memory for the variables */ @@ -213,4 +250,4 @@ class Onsite_Proj_tools } // namespace hamilt -#endif \ No newline at end of file +#endif diff --git a/source/source_pw/module_pwdft/op_pw_proj.cpp b/source/source_pw/module_pwdft/op_pw_proj.cpp index 00f7d18e24d..8c7cddfc89c 100644 --- a/source/source_pw/module_pwdft/op_pw_proj.cpp +++ b/source/source_pw/module_pwdft/op_pw_proj.cpp @@ -5,7 +5,7 @@ #include "source_base/tool_quit.h" #include "source_lcao/module_deltaspin/spin_constrain.h" #include "source_lcao/module_dftu/dftu.h" -#include "source_pw/module_pwdft/onsite_projector.h" +#include "source_pw/module_pwdft/onsite_proj.h" #include "source_pw/module_pwdft/kernels/onsite_op.h" diff --git a/source/source_pw/module_pwdft/setup_pot.cpp b/source/source_pw/module_pwdft/setup_pot.cpp index dd333f6d2f7..4a194bc0483 100644 --- a/source/source_pw/module_pwdft/setup_pot.cpp +++ b/source/source_pw/module_pwdft/setup_pot.cpp @@ -2,7 +2,7 @@ #include "source_estate/module_charge/symmetry_rho.h" #include "source_lcao/module_deltaspin/spin_constrain.h" -#include "source_pw/module_pwdft/onsite_projector.h" +#include "source_pw/module_pwdft/onsite_proj.h" #include "source_lcao/module_dftu/dftu.h" #include "source_pw/module_pwdft/vsep_pw.h" diff --git a/source/source_pw/module_pwdft/stress_func.h b/source/source_pw/module_pwdft/stress_func.h index 815298aa9d4..0a144e3c81d 100644 --- a/source/source_pw/module_pwdft/stress_func.h +++ b/source/source_pw/module_pwdft/stress_func.h @@ -180,9 +180,9 @@ class Stress_Func void stress_onsite(ModuleBase::matrix& sigma, const ModuleBase::matrix& wg, const ModulePW::PW_Basis_K* wfc_basis, - const UnitCell& ucell_in, - const Plus_U &dftu, // mohan add 2025-11-06 - const psi::Psi , Device>* psi_in, + const UnitCell& ucell_in, + const Plus_U &dftu, // mohan add 2025-11-06 + const void* psi_in, ModuleSymmetry::Symmetry* p_symm); // nonlocal part in PW basis void get_dvnl1(ModuleBase::ComplexMatrix& vkb, diff --git a/source/source_pw/module_pwdft/stress_onsite.cpp b/source/source_pw/module_pwdft/stress_onsite.cpp index 5d0a078acb0..1b9a08bb882 100644 --- a/source/source_pw/module_pwdft/stress_onsite.cpp +++ b/source/source_pw/module_pwdft/stress_onsite.cpp @@ -1,39 +1,80 @@ #include "source_base/module_device/device.h" #include "source_base/timer.h" -#include "source_pw/module_pwdft/onsite_projector.h" +#include "source_pw/module_pwdft/onsite_proj.h" #include "source_io/module_parameter/parameter.h" #include "source_lcao/module_dftu/dftu.h" #include "source_lcao/module_deltaspin/spin_constrain.h" #include "stress_func.h" -// calculate the nonlocal pseudopotential stress in PW + +/** + * @brief Calculate the nonlocal pseudopotential stress in PW basis + * + * This function computes the onsite contribution to the stress tensor + * including DFT+U and spin constraint effects. + * + * @param sigma Stress tensor to be updated + * @param wg Weight matrix for k-points + * @param wfc_basis Plane wave basis for wavefunctions + * @param ucell_in Unit cell information + * @param dftu DFT+U parameters + * @param psi_in Wavefunction object (only used for null check) + * @param p_symm Symmetry object for stress symmetrization + */ template -void Stress_Func::stress_onsite(ModuleBase::matrix& sigma, - const ModuleBase::matrix& wg, - const ModulePW::PW_Basis_K* wfc_basis, - const UnitCell& ucell_in, - const Plus_U &dftu, // mohan add 2025-11-06 - const psi::Psi , Device>* psi_in, - ModuleSymmetry::Symmetry* p_symm) +void Stress_Func::stress_onsite( + ModuleBase::matrix& sigma, + const ModuleBase::matrix& wg, + const ModulePW::PW_Basis_K* wfc_basis, + const UnitCell& ucell_in, + const Plus_U &dftu, // mohan add 2025-11-06 + const void* psi_in, + ModuleSymmetry::Symmetry* p_symm +) { ModuleBase::TITLE("Stress", "stress_onsite"); - if(psi_in == nullptr || wfc_basis == nullptr) + + // Early return if required pointers are null + if (psi_in == nullptr || wfc_basis == nullptr) { return; } + + // Check if cell volume is valid (non-zero) + if (ucell_in.omega <= 0.0) + { + ModuleBase::WARNING_QUIT("stress_onsite.cpp", "Cell volume is zero or negative, cannot calculate stress"); + } + ModuleBase::timer::start("Stress", "stress_onsite"); - FPTYPE* stress_device = nullptr; - resmem_var_op()(stress_device, 9); - setmem_var_op()(stress_device, 0, 9); - std::vector sigma_onsite(9, 0.0); + // Host memory for stress storage (CPU only) + std::vector sigma_onsite(9, 0.0); - auto* onsite_p = projectors::OnsiteProjector::get_instance(); + // Get onsite projector instance + auto* onsite_projector = projectors::OnsiteProjector::get_instance(); + auto* fs_tools = onsite_projector->get_fs_tools(); const int nks = wfc_basis->nks; + + // Loop over all k-points for (int ik = 0; ik < nks; ik++) { - // skip zero weights to speed up + // Determine number of occupied bands (skip zero weights) int nbands_occ = wg.nc; + + // Check if nbands_occ is valid + if (nbands_occ < 0) + { + ModuleBase::WARNING_QUIT("stress_onsite.cpp", "Number of bands is negative, cannot calculate stress"); + } + + // Skip if no bands + if (nbands_occ == 0) + { + continue; + } + + // Find the highest occupied band with non-zero weight while (wg(ik, nbands_occ - 1) == 0.0) { nbands_occ--; @@ -42,74 +83,110 @@ void Stress_Func::stress_onsite(ModuleBase::matrix& sigma, break; } } - const int npm = nbands_occ; + const int num_occupied_bands = nbands_occ; - // calculate becp = for all beta functions - onsite_p->get_fs_tools()->cal_becp(ik, npm); + // Calculate becp = for all beta functions + fs_tools->cal_becp(ik, num_occupied_bands); - // calculate dbecp = for all beta functions - // calculate stress = \sum * * D_{ij} + // Calculate stress contributions for each tensor component for (int ipol = 0; ipol < 3; ipol++) { for (int jpol = 0; jpol <= ipol; jpol++) { - FPTYPE* stress_device_tmp = stress_device + (ipol * 3 + jpol); - onsite_p->get_fs_tools()->cal_dbecp_s(ik, npm, ipol, jpol); - if(PARAM.inp.dft_plus_u) + const int idx = ipol * 3 + jpol; + + // Calculate dbecp_s = + fs_tools->cal_dbecp_s(ik, num_occupied_bands, ipol, jpol); + + // Add DFT+U contribution if enabled + if (PARAM.inp.dft_plus_u) { - onsite_p->get_fs_tools()->cal_stress_dftu(ik, - npm, - stress_device_tmp, - dftu.orbital_corr.data(), - dftu.get_eff_pot_pw(0), - dftu.get_size_eff_pot_pw(), - wg.c); + // Calculate DFT+U stress contribution + double dftu_stress = fs_tools->cal_stress_dftu( + ik, + num_occupied_bands, + dftu.orbital_corr.data(), + dftu.get_eff_pot_pw(0), + dftu.get_size_eff_pot_pw(), + wg.c + ); + + sigma_onsite[idx] += dftu_stress; +#ifdef __DEBUG + std::cout << " idx=" << idx << " stress=" << sigma_onsite[idx] << std::endl; +#endif } - if(PARAM.inp.sc_mag_switch) + + // Add spin constraint contribution if enabled + if (PARAM.inp.sc_mag_switch) { - spinconstrain::SpinConstrain>& sc = + // Get spin constraint instance + spinconstrain::SpinConstrain>& spin_constrain = spinconstrain::SpinConstrain>::getScInstance(); - const std::vector>& lambda = sc.get_sc_lambda(); - onsite_p->get_fs_tools()->cal_stress_dspin(ik, npm, stress_device_tmp, lambda.data(), wg.c); + + // Get lambda parameters + const std::vector>& lambda = spin_constrain.get_sc_lambda(); + + // Calculate spin constraint stress contribution + double dspin_stress = fs_tools->cal_stress_dspin( + ik, + num_occupied_bands, + lambda.data(), + wg.c + ); + + sigma_onsite[idx] += dspin_stress; } } } } - // transfer stress from device to host - syncmem_var_d2h_op()(sigma_onsite.data(), stress_device, 9); - delmem_var_op()(stress_device); + // No device memory to clean up (using CPU only) - // sum up forcenl from all processors - for (int l = 0; l < 3; l++) + // Step 1: Reduce stress contributions from all processors + for (int i = 0; i < 3; i++) { - for (int m = 0; m < 3; m++) + for (int j = 0; j < 3; j++) { - if (m > l) + const int idx = i * 3 + j; + if(j>i) { - sigma_onsite[l * 3 + m] = sigma_onsite[m * 3 + l]; + sigma_onsite[idx]=sigma_onsite[j*3+i]; } - Parallel_Reduce::reduce_all(sigma_onsite[l * 3 + m]); // qianrui fix a bug for kpar > 1 + Parallel_Reduce::reduce_all(sigma_onsite[idx]); // qianrui fix a bug for kpar > 1 } } - // rescale the stress with 1/omega - for (int ipol = 0; ipol < 3; ipol++) + // Step 2: Rescale stress with 1/omega + const double inv_omega = 1.0 / ucell_in.omega; + for (int i = 0; i < 3; i++) { - for (int jpol = 0; jpol < 3; jpol++) + for (int j = 0; j < 3; j++) { - sigma_onsite[ipol * 3 + jpol] *= 1.0 / ucell_in.omega; + const int idx = i * 3 + j; + sigma_onsite[idx] *= inv_omega; } } - for (int ipol = 0; ipol < 3; ipol++) +#ifdef __DEBUG + // Add to total stress + for (int idx = 0; idx < 9; idx++) + { + std::cout << " idx=" << idx << " stress=" << sigma_onsite[idx] << std::endl; + } +#endif + + // Step 3: Assign stress values to output matrix + for (int i = 0; i < 3; i++) { - for (int jpol = 0; jpol < 3; jpol++) + for (int j = 0; j < 3; j++) { - sigma(ipol, jpol) = sigma_onsite[ipol * 3 + jpol]; + const int idx = i * 3 + j; + sigma(i, j) = sigma_onsite[idx]; } } + // Symmetrize stress tensor if symmetry is enabled if (ModuleSymmetry::Symmetry::symm_flag == 1) { p_symm->symmetrize_mat3(sigma, ucell_in.lat); diff --git a/tests/01_PW/BUG_SCF_DSPIN/INPUT b/tests/01_PW/BUG_SCF_DSPIN/INPUT new file mode 100644 index 00000000000..94350f4eef1 --- /dev/null +++ b/tests/01_PW/BUG_SCF_DSPIN/INPUT @@ -0,0 +1,36 @@ +INPUT_PARAMETERS +pseudo_dir ../../../tests/PP_ORB +orbital_dir ../../../tests/PP_ORB +calculation scf +ecutwfc 20 +scf_thr 1.0e-5 +scf_nmax 20 + +smearing_method gaussian +smearing_sigma 0.07 + +mixing_type pulay +mixing_ndim 10 +mixing_beta 0.1 + +ks_solver cg +basis_type pw +symmetry 0 + +noncolin true +nspin 4 +lspinorb true +cal_force 1 +cal_stress 1 + +#deltaspin +sc_mag_switch 1 # switch to control spin-constrained DFT +decay_grad_switch 1 # switch to control gradient break condition +sc_thr 1e-7 # Convergence criterion of spin-constrained iteration (RMS) in uB +nsc 150 # Maximal number of spin-constrained iteration +nsc_min 2 # Minimum number of spin-constrained iteration +sc_scf_nmin 2 # Minimum number of outer scf loop before initializing lambda loop +alpha_trial 0.01 # Initial trial step size for lambda in eV/uB^2 +sccut 3 # Maximal step size for lambda in eV/uB +sc_drop_thr 1.0e-2 # Convergence criterion ratio of lambda iteration in Spin-constrained DFT +sc_scf_thr 1.0e-4 # Density error threshold for inner loop of spin-constrained SCF diff --git a/tests/01_PW/BUG_SCF_DSPIN/KPT b/tests/01_PW/BUG_SCF_DSPIN/KPT new file mode 100644 index 00000000000..4fd38968a05 --- /dev/null +++ b/tests/01_PW/BUG_SCF_DSPIN/KPT @@ -0,0 +1,4 @@ +K_POINTS +0 +Gamma +2 2 1 0 0 0 diff --git a/tests/01_PW/BUG_SCF_DSPIN/STRU b/tests/01_PW/BUG_SCF_DSPIN/STRU new file mode 100644 index 00000000000..ae2b187b97b --- /dev/null +++ b/tests/01_PW/BUG_SCF_DSPIN/STRU @@ -0,0 +1,21 @@ +ATOMIC_SPECIES +Fe 55.845 Fe.upf + +NUMERICAL_ORBITAL +Fe_gga_6au_100Ry_2s1p1d.orb + +LATTICE_CONSTANT +1.889725989 + +LATTICE_VECTORS + 2.8328152400000000 0.0000000000000000 0.0000000000000000 + 0.0000000000000000 2.8328152400000000 0.0000000000000000 + 0.0000000000000000 0.0000000000000000 2.8328152400000000 +ATOMIC_POSITIONS +Direct + +Fe +1.0 +2 +0.0 0.0 0.0 mag 5 angle1 90 angle2 0 +0.5 0.5 0.5 mag 5 angle1 90 angle2 0 diff --git a/tests/01_PW/BUG_SCF_DSPIN/sc.json b/tests/01_PW/BUG_SCF_DSPIN/sc.json new file mode 100644 index 00000000000..e1fa3e088bd --- /dev/null +++ b/tests/01_PW/BUG_SCF_DSPIN/sc.json @@ -0,0 +1,23 @@ +[ + { + "element": "Fe", + "itype": 0, + "ScDecayGrad": 0.9, + "ScAtomData": [ + { + "index": 0, + "lambda": [0, 0, 0], + "target_mag": [2.386, 0.0, 0.0], + "constrain": [1,1,1] + }, + { + "index": 1, + "lambda": [0, 0, 0], + "target_mag_val": 2.386, + "target_mag_angle1": 90.0, + "target_mag_angle2": 0.0, + "constrain": [1,1,1] + } + ] + } +] diff --git a/tests/03_NAO_multik/99_SCF_DPSIN/INPUT b/tests/03_NAO_multik/99_SCF_DPSIN/INPUT new file mode 100644 index 00000000000..499059e1ff3 --- /dev/null +++ b/tests/03_NAO_multik/99_SCF_DPSIN/INPUT @@ -0,0 +1,38 @@ +INPUT_PARAMETERS +pseudo_dir ../../../tests/PP_ORB +orbital_dir ../../../tests/PP_ORB +calculation scf +ecutwfc 20 +scf_thr 1.0e-5 +scf_nmax 20 + +smearing_method gaussian +smearing_sigma 0.07 + +mixing_type pulay +mixing_ndim 10 +mixing_beta 0.1 + +ks_solver genelpa +basis_type lcao +symmetry 0 + +noncolin true +nspin 4 +lspinorb true +out_mul true +cal_force 1 +cal_stress 1 + +#deltaspin +sc_mag_switch 1 # switch to control spin-constrained DFT +decay_grad_switch 1 # switch to control gradient break condition +sc_thr 1e-7 # Convergence criterion of spin-constrained iteration (RMS) in uB +nsc 150 # Maximal number of spin-constrained iteration +nsc_min 2 # Minimum number of spin-constrained iteration +sc_scf_nmin 2 # Minimum number of outer scf loop before initializing lambda loop +alpha_trial 0.01 # Initial trial step size for lambda in eV/uB^2 +sccut 3 # Maximal step size for lambda in eV/uB +sc_drop_thr 1.0e-2 # Convergence criterion ratio of lambda iteration in Spin-constrained DFT +sc_scf_thr 1.0e-4 # Density error threshold for inner loop of spin-constrained SCF +#sc_file sc.json # diff --git a/tests/03_NAO_multik/99_SCF_DPSIN/KPT b/tests/03_NAO_multik/99_SCF_DPSIN/KPT new file mode 100644 index 00000000000..4fd38968a05 --- /dev/null +++ b/tests/03_NAO_multik/99_SCF_DPSIN/KPT @@ -0,0 +1,4 @@ +K_POINTS +0 +Gamma +2 2 1 0 0 0 diff --git a/tests/03_NAO_multik/99_SCF_DPSIN/STRU b/tests/03_NAO_multik/99_SCF_DPSIN/STRU new file mode 100644 index 00000000000..ae2b187b97b --- /dev/null +++ b/tests/03_NAO_multik/99_SCF_DPSIN/STRU @@ -0,0 +1,21 @@ +ATOMIC_SPECIES +Fe 55.845 Fe.upf + +NUMERICAL_ORBITAL +Fe_gga_6au_100Ry_2s1p1d.orb + +LATTICE_CONSTANT +1.889725989 + +LATTICE_VECTORS + 2.8328152400000000 0.0000000000000000 0.0000000000000000 + 0.0000000000000000 2.8328152400000000 0.0000000000000000 + 0.0000000000000000 0.0000000000000000 2.8328152400000000 +ATOMIC_POSITIONS +Direct + +Fe +1.0 +2 +0.0 0.0 0.0 mag 5 angle1 90 angle2 0 +0.5 0.5 0.5 mag 5 angle1 90 angle2 0 diff --git a/tests/03_NAO_multik/99_SCF_DPSIN/sc.json b/tests/03_NAO_multik/99_SCF_DPSIN/sc.json new file mode 100644 index 00000000000..e1fa3e088bd --- /dev/null +++ b/tests/03_NAO_multik/99_SCF_DPSIN/sc.json @@ -0,0 +1,23 @@ +[ + { + "element": "Fe", + "itype": 0, + "ScDecayGrad": 0.9, + "ScAtomData": [ + { + "index": 0, + "lambda": [0, 0, 0], + "target_mag": [2.386, 0.0, 0.0], + "constrain": [1,1,1] + }, + { + "index": 1, + "lambda": [0, 0, 0], + "target_mag_val": 2.386, + "target_mag_angle1": 90.0, + "target_mag_angle2": 0.0, + "constrain": [1,1,1] + } + ] + } +] diff --git a/tests/11_PW_GPU/001_PW_BPCG_GPU/README b/tests/11_PW_GPU/001_PW_BPCG_GPU/README deleted file mode 100644 index b8f97be67a1..00000000000 --- a/tests/11_PW_GPU/001_PW_BPCG_GPU/README +++ /dev/null @@ -1,9 +0,0 @@ -This test for: -*GaAs-deformation -*PW -*kpoints 2*2*2 -*sg15 pseudopotential -*smearing_method gauss -*ks_solver bpcg -*mixing_type broyden-kerker -*mixing_beta 0.4 diff --git a/tests/11_PW_GPU/BUG_nspin4_u/INPUT b/tests/11_PW_GPU/BUG_nspin4_u/INPUT new file mode 100644 index 00000000000..f23760c0d42 --- /dev/null +++ b/tests/11_PW_GPU/BUG_nspin4_u/INPUT @@ -0,0 +1,48 @@ +INPUT_PARAMETERS +suffix autotest +nbands 40 +device gpu + +calculation scf +ecutwfc 20 +scf_thr 1.0e-8 +scf_nmax 50 +out_chg 0 + +#init_chg file +#out_dos 1 +#dos_sigma 0.05 +#out_band 1 + +smearing_method gaussian +smearing_sigma 0.01 + +#force_thr_ev 0.01 +#relax_method cg +#relax_bfgs_init 0.5 + +mixing_type pulay +mixing_beta 0.3 +mixing_restart 1e-3 +mixing_dmr 1 +mixing_gg0 1.1 + +ks_solver dav_subspace +diago_smooth_ethr true +pw_diag_ndim 2 +basis_type pw +gamma_only 0 +noncolin 1 +lspinorb 1 +cal_force 1 +cal_stress 1 + +#Parameter DFT+U +dft_plus_u 1 +orbital_corr 2 +hubbard_u 5.0 +onsite_radius 3.0 +pseudo_dir ../../PP_ORB +orbital_dir ../../PP_ORB + +pw_seed 1 diff --git a/tests/11_PW_GPU/BUG_nspin4_u/KPT b/tests/11_PW_GPU/BUG_nspin4_u/KPT new file mode 100644 index 00000000000..e769af76382 --- /dev/null +++ b/tests/11_PW_GPU/BUG_nspin4_u/KPT @@ -0,0 +1,4 @@ +K_POINTS +0 +Gamma +2 1 1 0 0 0 diff --git a/tests/11_PW_GPU/BUG_nspin4_u/README b/tests/11_PW_GPU/BUG_nspin4_u/README new file mode 100644 index 00000000000..2f4f21efcc6 --- /dev/null +++ b/tests/11_PW_GPU/BUG_nspin4_u/README @@ -0,0 +1 @@ +GPU: DFTU + NSPIN4, Fe2, multi-k case diff --git a/tests/11_PW_GPU/BUG_nspin4_u/STRU b/tests/11_PW_GPU/BUG_nspin4_u/STRU new file mode 100644 index 00000000000..91021e0a697 --- /dev/null +++ b/tests/11_PW_GPU/BUG_nspin4_u/STRU @@ -0,0 +1,22 @@ +ATOMIC_SPECIES +Fe 1.000 Fe.upf + +NUMERICAL_ORBITAL +Fe_gga_6au_100Ry_4s2p2d1f.orb + +LATTICE_CONSTANT +8.190 + +LATTICE_VECTORS + 1.00 0.50 0.50 + 0.50 1.00 0.50 + 0.50 0.50 1.00 +ATOMIC_POSITIONS +Direct + +Fe +0.0 +2 +0.00 0.00 0.00 mag 1.0 1.0 1.0 +0.51 0.51 0.51 mag 1.0 1.0 1.0 + diff --git a/tests/11_PW_GPU/CASES_GPU.txt b/tests/11_PW_GPU/CASES_GPU.txt index f550b7f0445..a10f2a682e2 100644 --- a/tests/11_PW_GPU/CASES_GPU.txt +++ b/tests/11_PW_GPU/CASES_GPU.txt @@ -1,7 +1,7 @@ -001_PW_BPCG_GPU -002_PW_CG_GPU -003_PW_DA_GPU -004_PW_DS_GPU -005_PW_CG_GPU_float -006_PW_get_wf_GPU -007_PW_OW_GPU +scf_bpcg +scf_cg +scf_cg_single +scf_dav +scf_dav_sub +scf_out_wf +scf_out_wf_norm diff --git a/tests/11_PW_GPU/001_PW_BPCG_GPU/INPUT b/tests/11_PW_GPU/scf_bpcg/INPUT similarity index 94% rename from tests/11_PW_GPU/001_PW_BPCG_GPU/INPUT rename to tests/11_PW_GPU/scf_bpcg/INPUT index 6893f164762..53cfde6f436 100644 --- a/tests/11_PW_GPU/001_PW_BPCG_GPU/INPUT +++ b/tests/11_PW_GPU/scf_bpcg/INPUT @@ -33,6 +33,6 @@ mixing_type broyden mixing_beta 0.4 mixing_gg0 1.5 -pw_seed 1 +pw_seed 1 diago_smooth_ethr 1 -use_k_continuity 1 +use_k_continuity 1 diff --git a/tests/11_PW_GPU/001_PW_BPCG_GPU/KPT b/tests/11_PW_GPU/scf_bpcg/KPT similarity index 100% rename from tests/11_PW_GPU/001_PW_BPCG_GPU/KPT rename to tests/11_PW_GPU/scf_bpcg/KPT diff --git a/tests/11_PW_GPU/scf_bpcg/README b/tests/11_PW_GPU/scf_bpcg/README new file mode 100644 index 00000000000..d0477404fef --- /dev/null +++ b/tests/11_PW_GPU/scf_bpcg/README @@ -0,0 +1 @@ +This test for: BPCG method for GaAs diff --git a/tests/11_PW_GPU/001_PW_BPCG_GPU/STRU b/tests/11_PW_GPU/scf_bpcg/STRU similarity index 100% rename from tests/11_PW_GPU/001_PW_BPCG_GPU/STRU rename to tests/11_PW_GPU/scf_bpcg/STRU diff --git a/tests/11_PW_GPU/001_PW_BPCG_GPU/result.ref b/tests/11_PW_GPU/scf_bpcg/result.ref similarity index 100% rename from tests/11_PW_GPU/001_PW_BPCG_GPU/result.ref rename to tests/11_PW_GPU/scf_bpcg/result.ref diff --git a/tests/11_PW_GPU/001_PW_BPCG_GPU/threshold b/tests/11_PW_GPU/scf_bpcg/threshold similarity index 100% rename from tests/11_PW_GPU/001_PW_BPCG_GPU/threshold rename to tests/11_PW_GPU/scf_bpcg/threshold diff --git a/tests/11_PW_GPU/002_PW_CG_GPU/INPUT b/tests/11_PW_GPU/scf_cg/INPUT similarity index 100% rename from tests/11_PW_GPU/002_PW_CG_GPU/INPUT rename to tests/11_PW_GPU/scf_cg/INPUT diff --git a/tests/11_PW_GPU/002_PW_CG_GPU/KPT b/tests/11_PW_GPU/scf_cg/KPT similarity index 100% rename from tests/11_PW_GPU/002_PW_CG_GPU/KPT rename to tests/11_PW_GPU/scf_cg/KPT diff --git a/tests/11_PW_GPU/002_PW_CG_GPU/README b/tests/11_PW_GPU/scf_cg/README similarity index 100% rename from tests/11_PW_GPU/002_PW_CG_GPU/README rename to tests/11_PW_GPU/scf_cg/README diff --git a/tests/11_PW_GPU/002_PW_CG_GPU/STRU b/tests/11_PW_GPU/scf_cg/STRU similarity index 100% rename from tests/11_PW_GPU/002_PW_CG_GPU/STRU rename to tests/11_PW_GPU/scf_cg/STRU diff --git a/tests/11_PW_GPU/002_PW_CG_GPU/result.ref b/tests/11_PW_GPU/scf_cg/result.ref similarity index 100% rename from tests/11_PW_GPU/002_PW_CG_GPU/result.ref rename to tests/11_PW_GPU/scf_cg/result.ref diff --git a/tests/11_PW_GPU/002_PW_CG_GPU/threshold b/tests/11_PW_GPU/scf_cg/threshold similarity index 100% rename from tests/11_PW_GPU/002_PW_CG_GPU/threshold rename to tests/11_PW_GPU/scf_cg/threshold diff --git a/tests/11_PW_GPU/005_PW_CG_GPU_float/INPUT b/tests/11_PW_GPU/scf_cg_single/INPUT similarity index 100% rename from tests/11_PW_GPU/005_PW_CG_GPU_float/INPUT rename to tests/11_PW_GPU/scf_cg_single/INPUT diff --git a/tests/11_PW_GPU/003_PW_DA_GPU/KPT b/tests/11_PW_GPU/scf_cg_single/KPT similarity index 100% rename from tests/11_PW_GPU/003_PW_DA_GPU/KPT rename to tests/11_PW_GPU/scf_cg_single/KPT diff --git a/tests/11_PW_GPU/005_PW_CG_GPU_float/README b/tests/11_PW_GPU/scf_cg_single/README similarity index 100% rename from tests/11_PW_GPU/005_PW_CG_GPU_float/README rename to tests/11_PW_GPU/scf_cg_single/README diff --git a/tests/11_PW_GPU/003_PW_DA_GPU/STRU b/tests/11_PW_GPU/scf_cg_single/STRU similarity index 100% rename from tests/11_PW_GPU/003_PW_DA_GPU/STRU rename to tests/11_PW_GPU/scf_cg_single/STRU diff --git a/tests/11_PW_GPU/005_PW_CG_GPU_float/result.ref b/tests/11_PW_GPU/scf_cg_single/result.ref similarity index 100% rename from tests/11_PW_GPU/005_PW_CG_GPU_float/result.ref rename to tests/11_PW_GPU/scf_cg_single/result.ref diff --git a/tests/11_PW_GPU/005_PW_CG_GPU_float/threshold b/tests/11_PW_GPU/scf_cg_single/threshold similarity index 100% rename from tests/11_PW_GPU/005_PW_CG_GPU_float/threshold rename to tests/11_PW_GPU/scf_cg_single/threshold diff --git a/tests/11_PW_GPU/003_PW_DA_GPU/INPUT b/tests/11_PW_GPU/scf_dav/INPUT similarity index 100% rename from tests/11_PW_GPU/003_PW_DA_GPU/INPUT rename to tests/11_PW_GPU/scf_dav/INPUT diff --git a/tests/11_PW_GPU/004_PW_DS_GPU/KPT b/tests/11_PW_GPU/scf_dav/KPT similarity index 100% rename from tests/11_PW_GPU/004_PW_DS_GPU/KPT rename to tests/11_PW_GPU/scf_dav/KPT diff --git a/tests/11_PW_GPU/003_PW_DA_GPU/README b/tests/11_PW_GPU/scf_dav/README similarity index 100% rename from tests/11_PW_GPU/003_PW_DA_GPU/README rename to tests/11_PW_GPU/scf_dav/README diff --git a/tests/11_PW_GPU/004_PW_DS_GPU/STRU b/tests/11_PW_GPU/scf_dav/STRU similarity index 100% rename from tests/11_PW_GPU/004_PW_DS_GPU/STRU rename to tests/11_PW_GPU/scf_dav/STRU diff --git a/tests/11_PW_GPU/003_PW_DA_GPU/result.ref b/tests/11_PW_GPU/scf_dav/result.ref similarity index 100% rename from tests/11_PW_GPU/003_PW_DA_GPU/result.ref rename to tests/11_PW_GPU/scf_dav/result.ref diff --git a/tests/11_PW_GPU/003_PW_DA_GPU/threshold b/tests/11_PW_GPU/scf_dav/threshold similarity index 100% rename from tests/11_PW_GPU/003_PW_DA_GPU/threshold rename to tests/11_PW_GPU/scf_dav/threshold diff --git a/tests/11_PW_GPU/004_PW_DS_GPU/INPUT b/tests/11_PW_GPU/scf_dav_sub/INPUT similarity index 100% rename from tests/11_PW_GPU/004_PW_DS_GPU/INPUT rename to tests/11_PW_GPU/scf_dav_sub/INPUT diff --git a/tests/11_PW_GPU/005_PW_CG_GPU_float/KPT b/tests/11_PW_GPU/scf_dav_sub/KPT similarity index 100% rename from tests/11_PW_GPU/005_PW_CG_GPU_float/KPT rename to tests/11_PW_GPU/scf_dav_sub/KPT diff --git a/tests/11_PW_GPU/004_PW_DS_GPU/README b/tests/11_PW_GPU/scf_dav_sub/README similarity index 100% rename from tests/11_PW_GPU/004_PW_DS_GPU/README rename to tests/11_PW_GPU/scf_dav_sub/README diff --git a/tests/11_PW_GPU/005_PW_CG_GPU_float/STRU b/tests/11_PW_GPU/scf_dav_sub/STRU similarity index 100% rename from tests/11_PW_GPU/005_PW_CG_GPU_float/STRU rename to tests/11_PW_GPU/scf_dav_sub/STRU diff --git a/tests/11_PW_GPU/004_PW_DS_GPU/result.ref b/tests/11_PW_GPU/scf_dav_sub/result.ref similarity index 100% rename from tests/11_PW_GPU/004_PW_DS_GPU/result.ref rename to tests/11_PW_GPU/scf_dav_sub/result.ref diff --git a/tests/11_PW_GPU/004_PW_DS_GPU/threshold b/tests/11_PW_GPU/scf_dav_sub/threshold similarity index 100% rename from tests/11_PW_GPU/004_PW_DS_GPU/threshold rename to tests/11_PW_GPU/scf_dav_sub/threshold diff --git a/tests/11_PW_GPU/007_PW_OW_GPU/INPUT b/tests/11_PW_GPU/scf_out_wf/INPUT similarity index 100% rename from tests/11_PW_GPU/007_PW_OW_GPU/INPUT rename to tests/11_PW_GPU/scf_out_wf/INPUT diff --git a/tests/11_PW_GPU/006_PW_get_wf_GPU/KPT b/tests/11_PW_GPU/scf_out_wf/KPT similarity index 100% rename from tests/11_PW_GPU/006_PW_get_wf_GPU/KPT rename to tests/11_PW_GPU/scf_out_wf/KPT diff --git a/tests/11_PW_GPU/007_PW_OW_GPU/README b/tests/11_PW_GPU/scf_out_wf/README similarity index 100% rename from tests/11_PW_GPU/007_PW_OW_GPU/README rename to tests/11_PW_GPU/scf_out_wf/README diff --git a/tests/11_PW_GPU/006_PW_get_wf_GPU/STRU b/tests/11_PW_GPU/scf_out_wf/STRU similarity index 100% rename from tests/11_PW_GPU/006_PW_get_wf_GPU/STRU rename to tests/11_PW_GPU/scf_out_wf/STRU diff --git a/tests/11_PW_GPU/007_PW_OW_GPU/result.ref b/tests/11_PW_GPU/scf_out_wf/result.ref similarity index 100% rename from tests/11_PW_GPU/007_PW_OW_GPU/result.ref rename to tests/11_PW_GPU/scf_out_wf/result.ref diff --git a/tests/11_PW_GPU/006_PW_get_wf_GPU/INPUT b/tests/11_PW_GPU/scf_out_wf_norm/INPUT similarity index 100% rename from tests/11_PW_GPU/006_PW_get_wf_GPU/INPUT rename to tests/11_PW_GPU/scf_out_wf_norm/INPUT diff --git a/tests/11_PW_GPU/007_PW_OW_GPU/KPT b/tests/11_PW_GPU/scf_out_wf_norm/KPT similarity index 100% rename from tests/11_PW_GPU/007_PW_OW_GPU/KPT rename to tests/11_PW_GPU/scf_out_wf_norm/KPT diff --git a/tests/11_PW_GPU/006_PW_get_wf_GPU/README b/tests/11_PW_GPU/scf_out_wf_norm/README similarity index 100% rename from tests/11_PW_GPU/006_PW_get_wf_GPU/README rename to tests/11_PW_GPU/scf_out_wf_norm/README diff --git a/tests/11_PW_GPU/007_PW_OW_GPU/STRU b/tests/11_PW_GPU/scf_out_wf_norm/STRU similarity index 100% rename from tests/11_PW_GPU/007_PW_OW_GPU/STRU rename to tests/11_PW_GPU/scf_out_wf_norm/STRU diff --git a/tests/11_PW_GPU/006_PW_get_wf_GPU/result.ref b/tests/11_PW_GPU/scf_out_wf_norm/result.ref similarity index 100% rename from tests/11_PW_GPU/006_PW_get_wf_GPU/result.ref rename to tests/11_PW_GPU/scf_out_wf_norm/result.ref