Skip to content

Commit

Permalink
Merge pull request #388 from ISISNeutronMuon/chi/fold-change
Browse files Browse the repository at this point in the history
Coordinate folding change
  • Loading branch information
MBartkowiakSTFC authored Mar 25, 2024
2 parents 789e6d5 + bbdc4f6 commit 87de379
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
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

0 comments on commit 87de379

Please sign in to comment.