Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion source/module_io/read_input_item_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void ReadInput::item_system()
}
{
Input_Item item("esolver_type");
item.annotation = "the energy solver: ksdft, sdft, ofdft, tddft, lj, dp";
item.annotation = "the energy solver: ksdft, sdft, ofdft, tddft, lj, dp, ks-lr, lr";
read_sync_string(input.esolver_type);
item.check_value = [](const Input_Item& item, const Parameter& para) {
const std::vector<std::string> esolver_types = { "ksdft", "sdft", "ofdft", "tddft", "lj", "dp", "lr", "ks-lr" };
Expand All @@ -124,6 +124,12 @@ void ReadInput::item_system()
}
}
};
item.reset_value = [](const Input_Item& item, Parameter& para) {
if (para.input.esolver_type == "lr" && para.input.calculation == "scf")
{ // for LR-only calculation based on the ground-state, set calculation to "nscf"
para.input.calculation = "nscf";
}
};
this->add_item(item);
}
{
Expand Down
6 changes: 6 additions & 0 deletions source/module_io/test_serial/read_input_item_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ TEST_F(InputTest, Item_test)
EXPECT_EXIT(it->second.check_value(it->second, param), ::testing::ExitedWithCode(0), "");
output = testing::internal::GetCapturedStdout();
EXPECT_THAT(output, testing::HasSubstr("NOTICE"));

param.input.esolver_type = "lr";
param.input.calculation = "scf";
it = find_label("esolver_type", readinput.input_lists);
it->second.reset_value(it->second, param);
EXPECT_EQ(param.input.calculation, "nscf");
}
{ // nspin
auto it = find_label("nspin", readinput.input_lists);
Expand Down
26 changes: 2 additions & 24 deletions source/module_lr/esolver_lrtd_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,6 @@ void LR::ESolver_LR<double>::move_exx_lri(std::shared_ptr<Exx_LRI<std::complex<d
template<>void LR::ESolver_LR<double>::set_gint() { this->gint_ = &this->gint_g_;this->gint_g_.gridt = &this->gt_; }
template<>void LR::ESolver_LR<std::complex<double>>::set_gint() { this->gint_ = &this->gint_k_; this->gint_k_.gridt = &this->gt_; }

inline double getreal(std::complex<double> x) { return x.real(); }
inline double getreal(double x) { return x; }

inline void redirect_log(const bool& out_alllog)
{
GlobalV::ofs_running.close();
std::stringstream ss;
if (out_alllog)
{
ss << PARAM.globalv.global_out_dir << "running_lr_" << GlobalV::MY_RANK + 1 << ".log";
GlobalV::ofs_running.open(ss.str());
}
else
{
if (GlobalV::MY_RANK == 0)
{
ss << PARAM.globalv.global_out_dir << "running_lr.log";
GlobalV::ofs_running.open(ss.str());
}
}
}

inline int cal_nupdown_form_occ(const ModuleBase::matrix& wg)
{ // only for nspin=2
const int& nk = wg.nr / 2;
Expand Down Expand Up @@ -155,7 +133,6 @@ LR::ESolver_LR<T, TR>::ESolver_LR(ModuleESolver::ESolver_KS_LCAO<T, TR>&& ks_sol
, exx_info(GlobalC::exx_info)
#endif
{
redirect_log(inp.out_alllog);
ModuleBase::TITLE("ESolver_LR", "ESolver_LR(KS)");

if (this->input.lr_solver == "spectrum") {
Expand Down Expand Up @@ -259,7 +236,6 @@ LR::ESolver_LR<T, TR>::ESolver_LR(const Input_para& inp, UnitCell& ucell) : inpu
, exx_info(GlobalC::exx_info)
#endif
{
redirect_log(inp.out_alllog);
ModuleBase::TITLE("ESolver_LR", "ESolver_LR(from scratch)");
// xc kernel
this->xc_kernel = inp.xc_kernel;
Expand Down Expand Up @@ -431,6 +407,7 @@ template <typename T, typename TR>
void LR::ESolver_LR<T, TR>::runner(int istep, UnitCell& cell)
{
ModuleBase::TITLE("ESolver_LR", "runner");
ModuleBase::timer::tick("ESolver_LR", "runner");
//allocate 2-particle state and setup 2d division
this->setup_eigenvectors_X();
this->pelec->ekb.create(nspin, this->nstates);
Expand Down Expand Up @@ -494,6 +471,7 @@ void LR::ESolver_LR<T, TR>::runner(int istep, UnitCell& cell)
for (int is = 0;is < nspin;++is) { read_states(spin_types[is], this->pelec->ekb.c + is * nstates, this->X[is].template data<T>(), nloc_per_band, nstates); }
}
}
ModuleBase::timer::tick("ESolver_LR", "runner");
return;
}

Expand Down
3 changes: 1 addition & 2 deletions source/module_lr/operator_casida/operator_lr_diag.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ namespace LR
const bool is_first_node = false)const override
{
ModuleBase::TITLE("OperatorLRDiag", "act");
const int nlocal_ph = nk * pX.get_local_size(); // local size of particle-hole basis
hsolver::vector_mul_vector_op<T, Device>()(this->ctx,
nk * pX.get_local_size(),
nk * pX.get_local_size(), // local size of particle-hole basis
hpsi,
psi_in,
this->eig_ks_diff.c);
Expand Down
16 changes: 6 additions & 10 deletions source/module_lr/utils/lr_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,37 +62,33 @@ namespace LR_Util
template<>
void matsym<double>(const double* in, const int n, const Parallel_2D& pmat, double* out)
{
for (int i = 0;i < pmat.get_local_size();++i) {out[i] = in[i];
}
for (int i = 0;i < pmat.get_local_size();++i) { out[i] = in[i]; }
const double alpha = 0.5, beta = 0.5;
const int i1 = 1;
pdtran_(&n, &n, &alpha, in, &i1, &i1, pmat.desc, &beta, out, &i1, &i1, pmat.desc);
}
template<>
void matsym<double>(double* inout, const int n, const Parallel_2D& pmat)
{
std::vector<double> tmp(n * n);
for (int i = 0;i < pmat.get_local_size();++i) {tmp[i] = inout[i];
}
std::vector<double> tmp(pmat.get_local_size());
std::copy(inout, inout + pmat.get_local_size(), tmp.begin());
const double alpha = 0.5, beta = 0.5;
const int i1 = 1;
pdtran_(&n, &n, &alpha, tmp.data(), &i1, &i1, pmat.desc, &beta, inout, &i1, &i1, pmat.desc);
}
template<>
void matsym<std::complex<double>>(const std::complex<double>* in, const int n, const Parallel_2D& pmat, std::complex<double>* out)
{
for (int i = 0;i < pmat.get_local_size();++i) {out[i] = in[i];
}
for (int i = 0;i < pmat.get_local_size();++i) { out[i] = in[i]; }
const std::complex<double> alpha(0.5, 0.0), beta(0.5, 0.0);
const int i1 = 1;
pztranc_(&n, &n, &alpha, in, &i1, &i1, pmat.desc, &beta, out, &i1, &i1, pmat.desc);
}
template<>
void matsym<std::complex<double>>(std::complex<double>* inout, const int n, const Parallel_2D& pmat)
{
std::vector<std::complex<double>> tmp(n * n);
for (int i = 0;i < pmat.get_local_size();++i) {tmp[i] = inout[i];
}
std::vector<std::complex<double>> tmp(pmat.get_local_size());
std::copy(inout, inout + pmat.get_local_size(), tmp.begin());
const std::complex<double> alpha(0.5, 0.0), beta(0.5, 0.0);
const int i1 = 1;
pztranc_(&n, &n, &alpha, tmp.data(), &i1, &i1, pmat.desc, &beta, inout, &i1, &i1, pmat.desc);
Expand Down
3 changes: 1 addition & 2 deletions tests/integrate/tools/catch_properties.sh
Original file line number Diff line number Diff line change
Expand Up @@ -536,10 +536,9 @@ if ! test -z "$out_current" && [ $out_current ]; then
fi

if [ $is_lr == 1 ]; then
lr_path=OUT.autotest/running_lr.log
lrns=$(get_input_key_value "lr_nstates" "INPUT")
lrns1=`echo "$lrns + 1" |bc`
grep -A$lrns1 "Excitation Energy" $lr_path | awk 'NR > 2 && $2 ~ /^[0-9]+\.[0-9]+$/ {print $2}' > lr_eig.txt
grep -A$lrns1 "Excitation Energy" $running_path | awk 'NR > 2 && $2 ~ /^[0-9]+\.[0-9]+$/ {print $2}' > lr_eig.txt
lreig_tot=`sum_file lr_eig.txt`
echo "totexcitationenergyref $lreig_tot" >>$1
fi
Expand Down
Loading