Skip to content

Commit 3d64446

Browse files
authored
Feature: enable get_s for nspin=4 (#5614)
1 parent 93ac7e3 commit 3d64446

File tree

3 files changed

+51
-34
lines changed

3 files changed

+51
-34
lines changed

source/module_esolver/esolver.cpp

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -186,39 +186,29 @@ ESolver* init_esolver(const Input_para& inp, UnitCell& ucell)
186186
}
187187
}
188188
else if (esolver_type == "ksdft_lcao")
189-
{
190-
if (PARAM.globalv.gamma_only_local)
191-
{
192-
if (PARAM.inp.calculation == "get_S")
189+
{
190+
if (PARAM.inp.calculation == "get_S")
191+
{
192+
if (PARAM.globalv.gamma_only_local)
193193
{
194194
ModuleBase::WARNING_QUIT("ESolver", "get_S is not implemented for gamma_only");
195195
}
196196
else
197197
{
198-
return new ESolver_KS_LCAO<double, double>();
198+
return new ESolver_GetS();
199199
}
200200
}
201+
if (PARAM.globalv.gamma_only_local)
202+
{
203+
return new ESolver_KS_LCAO<double, double>();
204+
}
201205
else if (PARAM.inp.nspin < 4)
202206
{
203-
if (PARAM.inp.calculation == "get_S")
204-
{
205-
return new ESolver_GetS();
206-
}
207-
else
208-
{
209-
return new ESolver_KS_LCAO<std::complex<double>, double>();
210-
}
207+
return new ESolver_KS_LCAO<std::complex<double>, double>();
211208
}
212209
else
213210
{
214-
if (PARAM.inp.calculation == "get_S")
215-
{
216-
ModuleBase::WARNING_QUIT("ESolver", "get_S is not implemented for npsin=4");
217-
}
218-
else
219-
{
220-
return new ESolver_KS_LCAO<std::complex<double>, std::complex<double>>();
221-
}
211+
return new ESolver_KS_LCAO<std::complex<double>, std::complex<double>>();
222212
}
223213
}
224214
else if (esolver_type == "ksdft_lcao_tddft")

source/module_esolver/esolver_gets.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,24 @@ void ESolver_GetS::runner(UnitCell& ucell, const int istep)
103103

104104
if (this->p_hamilt == nullptr)
105105
{
106-
this->p_hamilt = new hamilt::HamiltLCAO<std::complex<double>, double>(&this->pv,
107-
this->kv,
108-
*(two_center_bundle_.overlap_orb),
109-
orb_.cutoffs());
110-
dynamic_cast<hamilt::OperatorLCAO<std::complex<double>, double>*>(this->p_hamilt->ops)->contributeHR();
106+
if (PARAM.inp.nspin == 4)
107+
{
108+
this->p_hamilt
109+
= new hamilt::HamiltLCAO<std::complex<double>, std::complex<double>>(&this->pv,
110+
this->kv,
111+
*(two_center_bundle_.overlap_orb),
112+
orb_.cutoffs());
113+
dynamic_cast<hamilt::OperatorLCAO<std::complex<double>, std::complex<double>>*>(this->p_hamilt->ops)
114+
->contributeHR();
115+
}
116+
else
117+
{
118+
this->p_hamilt = new hamilt::HamiltLCAO<std::complex<double>, double>(&this->pv,
119+
this->kv,
120+
*(two_center_bundle_.overlap_orb),
121+
orb_.cutoffs());
122+
dynamic_cast<hamilt::OperatorLCAO<std::complex<double>, double>*>(this->p_hamilt->ops)->contributeHR();
123+
}
111124
}
112125

113126
const std::string fn = PARAM.globalv.global_out_dir + "SR.csr";

source/module_io/write_HS_R.cpp

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,28 @@ void ModuleIO::output_SR(Parallel_Orbitals& pv,
171171

172172
const int istep = 0;
173173

174-
ModuleIO::save_sparse(HS_Arrays.SR_sparse,
175-
HS_Arrays.all_R_coor,
176-
sparse_thr,
177-
binary,
178-
SR_filename,
179-
pv,
180-
"S",
181-
istep);
174+
if (PARAM.inp.nspin == 4)
175+
{
176+
ModuleIO::save_sparse(HS_Arrays.SR_soc_sparse,
177+
HS_Arrays.all_R_coor,
178+
sparse_thr,
179+
binary,
180+
SR_filename,
181+
pv,
182+
"S",
183+
istep);
184+
}
185+
else
186+
{
187+
ModuleIO::save_sparse(HS_Arrays.SR_sparse,
188+
HS_Arrays.all_R_coor,
189+
sparse_thr,
190+
binary,
191+
SR_filename,
192+
pv,
193+
"S",
194+
istep);
195+
}
182196

183197
sparse_format::destroy_HS_R_sparse(HS_Arrays);
184198

0 commit comments

Comments
 (0)