Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions src/MGmol.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,11 @@ class MGmol : public MGmolInterface
{
forces_->force(orbitals, ions);
}
void setPositions(const std::vector<double>& positions,
const std::vector<short>& atnumbers)
{
ions_->setPositions(positions, atnumbers);
}

/*
* simply dump current state
Expand Down
3 changes: 3 additions & 0 deletions src/MGmolInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class MGmolInterface

virtual void getAtomicPositions(std::vector<double>& tau) = 0;
virtual void getAtomicNumbers(std::vector<short>& an) = 0;
virtual void setPositions(const std::vector<double>& positions,
const std::vector<short>& atnumbers)
= 0;
virtual std::shared_ptr<ProjectedMatricesInterface> getProjectedMatrices()
= 0;
virtual void dumpRestart() = 0;
Expand Down
6 changes: 6 additions & 0 deletions tests/RestartEnergyAndForces/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@
shutil.rmtree('WF')

test_energy=1.e18
l=-1
for line in lines:
if line.count(b'Positions'):
l=0
if l>=0 and l<4:
print(line)
l=l+1
if line.count(b'%%'):
print(line)
words=line.split()
Expand Down
32 changes: 32 additions & 0 deletions tests/RestartEnergyAndForces/testRestartEnergyAndForces.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ int main(int argc, char** argv)
}
}

mgmol->setPositions(positions, anumbers);

Mesh* mymesh = Mesh::instance();
const pb::Grid& mygrid = mymesh->grid();
const pb::PEenv& myPEenv = mymesh->peenv();
Expand Down Expand Up @@ -165,6 +167,36 @@ int main(int argc, char** argv)
projmatrices->setDMuniform(ct.getNelSpin(), 0);
projmatrices->printDM(std::cout);

// swap H and O to make sure order of atoms in list does not matter
double x = positions[0];
double y = positions[1];
double z = positions[2];
positions[0] = positions[3];
positions[1] = positions[4];
positions[2] = positions[5];
positions[3] = x;
positions[4] = y;
positions[5] = z;
short tmp = anumbers[0];
anumbers[0] = anumbers[1];
anumbers[1] = tmp;
if (MPIdata::onpe0)
{
std::cout << "Positions:" << std::endl;
std::vector<short>::iterator ita = anumbers.begin();
for (std::vector<double>::iterator it = positions.begin();
it != positions.end(); it += 3)
{
std::cout << *ita;
for (int i = 0; i < 3; i++)
std::cout << " " << *(it + i);
std::cout << std::endl;
ita++;
}
}

mgmol->setPositions(positions, anumbers);

//
// evaluate energy and forces with wavefunctions just read
//
Expand Down