This is the code for calculating the phase diagrams and free energy surfaces.
There are two makefiles.
Example imput decks also available
--------------------------------------------------
makeCanonicalTorusUmbrella makes a SERIAL executable which was used to do simple simulations and obtain snapshots. The umbrella sampling functionality was not used. To run the code prepare a keyword file called optionsX.txt and exectute:
	./CanonicalTorusUmbrella.out X
A annotated example of an options file is show below
GEOMETRY Torus            -> the shape of the surface. Choose plane, sphere, torus, cone, or eggbox
RADIUS 7                  -> if the GEOMETRY is "sphere" this is it's radius 
BOXX 24.81                -> if the GEOMETRY  is "plane" or "eggbox" this is the extent in the X direction
BOXY 24.81                -> if the GEOEMTRY  is "plane" or "eggbox" this is the extent in the y direction
TORUSA 5.0                -> if the GEOMETRY is  "torus" this is the tube radius
TORUSC 7.0                -> if the GEOMETRY is  "torus" this is the wheel diameter
HEIGHT 1.0                -> if the GEOMETRY is  "torus" this this is the peak height
POTENTIAL MorseTs         -> the potential/ Choose LennardJonesTs,MorseTs or LennardJonesLambda
EPSILON 1.0               -> the depth of the first minimum
RHO 6                     -> the range parameter of the morse potential
CUTOFF 2.2272468          -> the cuttoff of the potential
INITFROMFILE 0            -> if 0 start from scratch, if 1 start from stateX.csv (format X1,Y2,Z3 \n X2,Y2,Z2.....)
RESTART 0                 -> if 1: restart an existing simulation, including reloading running averages etc... 
ACTIVITY 20.9             -> not used here. The activity for grand canonical simulations.
NEIGHBOURCUTOFF 1.45      -> cutoff for counting wether particles are neighbours
NUMBEROFPARTICLES 300     -> the number of particles
SEED 3545919487485959945  -> a seed for the random number generator. Be sure to vary.
MAXSTEPS 27000000000      -> the total number of monte carlo steps in the main section of the simulation
EQUILIBRIATE 2700000000   -> the number of equilibrium steps before measurments are taken
FRAMERATE 2700000000      -> output a full snapshot every FRAMERATE steps
RECORDRATE 270000         -> "push" th e runnig average this often and save it
AVERAGERATE 2000          -> measure variables (like energy, etc) and add to runing average this often
LAMBDA 0.0                -> used for umbrella sampling. Leave at 0 otherwise
TARGETNUCLEUS 0           -> used for umbrella sampling. Leave at 0 otherwise
UMBRELLARATE 2000         -> used for umbrella sampling. Leave at 0 otherwise
ORDERCUTOFF -1            -> used for defining clusters. Leave at -1

The output files are:

data.txt: used for restarts
state0.txt: the final state of the system (see above)
history.csv: snapshots of the system, taken every FRAMERATE steps. Format N,X1,Y1,Z1,...X,YN,ZN one snapshot per line
neighbours_history.csv: snapshots of the number of neighbours of each partical, corresponding to history.csv
Nucleas_fequency/scaled: used for umbrella sampling: ignore.

-------------------------------------------------------------------------------------------------------

makeCanonicalTorus makes a SERIAL executable which behaves much like the program above but with more extensive outputs. It was used for most major simulations, including phase diagrams and the free energy plots.

Inputs are the same as above. **NOTE non-torus geometries may fail: some outputs are torus-specific**

Additional outputs (* = used in paper):
*angle_energy.csv: the average energy of a paticle as a function of its angle around the torus bar (as fig 5B)
angle_hist_histogram.csv: the frequency of particles found at given angle (binned, un-normalised)
bond_angle.dat: 2D histogram of average particle angle and |psi_6| (not used in this paper) per snapshot
*bond_angel_free.data: used for fig4 heat maps: an un-normalised histogram of N_X and N_outside
bond_angle_particles.dat: 2D histogram of average particle angle and |psi_6| (not used in this paper) per snapshot
bond_order_history.csv: bond order of each particle for each snapshot in history.csv
*bond_histogram.csv: u-normalised histogram of |psi_6| used in figS5
bond_running_average.csv: a running average of |psi_6|
energy_histogram.csv: a histogram of the postential enrgy of each particle
energy_runing_average: a runing average of the total energy of the system
liquid_running_average: the number of particles with more then ORDERCUTOFF neighbours (always 300)
neighbours_histogram: a histogram of the number of nearest neighbours of particles.

-----------------------------------------------------------------------------------------------------------
MakeGcTorusMax makes a SERIAL executable for running Grand Canonical simulations on a torus. 

Options are the same as above (pay attention to ACTIVITY though).
All the output is as above, we used "angle_energy.csv" to make fig5B

