|
23 | 23 | #include "module_base/parallel_common.h" |
24 | 24 | #endif |
25 | 25 |
|
| 26 | +// test by jghan |
| 27 | +#include "module_rdmft/rdmft_tools.h" |
| 28 | + |
26 | 29 | namespace ModuleESolver |
27 | 30 | { |
28 | 31 |
|
@@ -381,33 +384,34 @@ namespace ModuleESolver |
381 | 384 | auto iterstart = std::chrono::system_clock::now(); |
382 | 385 | #endif |
383 | 386 |
|
384 | | - ModuleBase::TITLE("RDMFT", "E & Egradient"); |
385 | | - ModuleBase::timer::tick("RDMFT", "E & Egradient"); |
386 | | - if( iter==2 ) // ( iter>=2 && GlobalV::CALCULATION == "rdmft" && ModuleESolver::determine_type() == "ksdft_lcao" ) |
387 | | - { |
388 | | - if( iter==2 ) |
389 | | - { |
390 | | - ModuleBase::matrix occ_number_ks(this->pelec->wg); |
391 | | - for(int ik=0; ik < occ_number_ks.nr; ++ik) |
392 | | - { |
393 | | - for(int inb=0; inb < occ_number_ks.nc; ++inb) occ_number_ks(ik, inb) /= this->kv.wk[ik]; |
394 | | - } |
395 | | - this->update_elec_rdmft(occ_number_ks, *(this->psi)); |
396 | | - } |
397 | | - else |
398 | | - { |
399 | | - // this should update occ_number and wfc in another way when iter>2 |
400 | | - // this->update_elec_rdmft(occ_number, wfc); |
401 | | - } |
402 | | - |
403 | | - // do rdmft calculation |
404 | | - ModuleBase::matrix E_gradient_occNum(this->pelec->wg.nr, this->pelec->wg.nc, true); |
405 | | - psi::Psi<T> E_gradient_wfc(this->psi->get_nk(), this->psi->get_nbands(), this->psi->get_nbasis()); |
406 | | - double Etotal = this->Run_rdmft(E_gradient_occNum, E_gradient_wfc); // add by jghan 2024-03-16 |
| 387 | + // ModuleBase::TITLE("RDMFT", "E & Egradient"); |
| 388 | + // ModuleBase::timer::tick("RDMFT", "E & Egradient"); |
| 389 | + // if( iter==2 ) // ( iter>=2 && GlobalV::CALCULATION == "rdmft" && ModuleESolver::determine_type() == "ksdft_lcao" ) |
| 390 | + // { |
| 391 | + // std::cout << "\n\n\n******\ndo rdmft_esolver.update_elec() successfully\n******\n\n\n" << std::endl; |
| 392 | + // if( iter==2 ) |
| 393 | + // { |
| 394 | + // ModuleBase::matrix occ_number_ks(this->pelec->wg); |
| 395 | + // for(int ik=0; ik < occ_number_ks.nr; ++ik) |
| 396 | + // { |
| 397 | + // for(int inb=0; inb < occ_number_ks.nc; ++inb) occ_number_ks(ik, inb) /= this->kv.wk[ik]; |
| 398 | + // } |
| 399 | + // this->update_elec_rdmft(occ_number_ks, *(this->psi)); |
| 400 | + // } |
| 401 | + // else |
| 402 | + // { |
| 403 | + // // this should update occ_number and wfc in another way when iter>2 |
| 404 | + // // this->update_elec_rdmft(occ_number, wfc); |
| 405 | + // } |
| 406 | + |
| 407 | + // // do rdmft calculation |
| 408 | + // ModuleBase::matrix E_gradient_occNum(this->pelec->wg.nr, this->pelec->wg.nc, true); |
| 409 | + // psi::Psi<T> E_gradient_wfc(this->psi->get_nk(), this->psi->get_nbands(), this->psi->get_nbasis()); |
| 410 | + // double Etotal = this->Run_rdmft(E_gradient_occNum, E_gradient_wfc); // add by jghan 2024-03-16 |
407 | 411 |
|
408 | | - // continue; |
409 | | - } |
410 | | - ModuleBase::timer::tick("RDMFT", "E & Egradient"); |
| 412 | + // // continue; |
| 413 | + // } |
| 414 | + // ModuleBase::timer::tick("RDMFT", "E & Egradient"); |
411 | 415 |
|
412 | 416 |
|
413 | 417 | double diag_ethr = this->phsol->set_diagethr(istep, iter, drho); |
@@ -491,10 +495,61 @@ namespace ModuleESolver |
491 | 495 | SCF print: G1 -3.435545e+03 0.000000e+00 3.607e-01 2.862e-01 |
492 | 496 | */ |
493 | 497 | printiter(iter, drho, duration, diag_ethr); |
| 498 | + |
| 499 | + // // test by jghan for rdmft |
| 500 | + // if(GlobalV::dm_obj_type == "rdmft" && iter==2 && !GlobalC::exx_info.info_global.cal_exx) |
| 501 | + // { |
| 502 | + // this->conv_elec = true; |
| 503 | + // } |
| 504 | + |
494 | 505 | if (this->conv_elec) |
495 | 506 | { |
496 | 507 | this->niter = iter; |
497 | 508 | bool stop = this->do_after_converge(iter); |
| 509 | + |
| 510 | + // bool stop = false; |
| 511 | + // if( GlobalV::dm_obj_type != "rdmft" || GlobalC::exx_info.info_global.cal_exx ) |
| 512 | + // { |
| 513 | + // bool stop = this->do_after_converge(iter); |
| 514 | + // } |
| 515 | + |
| 516 | + // add by jghan 2024-04-08 |
| 517 | + // to get the initial values of wfc and occ_numbers |
| 518 | + if( GlobalV::dm_obj_type == "rdmft" || 1) |
| 519 | + // if( GlobalV::dm_obj_type == "rdmft" || (GlobalV::ESOLVER_TYPE == "dm" && GlobalV::DFT_FUNCTIONAL == "hf") || (GlobalV::ESOLVER_TYPE == "dm" && GlobalV::DFT_FUNCTIONAL == "pbe0") ) |
| 520 | + { |
| 521 | + ModuleBase::matrix occ_number_ks(this->pelec->wg); |
| 522 | + for(int ik=0; ik < occ_number_ks.nr; ++ik) |
| 523 | + { |
| 524 | + for(int inb=0; inb < occ_number_ks.nc; ++inb) occ_number_ks(ik, inb) /= this->kv.wk[ik]; |
| 525 | + } |
| 526 | + this->update_elec_rdmft(occ_number_ks, *(this->psi)); |
| 527 | + |
| 528 | + std::cout << "\n\n\n******\nget the initial values of wfc and occ_numbers successfully\n******\n\n\n" << std::endl; |
| 529 | + |
| 530 | + // // just test |
| 531 | + // ModuleBase::matrix E_gradient_occNum(this->pelec->wg.nr, this->pelec->wg.nc, true); |
| 532 | + // psi::Psi<T> E_gradient_wfc(this->psi->get_nk(), this->psi->get_nbands(), this->psi->get_nbasis()); |
| 533 | + // double E_RDMFT = this->Run_rdmft(E_gradient_occNum, E_gradient_wfc); |
| 534 | + |
| 535 | + // // delete in the future |
| 536 | + // std::cout << "\n\n occ_number(ik, inband): " << std::endl; |
| 537 | + // for(int ik=0; ik < occ_number_ks.nr; ++ik) |
| 538 | + // { |
| 539 | + // for(int inb=0; inb < occ_number_ks.nc; ++inb) std::cout << occ_number_ks(ik, inb) << " "; |
| 540 | + // std::cout << "\n" << std::endl; |
| 541 | + // } |
| 542 | + |
| 543 | + // std::cout << "\n\n wg(ik, inband): " << std::endl; |
| 544 | + // for(int ik=0; ik < occ_number_ks.nr; ++ik) |
| 545 | + // { |
| 546 | + // for(int inb=0; inb < occ_number_ks.nc; ++inb) std::cout << this->pelec->wg(ik, inb) << " "; |
| 547 | + // std::cout << "\n" << std::endl; |
| 548 | + // } |
| 549 | + |
| 550 | + break; |
| 551 | + } |
| 552 | + |
498 | 553 | if(stop) break; |
499 | 554 | } |
500 | 555 | } |
|
0 commit comments