In this folder is the code for calculating free energy profiles, as seen in figures 3,4,5 and 7.

There are 4 make-files and two small auxillery programs provided.

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

makeGcMax generates a SERIAL executable that simulates in the grand canonical ensemble on a sphere. It constrains the system so that the largest liquid cluster remains below a user-specified value. It takes one input which directs it to an external options file containing keyword arguments. If the options file is called optionsX.txt, the executable must be launched with:
	'./GcMax.out X'
An example options file, 'optionsGC.txt', with each keyword annotated is provided in the example input deck for grand canonical umbrella sampling.

Output are files

	history.csv, containing configuration snapshots of the system in the format
		 'N,x1,y2,z1,x2,y2,z2...xN,yN,zN'
	where N is the number of particles and x,y,z are Cartesian coordinates.

	bond/neighbours/cluster_history.csv which contains the bond orientational order/coordination number/containing liquid cluster of each particle for each snapshot in history.csv in the 		format
		'N,v1,v2,v3...vN'

	bond/energy/number_running_average.csv, contain the running average of the bond orientational order, potential energy and total particle number. 

	Nucleus_frequencies/scaled.csv are the same, and contain the number of times a nucleus of each size was recorded. this is what is used to calculate the free energy.
	
	data.txt simply counts the number of times an average was recorded.
	stateX.csv contains the final state of the system and is used for restarts or initialising future simulations.

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

makeGcUmbrellaRE generates a MPI executable that simulates the grand canonical ensemble on a sphere with umbrella sampling and replica exchange in the size of the target nucleus. It takes no input but each process reads an input file called options<RANK>.csv. An annotated example of such an options file, 'option0.csv' is provided in the example input deck. Launch with
	'mpirun GrandCanonicalUmbrella_RE.out'

Output files are

	history.csv & neighbours/cluster.csv as above but these are tied to a given rank, not target nucleus so beware that each snapshot could represent a different target nucleus.

	nucleus_re_XX_scaled/frequencies.csv are the histograms of nuclear size recorded by each rank for each possible nucleus size. These are mainly used for restarts.

	Nucleus_frequencies.csv is the fully sorted histogram of nucleus size for the target nucleus size that was originally given to this rank at the start of the simulation (before any 		exchanges were made).

	Nucleus_scaled.csv is the fully sorted histogram of nucleus size for the target nucleus size that was originally given to this rank at the start of the simulation (before any exchanges were made) BUT is has been re-scaled to divide out the imaginary umbrella sampling potential.

	stateX.csv as above.

--------------------------------------------------------------------------
 
makeCanonicalLsTMax produces an executable equivalent to makeGcMax but it simulated the canonical ensemble. There is an annotated example options file in the example input deck called 'optionsC.txt'.

Output as GcMax.out

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

makeCanonicalUmbrellaLsT produces an executable which is equivalent to makeGcUmbrellaRE but SERIAL and in the canonical ensemble.

Output as GcMax.out but the histogram in Nucleus_scaled.csv  has been re-scaled to divide out the fictitious biasing potential introduced by umbrella sampling.

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

The two auxilery programs are umbrella_hmo.c and umbrella_hmoC.c and are used to match the umbrella sampling data for the grand canonical and canonical ensembles respecivly. They must be run in the folder containing the output folders (runXX) from the above programs (this is explained more thoughoughly in the examples READMEs). They are compiles by
	cc umbrella_hmo.c -o umbrella_hmo.out -lm
	cc umbrella_hmoC.c -o umbrella_hmoC.out -lm 

Each takes four inputs: the number of umbrella sampling windows simulated, the maximum number of particles that can be on the sphere (this does not have to be exact, overestimate if neccessary), the index of the umbrella window that best matches the unbiased run (some trail and improvment may be required to find the most appropriot value.) and the increment in target nucleus size between each umbrella window.  

Both output a file called nuc_curve.csv. Each row of this file represent a different simulation (ie. different target nucleus) and each column the number of particles in the largest nucleus starting from 1.
 




