MW output files
===============

This section describes the different output files of MW. Generally, the files have a header that describes the data and for each step (including step 0) a series of data per atom. Here is a list of the different outputs and the associated keywords to use in the *output* block of the *runtime.inpt* file.

| Keyword                                 | Filename                                        |
| --------------------------------------- | ----------------------------------------------- |
| [step](#run.out)                        | run.out                                         |
| restart                                 | restart.xxx.out    (same format as *data.inpt*) |
| [trajectories](#trajectories.out)       | trajectories.out                                |
| [xyz](#trajectories.xyz)                | trajectories.xyz                                |
| [pdb](#trajectories.pdb)                | trajectories.pdb                                |
| [lammps](#trajectories.lammpstrj)       | trajectories.lammpstrj                          |
| [charges](#charges.out)                 | charges.out                                     |
| [total_charges](#total_charges.out)     | total_charges.out                               |
| [energies](#energies.out)               | energies.out     &    energies_breakdown.out    |
| [forces](#forces.out)                   | forces.out                                      |
| [elec_forces](#electrode_forces.out)    | electrode_forces.out                            |
| [dipoles](#dipoles.out)                 | dipoles.out                                     |
| [radius](#radius.out)                   | radius.out                                      |
| [polarization](#polarization.out)       | polarization.out                                |
| [potential_shift](#potential_shift.out) | potential_shift.out                             |
| [density](#density.out)                 | density.out      &     charge_density.out       |
| [temperature](#temperature.out)         | temperature.out                                 |



<a name="trajectories.xyz">

# trajectories.xyz

</a>

**Keyword: xyz** 

This file contains atomic coordinates and is readable by visualisation software such as VMD.
The xyz format (extension .xyz) is formatted as follows for each timestep:

```
   34418
# step        0
O       +4.325652246552878E+001 +4.210583510530589E+001 +1.882566925531533E+001
...
H1      +2.249059038894251E-001 +4.142403886183931E+001 +1.912298807923691E+001
...
H2      +4.258209758504747E+001 +4.224937060613090E+001 +1.954992950883959E+001
...
Na      +3.191812662659436E+001 +1.589913306330928E+001 +1.173136552132259E+002
...
Cl      +3.861340822256939E+001 +2.013602927057415E+001 +8.820481404446444E+001
...
P       +0.000000000000000E+000 +0.000000000000000E+000 +9.999996161042501E-001
...
C1      +1.601601268684763E+001 +9.632008233780541E+000 +2.026793247128378E+001
...
C2      +1.601601268684763E+001 +9.632008233780541E+000 +1.661381417500048E+002
...
```

The first line is the total number of atoms in the simulation box, the second line is a comment line where the step number is written, then for each atom is written one line with `name x y z` in angstroms.
The atoms are sorted by type, the non-metallic atoms first then the electrode atoms. 



<a name="trajectories.pdb">

# trajectories.pdb

</a>

**Keyword: pdb** 

This file contains atomic coordinates and charges and is readable by visualisation software such as VMD.
The pdb format (extension .pdb) is the Protein Data Bank format, described in detail at http://www.wwpdb.org/documentation/file-format-content/format33/v3.3.html . It is formatted as follows for each timestep:

```
CRYST1   82.581   82.581  352.256  90.00  90.00  90.00 P 1           1
ATOM      1 O            1      43.257  42.106  18.826       -0.85
...
ATOM   8800 O         8800      28.505  23.068 122.500       -0.85
ATOM   8801 H1           1       0.225  41.424  19.123        0.42
...
ATOM  26400 H2        8800      27.790  22.398 122.698        0.42
ATOM  26401 Na           0      31.918  15.899 117.314        1.00
...
ATOM  27121 C1        8801      16.016   9.632  20.268       5.E-4
...
```

The first line contains crystallographic data for the box (a, b, c, $'\alpha'$, $'\beta'$, $'\gamma'$) and the space group (here always P1). 
Then for each atom is written one line with `ATOM id name molid x y z occupancy beta` in angstroms. 
The atoms are sorted by type, the non-metallic atoms first then the electrode atoms. 

The `molid` is 0 if the atom does not belong to any molecule (eg. Na), n (from 1 to Nmol) for atoms that belong to molecule n and n + m (for m from 1 to Nelectrodes) for electrode atoms.

The `beta` field contains the charge of the atom. For electrode atoms, it is displayed in scientific notation but with small precision due to a limited number of characters.  



<a name="trajectories.lammpstrj">

# trajectories.lammpstrj

</a>

**Keyword: lammps** 

This file contains atomic coordinates and charges and is readable by visualisation software such as VMD.
The lammps format (extension .lammpstrj) is described in detail at https://lammps.sandia.gov/doc/dump.html . It is formatted as follows for each timestep:

```
ITEM: TIMESTEP
       0
ITEM: NUMBER OF ATOMS
   34418
ITEM: BOX BOUNDS
    0.000   82.581
    0.000   82.581
    0.000  352.256
ITEM: ATOMS element id molid x y z q vx vy vz
O                    1             1         43.257   42.106   18.826         -0.848    0.000    0.000    0.000
...
C1               27121          8801         16.016    9.632   20.268          0.000     5.208E-004    0.000    0.000
...
```

The first lines are self-explanatory. Then for each atom one line is written with `name id molid x y z q_point q_electrodes 0.0 0.0`. The position `x y z` are in angstroms. The `q_point` and `q_electrodes` are the mobile ions and the electrode atoms charges respectively and are written in two separate fields to simplify the visualization since they usually have different orders of magnitude. This format allows to include the electrode charge in the output with sufficient precision. The electrode charges field is called `vx` to trick VMD for visualization purposes. Indeed VMD is able to automatically load a .lammpstrj trajectory and read in the velocities. It is possible to use the script `\mw2\tools\charges.tcl` to load `vx` into a `user` buffer that can be used to color the electrode atoms.

**charges.tcl**

Usage: `vmd -e charges.tcl trajectories.lammpstrj`

```
set framecount [molinfo top get numframes]
set sel [atomselect top all]
for {set frame_no 0} {$frame_no<$framecount} {incr frame_no} {
$sel frame $frame_no
$sel set {user user2 user3} [$sel get {vx vy vz}]
}
$sel delete
```

In this way the electrode charges are loaded as a time-dependent quantity and can be visualized through the trajectory.

[Screenshot_from_2018-07-23_16_38_57](/uploads/91985f1f23d6ad09bf4a7a2c97e75fde/Screenshot_from_2018-07-23_16_38_57.png)



<a name="trajectories.out">

# trajectories.out

</a>

**Keyword: trajectories** 

This file contains atomic coordinates and velocities in atomic units.

#### Header
```
# Trajectories of mobile particles in atomic unit
# -----------------------------------------------
# Length:   1 au = 0.052917721067 nm
# Velocity: 1 au = 2.1876912633e6 m.s^-1
#           x                      y                       z                       vx                      vy                      vz          
```

#### Per step
```
# step        0
+2.252927235174144E+001 +1.491215117670267E+001 +5.634309399202423E+001 -6.311893173283321E-005 +3.225387570492293E-004 +2.407259791868403E-004
for each atom NOT in the electrodes ...
```



<a name="charges.out">

# charges.out

</a>

**Keyword: charges** 

This file contains per-atom electrode charges in atomic units.

#### Header
```
# Electrode atom charges in atomic unit
# -------------------------------------
# Charge:   1 au = 1.602176565e-19 C = 1 e
```

#### Per step
```
# step        0
-2.858639553520068E-002
for each atom in the electrodes ...
```



<a name="total_charges.out">

# total_charges.out

</a>

**Keyword: total_charges** 

This file contains per-electrode total charges in atomic units.

### Header

```
# Total charges on electrodes in atomic unit
# ------------------------------------------
# Charge:   1 au = 1.602176565e-19 C = 1 e
```

### Per step

```
      +0 -3.390240538228992E+000 +3.390240538229032E+000
for each step [step   first_electrode_charge   second_electrode_charge] ...
```



<a name="energies.out">

# energies.out

</a>

**Keyword: energies** 

This file contains standard energy terms in atomic units.

### Header

```
# Energy in atomic unit (1 Eh = 2625.499640 kJ/mol)
# -------------------------------------------------
# step         Hamiltonian             Total energy           Kinetic energy         Potential energy       Thermostat energy      External field energy
```

### Per step

```
       0 -1.521841718384888E+001 -1.525972630561134E+001  1.766533045123837E+000 -1.570496063867715E+001  4.130912176245664E-002 -1.321298712058023E+000
 for each step [step different_energy_terms] ...
```



# energies_breakdown.out

**Keyword: energies** 

This file contains requested energy terms or energy terms involved in the simulation in atomic units.

### Header

```
# Energy in atomic unit (1 Eh = 2625.499640 kJ/mol)
# -------------------------------------------------
# step         Hamiltonian             Total energy           Kinetic energy         Potential energy       Thermostat energy      External field energy
```

### Per step

```
       0 -1.521841718384888E+001 -1.525972630561134E+001  1.766533045123837E+000 -1.570496063867715E+001  4.130912176245664E-002 -1.321298712058023E+000
for each step [step requested_energy_terms] ...
```



<a name="forces.out">

# forces.out

</a>

**Keyword: forces** 

This file contains per-atom forces in atomic units.

#### Header
```
# Forces on mobile particles in atomic unit
# -----------------------------------------
# Force:   1 au = 8.2387225e-8 N = 51.421 eV/angstrom
#      fx_total                fy_total                fz_total               fx_coulomb              fy_coulomb              fz_coulomb           fx_intermolecular       fy_intermolecular       fz_intermolecular       fx_intramolecular       fy_intramolecular       fz_intramolecular 
```

#### Per step
```
# step        0  
+1.917484397957197E-003 -2.245047988217218E-003 +9.473756648384507E-003 -1.294605675949427E-003 +5.470893886095293E-003 +1.237801146679319E-003 +3.212090073906625E-003 -7.715941874312511E-003 +6.291265501705188E-003 +0.000000000000000E+000 +0.000000000000000E+000 +0.000000000000000E+000
for each atom NOT in the electrodes ...
```



<a name="electrode_forces.out">

# electrode_forces.out

</a>

**Keyword: elec_forces** 

This file contains per-electrode total forces in atomic units, the pressure exerted on each electrode calculated as the force on the electrode divided by the surface area, the velocity of the electrode and its center of mass position in the z direction. These quantities are only calculated if the keywords *piston* or *compute_force* are used in the *electrodes* block.

#### Header
```
# Total force on electrodes and pressure in atomic unit
# -----------------------------------------
# Force:   1 au = 8.2387225e-8 N = 51.421 eV/angstrom
# Pressure:   1 bar = 3.3988273773641905e-09 ua
#      fx_total                fy_total                fz_total              fx_coulomb_sr           fy_coulomb_sr           fz_coulomb_sr           fx_coulomb_k0           fy_coulomb_k0           fz_coulomb_k0           fx_coulomb_lr           fy_coulomb_lr           fz_coulomb_lr         fx_lennard_jones        fy_lennard_jones        fz_lennard_jones          fx_fumi_tosi            fy_fumi_tosi            fz_fumi_tosi               pressure               velocity_z                com_z  
```

#### Per step
```
# step        0       
-4.184444079019096E-004 -6.759856281322282E-005 -4.932743186981107E-002 -1.768612565417470E-004 +8.798245908302714E-005 +2.411734008488643E-001 +0.000000000000000E+000 +0.000000000000000E+000 -2.412987521249291E-001 +1.960851344827884E-005 -2.796957853870071E-006 -5.009297052230372E-006 +0.000000000000000E+000 +0.000000000000000E+000 +0.000000000000000E+000 -2.611916648084414E-004 -1.527840640423799E-004 -4.919707129669403E-002 -1.216416761833347E-005 +0.000000000000000E+000 +1.392924999999997E+001
for each electrode type ...
```



<a name="dipoles.out">

# dipoles.out

</a>

**Keyword: dipoles** 

This file contains atomic induced dipoles (not including the permanent dipoles) for each atom in atomic units.

#### Header
```
# Dipoles on mobile particles in atomic unit
# -----------------------------------------
# Dipole:   1 au = 2.541746 D
#          mux                     muy                     muz         
```

#### Per step
```
# step        0
-4.433484812765839E-001 -1.036234045576153E-001 -4.427922497523061E-001
for each atom ...
```



<a name="radius.out">

# radius.out

</a>

**Keyword: radius** 

This file contains atomic radii (*delta*) and dipolar deformation (*epsilonx*, *epsilony* and *epsilonz*) for each atom in atomic units.

#### Header
```
# Radius of mobile particles in atomic unit
# -----------------------------------------
# Radius:   1 au = 0.529177 angstrom
#        delta                epsilonx                epsilony                epsilonz     
```

#### Per step
```
# step        0
-2.595483626778200E-001 +1.453598964544551E-002 +3.875351590855750E-002 +2.197103355947514E-002
for each atom ...
```



<a name="polarization.out">

# polarization.out

</a>

**Keyword: polarization** 

This file contains the global polarization of the simulation box.

### Header

```
# Polarization of the simulation cell in atomic unit
# -----------------------------------------
# Polarization:   1 au = 57.214 765 75 C/m2
```

### Per step

```
      +0 +2.077663389940458E-004 +8.578553061308164E-003 -3.042513139463272E-003
for each step [step px py pz] ...
```



<a name="potential_shift.out">

# potential_shift.out

</a>

**Keyword: potential_shift** 

This file contains the electric potential shift due to neutral charges constraint on the electrodes.

#### Header

```
# Potential shift of the electrodes in atomic unit
# -----------------------------------------
# Potential:   1 au = 27.2113834 V
```

### Per step

```
       +0 +1.485283063533584E-001
for each step [step potential_shift] ...
```



<a name="density.out">

# density.out

</a>

**Keyword: density** 

This file contains the density profile in the z direction in atomic units (bohr$`^{-3}`$), it starts at *zmin* (by default 0.0) and stops at *zmax* (by default the box length $`L_z`$). Any atom present at $`z<zmin`$ is counted in the first bin and any atom with $`z>zmax`$ is counted in the last bin.

### Header

```
# Ion number density
# ------------------
# Average over          0 steps.
# z (au)     total             Na           Cl           O            H1           H2           C1           C2      
```

### Per bin

```
103.934936850  0.000000000  0.000000000  0.000000000  0.000000000  0.000000000  0.000000000  0.000000000  0.000000000
for each bin ...
```



# charge_density.out

**Keyword: density** 

This file contains the charge density profile in the z direction in atomic units (e.bohr$`^{-3}`$), it starts at *zmin* (by default 0.0) and stops at *zmax* (by default the box length $`L_z`$). Any atom present at $`z<zmin`$ is counted in the first bin and any atom with $`z>zmax`$ is counted in the last bin.

### Header

```
# Ion charge density
# ------------------
# Average over          0 steps.
# z (au)     total             Na           Cl           O            H1           H2           C1           C2      
```

### Per bin

```
103.934936850  0.000000000  0.000000000  0.000000000  0.000000000  0.000000000  0.000000000  0.000000000  0.000000000
for each bin ...
```



<a name="temperature.out">

# temperature.out

</a>

**Keyword: temperature** 

This file contains the temperature.

### Header

```
# Temperature in K
# ----------------
# step temperature (K)
```

### Per step

```
        0  2.987026510511217E+002
for each step [step temperature] ...
```



<a name="run.out">

# run.out

</a>

**Keyword: step**
This file is the main output of the simulation and contains various information on the simulation.

#### Header
```
**************************************************************************
**************************************************************************
**                                                                      **
**                                                                      **
**                              METAL WALLS                             **
**                                                                      **
**                                                                      **
**************************************************************************
**************************************************************************
Development version of MetalWalls based on release 18.07
commit 2a8aeb85384930537300a5313a131708f967d582

Compiled with Intel Fortran 19. 0. 0 on  Feb 14 2020 at   11:13:44
MPI library version 3.0
HOSTNAME: login3.occigen
F90:      mpiifort
F90FLAGS: -g -O3 -xHost -xCORE_AVX2 -align array64byte -mkl=cluster  -module ./build/include
FPPFLAGS: -fpp -DMW_USE_PLUMED
LDFLAGS:

Currently Loaded Modulefiles:
c/intel/.19.4
c++/intel/.19.4
fortran/intel/.19.4
mkl/19.4
idb/19.4
intel/19.4
intelpython3/2019.3
intelmpi/5.1.3.258

Parallel setup
==============

MPI communicator id:   ********
MPI communicator size:       56
MPI rank:                     0
```
It shows the version the compilation options it has been compiled with and the modules loaded at compile time, plus some information on the parallel environment.

#### System parameters
The System parameters section simply prints all parameters set in the *runtime.inpt* file but also the ones that have not been set, i.e. set with their default values. Here we only provide the different subsections contained in the system parameters, only the appropriate ones are present in this output file. 
```
System parameters:
==================

Time step:              4.13410E+01
Number of steps:            1000000
Total simulation time:  4.13410E+07

Total number of molecules:              2159
Total number of ions:                   6478
Total number of atoms:                  4800
Total number of degrees of freedom:    12954

charges    at t=0 are provided: yes
forces     at t=0 are provided: yes
dipoles    at t=0 are provided: yes
radius     at t=0 are provided:  no

box
---
velocities
----------
thermostat
----------
ion types
---------
electrodes
----------
Daim
----
molecules
---------
Lennard-Jones
-------------
Fumi-Tosi
---------
Damping
-------
polarization
------------
ewald
-----

```

#### Local work assignment
```
local work
----------
...
```

The work is distributed among the different processors. The localwork section details what is assigned to the process doing the output (rank 0 here). Each process will output different values in this section.

More details are given in the developer's section.

#### Algorithms parameters

```
Algorithms parameters:
======================
```

This section contains the parameters of the algorithms used for solving the electrode charges or the dipoles, such as tolerance, maximum number of iterations... Here are the different possibilities:

```
Electrodes parameters:
----------------------
constant charge
---------------
cg
--
matrix_inversion
----------------
maze
-------
```

```
Ion radius parameters:
----------------------
cgaim
-----
|cgaim| maximum number of iterations:          200
|cgaim| Residual error:                1.00000E-15
```



#### Time loop

Information that appears every time steps (frequency to be set in the *runtime.inpt* file). Pretty self explanatory except:

* `elapsed time`: wall clock time to perform the last iteration

There are also information for each specific algorithms that appear here. This is an example:

```
|step| step      5
|step| step      5 /    100 in this run.
|step| elapsed time:        1.38733E-01
|step| kinetic energy:      2.47459E+01 kJ/mol
|step| temperature:         2.90719E+02 K
|step| Global charge on electrode  1: -3.26645E+01
|step| Global charge on electrode  2:  3.26738E+01
|step| Global charge on electrodes:    9.30594E-03
|cg| number of iterations:           25
|cg| Residual norm:         7.89848E-05
|cg| Residual target:       8.54283E-05
```


#### Timings

This section contains different time statistics for the simulation. It shows:

* the total elapsed time in seconds
* a first rough break down between init, setup and main loop
* the portion of the time measured in the following breakdown
* a breakdown of the time spent
* the sum of timings and percentage of the breakdown is equal to the ones of the line `Time Breakdown`, i.e. 7.34710E+00 and 53.61 in this example.

```
Total elapsed time:  1.37054E+01 seconds.

Elapsed Times breakdown:
========================
                                   average (s)   cumul. (s) fraction (%)
  initialization:                  1.82475E-01  1.82475E-01         1.33
  setup:                           2.74965E-01  2.74965E-01         2.01
  main loop:                       1.32480E+01  1.32480E+01        96.66
  Time breakdown                     ----       7.34710E+00        53.61
  => Time NOT in breakdown           ----       6.35831E+00        46.39

Ions->Atoms Coulomb potential
-----------------------------
  long range                       1.64705E-03  1.66352E-01         1.21
  k==0                             2.59101E-03  2.61692E-01         1.91
  short range                      4.26518E-03  4.30783E-01         3.14

Atoms->Atoms Coulomb potential
------------------------------
  long range                       2.24967E-04  3.39475E-01         2.48
  k==0                             4.53605E-04  6.84490E-01         4.99
  short range                      6.05210E-04  9.13262E-01         6.66
  self                             2.56999E-06  3.87812E-03         0.03

Ions Coulomb forces
-------------------
  long range                       3.21367E-03  3.24581E-01         2.37
  k==0                             5.80811E-03  5.86619E-01         4.28
  short range                      1.43005E-02  1.44435E+00        10.54

Ions Coulomb potential
----------------------
  long range                       0.00000E+00  0.00000E+00         0.00
  k==0                             0.00000E+00  0.00000E+00         0.00
  short range                      0.00000E+00  0.00000E+00         0.00
  self                             0.00000E+00  0.00000E+00         0.00

Rattle
------
  positions                        7.44055E-03  7.44055E-01         5.43
  velocities                       3.41494E-03  3.41494E-01         2.49

Lennard-Jones
-------------
  melt forces                      1.52490E-03  1.54015E-01         1.12

Diagnostics
-------------
  diagnostics computations         1.86706E-04  1.86706E-02         0.14
  IO                               6.44799E-03  9.22062E-01         6.73                   
```
