Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot recompute rho after loading a restart file. #288

Open
dreamer2368 opened this issue Nov 9, 2024 · 0 comments
Open

cannot recompute rho after loading a restart file. #288

dreamer2368 opened this issue Nov 9, 2024 · 0 comments

Comments

@dreamer2368
Copy link
Collaborator

dreamer2368 commented Nov 9, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant