openforcefield / openff-benchmark

Comparison benchmarks between public force fields and Open Force Field Initiative force fields
MIT License
11 stars 2 forks source link

[WIP] `openff-benchmark torsiondrive execute-single` #69

Open dotsdl opened 3 years ago

dotsdl commented 3 years ago

Description

Single-molecule torsiondrive executor entrypoint for openff-benchmark.

Not working yet; getting hangs on the first cycle for driving ethane in ad-hoc tests.

Instructions for ad-hoc tests

  1. Clone the repository:
git clone git@github.com:openforcefield/openff-benchmark.git
cd openff-benchmark
git checkout torsiondrive-execute
  1. Install and activate the conda environment:
conda env create -f devtools/prod-envs/openff-benchmark-torsiondrive.yaml
conda activate openff-benchmark-torsiondrive
pip install -e .
  1. Go to data directory; run torsiondrive executor on ethane:
    
    cd openff/benchmark/data

openff-benchmark torsiondrive execute-single --dihedral 3 1 2 6 --program torchani --method ani2x -t 8 -m 8 --grid-spacing 15 -o ethane-ani2x ethane.sdf


This will output two files:
- `ethane-ani2x.json` : full torsiondrive optimization results as JSON structured data
- `ethane-ani2x.sdf` : an SDF giving the final molecule geometries, energies for each angle optimized by the torsiondrive

### Adding support for -180 angles

There is an open PR at lpwgroup/torsiondrive#60 that enables handling of -180 angles without resolving them to +180. To install this:

1. Clone the repository:

git clone git@github.com:dotsdl/torsiondrive.git cd torsiondrive git checkout support--180


2. Activate the conda environment; remove and replace installed `torsiondrive`:

conda activate openff-benchmark-torsiondrive conda remove --force torsiondrive pip install -e .



When you run `openff-benchmark torsiondrive execute-single`, it will now use `torsiondrive` with this fix introduced.

## To Do

- [ ] unit test coverage
- [x] ability to execute season-based specs on single molecules
- [x] ability to execute custom compute specs on single molecules

Not required, but need to identify path for:
- [ ] custom offxml passed as MM compute spec basis; must verify support in QCEngine

## Status
- [ ] Ready to go
dotsdl commented 3 years ago

@jthorton I think I could use your eyes here. When I run the ad-hoc tests above I get:

$ openff-benchmark torsiondrive execute-one-shot --dihedral 2 0 1 5 -s "1:1" -t 6 -m 4 --grid-spacing 15 ethane.sdf 
/home/david/.conda/envs/openff-benchmark-torsiondrive/lib/python3.7/site-packages/sqlalchemy/sql/coercions.py:308: SAWarning: implicitly coercing SELECT object to scalar subquery; please use the .scalar_subquery() method to produce a scalar subquery.
  "implicitly coercing SELECT object to scalar subquery; "
Processing spec: 'b3lyp-d3bj/dzvp'
1 initial tasks pushed to opt_queue
 - - - - - - - - - - - - - - - - - - - - - - - +

... '180'
1 initial tasks pushed to opt_queue
 - - - - - - - - - - - - - - - - - - - - - - - +

First energy for grid_id (180,) = -79.8440937933398
 + - - - - - - - - - - - - - - - - - - - - - + o

... '-165'
... '165'
Warning! dihedral values inconsistent with target grid_id
dihedral_values [-179.99483947] ref_grid_id (-165,)
Warning! dihedral values inconsistent with target grid_id
dihedral_values [-179.99483947] ref_grid_id (165,)
1 initial tasks pushed to opt_queue
 - - - - - - - - - - - - - - - - - - - - - - - +

First energy for grid_id (180,) = -79.8440937933398
 + - - - - - - - - - - - - - - - - - - - - - + o

... '-165'
... '165'
Warning! dihedral values inconsistent with target grid_id
dihedral_values [-179.99483947] ref_grid_id (-165,)
Warning! dihedral values inconsistent with target grid_id
dihedral_values [-179.99483947] ref_grid_id (-165,)
Warning! dihedral values inconsistent with target grid_id
dihedral_values [-179.99483947] ref_grid_id (165,)
Warning! dihedral values inconsistent with target grid_id
dihedral_values [-179.99483947] ref_grid_id (165,)
1 initial tasks pushed to opt_queue
 - - - - - - - - - - - - - - - - - - - - - - - +

First energy for grid_id (180,) = -79.8440937933398
 + - - - - - - - - - - - - - - - - - - - - - + o

... '-165'
... '165'

I suspect somewhere in either td_api.next_jobs_from_state or td_api.update_state we aren't getting geometries generated properly for the next iteration. Or could it be something with the starting molecule?

dotsdl commented 3 years ago

Basic functionality appears in place. Adding unit tests, then iterating on interface for usability. We are aiming to accommodate both season-based and custom compute spec execution, not necessarily via the exact same subcommand.

jthorton commented 3 years ago

great work so far, I would be careful with the torsiondrive options see here for our current production defaults https://github.com/openforcefield/openff-qcsubmit/blob/45e716e3cc70ee05614fbe951c627efc6d9eec84/openff/qcsubmit/datasets/datasets.py#L1534

dotsdl commented 3 years ago

From @jthorton:

AttributeError: 'FailedOperation' object has no attribute 'initial_molecule'

This error is to do with the return type from qcengine, if the task fails it returns a FailedOperation rather than an OptimisationResult so the attributes are missing, I think we just need a path which checks the output from the grid point task and if it fails either tries again or rasies some better error.

dotsdl commented 3 years ago

Pushed latest changes. Known broken things:

  1. program, method, basis are added to the CLI entrypoint for openff-benchmark torsiondrive execute-single, but their usage is not implemented internally yet.
  2. We want all rotatable bonds to be driven if no dihedral is specified. This is not fully implemented.

@ldamore please use this implementation as the starting point for your work on openforcefield/openff-gopt#2. You can cut out the seasons usage in that implementation, simplifying it down. I will help you with feedback as much as I can.

codecov-commenter commented 3 years ago

Codecov Report

Merging #69 (a4304fe) into master (0bdb8ac) will decrease coverage by 0.33%. The diff coverage is 41.46%.