Comments (4)
Probably a type mismatch - no, it's converted correctly when passed to OpenMM
openff-evaluator/openff/evaluator/protocols/simulation.py
Lines 37 to 41 in e95b28b
from openff-evaluator.
OpenMM doesn't actually check the dimensionality of that argument. This block runs without error, even though I expected it to error:
import openmm
import openmm.unit
simulation = interchange.to_openmm_simulation(
integrator=openmm.LangevinMiddleIntegrator(
300 * openmm.unit.kelvin,
1 / openmm.unit.picosecond,
1.0,
)
)
simulation.minimizeEnergy(10 * openmm.unit.kilojoule_per_mole / openmm.unit.nanometer)
simulation.minimizeEnergy(10 * openmm.unit.kilojoule_per_mole)
simulation.minimizeEnergy(10 * openmm.unit.picosecond)
simulation.minimizeEnergy(10 * openmm.unit.kelvin)
from openff-evaluator.
This one is confusing to me. Switching the units over to
I don't think it's likely that the conversion drops the nanometer in the denominator:
In [1]: import openmm.unit
In [2]: 10 * openmm.unit.kilojoule_per_mole / openmm.unit.nanometer
Out[2]: Quantity(value=10, unit=kilojoule/(nanometer*mole))
In [3]: from openff.units import Quantity, unit
In [4]: from openff.units.openmm import to_openmm
In [5]: to_openmm(Quantity("10 kilojoule/mol/nanometer"))
Out[5]: Quantity(value=10.0, unit=kilojoule/(nanometer*mole))
In [6]: Quantity("10 kilojoule/mol/nanometer").to_openmm()
Out[6]: Quantity(value=10.0, unit=kilojoule/(nanometer*mole))
from openff-evaluator.
This can be reproduced with openmm==8.1.0beta
, but no earlier versions. Until builds were made of this release, I didn't have an easy way of accessing these changes. This behavior change is attributed to openmm/openmm#2972, though I don't believe that's the cause. Previously, no unit checks happened and I don't see how changing the default value of an argument would introduce new logic. I tried digging deeper, but most of the code his obfuscated by the nature of being SWIG-generated. Anyway,
from openff.toolkit import Molecule, ForceField
import openmm
import openmm.unit
molecule = Molecule.from_smiles("OC[C@H](O)[C@H]1OC(=O)C(O)=C1O")
molecule.generate_conformers()
interchange = ForceField("openff-2.1.0.offxml").create_interchange(molecule.to_topology())
simulation = interchange.to_openmm_simulation(
integrator=openmm.LangevinMiddleIntegrator(
300 * openmm.unit.kelvin,
1 / openmm.unit.picosecond,
1.0,
)
)
simulation.minimizeEnergy(10 * openmm.unit.kilojoule_per_mole / openmm.unit.nanometer)
simulation.minimizeEnergy(10 * openmm.unit.kilojoule_per_mole)
simulation.minimizeEnergy(10 * openmm.unit.picosecond)
simulation.minimizeEnergy(10 * openmm.unit.kelvin)
$ python repro.py
Traceback (most recent call last):
File "/Users/mattthompson/software/openff-evaluator/repro.py", line 21, in <module>
simulation.minimizeEnergy(10 * openmm.unit.kilojoule_per_mole)
File "/Users/mattthompson/mambaforge/envs/openmm-beta/lib/python3.11/site-packages/openmm/app/simulation.py", line 143, in minimizeEnergy
mm.LocalEnergyMinimizer.minimize(self.context, tolerance, maxIterations, reporter)
File "/Users/mattthompson/mambaforge/envs/openmm-beta/lib/python3.11/site-packages/openmm/openmm.py", line 12476, in minimize
tolerance = tolerance.value_in_unit(unit.kilojoules_per_mole/unit.nanometer)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mattthompson/mambaforge/envs/openmm-beta/lib/python3.11/site-packages/openmm/unit/quantity.py", line 626, in value_in_unit
val = self.in_units_of(unit)
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mattthompson/mambaforge/envs/openmm-beta/lib/python3.11/site-packages/openmm/unit/quantity.py", line 662, in in_units_of
raise TypeError('Unit "%s" is not compatible with Unit "%s".' % (self.unit, other_unit))
TypeError: Unit "kilojoule/mole" is not compatible with Unit "kilojoule/(nanometer*mole)".
from openff-evaluator.
Related Issues (20)
- Random halting of estimations (experiments/solvent2.nc) HOT 5
- Solvation free energy calculations failing HOT 10
- Loosen MDTraj constraint HOT 3
- tutorial data and script are outdated HOT 1
- unit bug forcebalance 1.9.4 + evaluator 0.4.1 + toolkit 0.11.4 in tutorial04 HOT 5
- Virtual sites missing from gradient calculations HOT 8
- Remove modules depending on Yank
- OpenMM 8 causing test failures HOT 2
- Star imports misconfigured HOT 1
- Unit-related AttributeError on code which previously worked HOT 6
- FilterBySmirks does not work with isotopes HOT 6
- Remove use of `pkg_resources`
- Pandas 2 breaks things HOT 3
- Tutorial01 HOT 5
- OE_LICENSE HOT 3
- unit HOT 16
- Pint removed upcast_types = [] from pint.compat HOT 3
- openff-evaluator conda installation problems HOT 3
- tutorial04 - No module named 'forcebalance' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openff-evaluator.