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

evaluator unit bug #276

Closed
wenyan4work opened this issue Dec 12, 2022 · 0 comments · Fixed by #277
Closed

evaluator unit bug #276

wenyan4work opened this issue Dec 12, 2022 · 0 comments · Fixed by #277

Comments

@wenyan4work
Copy link

wenyan4work commented Dec 12, 2022

there is a unit bug when forcebalance is used with openff-evaluator: openforcefield/openff-evaluator#482

The bug happens at the unit parsing and conversion part in evaluator_io.py:

if not isinstance(parameter_value, simtk_unit.Quantity):

If we print the type and value before and after that line:

        print('parameter_value 0: ', parameter_value)
        print('type: ', type(parameter_value))
        if not isinstance(parameter_value, simtk_unit.Quantity):
            parameter_value = parameter_value * simtk_unit.dimensionless
            print('parameter_value 1: ', parameter_value)
            print('type: ', type(parameter_value))

we get

parameter_value 0:  5.27e-05 kilocalorie / mole
type:  <class 'pint.util.Quantity'>
parameter_value 1:  5.27e-05 dimensionless kilocalorie / mole
type:  <class 'pint.util.Quantity'>

after openff-units package was introduced, parameter_value is already a pint Quantity, but since it is not a simtk_unit.Quantity, it is multiplied by a dimensionelss number, then in the following step

return openmm_quantity_to_pint(parameter_value), is_cosmetic

it is converted to a dimensionless quantity.

How to fix this?
Perhaps the easiest change is to modify the last line of L356 to return parameter_value, is_cosmetic, I got the following error:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant