Skip to content

Tutorial 04 - Optimizing Force Fields Using Partial Charges #715

@faranaknejat1991-bot

Description

@faranaknejat1991-bot

Hello:

I'm using ubuntu 22.04. I installed OpenFF using "conda install -c conda-forge openff-evaluator".
I have been able to run a successful run from the given example (CCO) and I was able to optimize the Lj parameters.

I am also interested to be able to optimize the partial charges. This is where the issue comes from. I have introduced the "cosmetic_attribute" for the partial charges. The program runs and changes the partial charges, however, since the partial charges do not add up to zero after being changed, the program crashes.

I have looked up the SMIRNOFF format to do this but still the program crashes. I think there has to be a way to constrain the partial charges to be zero after they are being changed. And I don't think this is explained fully in here: "https://openforcefield.github.io/standards/standards/smirnoff/#partial-charge-and-electrostatics-models".

If I use this format for the Force Field which I have specified the parametrize key word inside the Library of Charges:

The Open Force Field Initiative 2025-06-18

Then error message is:
openff.interchange.exceptions.NonintegralMoleculeChargeError: Molecue CCO has a net charge of -0.1315656 compared to a total formal charge of 0.0.

Now, I have looked online and realize the best way to constrain the total charge (Neutrality) is to use the keyword "parameter_eval" under the library of charge tag. The way I a have approached this is to say that the charge of the end hydrogen will be the sum of the negative of the other charges. Then the force field is:

The Open Force Field Initiative 2025-06-18

Then the error message is:
openff.toolkit.utils.exceptions.IncompatibleUnitError: charge_increment=-0.05 dimensionless should have units of elementary_charge.

This error message does not make sense since the unit of the "parameter_eval" is automatically correct.
Please let me know if you need anything else. I have search everywhere and can't find a solution!
I have attached the full env as well.

full-env.yaml

Thanks,
Ab

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions