Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tempering update #454

Merged
merged 25 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
040c14f
added exchange_map parameter
IVinterbladh Jul 4, 2023
83930e9
added part to output for tempering
IVinterbladh Jul 4, 2023
a144ad9
trying to output exchanges
IVinterbladh Jul 4, 2023
bd61f80
added exchange statistics to out-file regarding parallel tempering ex…
IVinterbladh Jul 4, 2023
6a2ca3b
updated exchange statistics for parallel tempering
IVinterbladh Jul 4, 2023
fbb3558
changed to small letters for xyzqi etc. in tempering argument in sch…
IVinterbladh Dec 12, 2023
29da4d4
Merge branch 'master' into tempering_update
mlund Dec 13, 2023
22c6aa7
fixed 3 first comments in PR #441
IVinterbladh Dec 21, 2023
db288ce
Merge branch 'tempering_update' of github.com:mlund/faunus into tempe…
IVinterbladh Dec 21, 2023
f87b6be
Merge branch 'master' into tempering_update
mlund Jun 17, 2024
5b552da
merging remote to local
IVinterbladh Jul 15, 2024
831f0fb
Merge branch 'master' into tempering_update
IVinterbladh Jul 15, 2024
776a3e3
update to tempering print out file
IVinterbladh Jul 16, 2024
d1e886e
modified move.h
IVinterbladh Jul 17, 2024
3f7f642
fixed missing bracket
IVinterbladh Jul 17, 2024
d6e6777
error fixed
IVinterbladh Jul 17, 2024
40db3f8
test
IVinterbladh Jul 17, 2024
3e25932
test
IVinterbladh Jul 17, 2024
b8a6939
test3
IVinterbladh Jul 17, 2024
bd33c8f
fixed errors with writing to exchange file for tempering
IVinterbladh Jul 18, 2024
8df3cad
updated temper example notebook and parallel tempering documentation …
IVinterbladh Jul 18, 2024
6e51290
Merge branch 'master' into tempering_update
IVinterbladh Jul 18, 2024
448c2c0
Update moves.md
mlund Jul 19, 2024
2c1b096
Update moves.md
mlund Jul 19, 2024
89929cf
Update move.cpp
mlund Jul 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions docs/_docs/moves.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ The default value of `repeat` is the number of atoms in the `molecule` minus two
`volume_scale=isotropic` | How to apply exchanged volumes: `z`, `xy`, `isotropic`, `isochoric`
`nstep=1` | Number of sweeps between samples.
`partner_policy=oddeven` | Policy used to create partner pairs (currently only `oddeven`)
`file` | Exchange statistics from the tempering moves (`.dat|.dat.gz`)

We consider an extended ensemble, consisting of _n_
sub-systems or replicas, each in a distinct thermodynamic state (different
Expand Down Expand Up @@ -352,8 +353,15 @@ Support for fluctuating number of particles, i.e.
grand canonical moves is currently untested and should be
considered experimental.

#Exchange statistics
In the output file, the acceptance and attempts of an exchange direction can be found under exchange in temper;moves. Next, the first tap under exchangempi gives which mpi box the outfile represents (ex. 0, 1,...). Under this number the tab exchanges all executed temper movements are listed. For each movement two placeholders are given, which represents the mpi's the tempering algorithm tries to switch. If the tempering move was not accepted, both the placeholders will be -1. When the tempering move is accepted do the placeholders contain the numbers of the interchanged mpi's. In faunus/examples/temper there is a notebook "temper\_exchange\_statistics.ipynb" illustrating how this aquired data can be used to study how the mpi's are exchanged.

# Exchange statistics

If `file` is provided, an exchange file for each MPI rank is created.
For respective step accepted and rejected attempts of exchange direction are recorded.
If the tempering move was rejected, the number -1 is recorded.
When the tempering move is accepted, the number of the interchanged mpi is recorded.
For example, in the exchange file for MPI rank 2 an accepted temper move with rank 3 will record a 3, meaning the mpi's `2 <-> 3` etc.
In `examples/temper/` contains a notebook illustrating how this can be used to study how exchange statistics.


## Volume Move
Expand Down
89 changes: 89 additions & 0 deletions examples/temper/temper_exchange_statictics.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "d5e44a45",
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"import numpy as np\n",
"import os.path, os, sys, glob, json, copy\n",
"from jinja2 import Template\n",
"from itertools import product\n",
"import ruamel_yaml as yaml\n",
"from io import StringIO \n",
"import json\n",
"\n",
"workdir = 'workdir_example_name' #Change to name of directory where files are located\n",
"\n",
"counter = 0 \n",
"mpi_where = 0 #Which mpi to start in"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c30e78d2",
"metadata": {},
"outputs": [],
"source": [
"\n",
"counter = 1 \n",
"mpi_where = 9 #which mpi to start in\n",
"steps = 10 #number of tempering events\n",
"\n",
"plt.plot(0, mpi_where, 'k*', markersize=7) #starting point\n",
"plt.title(f'Movement of original mpi {mpi_where}')\n",
"\n",
"\n",
"mpiX = np.loadtxt(f'{workdir}/mpi{mpi_where}.exchange.dat', delimiter=' ', skiprows=1) # mpi exchange file to start with\n",
"\n",
"while counter <= len(mpiX):# go throuhg all exchanges, once the counter is larger than the length of the exchange file, there where no more exchanges\n",
" if counter != mpiX[counter-1][0]: # check if the counter is the same as the step number\n",
" plt.plot(counter, mpi_where, 'r*') # if not, there was no exchange and mpi_where stays the same\n",
" counter += 1\n",
" continue\n",
" \n",
" if mpiX[counter-1][1] == -1: # if -1 the exchanges was not accepted add to counter, mpi_where stays the same\n",
" plt.plot(counter, mpi_where, 'r*')\n",
" counter += 1\n",
" continue\n",
" else: # check between which ranks were swapped \n",
" if mpi_where < mpiX[counter-1][1]: # if mpi_where is smaller than the rank the exchange was made with mpi number mpi_where + 1\n",
" mpi_where += 1 \n",
" if mpi_where > mpiX[counter-1][1]: # if mpi_where is larger than the rank the exchange was made with mpi number mpi_where - 1\n",
" mpi_where -= 1 \n",
"\n",
" plt.plot(counter, mpi_where, 'bo')\n",
" mpiX = np.loadtxt(f'{workdir}/mpi{mpi_where}.exchange.dat', delimiter=' ', skiprows=1) # load exchange file for currect mpi \n",
" counter += 1\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading