Skip to content

Commit

Permalink
Merge branch 'protos' of https://github.com/ISISNeutronMuon/MDANSE in…
Browse files Browse the repository at this point in the history
…to minimum-effort-atom-labels
  • Loading branch information
MBartkowiakSTFC committed Mar 25, 2024
2 parents 6ac7f2a + f6de82b commit 4ac303e
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 33 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
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,15 @@ def configure(self, value):
trajConfig = self._configurable[self._dependencies["trajectory"]]
atomSelectionConfig = self._configurable[self._dependencies["atom_selection"]]

allAtoms = sorted_atoms(trajConfig["chemical_system"].atom_list)
allAtoms = sorted_atoms(trajConfig["instance"].chemical_system.atom_list)

groups = collections.OrderedDict()
for i in range(atomSelectionConfig["selection_length"]):
idx = atomSelectionConfig["indexes"][i][0]
el = atomSelectionConfig["elements"][i][0]
mass = atomSelectionConfig["masses"][i][0]
at = allAtoms[idx]
lvl = LEVELS[value][
at.top_level_chemical_entity().__class__.__name__.lower()
]
lvl = LEVELS[value][at.top_level_chemical_entity.__class__.__name__.lower()]
parent = self.find_parent(at, lvl)
d = groups.setdefault(parent, {})
d.setdefault("indexes", []).append(idx)
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
2 changes: 2 additions & 0 deletions MDANSE/Src/MDANSE/Framework/Jobs/CroppedTrajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class CroppedTrajectory(IJob):
Crop a trajectory in terms of the contents of the simulation box (selected atoms or molecules) and the trajectory length.
"""

enabled = False

label = "Cropped Trajectory"

category = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class CurrentCorrelationFunction(IJob):
in space and time)'
"""

enabled = False

label = "Current Correlation Function"

category = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
class DipoleAutoCorrelationFunction(IJob):
""" """

enabled = False

label = "Dipole AutoCorrelation Function"

category = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class GlobalMotionFilteredTrajectory(IJob):
In the global motion filtered trajectory, the universe is made infinite and all the configurations contiguous.
"""

enabled = False

label = "Global Motion Filtered Trajectory"

category = (
Expand Down
2 changes: 2 additions & 0 deletions MDANSE/Src/MDANSE/Framework/Jobs/McStasVirtualInstrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class McStasVirtualInstrument(IJob):
instrument resolution, self-shielding and multiple scattering.
"""

enabled = False

label = "McStas Virtual Instrument"

category = (
Expand Down
4 changes: 0 additions & 4 deletions MDANSE/Src/MDANSE/Framework/Jobs/RadiusOfGyration.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ class RadiusOfGyration(IJob):
"AtomSelectionConfigurator",
{"dependencies": {"trajectory": "trajectory"}},
)
settings["weights"] = (
"WeightsConfigurator",
{"dependencies": {"atom_selection": "atom_selection"}},
)
settings["output_files"] = (
"OutputFilesConfigurator",
{"formats": ["MDAFormat", "TextFormat"]},
Expand Down
2 changes: 2 additions & 0 deletions MDANSE/Src/MDANSE/Framework/Jobs/RigidBodyTrajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class RigidBodyTrajectory(IJob):
doi: 10.1080/08927029108022453.
"""

enabled = False

label = "Rigid Body Trajectory"

category = (
Expand Down
20 changes: 7 additions & 13 deletions MDANSE/Tests/UnitTests/Analysis/test_scattering.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def qvector_spherical_lattice(trajectory):
)


@pytest.fixture(scope="function")
@pytest.fixture(scope="module")
def dcsf():
temp_name = tempfile.mktemp()
parameters = {}
Expand All @@ -45,7 +45,7 @@ def dcsf():
"SphericalLatticeQVectors",
{"seed": 0, "shells": (5.0, 36, 10.0), "n_vectors": 10, "width": 9.0},
)
parameters["running_mode"] = ("monoprocessor",)
parameters["running_mode"] = ("single-core",)
parameters["trajectory"] = short_traj
parameters["weights"] = "b_coherent"
dcsf = IJob.create("DynamicCoherentStructureFactor")
Expand All @@ -54,7 +54,7 @@ def dcsf():
os.remove(temp_name + ".mda")


@pytest.fixture(scope="function")
@pytest.fixture(scope="module")
def disf():
temp_name = tempfile.mktemp()
parameters = {}
Expand All @@ -67,7 +67,7 @@ def disf():
"SphericalLatticeQVectors",
{"seed": 0, "shells": (5.0, 36, 10.0), "n_vectors": 10, "width": 9.0},
)
parameters["running_mode"] = ("monoprocessor",)
parameters["running_mode"] = ("single-core",)
parameters["trajectory"] = short_traj
parameters["weights"] = "b_incoherent2"
disf = IJob.create("DynamicIncoherentStructureFactor")
Expand Down Expand Up @@ -151,35 +151,29 @@ def test_gdisf(trajectory):
os.remove(temp_name + ".mda")


@pytest.mark.xfail(reason="see docstring")
def test_ndtsf(disf, dcsf, qvector_spherical_lattice):
"""A known problem that will have to be fixed."""
temp_name = tempfile.mktemp()
parameters = {}
parameters["atom_selection"] = None
parameters["atom_transmutation"] = None
parameters["frames"] = (0, 10, 1)
parameters["disf_input_file"] = disf
parameters["dcsf_input_file"] = dcsf
parameters["q_vectors"] = qvector_spherical_lattice
parameters["running_mode"] = ("monoprocessor",)
parameters["running_mode"] = ("single-core",)
parameters["trajectory"] = short_traj
parameters["output_files"] = (temp_name, ("MDAFormat",))
parameters["weights"] = "b_incoherent2"
ndtsf = IJob.create("NeutronDynamicTotalStructureFactor")
ndtsf.run(parameters, status=True)
assert path.exists(temp_name + ".mda")
assert path.isfile(temp_name + ".mda")
os.remove(temp_name + ".mda")


@pytest.mark.xfail(reason="see docstring")
def test_ssfsf(disf):
"""Also fails at the moment. Must be fixed soon"""
temp_name = tempfile.mktemp()
parameters = {}
parameters["sample_inc"] = disf
parameters["running_mode"] = ("monoprocessor",)
parameters["running_mode"] = ("single-core",)
parameters["instrument_resolution"] = ("Ideal", {})
parameters["output_files"] = (temp_name, ("MDAFormat",))
ndtsf = IJob.create("StructureFactorFromScatteringFunction")
Expand All @@ -203,7 +197,7 @@ def test_ccf(qvector_spherical_lattice):
parameters["interpolation_mode"] = "automatic"
parameters["output_files"] = (temp_name, ("MDAFormat",))
parameters["q_vectors"] = qvector_spherical_lattice
parameters["running_mode"] = ("monoprocessor",)
parameters["running_mode"] = ("single-core",)
parameters["trajectory"] = short_traj
parameters["weights"] = "b_coherent"
ndtsf = IJob.create("CurrentCorrelationFunction")
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 4ac303e

Please sign in to comment.