Skip to content

Commit e7f16db

Browse files
authored
add molecule wrapping when reading restart file
RASPA-2/3, or the previous version of gRASPA, cannot handle atoms in the molecules being wrapped to two sides of the box. Now, adding this new feature in gRASPA, each atom will be wrapped to the nearest image from the 1st atom in the molecule.
1 parent 05f1eab commit e7f16db

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src_clean/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ int main(void)
225225
cudaMalloc(&Sims[a].d_a, sizeof(Atoms)*NComponents.x);
226226
if(RunSingleSim)
227227
{
228-
if(a == SelectedSim && ReadRestart) {RestartFileParser(Sims[a], SystemComponents[a]); AlreadyHasFractionalMolecule = true;}
228+
if(a == SelectedSim && ReadRestart) {RestartFileParser(Sims[a], Box[a], SystemComponents[a]); AlreadyHasFractionalMolecule = true;}
229229
}
230230
Copy_Atom_data_to_device((size_t) NComponents.x, device_System, SystemComponents[a].HostSystem);
231231
Prepare_TempSystem_On_Host(SystemComponents[a].TempSystem);

src_clean/read_data.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2175,7 +2175,7 @@ void read_component_values_from_simulation_input(Components& SystemComponents, M
21752175
std::cout << "-------------- END OF READING " << start_string << " (" << MolName << ")" << " --------------\n";
21762176
}
21772177

2178-
void RestartFileParser(Simulations& Sims, Components& SystemComponents)
2178+
void RestartFileParser(Simulations& Sims, Boxsize& Box, Components& SystemComponents)
21792179
{
21802180
bool UseChargesFromCIFFile = true; //Zhao's note: if not, use charge from pseudo atoms file, not implemented (if reading poscar, then self-defined charges probably need a separate file //
21812181
std::string scannedLine; std::string str;
@@ -2320,6 +2320,21 @@ void RestartFileParser(Simulations& Sims, Components& SystemComponents)
23202320
//printf("Reading Positions, atom: %zu, xyz: %.5f %.5f %.5f, Type: %zu, MolID: %zu\n", atom, pos[atom].x, pos[atom].y, pos[atom].z, Type[atom], MolID[atom]);
23212321
//Zhao's note: adjust the MolID from absolute to relative to component//
23222322
MolID[atom] -= PreviousCompNMol;
2323+
//Zhao's note, 051724, Consider adding a wrap/unwrap here//
2324+
//Calculate atom distance between atom A and the first atom in the molecule//
2325+
//I know, many code will consider using the oxygen atom as the reference for wrapping, no, this is not general enough//
2326+
//We will use the first atom//
2327+
double3 first_bead_pos;
2328+
if(atomid == 0)
2329+
{
2330+
first_bead_pos = pos[atom];
2331+
}
2332+
else if(atomid != 0)
2333+
{
2334+
double3 dist_vec = pos[atom] - first_bead_pos;
2335+
PBC(dist_vec, Box.Cell, Box.InverseCell, Box.Cubic);
2336+
pos[atom] = first_bead_pos + dist_vec;
2337+
}
23232338
}
23242339
//Read charge//
23252340
if((counter >= start + interval * 3) && (counter < start + interval * 4))

src_clean/read_data.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void MoleculeDefinitionParser(Atoms& Mol, Components& SystemComponents, std::str
2424

2525
void read_component_values_from_simulation_input(Components& SystemComponents, Move_Statistics& MoveStats, size_t AdsorbateComponent, Atoms& Mol, PseudoAtomDefinitions PseudoAtom, size_t Allocate_space);
2626

27-
void RestartFileParser(Simulations& Sims, Components& SystemComponents);
27+
void RestartFileParser(Simulations& Sims, Boxsize& Box, Components& SystemComponents);
2828

2929
void read_Ewald_Parameters_from_input(double CutOffCoul, Boxsize& Box, double precision);
3030

0 commit comments

Comments
 (0)