@@ -24,13 +24,6 @@ LCAO_gen_fixedH::~LCAO_gen_fixedH()
2424void LCAO_gen_fixedH::calculate_NL_no (double * HlocR)
2525{
2626 ModuleBase::TITLE (" LCAO_gen_fixedH" ," calculate_NL_no" );
27- if (GlobalV::NSPIN==4 )
28- {
29- this ->build_Nonlocal_mu (HlocR, false );
30- return ;
31- // ModuleBase::WARNING_QUIT("LCAO_gen_fixedH::calculate_NL_no","noncollinear case shoule be complex<double>* type");
32- }
33-
3427 if (GlobalV::GAMMA_ONLY_LOCAL)
3528 {
3629 // for gamma only.
@@ -64,16 +57,6 @@ void LCAO_gen_fixedH::calculate_NL_no(double* HlocR)
6457 return ;
6558}
6659
67- /* void LCAO_gen_fixedH::calculate_NL_no(std::complex<double>* HlocR)
68- {
69- ModuleBase::TITLE("LCAO_gen_fixedH","calculate_NL_no");
70- if(GlobalV::NSPIN!=4) ModuleBase::WARNING_QUIT("LCAO_gen_fixedH::calculate_NL_no","complex<double>* type shoule be noncollinear case");
71-
72- this->build_Nonlocal_mu(HlocR, false);
73-
74- return;
75- }*/
76-
7760void LCAO_gen_fixedH::calculate_T_no (double * HlocR)
7861{
7962 ModuleBase::TITLE (" LCAO_gen_fixedH" ," calculate_T_no" );
@@ -733,39 +716,51 @@ void LCAO_gen_fixedH::build_Nonlocal_mu_new(double* NLloc, const bool &calc_deri
733716 {
734717 std::vector<double > nlm_1=(*nlm_cur1_e)[iw1_all];
735718 std::vector<double > nlm_2=(*nlm_cur2_e)[iw2_all];
736- double nlm_tmp = 0.0 ;
737-
738- const int nproj = GlobalC::ucell.infoNL .nproj [T0];
739- int ib = 0 ;
740- for (int nb = 0 ; nb < nproj; nb++)
719+ if (GlobalV::NSPIN==4 )
741720 {
742- const int L0 = GlobalC::ucell.infoNL .Beta [T0].Proj [nb].getL ();
743- for (int m=0 ;m<2 *L0+1 ;m++)
721+ std::complex <double > nlm_tmp = ModuleBase::ZERO;
722+ int is0 = (j-j0*GlobalV::NPOL) + (k-k0*GlobalV::NPOL)*2 ;
723+ for (int no = 0 ; no < GlobalC::ucell.atoms [T0].non_zero_count_soc [is0]; no++)
744724 {
745- if (nlm_1[ib]!=0.0 && nlm_2[ib]!=0.0 )
725+ const int p1 = GlobalC::ucell.atoms [T0].index1_soc [is0][no];
726+ const int p2 = GlobalC::ucell.atoms [T0].index2_soc [is0][no];
727+ nlm_tmp += nlm_1[p1] * nlm_2[p2] * GlobalC::ucell.atoms [T0].d_so (is0, p2, p1);
728+ }
729+ this ->LM ->Hloc_fixedR_soc [nnr+nnr_inner] += nlm_tmp;
730+ }
731+ else
732+ {
733+ double nlm_tmp = 0.0 ;
734+ const int nproj = GlobalC::ucell.infoNL .nproj [T0];
735+ int ib = 0 ;
736+ for (int nb = 0 ; nb < nproj; nb++)
737+ {
738+ const int L0 = GlobalC::ucell.infoNL .Beta [T0].Proj [nb].getL ();
739+ for (int m=0 ;m<2 *L0+1 ;m++)
746740 {
747- nlm_tmp += nlm_1[ib]*nlm_2[ib]*GlobalC::ucell.atoms [T0].dion (nb,nb);
741+ if (nlm_1[ib]!=0.0 && nlm_2[ib]!=0.0 )
742+ {
743+ nlm_tmp += nlm_1[ib]*nlm_2[ib]*GlobalC::ucell.atoms [T0].dion (nb,nb);
744+ }
745+ ib+=1 ;
748746 }
749- ib+=1 ;
750747 }
751- }
752- assert (ib==nlm_1.size ());
748+ assert (ib==nlm_1.size ());
753749
754- if (GlobalV::GAMMA_ONLY_LOCAL)
755- {
756- // mohan add 2010-12-20
757- if ( nlm_tmp!=0.0 )
750+ if (GlobalV::GAMMA_ONLY_LOCAL)
758751 {
759- // GlobalV::ofs_running << std::setw(10) << iw1_all << std::setw(10)
760- // << iw2_all << std::setw(20) << nlm[0] << std::endl;
761- this ->LM ->set_HSgamma (iw1_all,iw2_all,nlm_tmp,' N' , NLloc);// N stands for nonlocal.
752+ // mohan add 2010-12-20
753+ if ( nlm_tmp!=0.0 )
754+ {
755+ this ->LM ->set_HSgamma (iw1_all,iw2_all,nlm_tmp,' N' , NLloc);// N stands for nonlocal.
756+ }
762757 }
763- }
764- else
765- {
766- if ( nlm_tmp!=0.0 )
758+ else
767759 {
768- NLloc[nnr+nnr_inner] += nlm_tmp;
760+ if ( nlm_tmp!=0.0 )
761+ {
762+ NLloc[nnr+nnr_inner] += nlm_tmp;
763+ }
769764 }
770765 }
771766 }// calc_deri
@@ -874,12 +869,10 @@ void LCAO_gen_fixedH::build_Nonlocal_mu_new(double* NLloc, const bool &calc_deri
874869
875870 if (!GlobalV::GAMMA_ONLY_LOCAL)
876871 {
877- // std::cout << " nr=" << nnr << std::endl;
878- // std::cout << " pv->nnr=" << pv->nnr << std::endl;
879- // GlobalV::ofs_running << " nr=" << nnr << std::endl;
880- // GlobalV::ofs_running << " pv->nnr=" << pv->nnr << std::endl;
881872 if ( nnr!=pv->nnr )
882873 {
874+ GlobalV::ofs_running << " nr=" << nnr << std::endl;
875+ GlobalV::ofs_running << " pv->nnr=" << pv->nnr << std::endl;
883876 ModuleBase::WARNING_QUIT (" LCAO_gen_fixedH::build_Nonlocal_mu_new" ," nnr!=LNNR.nnr" );
884877 }
885878 }
@@ -1025,6 +1018,13 @@ void LCAO_gen_fixedH::build_Nonlocal_mu(double* NLloc, const bool &calc_deri)
10251018 if (!calc_deri)
10261019 {
10271020 int is0 = (j-j0*GlobalV::NPOL) + (k-k0*GlobalV::NPOL)*2 ;
1021+ // Note : there was a bug in the old implementation
1022+ // of soc nonlocal PP, which does not seem to affect the
1023+ // converged results though.
1024+ // However, there is a discrepancy in the integrate test case
1025+ // 240*soc, when checked against the new method.
1026+ // The origin of the bug is the mismatch between the indexes
1027+ // of <psi|beta> and d_so
10281028 GlobalC::UOT.snap_psibeta (
10291029 GlobalC::ORB,
10301030 GlobalC::ucell.infoNL ,
0 commit comments