Skip to content

Commit e295015

Browse files
committed
enable complex spin2 and fix a parameter bug
1 parent 196fc4e commit e295015

File tree

4 files changed

+6
-14
lines changed

4 files changed

+6
-14
lines changed

source/module_esolver/esolver.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,8 @@ ESolver* init_esolver(const Input_para& inp, UnitCell& ucell)
187187
else if (esolver_type == "lr_lcao")
188188
{
189189
// use constructor rather than Init function to initialize reference (instead of pointers) to ucell
190-
if (PARAM.globalv.gamma_only_local){
191-
return new LR::ESolver_LR<double, double>(inp, ucell);
192-
} else if (PARAM.inp.nspin < 2) {
193-
return new LR::ESolver_LR<std::complex<double>, double>(inp, ucell);
194-
} else {
195-
throw std::runtime_error("LR-TDDFT is not implemented for spin polarized case");
196-
}
190+
if (PARAM.globalv.gamma_only_local) { return new LR::ESolver_LR<double, double>(inp, ucell); }
191+
else { return new LR::ESolver_LR<std::complex<double>, double>(inp, ucell); }
197192
}
198193
else if (esolver_type == "ksdft_lr_lcao")
199194
{

source/module_io/read_input_item_tddft.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,6 @@ void ReadInput::item_lr_tddft()
343343
para.input.abs_wavelen_range.push_back(std::stod(item.str_values[i]));
344344
}
345345
};
346-
item.check_value = [](const Input_Item& item, const Parameter& para) {
347-
auto& awr = para.input.abs_wavelen_range;
348-
if (awr.size() < 2) { ModuleBase::WARNING_QUIT("ReadInput", "abs_wavelen_range must have two values"); }
349-
};
350346
sync_doublevec(input.abs_wavelen_range, 2, 0.0);
351347
this->add_item(item);
352348
}

source/module_lr/esolver_lrtd_lcao.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ inline int cal_nupdown_form_occ(const ModuleBase::matrix& wg)
7777
{
7878
const int nu = static_cast<int>(std::lround(occ_sum_k(0, ib)));
7979
const int nd = static_cast<int>(std::lround(occ_sum_k(1, ib)));
80-
if (!(nu + nd)) { break; }
80+
if ((nu + nd) == 0) { break; }
8181
nupdown += nu - nd;
8282
}
8383
return nupdown;
@@ -139,9 +139,10 @@ void LR::ESolver_LR<T, TR>::reset_dim_spin2()
139139
{
140140
this->openshell = true;
141141
nupdown > 0 ? ((nocc[1] -= nupdown) && (nvirt[1] += nupdown)) : ((nocc[0] += nupdown) && (nvirt[0] -= nupdown));
142-
// npairs = { nocc[0] * nvirt[0], nocc[1] * nvirt[1] };
142+
npairs = { nocc[0] * nvirt[0], nocc[1] * nvirt[1] };
143143
std::cout << "** Solve the spin-up and spin-down states separately for open-shell system. **" << std::endl;
144144
}
145+
for (int is : {0, 1}) { if (npairs[is] <= 0) { throw std::invalid_argument(std::string("ESolver_LR: npairs (nocc*nvirt) <= 0 for spin") + std::string(is == 0 ? "up" : "down")); } }
145146
if (nstates > (npairs[0] + npairs[1]) * nk) { throw std::invalid_argument("ESolver_LR: nstates > nocc*nvirt*nk"); }
146147
if (input.lr_unrestricted) { this->openshell = true; }
147148
}

source/module_parameter/input_parameter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ struct Input_para
303303
double lr_thr = 1e-2; ///< convergence threshold of the LR-TDDFT eigensolver
304304
bool out_wfc_lr = false; ///< whether to output the eigenvectors (excitation amplitudes) in the particle-hole basis
305305
bool lr_unrestricted = false; ///< whether to use the unrestricted construction for LR-TDDFT
306-
std::vector<double> abs_wavelen_range = { 0., 0. }; ///< the range of wavelength(nm) to output the absorption spectrum
306+
std::vector<double> abs_wavelen_range = {}; ///< the range of wavelength(nm) to output the absorption spectrum
307307
double abs_broadening = 0.01; ///< the broadening (eta) for LR-TDDFT absorption spectrum
308308
std::string ri_hartree_benchmark = "none"; ///< whether to use the RI approximation for the Hartree potential in LR-TDDFT for benchmark (with FHI-aims/ABACUS read-in style)
309309
std::vector<int> aims_nbasis = {}; ///< the number of basis functions for each atom type used in FHI-aims (for benchmark)

0 commit comments

Comments
 (0)