3.1. ReaxFF (basic): H₂O bond scan

This example shows how to fit a ReaxFF force field to reproduce a DFT-calculated H–OH bond dissociation curve of a water molecule in the gas phase.

../../_images/toc_simple_reaxff.png

Fig. 3.1 Bond length scan of a water molecule using Water2017.ff (initial, green), DFT (reference, blue), and refitted ReaxFF force field in this tutorial (red). The (88) means that the best fit was obtained for evaluation 88.

The ReaxFF force field Water2017.ff (DOI: 10.1021/acs.jpcb/7b02548) is used as a starting point for the parametrization.

Note

The Water2017.ff force field was originally optimized for liquid water, not gaseous water.

The tutorial files can be found in $AMSHOME/scripting/scm/params/examples/ReaxFF_water. The input files already exist if you want to skip generating them (then jump to Run the ReaxFF parametrization).

For each step, a few different ways are shown:

The differences are summarized at the end of the tutorial.

3.1.1. Calculate the reference data

The reference data will be a bond scan of one of the H–OH bonds in gaseous water. The easiest way to set up such a calculation is as follows:

1. Open AMSinput with the ADF panel active. (If you do not have an ADF license, you can use a different reference engine).
2. Draw a water molecule, or use the search box to search for water
3. Task → PES Scan, and click the arrow icon to the right.
4. Select the O atom and one of the H atoms
5. Click the + icon next to O(1) H(2) distance
6. Set the number of scan points for SC-1 to 11
7. Set the range minimum to 0.85 angstrom, and the maximum to 1.35 angstrom.
8. Save with the name H2O_pesscan and run
../../_images/RxFF_Water_GUI_scan.png

3.1.2. Import the reference data into ParAMS

Select the finished reference job in AMSjobs
Job → Add to ParAMS (Ctrl-T)
This brings up the ParAMS GUI and an import dialog
In the dialog, set Use ResultsImporter to Add Single Job (default)
Set Task (for new job) to PESScan (default)
Set Properties to pes (default)
Click Import
../../_images/RxFF_Water_GUI_import_dialog.png

This adds

  • A job with the ID H2O_pesscan to the Job Collection. It has task PESScan, with settings taken from the reference pes scan job (which bond to scan, the number of points to sample, etc.).

  • A training set of type PES with the detail H2O_pesscan, relative_to=3. The relative_to_3 means that the energies along the bond scan are calculated with respect to the 4th point (the indexing starts with 0), because that point was the lowest in energy. Select the entry and switch to the Info panel at the bottom to see the reference values.

  • An engine adf;<empty Settings>;. This engine contains the settings that were used in the reference calculation.

../../_images/RxFF_Water_GUI_imported_scan.png

If you would like to change the point along the bond scan that the other energies are relative to, it can be done as follows:

Go to the Training Set panel
Double-click in the Details column where it says H2O_pesscan, relative_to=3. This brings up a dialog with more details.
../../_images/RxFF_Water_GUI_click_PES_details.png
Note how the 4th value is 0.0 and all the other numbers are positive
../../_images/RxFF_Water_GUI_change_relative_to.png
On the PES line, change relative_to=3 to relative_to=0.
Click OK. Note: The reference values have not yet changed!
../../_images/RxFF_Water_GUI_change_relative_to_0.png
Select the entry on the Training Set panel.
Training Set → Get Data From Ref Jobs
This updates the reference values.
Double-click in the Details column where it says H2O_pesscan, relative_to=0. This brings up a dialog with more details.
Note how the 1st value is now 0.0, and some of the other numbers are negative
../../_images/RxFF_Water_GUI_change_relative_to_0_show.png
Change back: On the PES line, change relative_to=0 to relative_to=3.
Select the entry on the Training Set panel.
Training Set → Get Data From Ref Jobs
This updates the reference values.

3.1.3. Set the parameters to optimize

In this case, we will optimize all O-H bond parameters of the ReaxFF force field. The starting point (initial parameters) come from Water2017.ff (DOI: 10.1021/acs.jpcb/7b02548).

First, load Water2017.ff:

In the ParAMS GUI, select Parameters → Load ReaxFF Force Field → Water2017.ff

Next, only set the O-H bond parameters to be active:

Switch to the Parameters tab in the bottom half
In the Block drop-down, choose BND (bond parameters)
../../_images/RxFF_Water_GUI_select_block.png
In the Category drop-down, choose Standard - these are the parameters that are most common to optimize.
../../_images/RxFF_Water_GUI_select_active.png
Scroll down to the bottom, and tick the Active checkbox for all 12 parameters with Atoms equal to H O
../../_images/RxFF_Water_GUI_active_parameters.png

Tip

In the bottom search box, type H.O: to search for parameters between H and O (both BND and OFD parameters). Remember to clear the search box to see all parameters again.

Note

Normally you wouldn’t optimize all bond parameters, but only a few of them (you could try different combinations). Here, we optimize all bond parameters for illustration purposes only. For example, optimizing π-bond parameters for H₂O is not very useful!

See also

The equations that the parameters enter.

3.1.4. Run the ReaxFF parametrization

For ReaxFF, we recommend to use CMA-ES. It is a method which samples popsize parameters around a central point (mean). The first central point is the initial parameters. The sigma keyword affects how broad the sampled distribution is (how far away from the central point parameters are sampled).

After an iteration, which consists of popsize parameter evaluations, the central point and sigma are updated. The central point will approach the optimized parameters, and sigma will decrease as the optimization progresses. In this way, the sampled distribution is very broad in the beginning of the optimization, but becomes smaller with time.

When sigma reaches the minsigma value, the optimization stops.

See also

Tip

Decrease the initial sigma value for faster convergence (less global optimization).

Note: The settings panel in AMS2023 has changed compared to AMS2022.

Switch to the OptimizationPanel panel in the bottom table
Set Max loss function calls to 100
../../_images/RxFF_Water_GUI_settings_main.png
Click the MoreBtn next to Optimizers
For Optimization algorithm: #1 set Type to CMAES
Set σ₀ to 0.1
Set Popsize to 10
Set Min sigma to 0.0001
../../_images/RxFF_Water_GUI_settings_optimizer.png
Switch to the Details → Output panel
Set Training set logger General to 5
Also set Parameters, History, and Flush to 5.
../../_images/RxFF_Water_GUI_settings_output.png
File → Save As
Save with the name reaxff_water.params
File → Run

3.1.5. Visualize the results

For more details about graphs and results, see the Getting Started: Lennard-Jones tutorial.

On the Graphs tab, select Best H2O_pesscan_relative_to_3.

This plots the file optimization/training_set_results/best/pes_predictions/H2O_pesscan_relative_to_3.txt.

To compare to the bond scan using Water2017.ff, choose Data From → Training(initial): ΔE_prediction.

../../_images/RxFF_Water_GUI_results_bondscan.png

Tip

You double-click on a plot axis to access plot configuration settings.

3.1.6. ffield.ff: The force field file

To run new ReaxFF simulations with your fitted force field, you need the force field file ffield.ff.

You can find it in the results directory in optimization/training_set_results/best/ffield.ff.

New in AMS2024: After the parametrization job has finished, in the ParAMS GUI you can select File → Open Optimized Engine in AMSinput → Best training to open AMSinput with the engine settings (path to the trained force field file) already inserted into AMSinput.

Tip

The first line of the file is a header. Fill it with some meaningful content describing

  • who made it,

  • when it was made, and

  • the types of training data (systems, reference methods)

You can also change the header in the ParAMS GUI: Select Parameters → Edit ReaxFF header before running your job.

3.1.7. Summary of the 3 different ways

Differences of the three different ways of running this tutorial (GUI, Python, Command-line) are given below:

Action

GUI

Python

Command-line

Run reference job

AMSinput/AMSjobs

PLAMS

Import results

Import dialog

Results Importer

Run ParAMS

AMSjobs

ParAMSJob.run()

$AMSBIN/params

Final plot

Graphs panel

ParAMSResults.get_pes_prediction()

$AMSBIN/params plot

3.1.8. Next steps with ReaxFF parametrization

Check out the ReaxFF (advanced): ZnS for a more realistic parametrization, which also shows how to build a new ReaxFF force field from scratch.