# Thermodynamic Force Calculator for Abrupt AdResS¶

We introduced with the Abrupt AdResS method a new way of coupling the different simulation regions together. That is the basis for easier implementation into other codes. The implementation of smooth coupling GC- AdResS in GROMACS has several performance problems. However, the new Abrupt AdResS presents a very straight forward way to implement a new partitioning scheme, which solves two problems which affect the performance, the neighbor list search and the generic force kernel. Furthermore, we update the implementation to address this in a way that decouples the method directly from the core of any MD code, which does not hinder the performance and makes the scheme hardware independent. Theory, application and tests see https://aip.scitation.org/doi/10.1063/1.5031206 or https://arxiv.org/abs/1806.09870.

The drawback of this method is that a new (as in more direct) way to calculate the thermodynamic force is needed. While the theory is still the same, the interpolation has to be adapted.

## Purpose of Module¶

The new Abrupt coupling scheme introduces a density discrepancy which is very much restricted to the interface of the atomistic region and the coarse grained region. The thermodynamic force calculator in VOTCA (implemented up to version 1.3) is designed for the more smooth coupling over a larger region in space. Thus this code cannot be used for the small area of disturbance in this new scheme.

Here we present a thermodynamic force calculator for the abrupt coupling scheme. It is a mix between bash and Python and can be applied even to the older smooth coupling scheme.

## Background Information¶

Abrupt AdResS presents a very straight forward way to implement a new partitioning scheme. The drawback is that the particles mix in a very narrow region in space. The distance of the molecules at that interface can be too close, which has to be compensated via a force capping. However the flux of particles at that interface is fast, which leads to a rather localized discrepancy in the density.

The thermodynamic force calculator in VOTCA (up to version 1.3) is designed for a smooth and not very much disturbed region in space. Thus a new code to calculate the thermodynamic force was needed. The thermodynamic force is calculated by calculating the gradient of the density in a specific region in space. Thus any code taking this into account can be used. For the detailed discussion of the role and the basic principles behind this force see https://aip.scitation.org/doi/10.1063/1.5031206 or https://arxiv.org/abs/1806.09870.

The code provided here is designed for easy adjustable and can be used on different computer architectures (knowledge of bash is of an advantage).

## Building and Running¶

These three scripts present one way to calculate the thermodynamics force.

The central script is *smooth_dens.sh*. This is a Python 2.7 script which interpolates the density and generates the gradient of the density and provides the force as an ascii table.

*TF_calc_water_xplit_sphere.sh* is controlling the MD run, and which region to interpolate, and builds the tables needed. The commands and the options used are described in http://www.gromacs.org/ or if the spherical geometry for AdResS is used also here: http://www.votca.org/Documentation.

*run_tf_water_xplsit_sphere.sh* provides some possible input scenarios for *TF_calc_water_xplit_sphere.sh*.

To run *run_tf_water_xplsit_sphere.sh* one has to first enter the correct region, which should be interpolated in *TF_calc_water_xplit_sphere.sh*.

```
rmin = starting point along a distance with rref as origin
rmax = end point of the interpolation region
rbox = maximal box size (xsplit: x direction; sphere the maximal radius)
rref = is the point defined in the GROMACS input file
lc = defines the binning along the x direction or the radius
prefac = is basically a weighting on the thermodynamic force (small: more iteration, but more careful approach of the target density)
```

Note of caution: in *run_tf_water_xplsit_sphere.sh* and *TF_calc_water_xplit_sphere.sh* the GROMACS and VOTCA version used have to be specifically sourced. Then select which option in *run_tf_water_xplsit_sphere.sh* you want to use and comment the other out and execute:

```
for a new run without a thermodynamic force to start with:
bash run_tf_water_xplsit_sphere.sh 1 20 1
for a start from an existing thermodynamic force:
bash run_tf_water_xplsit_sphere.sh 21 20 2
```