1212#include " module_hamilt_pw/hamilt_pwdft/parallel_grid.h"
1313#include " module_io/read_wf2rho_pw.h"
1414#include " module_io/write_wfc_pw.h"
15+ #include " module_io/filename.h" // mohan add 2025-05-17
1516#include " module_parameter/parameter.h"
1617#include " module_psi/psi.h"
1718
@@ -219,10 +220,11 @@ TEST_F(ReadWfcRhoTest, ReadWfcRho)
219220#endif
220221
221222 // Write the wave functions to file
222- ModuleIO::write_wfc_pw (" WAVEFUNC" , *psi, *kv, wfcpw);
223+ const std::string global_out_dir = " ./" ;
224+ ModuleIO::write_wfc_pw (PARAM.input .out_wfc_pw , global_out_dir, *psi, *kv, wfcpw);
223225
224226 // Read the wave functions to charge density
225- std::ofstream running_log (" running_log.txt" );
227+ std::ofstream running_log (" running_log.txt" );
226228 ModuleIO::read_wf2rho_pw (wfcpw, symm, kv->ik2iktot , nkstot, kv->isk , chg, running_log);
227229
228230 // compare the charge density
@@ -232,22 +234,24 @@ TEST_F(ReadWfcRhoTest, ReadWfcRho)
232234 }
233235 // std::cout.precision(16);
234236 // std::cout<<chg.rho[0][0]<<std::endl;
235- if (GlobalV::NPROC == 1 ) {
236- EXPECT_NEAR (chg.rho [0 ][0 ], 8617.076357957576 , 1e-8 );
237- } else if (GlobalV::NPROC == 4 )
238- {
239- const std::vector<double > ref = {8207.849135313403 , 35.34776105132742 , 8207.849135313403 , 35.34776105132742 };
240- EXPECT_NEAR (chg.rho [0 ][0 ], ref[GlobalV::MY_RANK], 1e-8 );
241- // for (int ip = 0; ip < GlobalV::NPROC; ++ip)
242- // {
243- // if (GlobalV::MY_RANK == ip)
244- // {
245- // std::cout.precision(16);
246- // std::cout << GlobalV::MY_RANK << " " << chg.rho[0][0] << std::endl;
247- // }
248- // MPI_Barrier(MPI_COMM_WORLD);
249- // }
250- }
237+ if (GlobalV::NPROC == 1 )
238+ {
239+ EXPECT_NEAR (chg.rho [0 ][0 ], 8617.076357957576 , 1e-8 );
240+ }
241+ else if (GlobalV::NPROC == 4 )
242+ {
243+ const std::vector<double > ref = {8207.849135313403 , 35.34776105132742 , 8207.849135313403 , 35.34776105132742 };
244+ EXPECT_NEAR (chg.rho [0 ][0 ], ref[GlobalV::MY_RANK], 1e-8 );
245+ // for (int ip = 0; ip < GlobalV::NPROC; ++ip)
246+ // {
247+ // if (GlobalV::MY_RANK == ip)
248+ // {
249+ // std::cout.precision(16);
250+ // std::cout << GlobalV::MY_RANK << " " << chg.rho[0][0] << std::endl;
251+ // }
252+ // MPI_Barrier(MPI_COMM_WORLD);
253+ // }
254+ }
251255
252256 delete[] chg.rho ;
253257 delete[] chg._space_rho ;
0 commit comments