<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://vasp.at/wiki/index.php?action=history&amp;feed=atom&amp;title=Running_GRACE_force_fields_in_VASP</id>
	<title>Running GRACE force fields in VASP - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://vasp.at/wiki/index.php?action=history&amp;feed=atom&amp;title=Running_GRACE_force_fields_in_VASP"/>
	<link rel="alternate" type="text/html" href="https://vasp.at/wiki/index.php?title=Running_GRACE_force_fields_in_VASP&amp;action=history"/>
	<updated>2026-04-04T11:10:05Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.1</generator>
	<entry>
		<id>https://vasp.at/wiki/index.php?title=Running_GRACE_force_fields_in_VASP&amp;diff=35699&amp;oldid=prev</id>
		<title>Singraber: Created page with &quot;{{available|6.6.0}} Pre-trained [https://gracemaker.readthedocs.io/ GRACE] machine-learned force fields can be used as an alternative to {{VASP}}-native force fields to drive essentially every {{VASP}} simulation which uses the the prediction-only mode {{TAG|ML_MODE|run}}. This includes molecular dynamics simulations, ionic optimization (see {{TAG|IBRION}}) and :Categ...&quot;</title>
		<link rel="alternate" type="text/html" href="https://vasp.at/wiki/index.php?title=Running_GRACE_force_fields_in_VASP&amp;diff=35699&amp;oldid=prev"/>
		<updated>2026-03-31T22:13:34Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{available|6.6.0}} Pre-trained [https://gracemaker.readthedocs.io/ GRACE] machine-learned force fields can be used as an alternative to &lt;a href=&quot;/wiki/Category:Machine-learned_force_fields&quot; title=&quot;Category:Machine-learned force fields&quot;&gt;{{VASP}}-native force fields&lt;/a&gt; to drive essentially every {{VASP}} simulation which uses the the prediction-only mode {{TAG|ML_MODE|run}}. This includes &lt;a href=&quot;/wiki/Category:Molecular_dynamics&quot; title=&quot;Category:Molecular dynamics&quot;&gt;molecular dynamics simulations&lt;/a&gt;, &lt;a href=&quot;/wiki/Structure_optimization&quot; title=&quot;Structure optimization&quot;&gt;ionic optimization&lt;/a&gt; (see {{TAG|IBRION}}) and :Categ...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{available|6.6.0}}&lt;br /&gt;
Pre-trained [https://gracemaker.readthedocs.io/ GRACE] machine-learned force fields can be used as an alternative to [[:Category:Machine-learned_force_fields|{{VASP}}-native force fields]] to drive essentially every {{VASP}} simulation which uses the the prediction-only mode {{TAG|ML_MODE|run}}. This includes [[:Category:Molecular_dynamics|molecular dynamics simulations]], [[Structure_optimization|ionic optimization]] (see {{TAG|IBRION}}) and [[:Category:Advanced_molecular-dynamics_sampling|advanced sampling techniques]]. To be able to use GRACE force fields {{VASP}} must be built with [[VASPml_library|VASPml]] (&amp;lt;code&amp;gt;-Dlibvaspml&amp;lt;/code&amp;gt;) &amp;#039;&amp;#039;&amp;#039;and&amp;#039;&amp;#039;&amp;#039; GRACE support (&amp;lt;code&amp;gt;-DVASPML_ENABLE_GRACE&amp;lt;/code&amp;gt;), for details see the [[Makefile.include#VASPml_(experimental)|build customization options]]. {{NB|warning|Due to an incompatibility in the interface layer GRACE force fields from versions 0.5.8 and 0.5.9 of &amp;lt;code&amp;gt;tensorpotential&amp;lt;/code&amp;gt; cannot be used together with {{VASP}}. A fix is currently work in progress. In the meantime please use force fields from &amp;lt;code&amp;gt;tensorpotential&amp;lt;/code&amp;gt; 0.5.7. Be aware that for these models the &amp;lt;code&amp;gt;metadata.json&amp;lt;/code&amp;gt; file generation step is mandatory (see box below).}}&lt;br /&gt;
&lt;br /&gt;
== Models ==&lt;br /&gt;
&lt;br /&gt;
The easiest way to obtain [https://gracemaker.readthedocs.io/en/latest/gracemaker/foundation/ GRACE models] is to download them via the [https://pypi.org/project/tensorpotential/ tensorpotential package], directly with &amp;lt;code&amp;gt;pip&amp;lt;/code&amp;gt; or within a dedicated [https://en.wikipedia.org/wiki/Conda_(package_manager) conda] environment. {{NB|tip|The &amp;lt;code&amp;gt;tensorpotential&amp;lt;/code&amp;gt; package is &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; a runtime dependency of {{VASP}} but the most convenient way of listing and retrieving available models. Besides downloading a model the package is neither required for compiling nor for running {{VASP}} with GRACE force fields.}} Install &amp;lt;code&amp;gt;tensorpotential&amp;lt;/code&amp;gt; and all its dependencies simply with:&lt;br /&gt;
&lt;br /&gt;
 pip install tensorpotential==0.5.7&lt;br /&gt;
&lt;br /&gt;
After installation the command line tool &amp;lt;code&amp;gt;grace_models&amp;lt;/code&amp;gt; becomes available. First, inspect available models with&lt;br /&gt;
&lt;br /&gt;
 grace_models list&lt;br /&gt;
&lt;br /&gt;
which will produce output like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
Available models:&lt;br /&gt;
...&lt;br /&gt;
================================================================================&lt;br /&gt;
GRACE-2L-OMAT&lt;br /&gt;
	DESCRIPTION: A two-layer semi-local GRACE model, fitted on the OMat24 dataset, with fixed 6 A cutoff.&lt;br /&gt;
	PATH: /fsc/home/singraber/.cache/grace/GRACE-2L-OMAT&lt;br /&gt;
	CHECKPOINT: AVAILABLE, BUT NOT DOWNLOADED&lt;br /&gt;
	LICENSE: Academic Software License&lt;br /&gt;
================================================================================&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
[https://gracemaker.readthedocs.io/en/latest/gracemaker/foundation/ Select a model] and download it with the following command:&lt;br /&gt;
&lt;br /&gt;
 grace_models download [MODEL_NAME]&lt;br /&gt;
&lt;br /&gt;
Given the example model above the command would be &amp;lt;code&amp;gt;grace_models download GRACE-2L-OMAT&amp;lt;/code&amp;gt;. The GRACE model will be automatically downloaded and unpacked to the directory &amp;lt;code&amp;gt;~/.cache/grace/&amp;lt;/code&amp;gt;. {{NB|deprecated|{{VASP}} requires the file &amp;lt;code&amp;gt;metadata.json&amp;lt;/code&amp;gt; to be present inside the model directory. This file is automatically shipped with &amp;lt;code&amp;gt;tensorpotential&amp;lt;/code&amp;gt; for models created since version 0.5.9. If you have an older version and the file is not present, please try to upgrade &amp;lt;code&amp;gt;tensorpotential&amp;lt;/code&amp;gt; and re-download the models. Or, alternatively, create it from the &amp;lt;code&amp;gt;metadata.yaml&amp;lt;/code&amp;gt; file with a Python script containing the following code snippet: &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import yaml&lt;br /&gt;
import json&lt;br /&gt;
import pathlib&lt;br /&gt;
import sys&lt;br /&gt;
&lt;br /&gt;
path = pathlib.Path(sys.argv[1])&lt;br /&gt;
&lt;br /&gt;
with path.open() as f:&lt;br /&gt;
    data = yaml.safe_load(f)&lt;br /&gt;
&lt;br /&gt;
with path.with_suffix(&amp;quot;.json&amp;quot;).open(&amp;#039;w&amp;#039;) as f:&lt;br /&gt;
    json.dump(data, f)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Save the Python code in a file, e.g. &amp;lt;code&amp;gt;grace_yaml2json.py&amp;lt;/code&amp;gt;, and run it with: &amp;lt;syntaxhighlight lang=&amp;quot;shell&amp;quot;&amp;gt;python grace_yaml2json.py ~/.cache/grace/MODEL_NAME/metadata.yaml&amp;lt;/syntaxhighlight&amp;gt; This will automatically generate the missing JSON file in the model directory.||Hint for models created with &amp;lt;code&amp;gt;tensorpotential&amp;lt;/code&amp;gt; version &amp;lt; 0.5.9:}}&lt;br /&gt;
&lt;br /&gt;
== Select GRACE model in {{VASP}} ==&lt;br /&gt;
&lt;br /&gt;
In the {{FILE|INCAR}} file the GRACE force field method must be selected via {{TAG|ML_TYPE|grace}} and the model may be specified via {{TAG|ML_GRACE_MODEL}}. A minimal block of tags could look like this:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 # MD related settings, etc.&lt;br /&gt;
 ...&lt;br /&gt;
 # ML force field settings&lt;br /&gt;
 {{TAGBL|ML_LMLFF}}       = .TRUE.&lt;br /&gt;
 {{TAGBL|ML_LIB}}         = .TRUE.&lt;br /&gt;
 {{TAGBL|ML_MODE}}        = run&lt;br /&gt;
 {{TAGBL|ML_TYPE}}        = grace&lt;br /&gt;
 {{TAGBL|ML_GRACE_MODEL}} = GRACE-2L-OMAT&lt;br /&gt;
 ...&lt;br /&gt;
{{NB|important|The GRACE force field predictions are automatically offloaded to the GPU if one is available. However, currently parallelism via MPI is not supported when running GRACE force fields. Hence, start {{VASP}} with &amp;lt;code&amp;gt;mpirun -np 1 ...&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Machine-learned force fields]]&lt;br /&gt;
[[Category:Howto]]&lt;/div&gt;</summary>
		<author><name>Singraber</name></author>
	</entry>
</feed>