Skip to content

Commit

Permalink
post-Christmas, mostly opt/td edits
Browse files Browse the repository at this point in the history
  • Loading branch information
loriab committed Jan 14, 2025
1 parent 3e14768 commit 56da323
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
4 changes: 4 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ New Features
Enhancements
++++++++++++
- (:pr:`364`)
- (:pr:`364`)
- (:pr:`364`)
- (:pr:`364`) main storage for ``v2.TorsionDriveResult`` moved from ``optimization_history`` to ``scan_results``.
- (:pr:`364`) ``v2.TorsionDriveInput.initial_molecule`` restored from ``initial_molecules``.
- (:pr:`364`) default of OptimizationProtocol.trajectory_results changed to "none" from "all" in v1. much info can now come from properties.
- (:pr:`364`) v2.OptimizationProtocol renamed trajectory_results from trajectory in accordance with the protocol naming the controlled field. no default change yet.
- (:pr:`364`) v1/v2: import ElectronShell, BasisCenter, ECPPotential from top level models
Expand Down
4 changes: 2 additions & 2 deletions qcelemental/models/v1/procedures.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def convert_v(
dtop = {}
dtop["provenance"] = dself.pop("provenance")
dself.pop("initial_molecule")
dtop["initial_molecules"] = [mol.convert_v(target_version) for mol in self.initial_molecule]
dtop["initial_molecule"] = [mol.convert_v(target_version) for mol in self.initial_molecule]
dtop["specification"] = tdspec
dself.pop("schema_name")
dself.pop("schema_version")
Expand Down Expand Up @@ -548,7 +548,7 @@ def convert_v(
dtop["final_energies"] = dself.pop("final_energies")
dself.pop("final_molecules")
dtop["final_molecules"] = {k: m.convert_v(target_version) for k, m in self.final_molecules.items()}
dtop["optimization_history"] = {
dtop["scan_results"] = {
k: [opthist_class(**res).convert_v(target_version) for res in lst]
for k, lst in dself["optimization_history"].items()
}
Expand Down
15 changes: 7 additions & 8 deletions qcelemental/models/v2/torsion_drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class TorsionDriveInput(ProtoModel):
)

id: Optional[str] = None
initial_molecules: conlist(item_type=Molecule, min_length=1) = Field(
initial_molecule: conlist(item_type=Molecule, min_length=1) = Field(
..., description="The starting molecule(s) for the torsion drive."
)

Expand Down Expand Up @@ -154,8 +154,7 @@ def convert_v(
dself.pop("schema_version") # changed in v1
dself.pop("id") # unused in v1
dself["extras"] = dself["specification"].pop("extras")
dself.pop("initial_molecules")
dself["initial_molecule"] = [m.convert_v(target_version) for m in self.initial_molecules]
dself["initial_molecule"] = [m.convert_v(target_version) for m in self.initial_molecule]
dself["keywords"] = dself["specification"].pop("keywords")
dself["keywords"].pop("schema_name") # unused in v1

Expand Down Expand Up @@ -202,7 +201,7 @@ class TorsionDriveResult(ProtoModel):
final_molecules: Dict[str, Molecule] = Field(
..., description="The final molecule at each angle of the TorsionDrive scan."
)
optimization_history: Dict[str, List[OptimizationResult]] = Field(
scan_results: Dict[str, List[OptimizationResult]] = Field(
...,
description="The map of each angle of the TorsionDrive scan to each optimization computations.",
)
Expand All @@ -226,7 +225,7 @@ class TorsionDriveResult(ProtoModel):
)
provenance: Provenance = Field(..., description=str(Provenance.__doc__))

@field_validator("optimization_history") # TODO "scan_results")
@field_validator("scan_results")
@classmethod
def _scan_protocol(cls, v, info):
# Do not propogate validation errors
Expand Down Expand Up @@ -269,7 +268,7 @@ def convert_v(
dself = self.model_dump()
if target_version == 1:
try:
opthist_class = next(iter(self.optimization_history.values()))[0].__class__
opthist_class = next(iter(self.scan_results.values()))[0].__class__
except StopIteration:
opthist_class = None
dtop = {}
Expand All @@ -284,9 +283,9 @@ def convert_v(
dtop["final_molecules"] = {k: m.convert_v(target_version) for k, m in self.final_molecules.items()}
dtop["optimization_history"] = {
k: [opthist_class(**res).convert_v(target_version) for res in lst]
for k, lst in dself["optimization_history"].items()
for k, lst in dself["scan_results"].items()
}
dself.pop("optimization_history")
dself.pop("scan_results")

dself.pop("id") # unused in v1
dself.pop("native_files") # new in v2
Expand Down
4 changes: 2 additions & 2 deletions qcelemental/tests/test_model_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def torsiondrive_data_fixture(ethane_data_fixture, optimization_data_fixture, re

if "v2" in request.node.name:
input_data = {
"initial_molecules": [ethane] * 2,
"initial_molecule": [ethane] * 2,
"specification": {
"keywords": {"dihedrals": [(2, 0, 1, 5)], "grid_spacing": [180]},
"specification": {
Expand Down Expand Up @@ -294,7 +294,7 @@ def torsiondrive_data_fixture(ethane_data_fixture, optimization_data_fixture, re
"provenance": {"creator": "qcel"},
"final_energies": {"180": -2.3, "0": -4.5},
"final_molecules": {"180": ethane, "0": ethane},
"optimization_history": {"180": [optres, optres], "0": [optres]},
"scan_results": {"180": [optres, optres], "0": [optres]},
}
else:
ret = {
Expand Down

0 comments on commit 56da323

Please sign in to comment.