-
Notifications
You must be signed in to change notification settings - Fork 103
Fortran Introduction
The main examples directory contains the Fortran examples. The README contains some notes on the Fortran language, and on building the examples.
Here are some notes to assist in running the programs. Some details of tests carried out on the programs are also given. Do not expect to duplicate these results exactly, they are simply a guide as to the kind of behaviour to expect. If you find a definite programming error, please report it via the Issues tab above (you will need to be signed into GitHub to do this).
Most of the Fortran codes use a namelist
to input a few parameters from standard input.
This gives an easy way to specify default values in the program itself, and to use a
keyword-based syntax to specify values different from the default ones at run-time.
The input file, or string, should usually begin with &nml
and end with /
.
As a minimum, the program will expect to read &nml /
(an empty list),
and on a Linux/Unix/bash system a typical command line would be
echo '&nml /' | ./mc_nvt_lj
or similar. To change the parameters, the namelist input might include the new values like this
&nml nblock=20, nstep=10000, temperature=2.0 /
Alternatively the namelist may be supplied in a file,
for instance run.inp
containing
&nml
nblock=20,
nstep=10000,
temperature=2.0
/
and the program run like this
./mc_nvt_lj < run.inp
As indicated, the key=value
pairs may be set out on different lines if you wish.
Simulation runs for bulk liquids require a starting configuration which can usually be prepared using
the initialize
program (built, by the default SConstruct file, in build_initialize/
).
The default parameters produce an FCC configuration of 256 atoms at reduced density ρ=0.75,
writing out just the positions (for an MC program) to a file cnf.inp
.
You would run the program as described above,
for instance on a Linux/Unix/bash system like this
echo '&nml /' | ./initialize
If the parameter velocities=.true.
is supplied within the namelist,
then positions and velocities are written to the file,
corresponding to a reduced temperature T = 1.0.
These values of ρ and T (see below) lie in the liquid region of the Lennard-Jones phase diagram.
Non-default values may, of course, be supplied for this or other models.
The cnf.inp
file may then be copied to the directory in which the run is carried out.
Typically, runs produce a final configuration cnf.out
(which may be renamed to cnf.inp
as a starting point for further runs)
and intermediate configurations cnf.001
, cnf.002
etc during the run.
Some of the programs simulate a single chain of atoms, without periodic boundary conditions.
Initial configurations for these may also be prepared using the initialize
program
selecting molecules="chain"
, an appropriate number of atoms, for example n=13
,
and velocities=.true.
if required. There is an option constraints=.true.
if the velocities
should be chosen with constraints applied relative to the bonds between neighbouring atoms in the chain.
A utility program, adjust
, takes in an MC or MD configuration and
scales the velocities to change the kinetic energy per atom by a specified amount,
and/or the positions (and the box length) to change the density by a specified amount.
You may prefer to write your own program or script to perform these types of operation.
Our simulation configuration files have a very simple format: the first line is the number of molecules, the second line is the periodic box length (we always use cubic boxes), or occasionally the bond length (for chain molecules which are simulated without a box), and the third and subsequent lines each contain the coordinates of one atom or molecule. The first three numbers on each of these lines are always the (x,y,z) position, in simulation units (e.g. Lennard-Jones σ=1). The rest of the numbers on each line contain velocities, orientation vectors etc., as appropriate.
This format is not compatible with most molecular visualization programs,
such as JMOL
or VMD.
However, conversion into the basic XYZ format
is easily achieved using a simple program, script, or editor. For example,
on most Linux/Unix systems, the awk
language will be available:
awk '(NR==1) {print} (NR==2) {print "Comment line"} (NR>2) {printf "%5s%15.6f%15.6f%15.6f\n", ("Ar"),($1*3.4),($2*3.4),($3*3.4)}' cnf.inp > cnf.xyz
This produces a file which should be recognized as a set of Argon atoms with positions
(in Angstroms) appropriate to their van der Waals diameter.
This can be read into a molecular visualizer,
which will typically have various options for representing the atoms.
No attempt is made here to represent the periodicity of the system in the cnf.xyz
file.