Skip to content

Commit

Permalink
Improve default input parameters of DistanceHistogram-based jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
MBartkowiakSTFC committed Jan 24, 2025
1 parent b3bb2ec commit 3407469
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
12 changes: 9 additions & 3 deletions MDANSE/Src/MDANSE/Framework/Jobs/CoordinationNumber.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,14 @@ class CoordinationNumber(DistanceHistogram):
{"dependencies": {"trajectory": "trajectory"}},
)
settings["r_values"] = (
"RangeConfigurator",
{"valueType": float, "includeLast": True, "mini": 0.0},
"DistHistCutoffConfigurator",
{
"label": "r values (nm)",
"valueType": float,
"includeLast": True,
"mini": 0.0,
"dependencies": {"trajectory": "trajectory"},
},
)
settings["atom_selection"] = (
"AtomSelectionConfigurator",
Expand Down Expand Up @@ -159,7 +165,7 @@ def finalize(self):
self.hIntra[idi, idj] += self.hIntra[idj, idi]
self.hInter[idi, idj] += self.hInter[idj, idi]

fact = nij * nFrames * shellVolumes
fact = 2 * nij * nFrames * shellVolumes

self.hIntra[idi, idj, :] /= fact
self.hInter[idi, idj, :] /= fact
Expand Down
14 changes: 10 additions & 4 deletions MDANSE/Src/MDANSE/Framework/Jobs/XRayStaticStructureFactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,18 @@ class XRayStaticStructureFactor(DistanceHistogram):
{"dependencies": {"trajectory": "trajectory"}},
)
settings["r_values"] = (
"RangeConfigurator",
{"valueType": float, "includeLast": True, "mini": 0.0},
"DistHistCutoffConfigurator",
{
"label": "r values (nm)",
"valueType": float,
"includeLast": True,
"mini": 0.0,
"dependencies": {"trajectory": "trajectory"},
},
)
settings["q_values"] = (
"RangeConfigurator",
{"valueType": float, "includeLast": True, "mini": 0.0},
{"valueType": float, "includeLast": True, "mini": 0.0, "default": (0, 500, 1)},
)
settings["atom_selection"] = (
"AtomSelectionConfigurator",
Expand Down Expand Up @@ -164,7 +170,7 @@ def finalize(self):
self.hIntra[idi, idj] += self.hIntra[idj, idi]
self.hInter[idi, idj] += self.hInter[idj, idi]

fact = nij * nFrames * shellVolumes
fact = 2 * nij * nFrames * shellVolumes

pdfIntra = self.hIntra[idi, idj, :] / fact
pdfInter = self.hInter[idi, idj, :] / fact
Expand Down
7 changes: 6 additions & 1 deletion MDANSE/Src/MDANSE/Mathematics/Arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ def get_weights(props, contents, dim):
else:
normFactor += fact

if abs(normFactor) > 0.0: # if normFactor is 0, all weights are 0 too.
normalise = True
try:
len(normFactor)
except TypeError:
normalise = abs(normFactor) > 0.0 # if normFactor is 0, all weights are 0 too.
if normalise:
for k in list(weights.keys()):
weights[k] /= np.float64(normFactor)

Expand Down

0 comments on commit 3407469

Please sign in to comment.