4
4
#include " module_io/dipole_io.h"
5
5
#include " module_io/dm_io.h"
6
6
#include " module_io/rho_io.h"
7
+ #include " module_io/td_current_io.h"
7
8
#include " module_io/write_HS.h"
8
9
#include " module_io/write_HS_R.h"
9
- #include " module_io/td_current_io.h"
10
10
11
11
// --------------temporary----------------------------
12
12
#include " module_base/blas_connector.h"
@@ -39,7 +39,6 @@ ESolver_KS_LCAO_TDDFT::ESolver_KS_LCAO_TDDFT()
39
39
basisname = " LCAO" ;
40
40
}
41
41
42
-
43
42
ESolver_KS_LCAO_TDDFT::~ESolver_KS_LCAO_TDDFT ()
44
43
{
45
44
// this->orb_con.clear_after_ions(GlobalC::UOT, GlobalC::ORB, GlobalV::deepks_setorb, GlobalC::ucell.infoNL.nproj);
@@ -79,8 +78,8 @@ void ESolver_KS_LCAO_TDDFT::init(Input& inp, UnitCell& ucell)
79
78
this ->pelec = new elecstate::ElecStateLCAO_TDDFT (&(this ->chr ),
80
79
&(kv),
81
80
kv.nks ,
82
- &(this ->LOC ),
83
- &(this ->GK ), // mohan add 2024-04-01
81
+ &(this ->LOC ),
82
+ &(this ->GK ), // mohan add 2024-04-01
84
83
&(this ->LOWF ),
85
84
this ->pw_rho ,
86
85
pw_big);
@@ -105,7 +104,8 @@ void ESolver_KS_LCAO_TDDFT::init(Input& inp, UnitCell& ucell)
105
104
this ->LOC .ParaV = this ->LOWF .ParaV = this ->LM .ParaV ;
106
105
107
106
// init DensityMatrix
108
- dynamic_cast <elecstate::ElecStateLCAO<std::complex<double >>*>(this ->pelec )->init_DM (&kv, this ->LM .ParaV , GlobalV::NSPIN);
107
+ dynamic_cast <elecstate::ElecStateLCAO<std::complex<double >>*>(this ->pelec )
108
+ ->init_DM (&kv, this ->LM .ParaV , GlobalV::NSPIN);
109
109
110
110
// init Psi, HSolver, ElecState, Hamilt
111
111
if (this ->phsol == nullptr )
@@ -130,12 +130,8 @@ void ESolver_KS_LCAO_TDDFT::init(Input& inp, UnitCell& ucell)
130
130
this ->pelec_td = dynamic_cast <elecstate::ElecStateLCAO_TDDFT*>(this ->pelec );
131
131
}
132
132
133
- void ESolver_KS_LCAO_TDDFT::hamilt2density (
134
- int istep,
135
- int iter,
136
- double ethr)
133
+ void ESolver_KS_LCAO_TDDFT::hamilt2density (const int istep, const int iter, const double ethr)
137
134
{
138
-
139
135
pelec->charge ->save_rho_before_sum_band ();
140
136
141
137
if (wf.init_wfc == " file" )
@@ -184,12 +180,8 @@ void ESolver_KS_LCAO_TDDFT::hamilt2density(
184
180
this ->pelec ->f_en .demet = 0.0 ;
185
181
if (this ->psi != nullptr )
186
182
{
187
- this ->phsol ->solve (
188
- this ->p_hamilt ,
189
- this ->psi [0 ],
190
- this ->pelec_td ,
191
- GlobalV::KS_SOLVER);
192
- }
183
+ this ->phsol ->solve (this ->p_hamilt , this ->psi [0 ], this ->pelec_td , GlobalV::KS_SOLVER);
184
+ }
193
185
}
194
186
else
195
187
{
@@ -211,13 +203,9 @@ void ESolver_KS_LCAO_TDDFT::hamilt2density(
211
203
for (int ib = 0 ; ib < GlobalV::NBANDS; ib++)
212
204
{
213
205
std::setprecision (6 );
214
- GlobalV::ofs_running << ik + 1
215
- << " "
216
- << ib + 1
217
- << " "
218
- << this ->pelec_td ->wg (ik, ib)
219
- << std::endl;
220
- }
206
+ GlobalV::ofs_running << ik + 1 << " " << ib + 1 << " " << this ->pelec_td ->wg (ik, ib)
207
+ << std::endl;
208
+ }
221
209
}
222
210
GlobalV::ofs_running << std::endl;
223
211
GlobalV::ofs_running
@@ -239,12 +227,8 @@ void ESolver_KS_LCAO_TDDFT::hamilt2density(
239
227
Symmetry_rho srho;
240
228
for (int is = 0 ; is < GlobalV::NSPIN; is++)
241
229
{
242
- srho.begin (is,
243
- *(pelec->charge ),
244
- pw_rho,
245
- GlobalC::Pgrid,
246
- GlobalC::ucell.symm );
247
- }
230
+ srho.begin (is, *(pelec->charge ), pw_rho, GlobalC::Pgrid, GlobalC::ucell.symm );
231
+ }
248
232
}
249
233
250
234
// (6) compute magnetization, only for spin==2
@@ -280,29 +264,29 @@ void ESolver_KS_LCAO_TDDFT::update_pot(const int istep, const int iter)
280
264
this ->p_hamilt ->matrix (h_mat, s_mat);
281
265
if (hsolver::HSolverLCAO<std::complex<double >>::out_mat_hs[0 ])
282
266
{
283
- ModuleIO::save_mat (istep,
284
- h_mat.p ,
285
- GlobalV::NLOCAL,
286
- bit,
287
- hsolver::HSolverLCAO<std::complex<double >>::out_mat_hs[1 ],
288
- 1 ,
289
- GlobalV::out_app_flag,
290
- " H" ,
291
- " data-" + std::to_string (ik),
292
- *this ->LOWF .ParaV ,
293
- GlobalV::DRANK);
294
-
295
- ModuleIO::save_mat (istep,
296
- h_mat .p ,
297
- GlobalV::NLOCAL,
298
- bit,
299
- hsolver::HSolverLCAO<std::complex<double >>::out_mat_hs[1 ],
300
- 1 ,
301
- GlobalV::out_app_flag,
302
- " S" ,
303
- " data-" + std::to_string (ik),
304
- *this ->LOWF .ParaV ,
305
- GlobalV::DRANK);
267
+ ModuleIO::save_mat (istep,
268
+ h_mat.p ,
269
+ GlobalV::NLOCAL,
270
+ bit,
271
+ hsolver::HSolverLCAO<std::complex<double >>::out_mat_hs[1 ],
272
+ 1 ,
273
+ GlobalV::out_app_flag,
274
+ " H" ,
275
+ " data-" + std::to_string (ik),
276
+ *this ->LOWF .ParaV ,
277
+ GlobalV::DRANK);
278
+
279
+ ModuleIO::save_mat (istep,
280
+ s_mat .p ,
281
+ GlobalV::NLOCAL,
282
+ bit,
283
+ hsolver::HSolverLCAO<std::complex<double >>::out_mat_hs[1 ],
284
+ 1 ,
285
+ GlobalV::out_app_flag,
286
+ " S" ,
287
+ " data-" + std::to_string (ik),
288
+ *this ->LOWF .ParaV ,
289
+ GlobalV::DRANK);
306
290
}
307
291
}
308
292
}
@@ -313,14 +297,14 @@ void ESolver_KS_LCAO_TDDFT::update_pot(const int istep, const int iter)
313
297
if (elecstate::ElecStateLCAO<std::complex<double >>::out_wfc_lcao)
314
298
{
315
299
elecstate::ElecStateLCAO<std::complex<double >>::out_wfc_flag
316
- = elecstate::ElecStateLCAO<std::complex<double >>::out_wfc_lcao;
300
+ = elecstate::ElecStateLCAO<std::complex<double >>::out_wfc_lcao;
317
301
}
318
302
for (int ik = 0 ; ik < kv.nks ; ik++)
319
303
{
320
304
if (istep % GlobalV::out_interval == 0 )
321
305
{
322
- this ->psi [0 ].fix_k (ik);
323
- this ->pelec ->print_psi (this ->psi [0 ], istep);
306
+ this ->psi [0 ].fix_k (ik);
307
+ this ->pelec ->print_psi (this ->psi [0 ], istep);
324
308
}
325
309
}
326
310
elecstate::ElecStateLCAO<std::complex<double >>::out_wfc_flag = 0 ;
@@ -329,11 +313,11 @@ void ESolver_KS_LCAO_TDDFT::update_pot(const int istep, const int iter)
329
313
// Calculate new potential according to new Charge Density
330
314
if (!this ->conv_elec )
331
315
{
332
- if (GlobalV::NSPIN == 4 )
333
- {
334
- GlobalC::ucell.cal_ux ();
335
- }
336
- this ->pelec ->pot ->update_from_charge (this ->pelec ->charge , &GlobalC::ucell);
316
+ if (GlobalV::NSPIN == 4 )
317
+ {
318
+ GlobalC::ucell.cal_ux ();
319
+ }
320
+ this ->pelec ->pot ->update_from_charge (this ->pelec ->charge , &GlobalC::ucell);
337
321
this ->pelec ->f_en .descf = this ->pelec ->cal_delta_escf ();
338
322
}
339
323
else
@@ -344,19 +328,19 @@ void ESolver_KS_LCAO_TDDFT::update_pot(const int istep, const int iter)
344
328
// store wfc and Hk laststep
345
329
if (istep >= (wf.init_wfc == " file" ? 0 : 1 ) && this ->conv_elec )
346
330
{
347
- if (this ->psi_laststep == nullptr )
348
- {
331
+ if (this ->psi_laststep == nullptr )
332
+ {
349
333
#ifdef __MPI
350
- this ->psi_laststep = new psi::Psi<std::complex<double >>(kv.nks ,
351
- this ->LOWF .ParaV ->ncol_bands ,
352
- this ->LOWF .ParaV ->nrow ,
353
- nullptr );
334
+ this ->psi_laststep = new psi::Psi<std::complex<double >>(kv.nks ,
335
+ this ->LOWF .ParaV ->ncol_bands ,
336
+ this ->LOWF .ParaV ->nrow ,
337
+ nullptr );
354
338
#else
355
- this ->psi_laststep = new psi::Psi<std::complex<double >>(kv.nks , GlobalV::NBANDS, GlobalV::NLOCAL, nullptr );
339
+ this ->psi_laststep = new psi::Psi<std::complex<double >>(kv.nks , GlobalV::NBANDS, GlobalV::NLOCAL, nullptr );
356
340
#endif
357
- }
341
+ }
358
342
359
- if (td_htype == 1 )
343
+ if (td_htype == 1 )
360
344
{
361
345
if (this ->Hk_laststep == nullptr )
362
346
{
@@ -383,10 +367,10 @@ void ESolver_KS_LCAO_TDDFT::update_pot(const int istep, const int iter)
383
367
this ->psi ->fix_k (ik);
384
368
this ->psi_laststep ->fix_k (ik);
385
369
int size0 = psi->get_nbands () * psi->get_nbasis ();
386
- for (int index = 0 ; index < size0; ++index )
387
- {
388
- psi_laststep[0 ].get_pointer ()[index ] = psi[0 ].get_pointer ()[index ];
389
- }
370
+ for (int index = 0 ; index < size0; ++index )
371
+ {
372
+ psi_laststep[0 ].get_pointer ()[index ] = psi[0 ].get_pointer ()[index ];
373
+ }
390
374
391
375
// store Hamiltonian
392
376
if (td_htype == 1 )
@@ -400,9 +384,8 @@ void ESolver_KS_LCAO_TDDFT::update_pot(const int istep, const int iter)
400
384
}
401
385
402
386
// calculate energy density matrix for tddft
403
- if (istep >= (wf.init_wfc == " file" ? 0 : 2 )
404
- && module_tddft::Evolve_elec::td_edm == 0 )
405
- {
387
+ if (istep >= (wf.init_wfc == " file" ? 0 : 2 ) && module_tddft::Evolve_elec::td_edm == 0 )
388
+ {
406
389
this ->cal_edm_tddft ();
407
390
}
408
391
}
@@ -433,7 +416,6 @@ void ESolver_KS_LCAO_TDDFT::update_pot(const int istep, const int iter)
433
416
}
434
417
}
435
418
436
-
437
419
void ESolver_KS_LCAO_TDDFT::after_scf (const int istep)
438
420
{
439
421
for (int is = 0 ; is < GlobalV::NSPIN; is++)
@@ -445,42 +427,41 @@ void ESolver_KS_LCAO_TDDFT::after_scf(const int istep)
445
427
ModuleIO::write_dipole (pelec->charge ->rho_save [is], pelec->charge ->rhopw , is, istep, ss_dipole.str ());
446
428
}
447
429
}
448
- if (module_tddft::Evolve_elec::out_current == 1 )
430
+ if (module_tddft::Evolve_elec::out_current == 1 )
449
431
{
450
- elecstate::DensityMatrix<std::complex<double >, double >* tmp_DM =
451
- dynamic_cast <elecstate::ElecStateLCAO<std::complex<double >>*>(this ->pelec )->get_DM ();
432
+ elecstate::DensityMatrix<std::complex<double >, double >* tmp_DM
433
+ = dynamic_cast <elecstate::ElecStateLCAO<std::complex<double >>*>(this ->pelec )->get_DM ();
452
434
ModuleIO::write_current (istep,
453
- this ->psi ,
454
- pelec,
455
- kv,
456
- tmp_DM->get_paraV_pointer (),
457
- this ->RA ,
458
- this ->LM , // mohan add 2024-04-02
459
- this ->gen_h ); // mohan add 2024-02
460
- }
435
+ this ->psi ,
436
+ pelec,
437
+ kv,
438
+ tmp_DM->get_paraV_pointer (),
439
+ this ->RA ,
440
+ this ->LM , // mohan add 2024-04-02
441
+ this ->gen_h ); // mohan add 2024-02
442
+ }
461
443
ESolver_KS_LCAO<std::complex<double >, double >::after_scf (istep);
462
444
}
463
445
464
-
465
446
// use the original formula (Hamiltonian matrix) to calculate energy density matrix
466
447
void ESolver_KS_LCAO_TDDFT::cal_edm_tddft (void )
467
448
{
468
449
// mohan add 2024-03-27
469
- const int nlocal = GlobalV::NLOCAL;
470
- assert (nlocal>= 0 );
450
+ const int nlocal = GlobalV::NLOCAL;
451
+ assert (nlocal >= 0 );
471
452
472
- // this->LOC.edm_k_tddft.resize(kv.nks);
453
+ // this->LOC.edm_k_tddft.resize(kv.nks);
473
454
dynamic_cast <elecstate::ElecStateLCAO<std::complex<double >>*>(this ->pelec )->get_DM ()->EDMK .resize (kv.nks );
474
455
for (int ik = 0 ; ik < kv.nks ; ++ik)
475
456
{
476
- std::complex<double >* tmp_dmk =
477
- dynamic_cast <elecstate::ElecStateLCAO<std::complex<double >>*>(this ->pelec )->get_DM ()->get_DMK_pointer (ik);
457
+ std::complex<double >* tmp_dmk
458
+ = dynamic_cast <elecstate::ElecStateLCAO<std::complex<double >>*>(this ->pelec )->get_DM ()->get_DMK_pointer (ik);
478
459
479
- ModuleBase::ComplexMatrix& tmp_edmk =
480
- dynamic_cast <elecstate::ElecStateLCAO<std::complex<double >>*>(this ->pelec )->get_DM ()->EDMK [ik];
460
+ ModuleBase::ComplexMatrix& tmp_edmk
461
+ = dynamic_cast <elecstate::ElecStateLCAO<std::complex<double >>*>(this ->pelec )->get_DM ()->EDMK [ik];
481
462
482
- const Parallel_Orbitals* tmp_pv =
483
- dynamic_cast <elecstate::ElecStateLCAO<std::complex<double >>*>(this ->pelec )->get_DM ()->get_paraV_pointer ();
463
+ const Parallel_Orbitals* tmp_pv
464
+ = dynamic_cast <elecstate::ElecStateLCAO<std::complex<double >>*>(this ->pelec )->get_DM ()->get_paraV_pointer ();
484
465
485
466
#ifdef __MPI
486
467
@@ -489,7 +470,7 @@ void ESolver_KS_LCAO_TDDFT::cal_edm_tddft(void)
489
470
// ! whether the long type is safe, needs more discussion
490
471
const long nloc = this ->LOC .ParaV ->nloc ;
491
472
492
- // this->LOC.edm_k_tddft[ik].create(this->LOC.ParaV->ncol, this->LOC.ParaV->nrow);
473
+ // this->LOC.edm_k_tddft[ik].create(this->LOC.ParaV->ncol, this->LOC.ParaV->nrow);
493
474
tmp_edmk.create (this ->LOC .ParaV ->ncol , this ->LOC .ParaV ->nrow );
494
475
complex<double >* Htmp = new complex<double >[nloc];
495
476
complex<double >* Sinv = new complex<double >[nloc];
@@ -651,7 +632,7 @@ void ESolver_KS_LCAO_TDDFT::cal_edm_tddft(void)
651
632
&one_int,
652
633
this ->LOC .ParaV ->desc );
653
634
zcopy_ (&nloc, tmp4, &inc, tmp_edmk.c , &inc);
654
- // zcopy_(&nloc, tmp4, &inc, this->LOC.edm_k_tddft[ik].c, &inc);
635
+ // zcopy_(&nloc, tmp4, &inc, this->LOC.edm_k_tddft[ik].c, &inc);
655
636
delete[] Htmp;
656
637
delete[] Sinv;
657
638
delete[] tmp1;
@@ -661,7 +642,7 @@ void ESolver_KS_LCAO_TDDFT::cal_edm_tddft(void)
661
642
delete[] ipiv;
662
643
#else
663
644
// for serial version
664
- // this->LOC.edm_k_tddft[ik].create(this->LOC.ParaV->ncol, this->LOC.ParaV->nrow);
645
+ // this->LOC.edm_k_tddft[ik].create(this->LOC.ParaV->ncol, this->LOC.ParaV->nrow);
665
646
tmp_edmk.create (this ->LOC .ParaV ->ncol , this ->LOC .ParaV ->nrow );
666
647
ModuleBase::ComplexMatrix Sinv (nlocal, nlocal);
667
648
ModuleBase::ComplexMatrix Htmp (nlocal, nlocal);
@@ -679,7 +660,7 @@ void ESolver_KS_LCAO_TDDFT::cal_edm_tddft(void)
679
660
Sinv (i, j) = s_mat.p [i * nlocal + j];
680
661
}
681
662
}
682
- int INFO= 0 ;
663
+ int INFO = 0 ;
683
664
684
665
int lwork = 3 * nlocal - 1 ; // tmp
685
666
std::complex<double >* work = new std::complex<double >[lwork];
0 commit comments