|
2 | 2 | #include <vector> |
3 | 3 |
|
4 | 4 | #define private public |
5 | | -#include "module_parameter/parameter.h" |
6 | 5 | #include "module_elecstate/potentials/potential_new.h" |
7 | | -#undef private |
| 6 | +#include "module_hamilt_general/module_xc/xc_functional.h" |
| 7 | +#include "module_parameter/parameter.h" |
8 | 8 | // mock functions |
9 | 9 | Structure_Factor::Structure_Factor() |
10 | 10 | { |
@@ -44,14 +44,10 @@ surchem::surchem() |
44 | 44 | surchem::~surchem() |
45 | 45 | { |
46 | 46 | } |
47 | | - |
| 47 | +int XC_Functional::func_type = 1; |
| 48 | +bool XC_Functional::has_kedf = false; |
48 | 49 | namespace elecstate |
49 | 50 | { |
50 | | -int tmp_xc_func_type = 1; |
51 | | -int XC_Functional::get_func_type() |
52 | | -{ |
53 | | - return tmp_xc_func_type; |
54 | | -} |
55 | 51 |
|
56 | 52 | PotBase* Potential::get_pot_type(const std::string& pot_type) |
57 | 53 | { |
@@ -197,7 +193,8 @@ TEST_F(PotentialNewTest, ConstructorNRXX0) |
197 | 193 |
|
198 | 194 | TEST_F(PotentialNewTest, ConstructorXC3) |
199 | 195 | { |
200 | | - elecstate::tmp_xc_func_type = 3; |
| 196 | + XC_Functional::func_type = 3; |
| 197 | + XC_Functional::has_kedf = true; |
201 | 198 | rhopw->nrxx = 100; |
202 | 199 | pot = new elecstate::Potential(rhopw, rhopw, ucell, vloc, structure_factors, solvent, etxc, vtxc); |
203 | 200 | EXPECT_TRUE(pot->fixed_mode); |
@@ -463,7 +460,8 @@ TEST_F(PotentialNewTest, GetEffectiveVarrayNullptr) |
463 | 460 | TEST_F(PotentialNewTest, GetEffectiveVofkmatrix) |
464 | 461 | { |
465 | 462 | // construct potential |
466 | | - elecstate::tmp_xc_func_type = 3; |
| 463 | + XC_Functional::func_type = 3; |
| 464 | + XC_Functional::has_kedf = true; |
467 | 465 | rhopw->nrxx = 100; |
468 | 466 | pot = new elecstate::Potential(rhopw, rhopw, ucell, vloc, structure_factors, solvent, etxc, vtxc); |
469 | 467 | // |
@@ -532,7 +530,8 @@ TEST_F(PotentialNewTest, GetVeffSmooth) |
532 | 530 | { |
533 | 531 | // construct potential |
534 | 532 | rhopw->nrxx = 100; |
535 | | - elecstate::tmp_xc_func_type = 3; |
| 533 | + XC_Functional::func_type = 3; |
| 534 | + XC_Functional::has_kedf = true; |
536 | 535 | pot = new elecstate::Potential(rhopw, rhopw, ucell, vloc, structure_factors, solvent, etxc, vtxc); |
537 | 536 | // |
538 | 537 | ModuleBase::matrix veff_smooth_tmp = pot->get_veff_smooth(); |
@@ -576,28 +575,29 @@ TEST_F(PotentialNewTest, GetVofkSmooth) |
576 | 575 | TEST_F(PotentialNewTest, InterpolateVrsDoubleGrids) |
577 | 576 | { |
578 | 577 | PARAM.sys.double_grid = true; |
579 | | - elecstate::tmp_xc_func_type = 3; |
580 | | - // Init pw_basis |
581 | | - rhopw->initgrids(4, ModuleBase::Matrix3(1, 0, 0, 0, 1, 0, 0, 0, 1), 4); |
582 | | - rhopw->initparameters(false, 4); |
583 | | - rhopw->setuptransform(); |
584 | | - rhopw->collect_local_pw(); |
585 | | - |
586 | | - rhodpw->initgrids(4, ModuleBase::Matrix3(1, 0, 0, 0, 1, 0, 0, 0, 1), 6); |
587 | | - rhodpw->initparameters(false, 6); |
588 | | - static_cast<ModulePW::PW_Basis_Sup*>(rhodpw)->setuptransform(rhopw); |
589 | | - rhodpw->collect_local_pw(); |
590 | | - |
591 | | - pot = new elecstate::Potential(rhodpw, rhopw, ucell, vloc, structure_factors, solvent, etxc, vtxc); |
592 | | - |
593 | | - for (int ir = 0; ir < pot->v_effective.nr; ir++) |
594 | | - { |
595 | | - for (int ic = 0; ic < pot->v_effective.nc; ic++) |
596 | | - { |
597 | | - pot->v_effective(ir,ic) = ir+ic; |
598 | | - pot->vofk_effective(ir,ic) = ir+2*ic; |
599 | | - } |
600 | | - } |
| 578 | + XC_Functional::func_type = 3; |
| 579 | + XC_Functional::has_kedf = true; |
| 580 | + // Init pw_basis |
| 581 | + rhopw->initgrids(4, ModuleBase::Matrix3(1, 0, 0, 0, 1, 0, 0, 0, 1), 4); |
| 582 | + rhopw->initparameters(false, 4); |
| 583 | + rhopw->setuptransform(); |
| 584 | + rhopw->collect_local_pw(); |
| 585 | + |
| 586 | + rhodpw->initgrids(4, ModuleBase::Matrix3(1, 0, 0, 0, 1, 0, 0, 0, 1), 6); |
| 587 | + rhodpw->initparameters(false, 6); |
| 588 | + static_cast<ModulePW::PW_Basis_Sup*>(rhodpw)->setuptransform(rhopw); |
| 589 | + rhodpw->collect_local_pw(); |
| 590 | + |
| 591 | + pot = new elecstate::Potential(rhodpw, rhopw, ucell, vloc, structure_factors, solvent, etxc, vtxc); |
| 592 | + |
| 593 | + for (int ir = 0; ir < pot->v_effective.nr; ir++) |
| 594 | + { |
| 595 | + for (int ic = 0; ic < pot->v_effective.nc; ic++) |
| 596 | + { |
| 597 | + pot->v_effective(ir, ic) = ir + ic; |
| 598 | + pot->vofk_effective(ir, ic) = ir + 2 * ic; |
| 599 | + } |
| 600 | + } |
601 | 601 |
|
602 | 602 | pot->interpolate_vrs(); |
603 | 603 |
|
@@ -641,23 +641,24 @@ TEST_F(PotentialNewTest, InterpolateVrsWarningQuit) |
641 | 641 | TEST_F(PotentialNewTest, InterpolateVrsSingleGrids) |
642 | 642 | { |
643 | 643 | PARAM.sys.double_grid = false; |
644 | | - elecstate::tmp_xc_func_type = 3; |
645 | | - // Init pw_basis |
646 | | - rhopw->initgrids(4, ModuleBase::Matrix3(1, 0, 0, 0, 1, 0, 0, 0, 1), 4); |
647 | | - rhopw->initparameters(false, 4); |
648 | | - rhopw->setuptransform(); |
649 | | - rhopw->collect_local_pw(); |
650 | | - |
651 | | - pot = new elecstate::Potential(rhopw, rhopw, ucell, vloc, structure_factors, solvent, etxc, vtxc); |
652 | | - |
653 | | - for (int ir = 0; ir < pot->v_effective.nr; ir++) |
654 | | - { |
655 | | - for (int ic = 0; ic < pot->v_effective.nc; ic++) |
656 | | - { |
657 | | - pot->v_effective(ir,ic) = ir+ic; |
658 | | - pot->vofk_effective(ir,ic) = ir+2*ic; |
659 | | - } |
660 | | - } |
| 644 | + XC_Functional::func_type = 3; |
| 645 | + XC_Functional::has_kedf = true; |
| 646 | + // Init pw_basis |
| 647 | + rhopw->initgrids(4, ModuleBase::Matrix3(1, 0, 0, 0, 1, 0, 0, 0, 1), 4); |
| 648 | + rhopw->initparameters(false, 4); |
| 649 | + rhopw->setuptransform(); |
| 650 | + rhopw->collect_local_pw(); |
| 651 | + |
| 652 | + pot = new elecstate::Potential(rhopw, rhopw, ucell, vloc, structure_factors, solvent, etxc, vtxc); |
| 653 | + |
| 654 | + for (int ir = 0; ir < pot->v_effective.nr; ir++) |
| 655 | + { |
| 656 | + for (int ic = 0; ic < pot->v_effective.nc; ic++) |
| 657 | + { |
| 658 | + pot->v_effective(ir, ic) = ir + ic; |
| 659 | + pot->vofk_effective(ir, ic) = ir + 2 * ic; |
| 660 | + } |
| 661 | + } |
661 | 662 |
|
662 | 663 | pot->interpolate_vrs(); |
663 | 664 |
|
|
0 commit comments