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

Update classical.py and xmlio.py #168

Merged
merged 3 commits into from
Jul 4, 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
4 changes: 4 additions & 0 deletions dmff/api/xmlio.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ def parseForce(self, nodes):
inner = {}
inner["name"] = child.tag
inner["attrib"] = child.attrib
if child.text is not None:
inner["formula"] = child.text
ret["node"].append(inner)
return ret

Expand Down Expand Up @@ -178,6 +180,8 @@ def writeXML(
for node in force_info["node"]:
subnode = ET.SubElement(fnode, node["name"])
subnode.attrib = genStrDict(node["attrib"])
if "formula" in node:
subnode.text = node["formula"]

tree = ET.ElementTree(root)
xmlstr = minidom.parseString(ET.tostring(root)).toprettyxml(indent=" ")
Expand Down
12 changes: 6 additions & 6 deletions dmff/generators/classical.py
Copy link
Member

@WangXinyan940 WangXinyan940 Mar 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the mask in PeriodicTorsionForce is designed to control if tuning the whole term, including phase and k.

Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ def overwrite(self, paramset):
proper_phase = paramset[self.name]["proper_phase"]
proper_k = paramset[self.name]["proper_k"]
proper_shift = paramset[self.name]["proper_shift"]
proper_msks = paramset.mask[self.name]["proper"]
proper_msks = paramset.mask[self.name]["proper_phase"]
for nnode, key in enumerate(self.proper_keys):
self.ffinfo["Forces"][self.name]["node"][proper_node_indices[nnode]]["attrib"] = {
}
Expand Down Expand Up @@ -929,7 +929,7 @@ def overwrite(self, paramset):
improper_phase = paramset[self.name]["improper_phase"]
improper_k = paramset[self.name]["improper_k"]
improper_shift = paramset[self.name]["improper_shift"]
improper_msks = paramset.mask[self.name]["improper"]
improper_msks = paramset.mask[self.name]["improper_phase"]
for nnode, key in enumerate(self.imp_keys):
self.ffinfo["Forces"][self.name]["node"][improper_node_indices[nnode]]["attrib"] = {
}
Expand Down Expand Up @@ -2028,9 +2028,9 @@ def overwrite(self, paramset: ParamSet) -> None:
"""
radius = paramset[self.name]["radius"]
scale = paramset[self.name]["scale"]
for i in self.ffinfo.perParticleParamIndices:
self.ffinfo["Forces"][self.name]["node"][i]["attrib"]["radius"] = str(radius[i])
self.ffinfo["Forces"][self.name]["node"][i]["attrib"]["scale"] = str(scale[i])
for j, i in enumerate(self.perParticleParamIndices):
self.ffinfo["Forces"][self.name]["node"][i]["attrib"]["radius"] = str(radius[j])
self.ffinfo["Forces"][self.name]["node"][i]["attrib"]["scale"] = str(scale[j])

def _find_key_index(self, key: Tuple[str]) -> int:
"""
Expand Down Expand Up @@ -2109,4 +2109,4 @@ def potential_fn(positions: jnp.ndarray, box: jnp.ndarray, pairs: jnp.ndarray, p
return potential_fn


_DMFFGenerators["CustomGBForce"] = CustomGBGenerator
_DMFFGenerators["CustomGBForce"] = CustomGBGenerator
Loading