Skip to content

Commit dc736a2

Browse files
committed
Merge branch 'develop' into ucell5
2 parents 674d89e + ee4ad57 commit dc736a2

File tree

12 files changed

+21
-48
lines changed

12 files changed

+21
-48
lines changed

source/module_cell/test/unitcell_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,7 @@ TEST_F(UcellTest, CalUx1)
10351035
ucell->atoms[0].m_loc_[0].set(0, -1, 0);
10361036
ucell->atoms[1].m_loc_[0].set(1, 1, 1);
10371037
ucell->atoms[1].m_loc_[1].set(0, 0, 0);
1038+
PARAM.input.nspin = 4;
10381039
elecstate::cal_ux(*ucell);
10391040
EXPECT_FALSE(ucell->magnet.lsign_);
10401041
EXPECT_DOUBLE_EQ(ucell->magnet.ux_[0], 0);
@@ -1051,6 +1052,7 @@ TEST_F(UcellTest, CalUx2)
10511052
ucell->atoms[1].m_loc_[0].set(1, 1, 1);
10521053
ucell->atoms[1].m_loc_[1].set(0, 0, 0);
10531054
//(0,0,0) is also parallel to (1,1,1)
1055+
PARAM.input.nspin = 4;
10541056
elecstate::cal_ux(*ucell);
10551057
EXPECT_TRUE(ucell->magnet.lsign_);
10561058
EXPECT_NEAR(ucell->magnet.ux_[0], 0.57735, 1e-5);

source/module_elecstate/cal_ux.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
#include "cal_ux.h"
2+
#include "module_parameter/parameter.h"
23

34
namespace elecstate {
45

56
void cal_ux(UnitCell& ucell) {
7+
if (PARAM.inp.nspin != 4)
8+
{
9+
return;
10+
}
11+
612
double amag, uxmod;
713
int starting_it = 0;
814
int starting_ia = 0;

source/module_elecstate/cal_ux.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace elecstate {
77

8+
// Only for npsin = 4
89
void cal_ux(UnitCell& ucell);
910

1011
bool judge_parallel(double a[3], ModuleBase::Vector3<double> b);

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -606,10 +606,7 @@ void ESolver_KS_LCAO<TK, TR>::iter_init(UnitCell& ucell, const int istep, const
606606
// rho1 and rho2 are the same rho.
607607
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
608608

609-
if (PARAM.inp.nspin == 4)
610-
{
611-
elecstate::cal_ux(ucell);
612-
}
609+
elecstate::cal_ux(ucell);
613610

614611
//! update the potentials by using new electron charge density
615612
this->pelec->pot->update_from_charge(this->pelec->charge, &ucell);
@@ -842,10 +839,7 @@ void ESolver_KS_LCAO<TK, TR>::update_pot(UnitCell& ucell, const int istep, const
842839

843840
if (!this->conv_esolver)
844841
{
845-
if (PARAM.inp.nspin == 4)
846-
{
847-
elecstate::cal_ux(ucell);
848-
}
842+
elecstate::cal_ux(ucell);
849843
this->pelec->pot->update_from_charge(this->pelec->charge, &ucell);
850844
this->pelec->f_en.descf = this->pelec->cal_delta_escf();
851845
}

source/module_esolver/esolver_ks_lcao_tddft.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,7 @@ void ESolver_KS_LCAO_TDDFT::update_pot(UnitCell& ucell, const int istep, const i
238238
// Calculate new potential according to new Charge Density
239239
if (!this->conv_esolver)
240240
{
241-
if (PARAM.inp.nspin == 4)
242-
{
243-
elecstate::cal_ux(ucell);
244-
}
241+
elecstate::cal_ux(ucell);
245242
this->pelec->pot->update_from_charge(this->pelec->charge, &ucell);
246243
this->pelec->f_en.descf = this->pelec->cal_delta_escf();
247244
}

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,7 @@ void ESolver_KS_PW<T, Device>::before_scf(UnitCell& ucell, const int istep)
298298

299299
//! cal_ux should be called before init_scf because
300300
//! the direction of ux is used in noncoline_rho
301-
if (PARAM.inp.nspin == 4)
302-
{
303-
elecstate::cal_ux(ucell);
304-
}
301+
elecstate::cal_ux(ucell);
305302

306303
//! calculate the total local pseudopotential in real space
307304
this->pelec->init_scf(istep, this->sf.strucFac, this->ppcell.numeric, ucell.symm, (void*)this->pw_wfc);
@@ -472,10 +469,7 @@ void ESolver_KS_PW<T, Device>::update_pot(UnitCell& ucell, const int istep, cons
472469
{
473470
if (!this->conv_esolver)
474471
{
475-
if (PARAM.inp.nspin == 4)
476-
{
477-
elecstate::cal_ux(ucell);
478-
}
472+
elecstate::cal_ux(ucell);
479473
this->pelec->pot->update_from_charge(this->pelec->charge, &ucell);
480474
this->pelec->f_en.descf = this->pelec->cal_delta_escf();
481475
#ifdef __MPI

source/module_esolver/esolver_of.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,7 @@ void ESolver_OF::before_opt(const int istep, UnitCell& ucell)
310310
void ESolver_OF::update_potential(UnitCell& ucell)
311311
{
312312
// (1) get dL/dphi
313-
if (PARAM.inp.nspin == 4)
314-
{
315-
elecstate::cal_ux(ucell);
316-
}
313+
elecstate::cal_ux(ucell);
317314

318315
this->pelec->pot->update_from_charge(pelec->charge, &ucell); // Hartree + XC + external
319316
this->kinetic_potential(pelec->charge->rho,

source/module_esolver/esolver_of_tool.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,7 @@ void ESolver_OF::cal_potential(double* ptemp_phi, double* rdLdphi, UnitCell& uce
133133
}
134134
}
135135

136-
if (PARAM.inp.nspin == 4)
137-
{
138-
elecstate::cal_ux(ucell);
139-
}
136+
elecstate::cal_ux(ucell);
140137
this->pelec->pot->update_from_charge(this->ptemp_rho_, &ucell);
141138
ModuleBase::matrix& vr_eff = this->pelec->pot->get_effective_v();
142139

@@ -173,10 +170,7 @@ void ESolver_OF::cal_dEdtheta(double** ptemp_phi, Charge* temp_rho, UnitCell& uc
173170
{
174171
double* dphi_dtheta = new double[this->pw_rho->nrxx];
175172

176-
if (PARAM.inp.nspin == 4)
177-
{
178-
elecstate::cal_ux(ucell);
179-
}
173+
elecstate::cal_ux(ucell);
180174
this->pelec->pot->update_from_charge(temp_rho, &ucell);
181175
ModuleBase::matrix& vr_eff = this->pelec->pot->get_effective_v();
182176

source/module_esolver/lcao_before_scf.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,7 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
246246
// cal_ux should be called before init_scf because
247247
// the direction of ux is used in noncoline_rho
248248
//=========================================================
249-
if (PARAM.inp.nspin == 4)
250-
{
251-
elecstate::cal_ux(ucell);
252-
}
249+
elecstate::cal_ux(ucell);
253250

254251
// Peize Lin add 2016-12-03
255252
#ifdef __EXX // set xc type before the first cal of xc in pelec->init_scf

source/module_esolver/lcao_others.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,7 @@ void ESolver_KS_LCAO<TK, TR>::others(UnitCell& ucell, const int istep)
247247
// cal_ux should be called before init_scf because
248248
// the direction of ux is used in noncoline_rho
249249
//=========================================================
250-
if (PARAM.inp.nspin == 4)
251-
{
252-
elecstate::cal_ux(ucell);
253-
}
250+
elecstate::cal_ux(ucell);
254251

255252
// pelec should be initialized before these calculations
256253
this->pelec->init_scf(istep, this->sf.strucFac, this->ppcell.numeric, ucell.symm);

0 commit comments

Comments
 (0)