Skip to content

Commit

Permalink
Merge pull request #818 from dyzheng/new
Browse files Browse the repository at this point in the history
fix : support both element magnetization and atomic magnetization for initial setting in STRU file
  • Loading branch information
dyzheng authored Apr 6, 2022
2 parents 99eb436 + 7791c4f commit 0e74934
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 8 deletions.
3 changes: 1 addition & 2 deletions source/module_cell/read_atoms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ bool UnitCell_pseudo::read_atom_positions(std::ifstream &ifpos, std::ofstream &o
mv.z = true ;
atoms[it].vel[ia].set(0,0,0);
#ifndef __CMD
//atoms[it].mag[ia]=magnet.start_magnetization[it];//if this line is used, default startmag_type would be 2
atoms[it].mag[ia]=magnet.start_magnetization[it];//if this line is used, default startmag_type would be 2
#endif
atoms[it].angle1[ia]=0;
atoms[it].angle2[ia]=0;
Expand Down Expand Up @@ -633,7 +633,6 @@ bool UnitCell_pseudo::read_atom_positions(std::ifstream &ifpos, std::ofstream &o
tmp=ifpos.get();
}

cout<<"tmp"<<tmp<<'\n';
if((tmp >= 48 && tmp <= 57) or tmp=='-')
{
ifpos.putback(tmp);
Expand Down
10 changes: 4 additions & 6 deletions source/src_pw/charge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,11 @@ void Charge::atomic_rho(const int spin_number_need, double** rho_in)const // Pe
// check the start magnetization
const int startmag_type = [&]()->int
{
if(GlobalV::NSPIN==4) //zhengdy-soc, type 2 is still wrong.
return 1;
for(int it=0; it<GlobalC::ucell.ntype; it++)
for(int ia=0; ia<GlobalC::ucell.atoms[it].na; ia++)
if(GlobalC::ucell.atoms[it].mag[ia]!=0.0)
return 2;
return 1;
{
if( GlobalC::ucell.magnet.start_magnetization[it] != 0.0) return 1;
}
return 2;
}();
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_warning,"startmag_type",startmag_type);

Expand Down
1 change: 1 addition & 0 deletions tests/integrate/304_NO_GO_AF/jd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test for initial magnetization from elements, anti-ferromagnetic Fe2, LCAO
34 changes: 34 additions & 0 deletions tests/integrate/304_NO_GO_AF_atommag/INPUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
INPUT_PARAMETERS
suffix autotest
ntype 2
#nbands 40

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.02

#cal_force 1
#force_thr_ev 0.01
#relax_method cg
#relax_bfgs_init 0.5

mixing_type pulay
mixing_beta 0.4


ks_solver genelpa
basis_type lcao
gamma_only 1
symmetry 0
nspin 2

4 changes: 4 additions & 0 deletions tests/integrate/304_NO_GO_AF_atommag/KPT
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
K_POINTS
0
Gamma
1 1 1 0 0 0
29 changes: 29 additions & 0 deletions tests/integrate/304_NO_GO_AF_atommag/STRU
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ATOMIC_SPECIES
Fe1 1.000 ../tools/PP_ORB/Fe_ONCV_PBE-1.0.upf
Fe2 1.000 ../tools/PP_ORB/Fe_ONCV_PBE-1.0.upf

NUMERICAL_ORBITAL
../tools/PP_ORB/Fe_gga_9au_100Ry_4s2p2d1f.orb
../tools/PP_ORB/Fe_gga_9au_100Ry_4s2p2d1f.orb

LATTICE_CONSTANT
15

LATTICE_VECTORS
1.00 0.50 0.50
0.50 1.00 0.50
0.50 0.50 1.00
ATOMIC_POSITIONS
Direct

Fe1
0.0
1
0.00 0.00 0.00 1 1 1 mag 1.0

Fe2
0.0
1
0.50 0.50 0.50 1 1 1 mag -1.0


1 change: 1 addition & 0 deletions tests/integrate/304_NO_GO_AF_atommag/jd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test for initial magnetization from atoms, anti-ferromagnetic Fe2, LCAO
3 changes: 3 additions & 0 deletions tests/integrate/304_NO_GO_AF_atommag/result.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
etotref -6372.520190217967
etotperatomref -3186.2600951090
totaltimeref 12.081
1 change: 1 addition & 0 deletions tests/integrate/CASES
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
301_NO_GO_DJ_Si
#303_NO_GO_HP_15
304_NO_GO_AF
304_NO_GO_AF_atommag
304_NO_GO_FM
307_NO_GO_OH
308_NO_GO_CF_RE
Expand Down

0 comments on commit 0e74934

Please sign in to comment.