@@ -74,6 +74,7 @@ void LCAO_Deepks::init(
7474 const LCAO_Orbitals& orb,
7575 const int nat,
7676 const int ntype,
77+ const int nks,
7778 const Parallel_Orbitals& pv_in,
7879 std::vector<int > na)
7980{
@@ -97,13 +98,13 @@ void LCAO_Deepks::init(
9798 this ->nmaxd = nm;
9899
99100 GlobalV::ofs_running << " lmax of descriptor = " << this ->lmaxd << std::endl;
100- GlobalV::ofs_running << " nmax of descriptor= " << nmaxd << std::endl;
101+ GlobalV::ofs_running << " nmax of descriptor = " << nmaxd << std::endl;
101102
102103 int pdm_size = 0 ;
103104 this ->inlmax = tot_inl;
104105 if (!PARAM.inp .deepks_equiv )
105106 {
106- GlobalV::ofs_running << " total basis (all atoms) for descriptor= " << std::endl;
107+ GlobalV::ofs_running << " total basis (all atoms) for descriptor = " << std::endl;
107108
108109 // init pdm**
109110 pdm_size = (this ->lmaxd * 2 + 1 ) * (this ->lmaxd * 2 + 1 );
@@ -150,6 +151,15 @@ void LCAO_Deepks::init(
150151 int nloc=this ->pv ->nloc ;
151152 this ->h_mat .resize (nloc,0.0 );
152153 }
154+ else
155+ {
156+ int nloc=this ->pv ->nloc ;
157+ this ->h_mat_k .resize (nks);
158+ for (int ik = 0 ; ik < nks; ik++)
159+ {
160+ this ->h_mat_k [ik].resize (nloc,std::complex <double >(0.0 ,0.0 ));
161+ }
162+ }
153163 }
154164
155165 return ;
@@ -431,27 +441,51 @@ void LCAO_Deepks::del_orbital_pdm_shell(const int nks)
431441
432442void LCAO_Deepks::init_v_delta_pdm_shell (const int nks,const int nlocal)
433443{
434-
435- this ->v_delta_pdm_shell = new double **** [nks];
436-
437444 const int mn_size=(2 * this ->lmaxd + 1 ) * (2 * this ->lmaxd + 1 );
438- for (int iks=0 ; iks<nks; iks++)
439- {
440- this ->v_delta_pdm_shell [iks] = new double *** [nlocal];
445+ if (nks==1 ){
446+ this ->v_delta_pdm_shell = new double **** [nks];
447+ for (int iks=0 ; iks<nks; iks++)
448+ {
449+ this ->v_delta_pdm_shell [iks] = new double *** [nlocal];
441450
442- for (int mu=0 ; mu<nlocal; mu++)
451+ for (int mu=0 ; mu<nlocal; mu++)
452+ {
453+ this ->v_delta_pdm_shell [iks][mu] = new double ** [nlocal];
454+
455+ for (int nu=0 ; nu<nlocal; nu++)
456+ {
457+ this ->v_delta_pdm_shell [iks][mu][nu] = new double * [this ->inlmax ];
458+
459+ for (int inl = 0 ; inl < this ->inlmax ; inl++)
460+ {
461+ this ->v_delta_pdm_shell [iks][mu][nu][inl] = new double [mn_size];
462+ ModuleBase::GlobalFunc::ZEROS (v_delta_pdm_shell[iks][mu][nu][inl], mn_size);
463+ }
464+ }
465+ }
466+ }
467+ }
468+ else
469+ {
470+ this ->v_delta_pdm_shell_complex = new std::complex <double >**** [nks];
471+ for (int iks=0 ; iks<nks; iks++)
443472 {
444- this ->v_delta_pdm_shell [iks][mu] = new double ** [nlocal];
473+ this ->v_delta_pdm_shell_complex [iks] = new std:: complex < double >* ** [nlocal];
445474
446- for (int nu =0 ; nu <nlocal; nu ++)
475+ for (int mu =0 ; mu <nlocal; mu ++)
447476 {
448- this ->v_delta_pdm_shell [iks][mu][nu] = new double * [ this -> inlmax ];
477+ this ->v_delta_pdm_shell_complex [iks][mu] = new std:: complex < double >** [nlocal ];
449478
450- for (int inl = 0 ; inl < this -> inlmax ; inl ++)
479+ for (int nu= 0 ; nu<nlocal; nu ++)
451480 {
452- this ->v_delta_pdm_shell [iks][mu][nu][inl] = new double [mn_size];
453- ModuleBase::GlobalFunc::ZEROS (v_delta_pdm_shell[iks][mu][nu][inl], mn_size);
454- }
481+ this ->v_delta_pdm_shell_complex [iks][mu][nu] = new std::complex <double >* [this ->inlmax ];
482+
483+ for (int inl = 0 ; inl < this ->inlmax ; inl++)
484+ {
485+ this ->v_delta_pdm_shell_complex [iks][mu][nu][inl] = new std::complex <double > [mn_size];
486+ ModuleBase::GlobalFunc::ZEROS (v_delta_pdm_shell_complex[iks][mu][nu][inl], mn_size);
487+ }
488+ }
455489 }
456490 }
457491 }
@@ -461,23 +495,46 @@ void LCAO_Deepks::init_v_delta_pdm_shell(const int nks,const int nlocal)
461495
462496void LCAO_Deepks::del_v_delta_pdm_shell (const int nks,const int nlocal)
463497{
464- for ( int iks= 0 ; iks< nks; iks++ )
498+ if ( nks== 1 )
465499 {
466- for (int mu =0 ; mu<nlocal; mu ++)
500+ for (int iks =0 ; iks<nks; iks ++)
467501 {
468- for (int nu =0 ; nu <nlocal; nu ++)
502+ for (int mu =0 ; mu <nlocal; mu ++)
469503 {
470- for (int inl = 0 ;inl < this -> inlmax ; inl ++)
504+ for (int nu= 0 ; nu<nlocal; nu ++)
471505 {
472- delete[] this ->v_delta_pdm_shell [iks][mu][nu][inl];
506+ for (int inl = 0 ;inl < this ->inlmax ; inl++)
507+ {
508+ delete[] this ->v_delta_pdm_shell [iks][mu][nu][inl];
509+ }
510+ delete[] this ->v_delta_pdm_shell [iks][mu][nu];
511+ }
512+ delete[] this ->v_delta_pdm_shell [iks][mu];
513+ }
514+ delete[] this ->v_delta_pdm_shell [iks];
515+ }
516+ delete[] this ->v_delta_pdm_shell ;
517+ }
518+ else
519+ {
520+ for (int iks=0 ; iks<nks; iks++)
521+ {
522+ for (int mu=0 ; mu<nlocal; mu++)
523+ {
524+ for (int nu=0 ; nu<nlocal; nu++)
525+ {
526+ for (int inl = 0 ;inl < this ->inlmax ; inl++)
527+ {
528+ delete[] this ->v_delta_pdm_shell_complex [iks][mu][nu][inl];
529+ }
530+ delete[] this ->v_delta_pdm_shell_complex [iks][mu][nu];
473531 }
474- delete[] this ->v_delta_pdm_shell [iks][mu][nu];
532+ delete[] this ->v_delta_pdm_shell_complex [iks][mu];
475533 }
476- delete[] this ->v_delta_pdm_shell [iks][mu ];
534+ delete[] this ->v_delta_pdm_shell_complex [iks];
477535 }
478- delete[] this ->v_delta_pdm_shell [iks];
536+ delete[] this ->v_delta_pdm_shell_complex ;
479537 }
480- delete[] this ->v_delta_pdm_shell ;
481538
482539 return ;
483540}
0 commit comments