Skip to content

Commit 5a0ab6d

Browse files
committed
Fix Agent Governance check
1 parent 4fefedb commit 5a0ab6d

5 files changed

Lines changed: 17 additions & 183 deletions

File tree

source/source_estate/test/elecstate_base_test.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ void Charge::check_rho()
9595
* unit test of elecstate.cpp
9696
***********************************************/
9797

98+
namespace
99+
{
100+
constexpr int GLOBAL_NBANDS = 6;
101+
}
102+
98103
/**
99104
* - Tested Functions:
100105
* - InitNelecSpin: elecstate::ElecState::init_nelec_spin()
@@ -129,7 +134,7 @@ class MockElecState : public ElecState
129134
PARAM.input.nelec = 10.0;
130135
PARAM.input.nupdown = 0.0;
131136
PARAM.sys.two_fermi = false;
132-
PARAM.input.nbands = 6;
137+
PARAM.input.nbands = GLOBAL_NBANDS;
133138
PARAM.sys.nbands_l = 6;
134139
PARAM.sys.nlocal = 6;
135140
PARAM.input.esolver_type = "ksdft";
@@ -342,7 +347,7 @@ TEST_F(ElecStateTest, CalculateWeightsSkipWeights)
342347
elecstate->eferm,
343348
elecstate->f_en,
344349
elecstate->nelec_spin,
345-
PARAM.input.nbands,
350+
GLOBAL_NBANDS,
346351
elecstate->skip_weights));
347352
}
348353

@@ -356,7 +361,7 @@ TEST_F(ElecStateDeathTest, CalculateWeightsFixedOccupations)
356361
elecstate->eferm,
357362
elecstate->f_en,
358363
elecstate->nelec_spin,
359-
PARAM.input.nbands,
364+
GLOBAL_NBANDS,
360365
elecstate->skip_weights),
361366
::testing::ExitedWithCode(1),
362367
"");
@@ -398,7 +403,7 @@ TEST_F(ElecStateTest, CalculateWeightsIWeights)
398403
elecstate->eferm,
399404
elecstate->f_en,
400405
elecstate->nelec_spin,
401-
PARAM.input.nbands,
406+
GLOBAL_NBANDS,
402407
elecstate->skip_weights);
403408
EXPECT_DOUBLE_EQ(elecstate->wg(0, 0), 2.0);
404409
EXPECT_DOUBLE_EQ(elecstate->wg(nks - 1, PARAM.input.nelec / 2 - 1), 2.0);
@@ -469,7 +474,7 @@ TEST_F(ElecStateTest, CalculateWeightsIWeightsTwoFermi)
469474
elecstate->eferm,
470475
elecstate->f_en,
471476
elecstate->nelec_spin,
472-
PARAM.input.nbands,
477+
GLOBAL_NBANDS,
473478
elecstate->skip_weights);
474479
EXPECT_DOUBLE_EQ(elecstate->wg(0, 0), 1.1);
475480
EXPECT_DOUBLE_EQ(elecstate->wg(nks - 1, PARAM.input.nelec / 2 - 1), 1.0);
@@ -513,7 +518,7 @@ TEST_F(ElecStateTest, CalculateWeightsGWeights)
513518
elecstate->eferm,
514519
elecstate->f_en,
515520
elecstate->nelec_spin,
516-
PARAM.input.nbands,
521+
GLOBAL_NBANDS,
517522
elecstate->skip_weights);
518523
// PARAM.input.nelec = 10;
519524
// PARAM.input.nbands = 6;
@@ -590,7 +595,7 @@ TEST_F(ElecStateTest, CalculateWeightsGWeightsTwoFermi)
590595
elecstate->eferm,
591596
elecstate->f_en,
592597
elecstate->nelec_spin,
593-
PARAM.input.nbands,
598+
GLOBAL_NBANDS,
594599
elecstate->skip_weights);
595600
// PARAM.input.nelec = 10;
596601
// PARAM.input.nbands = 6;

source/source_estate/test_mpi/CMakeLists.txt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,3 @@ add_test(NAME MODULE_ESTATE_charge_mpi_test_4np
1616
COMMAND mpirun -np 4 ./MODULE_ESTATE_charge_mpi_test;
1717
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
1818
)
19-
20-
AddTest(
21-
TARGET MODULE_ESTATE_band_parallel_weights_test
22-
LIBS parameter base device
23-
SOURCES band_parallel_weights_test.cpp ../elecstate_tools.cpp ../occupy.cpp
24-
)
25-
26-
add_test(NAME MODULE_ESTATE_band_parallel_weights_test_4np
27-
COMMAND mpirun -np 4 ./MODULE_ESTATE_band_parallel_weights_test;
28-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
29-
)

source/source_estate/test_mpi/band_parallel_weights_test.cpp

Lines changed: 0 additions & 161 deletions
This file was deleted.

source/source_hsolver/test/test_hsolver_pw.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,13 +381,13 @@ TEST_F(TestHSolverPW, SolveLcaoInPW) {
381381
PARAM.sys.use_uspp,
382382
PARAM.input.basis_type,
383383
PARAM.input.calculation,
384-
PARAM.input.nbands);
384+
elecstate_test.ekb.nc);
385385
hsolver::HSolverLIP<std::complex<double>> hs_d_lip
386386
= hsolver::HSolverLIP<std::complex<double>>(&pwbk,
387387
PARAM.sys.use_uspp,
388388
PARAM.input.basis_type,
389389
PARAM.input.calculation,
390-
PARAM.input.nbands);
390+
elecstate_test.ekb.nc);
391391
hs_f_lip.solve(&hamilt_test_f, psi_test_cf, &elecstate_test,transform_test_cf, true,0.0,0, exx_info_local);
392392
EXPECT_DOUBLE_EQ(hsolver::DiagoIterAssist<std::complex<float>>::avg_iter, 0.0);
393393
for (int i = 0; i < psi_test_cf.size(); i++)

source/source_io/module_output/write_cube.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@ void ModuleIO::write_vdata_palgrid(const Parallel_Grid& pgrid,
4040
const int& nxyz = nx * ny * nz;
4141

4242
start = time(nullptr);
43+
const bool is_primary_band_group = GlobalV::MY_BNDGROUP == 0;
4344

4445
// reduce
4546
std::vector<double> data_xyz_full(nxyz); // data to be written
4647
#ifdef __MPI // reduce to rank 0
47-
if (GlobalV::MY_BNDGROUP == 0)
48+
if (is_primary_band_group)
4849
{
4950
pgrid.reduce(data_xyz_full.data(), data, reduce_all_pool);
5051
}
@@ -63,7 +64,7 @@ void ModuleIO::write_vdata_palgrid(const Parallel_Grid& pgrid,
6364
// Globally reduced data has one writer across MPI_COMM_WORLD.
6465
const bool is_world_root = my_rank == 0;
6566
// Pool-local data is written only by band group 0 to avoid competing writes.
66-
const bool is_primary_band_group_pool_root = GlobalV::MY_BNDGROUP == 0 && rank_in_pool == 0;
67+
const bool is_primary_band_group_pool_root = is_primary_band_group && rank_in_pool == 0;
6768
const bool should_write_cube = reduce_all_pool ? is_primary_band_group_pool_root : is_world_root;
6869
if (should_write_cube)
6970
{

0 commit comments

Comments
 (0)