Skip to content

Commit

Permalink
Merge pull request #693 from MolSSI/openff-qcsubmit-167
Browse files Browse the repository at this point in the history
`additional_keywords` to address openforcefield/openff-qcsubmit#167
  • Loading branch information
bennybp authored Oct 18, 2021
2 parents de022c9 + 7498b9f commit 867b1bc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions qcfractal/interface/collections/torsiondrive_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def add_entry(
dihedral_ranges: Optional[List[Tuple[int, int]]] = None,
energy_decrease_thresh: Optional[float] = None,
energy_upper_limit: Optional[float] = None,
additional_keywords: Optional[Dict[str, Any]] = None,
attributes: Dict[str, Any] = None,
save: bool = True,
) -> None:
Expand All @@ -112,6 +113,8 @@ def add_entry(
The threshold of energy decrease to trigger activating grid points
energy_upper_limit: Optional[float]
The upper limit of energy relative to current global minimum to trigger activating grid points
additional_keywords : Dict[str, Any], optional
Additional keywords to add to the torsiondrive's optimization runs
attributes : Dict[str, Any], optional
Additional attributes and descriptions for the entry
save : bool, optional
Expand All @@ -124,6 +127,9 @@ def add_entry(
if attributes is None:
attributes = {}

if additional_keywords is None:
additional_keywords = {}

# Build new objects
molecule_ids = self.client.add_molecules(initial_molecules)
td_keywords = TDKeywords(
Expand All @@ -132,6 +138,7 @@ def add_entry(
dihedral_ranges=dihedral_ranges,
energy_decrease_thresh=energy_decrease_thresh,
energy_upper_limit=energy_upper_limit,
additional_keywords=additional_keywords,
)

entry = TDEntry(name=name, initial_molecules=molecule_ids, td_keywords=td_keywords, attributes=attributes)
Expand Down
12 changes: 12 additions & 0 deletions qcfractal/interface/models/torsiondrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,22 @@ class TDKeywords(ProtoModel):
"start new optimizations, in unit of a.u. I.e. if energy_upper_limit = 0.05, current global "
"minimum energy is -9.9 , then a new task starting with energy -9.8 will be skipped.",
)
additional_keywords: Dict[str, Any] = Field(
{}, description="Additional keywords to add to the torsiondrive's optimization runs"
)

def __init__(self, **kwargs):
super().__init__(**recursive_normalizer(kwargs))

def dict(self, *args, **kwargs):
ret = super().dict(*args, **kwargs)

# For hash compatibility
if len(ret["additional_keywords"]) == 0:
ret.pop("additional_keywords")

return ret


_td_constr = constr(strip_whitespace=True, regex="torsiondrive")
_qcfractal_constr = constr(strip_whitespace=True, regex="qcfractal")
Expand Down
5 changes: 5 additions & 0 deletions qcfractal/services/torsiondrive_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ def initialize_from_api(cls, storage_socket, logger, service_input, tag=None, pr
"meta": {"procedure": "optimization", "qc_spec": output.qc_spec.dict(), "tag": meta.pop("tag", None)}
}
opt_template["meta"].update(output.optimization_spec.dict())

# allows for injection of e.g. additional constraints for
# optimizations created by torsiondrive service
opt_template["meta"]["keywords"].update(service_input.keywords.additional_keywords)

meta["optimization_template"] = json.dumps(opt_template)

# Move around geometric data
Expand Down

0 comments on commit 867b1bc

Please sign in to comment.