<commit_before>---
---
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
});
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
[![Edit](https://img.shields.io/badge/Github-Improve_this_page-orange.svg)]({{site.github.repository_url}}/blob/master/docs/{{page.path}})

# Analysis

Faunus can perform on-the-fly analysis during simulation by allowing for an arbitrary number
of analysis functions to be added. The list of analysis is defined in the `analysis` section
at the top level input:

~~~ yaml
analysis:
    - systemenergy: {file: energy.dat, nstep: 500, nskip: 2000}
    - xtcfile: {file: traj.xtc, nstep: 1000}
    - widom:  {molecule: water, ninsert: 20, nstep: 50}
    - molrdf: {name1: water, name2: water, nstep: 100,
               dr: 0.1, dim: 3, file: rdf.dat}
    - ...
~~~

**Note:** all analysis methods support the `nstep` keyword that defines the interval between
sampling points and the `nskip` keyword that defines the number of initial steps that are excluded from the analysis. In addition all analysis provide output statistics of number of sample
points, and the relative run-time spent on the analysis.
{: .notice--info}

## Density

### Bulk Density

`density`   |  Description
----------- |  -------------------------------------------
`nstep=0`   |  Interval between samples

This calculates the average density, $\langle N_i/V \rangle$ of molecules and atoms
which may fluctuate in _e.g._ the isobaric ensemble or the Grand Canonical ensemble.
For atomic groups, densities of individual atom types are reported.
The analysis also files probability density distributions of atomic and polyatomic molecules
as well as of atoms involved in ID transformations, _e.g._, acid-base equilibria.
The filename format is `rho-@name.dat`.

### Density Profile

`atomprofile`  | Description
-------------- | ---------------------------------------------
`nstep=0`      | Interval between samples
`atoms=[]`     | List of atom names to sample; `*` selects all
`charge=false` | Calc. charge density instead of density
`file`         | Output filename with profile
`dr=0.1`       | Radial resolution
`origo=[0,0,0]`| Center of the profile ($r=0$)

Calculates the summed density of `atoms` in spherical shells around
`origo` which by default is the center of the simulation box:

$$
\rho(r) = \frac{\langle N(r) \rangle}{4\pi r^2dr}
$$

This can be used to obtain charge profiles, measure excess pressure
etc.

### Density Slice

`sliceddensity` | Description
--------------- | ---------------------------------------------
`atoms=[]`      | List of atom names to sample; `*` selects all 
`file`          | Output filename with profile
`dz=0.1`        | Resolution along _z_-axis
`nstep`         | Interval between samples

Calculates the density in cuboidal slices of thickness _dz_ along the _z_ axis.


## Structure

### Atomic $g(r)$

Samples the pair correlation function between atom id's _i_ and _j_,

$$
    g_{ij}(r) = \frac{ N_{ij}(r) }{ \sum_{r=0}^{\infty} N_{ij}(r) } \cdot \frac{ \langle V \rangle }{ V(r) }
$$

where $N_{ij}(r)$ is the number of observed pairs, accumulated over the
entire ensemble, in the separation
interval $[r, r+dr]$ and $V(r)$ is the corresponding volume element
which depends on dimensionality, `dim`.

`atomrdf`      |  Description
-------------- | ---------------------------------------------------------
`file`         |  Output file, two column
`name1`        |  Atom name 1
`name2`        |  Atom name 2
`dr=0.1`       |  $g(r)$ resolution
`dim=3`        |  Dimensions for volume element
`nstep=0`      |  Interval between samples

`dim` |  $V(r)$        
----- | ---------------<commit_msg>update in docs<commit_after>---
---
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
});
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
[![Edit](https://img.shields.io/badge/Github-Improve_this_page-orange.svg)]({{site.github.repository_url}}/blob/master/docs/{{page.path}})

# Analysis

Faunus can perform on-the-fly analysis during simulation by allowing for an arbitrary number
of analysis functions to be added. The list of analysis is defined in the `analysis` section
at the top level input:

~~~ yaml
analysis:
    - systemenergy: {file: energy.dat, nstep: 500, nskip: 2000}
    - xtcfile: {file: traj.xtc, nstep: 1000}
    - widom:  {molecule: water, ninsert: 20, nstep: 50}
    - molrdf: {name1: water, name2: water, nstep: 100,
               dr: 0.1, dim: 3, file: rdf.dat}
    - ...
~~~

**Note:** all analysis methods support the `nstep` keyword that defines the interval between
sampling points and the `nskip` keyword that defines the number of initial steps that are excluded from the analysis. In addition all analysis provide output statistics of number of sample
points, and the relative run-time spent on the analysis.
{: .notice--info}

## Density

### Bulk Density

`density`   |  Description
----------- |  -------------------------------------------
`nstep=0`   |  Interval between samples

This calculates the average density, $\langle N_i/V \rangle$ of molecules and atoms
which may fluctuate in _e.g._ the isobaric ensemble or the Grand Canonical ensemble.
For atomic groups, densities of individual atom types are reported.
The analysis also files probability density distributions of atomic and polyatomic molecules
as well as of atoms involved in ID transformations, _e.g._, acid-base equilibria.
The filename format is `rho-@name.dat`.

### Density Profile

`atomprofile`  | Description
-------------- | ---------------------------------------------
`nstep=0`      | Interval between samples
`atoms=[]`     | List of atom names to sample; `*` selects all
`charge=false` | Calc. charge density instead of density
`file`         | Output filename with profile
`dr=0.1`       | Radial resolution
`origo=[0,0,0]`| Center of the profile ($r=0$)

Calculates the summed density of `atoms` in spherical shells around
`origo` which by default is the center of the simulation box:

$$
\rho(r) = \frac{\langle N(r) \rangle}{4\pi r^2dr}
$$

This can be used to obtain charge profiles, measure excess pressure
etc.

### Density Slice

`sliceddensity` | Description
--------------- | ---------------------------------------------
`atoms=[]`      | List of atom names to sample; `*` selects all 
`file`          | Output filename with profile
`dz=0.1`        | Resolution along _z_-axis
`nstep`         | Interval between samples

Calculates the density in cuboidal slices of thickness _dz_ along the _z_ axis.
The _z_ position of each atom is calculated with respect to the center of mass of all atoms of the same type in the sampled configuration.

## Structure

### Atomic $g(r)$

Samples the pair correlation function between atom id's _i_ and _j_,

$$
    g_{ij}(r) = \frac{ N_{ij}(r) }{ \sum_{r=0}^{\infty} N_{ij}(r) } \cdot \frac{ \langle V \rangle }{ V(r) }
$$

where $N_{ij}(r)$ is the number of observed pairs, accumulated over the
entire ensemble, in the separation
interval $[r, r+dr]$ and $V(r)$ is the corresponding volume element
which depends on dimensionality, `dim`.

`atomrdf`      |  Description
-------------- | ---------------------------------------------------------
`file`         |  Output file, two column
`name1`        |  Atom name 1
`name2`        |  Atom name 2
`dr=0.1`       |  $g(r)$ resolution
`dim=3`        |  Dimensions for volume element
`nstep=0`      |  Interval between samples

`dim` |  $V(r)$        
----- | ---------------
{'fraction_non_alphanumeric': 0.18443098337414615, 'fraction_numerical': 0.012372728444387164, 'mean_word_length': 2.721822541966427, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6922163', 'n_tokens_mistral': 2404, 'n_tokens_neox': 2280, 'n_words': 840}