Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1ad1292
Fix EnergyAndForces tests (#277)
jeanlucf22 Sep 26, 2024
8ac6cd6
Move factor 4pi out og linear solvers (#278)
jeanlucf22 Sep 30, 2024
a2ece1a
Move some code into PoissonSolverFactory (#279)
jeanlucf22 Sep 30, 2024
8b577ea
Clean up class Potentials (#280)
jeanlucf22 Oct 3, 2024
7ac691c
Clean up class Ions, add test for it (#281)
jeanlucf22 Oct 12, 2024
c05ba7f
Add test MD_MVP (#290)
jeanlucf22 Nov 25, 2024
bb8051d
Clean up code related to DM restart data (#292)
jeanlucf22 Dec 2, 2024
a227c04
Write dm (#291)
jeanlucf22 Dec 2, 2024
b263532
Remove unused function in Control (#294)
jeanlucf22 Dec 23, 2024
3eb52d6
Change symlink to restart in tests (#295)
jeanlucf22 Jan 3, 2025
c1d46bc
Extract number empty orbitals from restart file (#296)
jeanlucf22 Jan 7, 2025
eb53963
Clean up MD_IonicStepper restart data write (#297)
jeanlucf22 Jan 16, 2025
857673f
Clean up code based on compiler warnings (#299)
jeanlucf22 Jan 17, 2025
f294d3c
Add getForces for evaluateDMandEnergyAndForces (#300)
siuwuncheung Jan 23, 2025
98a79de
Add check for compatibility MVP/Mehrstellen (#301)
jeanlucf22 Jan 24, 2025
8eda83e
Add support for Br atom (#302)
jeanlucf22 Feb 3, 2025
f298d43
Clean up some HDFrestart functions (#303)
jeanlucf22 Feb 11, 2025
c690bc5
Fix and test restart single hdf5 file (#305)
jeanlucf22 Feb 17, 2025
9f1fc20
Save Hartree potential for write in restart file (#306)
jeanlucf22 Feb 17, 2025
8a1cf05
Speed-up recently added tests (#309)
jeanlucf22 Feb 19, 2025
8a26879
Encapsulate some functions in Potentials (#310)
jeanlucf22 Feb 20, 2025
59b79e7
Remove confusing 0 in naming restart files (#308)
jeanlucf22 Feb 20, 2025
16a818a
Add functionalities for extra info in restart file (#312)
jeanlucf22 Feb 20, 2025
77bd87e
MPI abort (#313)
jeanlucf22 Feb 21, 2025
8b84de4
Rho and VH restart (#311)
jeanlucf22 Feb 24, 2025
8003d70
Strenghten testIons (#315)
jeanlucf22 Mar 4, 2025
4efb34c
More clean up in class Potentials (#316)
jeanlucf22 Mar 4, 2025
2f511b7
Misc code fixes (#317)
jeanlucf22 Mar 14, 2025
45a2c80
Use unique restart filenames in test HDF5single (#318)
jeanlucf22 Mar 14, 2025
b6cf162
Swap ions in existing test (#319)
jeanlucf22 Mar 15, 2025
7fbfe13
Code clean up (#320)
jeanlucf22 Mar 17, 2025
14eb43f
Added functionalities to set local forces (#321)
jeanlucf22 Mar 21, 2025
c61b48d
Update mixed precision code (#322)
jeanlucf22 Mar 24, 2025
e37983b
Clean up and fixes Ions (#326)
jeanlucf22 Mar 26, 2025
89630b3
Fixes for build without HDF5P (#324)
jeanlucf22 Mar 26, 2025
e80193b
Fix testRhoVhRestart (#325)
jeanlucf22 Mar 26, 2025
bcad112
Fix a few more issues with class Ions (#328)
jeanlucf22 Mar 26, 2025
214213e
Merge branch 'release' into merge_release_20250326b
siuwuncheung Mar 26, 2025
27466ce
Merge branch 'ROMFPMD' into merge_release_20250326b
siuwuncheung Mar 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Electrostatic.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class Electrostatic

const bool isDielectric() { return diel_flag_; }
pb::GridFunc<RHODTYPE>* getRhoc() { return grhoc_; }

Poisson* getPoissonSolver() { return poisson_solver_; }

void setup(const short max_sweeps);
Expand Down
32 changes: 13 additions & 19 deletions src/Ions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,12 @@ Ions::Ions(const double lat[3], const std::vector<Species>& sp) : species_(sp)

Ions::Ions(const Ions& ions, const double shift[3]) : species_(ions.species_)
{
std::vector<Ion*>::const_iterator ion = ions.list_ions_.begin();
while (ion != ions.list_ions_.end())
for (const auto& ion : ions.list_ions_)
{
Ion* newion = new Ion(**ion);
Ion* newion = new Ion(*ion);
newion->shiftPosition(shift);
newion->setup();
list_ions_.push_back(newion);
ion++;
}
for (short i = 0; i < 3; ++i)
lattice_[i] = ions.lattice_[i];
Expand Down Expand Up @@ -947,10 +945,11 @@ void Ions::initFromRestartFile(HDFrestart& h5_file)
num_ions_ = at_names.size();
#ifdef MGMOL_USE_HDF5P
if (!h5_file.useHdf5p())
#endif
{
mmpi.allreduce(&num_ions_, 1, MPI_SUM);
}
#endif

if (onpe0 && ct.verbose > 0)
{
(*MPIdata::sout) << "Ions::setFromRestartFile(), read " << num_ions_
Expand Down Expand Up @@ -2211,22 +2210,22 @@ void Ions::getLocalPositions(std::vector<double>& tau) const
void Ions::getLocalNames(std::vector<std::string>& names) const
{
names.clear();
for (auto& ion : local_ions_)
for (const auto& ion : local_ions_)
{
names.push_back(ion->name());
}
}

void Ions::getNames(std::vector<std::string>& names) const
{
names.clear();
for (auto& ion : list_ions_)
{
names.push_back(ion->name());
}
std::vector<std::string> local_names;
getLocalNames(local_names);

MGmol_MPI& mmpi = *(MGmol_MPI::instance());
mmpi.allGatherV(local_names, names);
}

void Ions::getPositions(std::vector<double>& tau)
void Ions::getPositions(std::vector<double>& tau) const
{
std::vector<double> tau_local(3 * local_ions_.size());

Expand All @@ -2236,10 +2235,9 @@ void Ions::getPositions(std::vector<double>& tau)
mmpi.allGatherV(tau_local, tau);
}

void Ions::getAtomicNumbers(std::vector<short>& atnumbers)
void Ions::getAtomicNumbers(std::vector<short>& atnumbers) const
{
std::vector<short> local_atnumbers;

for (auto& ion : local_ions_)
{
local_atnumbers.push_back(ion->atomic_number());
Expand All @@ -2249,15 +2247,11 @@ void Ions::getAtomicNumbers(std::vector<short>& atnumbers)
mmpi.allGatherV(local_atnumbers, atnumbers);
}

void Ions::getForces(std::vector<double>& forces)
void Ions::getForces(std::vector<double>& forces) const
{
std::vector<double> forces_local(3 * local_ions_.size());

getLocalForces(forces_local);

int n = getNumIons();
forces.resize(3 * n);

MGmol_MPI& mmpi = *(MGmol_MPI::instance());
mmpi.allGatherV(forces_local, forces);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Ions.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,10 @@ class Ions
void getLocalPositions(std::vector<double>& tau) const;
void getLocalNames(std::vector<std::string>& names) const;
void getNames(std::vector<std::string>& names) const;
void getPositions(std::vector<double>& tau);
void getAtomicNumbers(std::vector<short>& atnumbers);
void getPositions(std::vector<double>& tau) const;
void getAtomicNumbers(std::vector<short>& atnumbers) const;

void getForces(std::vector<double>& forces);
void getForces(std::vector<double>& forces) const;
void getLocalForces(std::vector<double>& tau) const;

/*!
Expand Down
18 changes: 10 additions & 8 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -557,14 +557,16 @@ add_test(NAME testMD_D72
${CMAKE_CURRENT_SOURCE_DIR}/MD_D72/coords.in
${CMAKE_CURRENT_SOURCE_DIR}/MD_D72/lrs.in
${CMAKE_CURRENT_SOURCE_DIR}/../potentials)
add_test(NAME testHDF5single
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/HDF5single/test.py
${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ${MPIEXEC_PREFLAGS}
${CMAKE_CURRENT_BINARY_DIR}/../src/mgmol-opt
${CMAKE_CURRENT_SOURCE_DIR}/HDF5single/mgmol.cfg
${CMAKE_CURRENT_SOURCE_DIR}/HDF5single/md.cfg
${CMAKE_CURRENT_SOURCE_DIR}/HDF5single/h2o.xyz
${CMAKE_CURRENT_SOURCE_DIR}/../potentials)
if(MGMOL_USE_HDF5P)
add_test(NAME testHDF5single
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/HDF5single/test.py
${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ${MPIEXEC_PREFLAGS}
${CMAKE_CURRENT_BINARY_DIR}/../src/mgmol-opt
${CMAKE_CURRENT_SOURCE_DIR}/HDF5single/mgmol.cfg
${CMAKE_CURRENT_SOURCE_DIR}/HDF5single/md.cfg
${CMAKE_CURRENT_SOURCE_DIR}/HDF5single/h2o.xyz
${CMAKE_CURRENT_SOURCE_DIR}/../potentials)
endif()
add_test(NAME testMD_MVP
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MD_MVP/test.py
${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ${MPIEXEC_PREFLAGS}
Expand Down
1 change: 0 additions & 1 deletion tests/MVP/mvp.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ solver=MVP
nb_inner_it=2
[Restart]
output_level=2
output_type=single_file
4 changes: 2 additions & 2 deletions tests/RhoVhRestart/testRhoVhRestart.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ int testRhoRestart(MGmolInterface* mgmol_)
/* check if the recomputed density is the same */
for (int d = 0; d < (int)rho0.size(); d++)
{
double error = abs(rho0[d] - rho->rho_[0][d]) / abs(rho0[d]);
if (error > 1e-10)
double error = abs(rho0[d] - rho->rho_[0][d]);
if (error > 1e-10 * abs(rho0[d]))
{
printf("rank %d, rho[%d]=%.15e, rho0[%d]=%.15e\n", rank, d,
rho->rho_[0][d], d, rho0[d]);
Expand Down
30 changes: 25 additions & 5 deletions tests/testIons.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ int main(int argc, char** argv)
ions.getAtomicNumbers(anumbers);
if (myrank == 0)
{
std::cout << "Positions:" << std::endl;
int i = 0;
for (auto& position : positions)
{
Expand All @@ -121,7 +122,7 @@ int main(int argc, char** argv)
MPI_Barrier(MPI_COMM_WORLD);

// swap x and z
for (size_t i = 0; i < positions.size() - 2; i++)
for (size_t i = 0; i < positions.size() - 2; i += 3)
{
double x = positions[i];
double z = positions[i + 2];
Expand Down Expand Up @@ -162,10 +163,13 @@ int main(int argc, char** argv)
MPI_Barrier(MPI_COMM_WORLD);

std::vector<double> forces(3 * na);
// arbitrary value
const double fval = 1.12;
// set forces to a different arbitrary value for each component
int i = 0;
for (auto& f : forces)
f = fval;
{
f = (double)i;
i++;
}

ions.getNames(names);
ions.setLocalForces(forces, names);
Expand All @@ -177,13 +181,29 @@ int main(int argc, char** argv)
ions.getLocalForces(lforces);
for (auto& f : lforces)
{
if (std::abs(f - fval) > 1.e-14)
if (std::fmod(f, 1.) > 1.e-14)
{
std::cerr << "f = " << f << std::endl;
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
}
}

ions.getForces(forces);
if (myrank == 0)
for (auto f0 = forces.begin(); f0 != forces.end(); f0++)
{
std::cout << "f0 = " << *f0 << std::endl;
for (auto f1 = f0 + 1; f1 != forces.end(); f1++)
{
// make sure each force component is different
if (std::abs(*f0 - *f1) < 1.e-14)
{
std::cerr << "f0 = " << *f0 << ", f1 = " << *f1
<< std::endl;
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
}
}
}
mpirc = MPI_Finalize();
if (mpirc != MPI_SUCCESS)
{
Expand Down
Loading