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

Coordinate folding change #388

Merged
merged 3 commits into from
Mar 25, 2024
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
12 changes: 6 additions & 6 deletions MDANSE/Extensions/fold_coordinates.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,22 @@ def fold_coordinates(
by = box_coords[i,j,1]
bz = box_coords[i,j,2]

while bx < -0.5:
while bx < 0.0:
bx += 1.0

while by < -0.5:
while by < 0.0:
by += 1.0

while bz < -0.5:
while bz < 0.0:
bz += 1.0

while bx > 0.5:
while bx >= 1.0:
bx -= 1.0

while by > 0.5:
while by >= 1.0:
by -= 1.0

while bz > 0.5:
while bz >= 1.0:
bz -= 1.0

box_coords[i,j,0] = bx
Expand Down
6 changes: 6 additions & 0 deletions MDANSE/Src/MDANSE/Framework/Converters/ASE.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ class ASE(Converter):
"mini": 0,
},
)
settings["fold"] = (
"BooleanConfigurator",
{"default": False, "label": "Fold coordinates into box"},
)
settings["output_file"] = (
"OutputTrajectoryConfigurator",
{
Expand Down Expand Up @@ -156,6 +160,8 @@ def run_step(self, index):
realConf = PeriodicRealConfiguration(
self._trajectory.chemical_system, coords, unitCell
)
if self._configuration["fold"]["value"]:
realConf.fold_coordinates()
else:
realConf = RealConfiguration(
self._trajectory.chemical_system,
Expand Down
7 changes: 6 additions & 1 deletion MDANSE/Src/MDANSE/Framework/Converters/CP2K.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ class CP2K(Converter):
"dependencies": {"input_file": "pos_file"},
},
)
settings["fold"] = (
"BooleanConfigurator",
{"default": False, "label": "Fold coordinates into box"},
)
settings["output_file"] = (
"OutputTrajectoryConfigurator",
{
Expand Down Expand Up @@ -232,7 +236,8 @@ def run_step(self, index):
self._trajectory.chemical_system, coords, unitcell, **variables
)

realConf.fold_coordinates()
if self._configuration["fold"]["value"]:
realConf.fold_coordinates()

self._trajectory.chemical_system.configuration = realConf

Expand Down
2 changes: 1 addition & 1 deletion MDANSE/Src/MDANSE/Framework/Converters/DFTB.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class DFTB(Forcite):
)
settings["fold"] = (
"BooleanConfigurator",
{"default": True, "label": "Fold coordinates in to box"},
{"default": False, "label": "Fold coordinates into box"},
)
settings["output_file"] = (
"OutputTrajectoryConfigurator",
Expand Down
2 changes: 1 addition & 1 deletion MDANSE/Src/MDANSE/Framework/Converters/Discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ class Discover(Converter):
)
settings["fold"] = (
"BooleanConfigurator",
{"default": True, "label": "Fold coordinates into box"},
{"default": False, "label": "Fold coordinates into box"},
)
settings["output_file"] = (
"OutputTrajectoryConfigurator",
Expand Down
6 changes: 3 additions & 3 deletions MDANSE/Tests/UnitTests/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,9 @@ def test_fold_coordinates(self):
np.allclose(
conf["coordinates"],
[
[-0.65955991, 1.40648987, -1.9977125],
[1.04665145, -1.06488218, -0.1532281],
[-0.27479577, -0.08878546, 1.93534948],
[1.34044009, 2.40648987, -1.9977125],
[0.04665145, 1.93511782, -0.1532281],
[1.72520423, 0.91121454, -2.06465052],
[-0.22366532, 1.38389029, -0.29560999],
],
rtol=1.0e-6,
Expand Down
Loading