# New Force Field Framework 🎉

**URL:** <https://discuss.avogadro.cc/t/new-force-field-framework/4921>\
**Category:** General Discussion\
**Created:** [October 23, 2023, 6:47pm UTC](https://discuss.avogadro.cc/t/new-force-field-framework/4921 "2023-10-23T18:47:28Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ghutchis](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/ghutchis/32/456_2.png) [@ghutchis](https://discuss.avogadro.cc/u/ghutchis)\
**Post date:** [October 23, 2023, 6:47pm UTC](https://discuss.avogadro.cc/t/new-force-field-framework/4921/1 "2023-10-23T18:47:28Z")

</div>

I will shortly be merging in the new force field framework.

- You will be able to create and install Python scripts for optimizing molecules & unit cells
  - e.g. ML potentials like ANI-1ccx and ANI-2x
  - calculators for materials like ASE, OpenKIM, etc.
  - `xtb-python` like GFN-FF

- Each script can declare what it supports:
  - unit cells or only molecules
  - charged species
  - radicals
  - specific elements (e.g., only HCON or Ag / Au alloys, or C nanomaterials, etc.)
  - analytical gradients

- Scripts get a copy of the current molecule in a range of file formats (e.g., a temporary file)
- Scripts return energies and/or gradients

Avogadro handles frozen atoms / constraints by modifying the forces / gradients back from the script. Right now, there’s just freeze / unfreeze selected atoms.

Still to come:

- Auto-optimize tool interface with “live” optimization. Real Soon Now™
- Full replacement for Open Babel optimization (e.g., right now, this is an extra option - 1.99 / 2.0 will merge them)
- Distance / angle / torsion constraints (e.g., debugging this took a bunch of time, so I haven’t had time to code these up)

---

<div class="post-metadata">

**Author:** ![ghutchis](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/ghutchis/32/456_2.png) [@ghutchis](https://discuss.avogadro.cc/u/ghutchis)\
**Post date:** [October 23, 2023, 6:48pm UTC](https://discuss.avogadro.cc/t/new-force-field-framework/4921/2 "2023-10-23T18:48:24Z")

</div>

Fancy new demo:

![AvoOpt](https://discuss.avogadro.cc/uploads/default/original/2X/8/83dd6ce070e1711f05da350053fb187b3e32785d.gif)

---

<div class="post-metadata">

**Author:** ![dermewes](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/dermewes/32/1707_2.png) [@dermewes](https://discuss.avogadro.cc/u/dermewes)\
**Post date:** [October 31, 2023, 7:24am UTC](https://discuss.avogadro.cc/t/new-force-field-framework/4921/3 "2023-10-31T07:24:28Z")

</div>

Great work. Been waiting for this for a while, can’t wait to try it out!

---

<div class="post-metadata">

**Author:** ![ghutchis](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/ghutchis/32/456_2.png) [@ghutchis](https://discuss.avogadro.cc/u/ghutchis)\
**Post date:** [October 31, 2023, 10:51am UTC](https://discuss.avogadro.cc/t/new-force-field-framework/4921/4 "2023-10-31T10:51:50Z")

</div>

Please let us know how it goes - it’s obviously really new so I’m sure there will be bugs.

---

<div class="post-metadata">

**Author:** ![arugula\_jones](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/arugula_jones/32/1553_2.png) [@arugula\_jones](https://discuss.avogadro.cc/u/arugula_jones)\
**Post date:** [November 6, 2023, 10:10pm UTC](https://discuss.avogadro.cc/t/new-force-field-framework/4921/5 "2023-11-06T22:10:06Z")

</div>

Would you give a bit more info about how to interface with this framework? Trying to figure out how to play with something a little more powerful than LJ when testing.

Best,  
Sam

---

<div class="post-metadata">

**Author:** ![ghutchis](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/ghutchis/32/456_2.png) [@ghutchis](https://discuss.avogadro.cc/u/ghutchis)\
**Post date:** [November 6, 2023, 10:23pm UTC](https://discuss.avogadro.cc/t/new-force-field-framework/4921/6 "2023-11-06T22:23:03Z")

</div>

> [@arugula\_jones](#):
>
> Would you give a bit more info about how to interface with this framework? Trying to figure out how to play with something a little more powerful than LJ when testing.

If you `conda install -c conda-forge openbabel` you’ll get the MMFF94 and UFF force fields. If you ` conda install -c xtb-python` you should get GFN-FF.

I was working on an Open Babel interface that doesn’t require the Python bindings, but had a bunch of hard to debug issues. I’m making progress on that and will likely implement UFF internally as well.

---

<div class="post-metadata">

**Author:** ![arugula\_jones](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/arugula_jones/32/1553_2.png) [@arugula\_jones](https://discuss.avogadro.cc/u/arugula_jones)\
**Post date:** [November 7, 2023, 12:37am UTC](https://discuss.avogadro.cc/t/new-force-field-framework/4921/7 "2023-11-07T00:37:04Z")

</div>

Thanks i’ll give it a shot!

---

<div class="post-metadata">

**Author:** ![arugula\_jones](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/arugula_jones/32/1553_2.png) [@arugula\_jones](https://discuss.avogadro.cc/u/arugula_jones)\
**Post date:** [November 7, 2023, 6:37pm UTC](https://discuss.avogadro.cc/t/new-force-field-framework/4921/8 "2023-11-07T18:37:58Z")

</div>

Ok - Installed the conda packages. How do I get avogadro to ‘read’ them? I’m not seeing any options other than LJ. Do I need to develop my own script following something like:  
[https://two.avogadro.cc/develop/scripts/energy.html](https://two.avogadro.cc/develop/scripts/energy.html)

Thanks!

---

<div class="post-metadata">

**Author:** ![ghutchis](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/ghutchis/32/456_2.png) [@ghutchis](https://discuss.avogadro.cc/u/ghutchis)\
**Post date:** [November 7, 2023, 6:39pm UTC](https://discuss.avogadro.cc/t/new-force-field-framework/4921/9 "2023-11-07T18:39:45Z")

</div>

No, a bunch of scripts should be installed with 1.98.

What OS are you using? Have you restarted Avo2 after installing the conda packages?

If you launch from the command-line prompt, you should currently see messages about registering the force fields.

---

<div class="post-metadata">

**Author:** ![arugula\_jones](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/arugula_jones/32/1553_2.png) [@arugula\_jones](https://discuss.avogadro.cc/u/arugula_jones)\
**Post date:** [November 7, 2023, 6:46pm UTC](https://discuss.avogadro.cc/t/new-force-field-framework/4921/10 "2023-11-07T18:46:05Z")

</div>

Hmm. Ok, I think I see whats going on. I think it isn’t finding my python interpreter, ubuntu jammy Jellyfish.

Ok, I set my python path and it found the force fields. Thanks!

---

<div class="post-metadata">

**Author:** ![ghutchis](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/ghutchis/32/456_2.png) [@ghutchis](https://discuss.avogadro.cc/u/ghutchis)\
**Post date:** [November 7, 2023, 8:04pm UTC](https://discuss.avogadro.cc/t/new-force-field-framework/4921/11 "2023-11-07T20:04:13Z")

</div>

Yes, we need some better tools for finding Python and selecting Python environments.
