openforcefield / openff-bespokefit

Automated tools for the generation of bespoke SMIRNOFF format parameters for individual molecules.
https://docs.openforcefield.org/bespokefit
MIT License
59 stars 9 forks source link

Using the ANI to compute the single point energy and use xTB for geometry optimisation #157

Open xiki-tempula opened 2 years ago

xiki-tempula commented 2 years ago

In https://github.com/openforcefield/openff-bespokefit/issues/152#issuecomment-1088547027, it is mentioned that Of course as we use QCEngine to do our QC reference generation you can use any supported package, however with ANI we often hit geometry optimisation convergence issues in testing but you are welcome to try yourself just add the following to your run command --default-qc-spec torchani ani2x none

I wonder if it is possible to use xTB for geometry optimisation and ANI for energy calculation? So as to skip the geometry optimisation convergence issue with ANI.

jthorton commented 2 years ago

Hi @xiki-tempula you must be reading my mind!! this is something I am currently looking to implement. This would allow users to select two different QC specifications to perform torsiondrives with the first to do the geometry optimisation and the second to perform single-point calculations. Ill let you know when we have a working proof of concept to try out!

xiki-tempula commented 2 years ago

Thanks. Eager to try it out when it is available. It might also be good to use TorsionDrive entirely on the xTB. After the TorsionDrive finishes and give all the conformations, one run ANI on these conformations to get the potential energy landscape.

xiki-tempula commented 2 years ago

@jthorton While we are at this issue. I think it would be nice to do the single point energy with psi4 as well. So one did the geometry optimisation with xTB and do the energy calculation with psi4 or ANI.

jthorton commented 2 years ago

@xiki-tempula Yes that should be possible my current implementation makes the options for the torsiondrives and single points fully configurable so users can pick any engine supported by QCEngine for either task!

xiki-tempula commented 2 years ago

@jthorton Thanks. I wonder how should I do it? I would imagine that the interface could be --default-qc-sp torchani ani2x none --default-qc-opt xtb gfn2xtb none Which specifies the level for the opt (geometry optimisation) and sp (single point energy).

jthorton commented 2 years ago

Yeah that's something that is not quite clear yet, you will have ultimate control by editing the workflow json files but we should come up with a way to edit this via the CLI as well. I think something similar to what you suggest would be a good start.

xiki-tempula commented 2 years ago

@jthorton Thanks. I was wondering if I could have the default the workflow json files so I could try edit things and see how it goes? Thanks. The default one from here https://openff-bespokefit.readthedocs.io/en/latest/getting-started/quick-start.html#configuring-the-workflow-factory doesn't seems to support this functionality.

jthorton commented 2 years ago

Hi @xiki-tempula, I have a working prototype of this in #167 if you wanted to try it out and let me know how it goes? The PR introduces extra CLI arguments which let you specify a single point specification with the flag --evaluation-qc-spec it works the same way as the --default-qc-spec flag in that you should pass it the program method and basis. Note I have found issues when trying to use xtb+psi4 this way so I would avoid this for now.

xiki-tempula commented 2 years ago

Sorry, just to be sure. So currently I cannot use xTB for geometry optimisation and psi4 for single point energy. But I could use xTB for geometry optimisation and ANI for single point calculation.

So I would imagine that if I wish to do xTB + ANI, it would be openff-bespoke executor run --file "lig.sdf" --workflow "default" --output "lig.json" --output-force-field "lig.offxml" --default-qc-spec xtb gfn2xtb none --evaluation-qc-spec torchani ani2x none?

jthorton commented 2 years ago

So currently I cannot use xTB for geometry optimisation and psi4 for single point energy. But I could use xTB for geometry optimisation and ANI for single point calculation.

That's what I found in testing using xtb + psi4 for a long time causes it to crash but xtb and ani was fine. Yes, that command looks correct!

xiki-tempula commented 1 year ago

Hi @jthorton sorry for the delay. I'm picking out this issue again. I wonder if the branch is still up to date? I set the env up with openff-bespokefit/devtools/conda-envs/test-env.yaml

where I added in xtb-python, torchani so I could use them. However, I found that I had some trouble running the command for testing

openff-bespoke executor run --smiles             "CC(=O)NC1=CC=C(C=C1)O" \
                            --workflow           "default"              \
                            --output             "bespokenfit_psi4.json"   \
                            --output-force-field "bespokenfit_psi4.offxml" \
                            --n-qc-compute-workers 4                   \
                            --qc-compute-n-cores   4                   \
                --default-qc-spec xtb gfn2xtb none \
                --evaluation-qc-spec torchani ani2x none

Where I got Traceback (most recent call last):

  File "/sharedfs-home/zwu/.conda/envs/openff-bespokefit/bin/openff-bespoke", line 33, in <module>
    sys.exit(load_entry_point('openff-bespokefit', 'console_scripts', 'openff-bespoke')())
  File "/sharedfs-home/zwu/.conda/envs/openff-bespokefit/bin/openff-bespoke", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/sharedfs-home/zwu/.conda/envs/openff-bespokefit/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/sharedfs-home/zwu/.conda/envs/openff-bespokefit/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/sharedfs-home/zwu/src/openff-bespokefit/openff/bespokefit/cli/__init__.py", line 3, in <module>
    from openff.bespokefit.cli.cli import cli
  File "/sharedfs-home/zwu/src/openff-bespokefit/openff/bespokefit/cli/cli.py", line 3, in <module>
    from openff.bespokefit.cli.cache import cache_cli
  File "/sharedfs-home/zwu/src/openff-bespokefit/openff/bespokefit/cli/cache.py", line 27, in <module>
    from openff.bespokefit.executor.services import current_settings
  File "/sharedfs-home/zwu/src/openff-bespokefit/openff/bespokefit/executor/__init__.py", line 3, in <module>
    from openff.bespokefit.executor.executor import (
  File "/sharedfs-home/zwu/src/openff-bespokefit/openff/bespokefit/executor/executor.py", line 23, in <module>
    from openff.bespokefit.executor.services.coordinator.models import (
  File "/sharedfs-home/zwu/src/openff-bespokefit/openff/bespokefit/executor/services/coordinator/__init__.py", line 1, in <module>
    from openff.bespokefit.executor.services.coordinator.app import router
  File "/sharedfs-home/zwu/src/openff-bespokefit/openff/bespokefit/executor/services/coordinator/app.py", line 13, in <module>
    from openff.bespokefit.executor.services.coordinator import worker
  File "/sharedfs-home/zwu/src/openff-bespokefit/openff/bespokefit/executor/services/coordinator/worker.py", line 8, in <module>
    from openff.bespokefit.executor.services.coordinator.storage import (
  File "/sharedfs-home/zwu/src/openff-bespokefit/openff/bespokefit/executor/services/coordinator/storage.py", line 5, in <module>
    from openff.bespokefit.executor.services.coordinator.models import CoordinatorTask
  File "/sharedfs-home/zwu/src/openff-bespokefit/openff/bespokefit/executor/services/coordinator/models.py", line 6, in <module>
    from openff.bespokefit.executor.services.coordinator.stages import StageType
  File "/sharedfs-home/zwu/src/openff-bespokefit/openff/bespokefit/executor/services/coordinator/stages.py", line 23, in <module>
    from openff.bespokefit.executor.services.coordinator.utils import get_cached_parameters
  File "/sharedfs-home/zwu/src/openff-bespokefit/openff/bespokefit/executor/services/coordinator/utils.py", line 8, in <module>
    from openff.bespokefit.schema.fitting import BespokeOptimizationSchema
  File "/sharedfs-home/zwu/src/openff-bespokefit/openff/bespokefit/schema/fitting.py", line 20, in <module>
    from openff.bespokefit.utilities.smirks import SMIRKSettings, SMIRKSType
  File "/sharedfs-home/zwu/src/openff-bespokefit/openff/bespokefit/utilities/smirks.py", line 21, in <module>
    from openff.bespokefit.utilities.smirnoff import ForceFieldEditor, SMIRKSType
  File "/sharedfs-home/zwu/src/openff-bespokefit/openff/bespokefit/utilities/smirnoff.py", line 10, in <module>
    from openff.toolkit.typing.engines.smirnoff import (
ImportError: cannot import name 'ParameterLookupError' from 'openff.toolkit.typing.engines.smirnoff' (/sharedfs-home/zwu/.conda/envs/openff-bespokefit/lib/python3.10/site-packages/openff/toolkit/typing/engines/smirnoff/__init__.py)

Please also find my conda env attached conda.log The main branch works fine though. Thanks.

jthorton commented 1 year ago

Hi @xiki-tempula, this branch fell out of sync and needs updating to work with new versions of the toolkit, I'll look into updating this and getting it back online for testing soon.

xiki-tempula commented 10 months ago

Hi, I wonder if this branch will be merged to the main? Thank you.