-
Notifications
You must be signed in to change notification settings - Fork 15
Closed
Labels
Description
For debugging purpose, I'm trying to check if I'm properly loading the density from a restart file. Following snippet attempts to load a restart file, recompute the density and compare it from the density in the restart file:
MGmol_MPI& mmpi = *(MGmol_MPI::instance());
const int rank = mmpi.mypeGlobal();
const int nprocs = mmpi.size();
Control& ct = *(Control::instance());
MGmol<OrbitalsType> *mgmol = static_cast<MGmol<OrbitalsType> *>(mgmol_);
std::shared_ptr<Rho<OrbitalsType>> rho = mgmol->getRho();
/* load a restart file */
mgmol->loadRestartFile(ct.restart_file);
/* save density from the restart file to elsewhere */
std::vector<RHODTYPE> rho0(rho->rho_[0].size());
rho0 = rho->rho_[0];
/* recompute rho from the orbital */
rho->update(*mgmol->getOrbitals());
/* check if the recomputed density is the same */
for (int d = 0; d < rho0.size(); d++)
{
if (rho0[d] != rho->rho_[0][d])
printf("rank %d, rho[%d]=%.15e, rho0[%d]=%.15e\n", rank, d, rho->rho_[0][d], d, rho0[d]);
}
This is also implemented in rho-bug branch, as an executable test_rho_restart. This does not need libROM library, same installation as release branch. It can be run just as mgmol_opt:
test_rho_restart -c carbyne.cfg
However, when I try this on any restart file of Carbyne example, I receive the following error:
Rho<OrbitalsType>::rescaleTotalCharge(), charge = 1.96e+02
Rescaling factor: 2.55e-01
Num. electrons: 5.00e+01
Error on density too large to continue. Abort.
@jeanlucf22 , can you take a look at this minimal example and check if I'm doing something wrong here? This test is necessary before I get into debugging other parts of ROM. I can send you a config and restart file as well if needed.
Reactions are currently unavailable