Multihistogram
ParallelTemperingMonteCarlo.Multihistogram.Entropycalc — Method
Entropycalc(alpha::Vector, bmat::Matrix, HistArray::Matrix, nsum::VorS, NBins::Int)Having determined the vector solution to Ax=b, we input alpha and the "b-matrix" the term n_{ij}*(ln(n_{ij} + beta_iE_j) we can find the entropy as a function of energy.
ParallelTemperingMonteCarlo.Multihistogram.amatrix — Method
amatrix(HistArray::Matrix, nsum::VorS, NTraj::Int; debug = false)This function calculates the LHS of the multihistogram equation, the A matrix.
ParallelTemperingMonteCarlo.Multihistogram.analysis — Method
analysis(energyvector::VorS, S_E::Vector, beta::VorS, kB::Float64, NPoints::Int; debug = false)NPoints determines how densely the points are populated.
Analysis takes in the energy bin values, entropy per energy and inverse temperatures beta. It calculates the temperatures T, and then finds the partition function – note that the boltzmann factors XP are self-scaling so they vary from 1 to 100, this is not necessary but prevents numerical errors in regions where the partition function would otherwise explode in value.
Output is the partition function, heat capacity and its first derivative as a function of temperature.
ParallelTemperingMonteCarlo.Multihistogram.bvector — Method
bvector(HistArray::Matrix{N}, energyvector::VorS, beta::VorS, nsum::VorS, NTraj::Int, NBins::Int; debug = false) where N <: NumberFunction to calculate the b vector relevant to solving the RHS of the multihistogram equation.
ParallelTemperingMonteCarlo.Multihistogram.initialise — Method
initialise(xdir::String)
initialise(Output::Output,Tvec::TempGrid)Function to retrieve all histogram information from the histogram directory outputted by Edison's PTMC code for method one, or directly from the output data given from the Julia PTMC code.
We read the files with readfile, process the file with processhist! and output all relevant arrays and constants as defined in the constituent functions.
ParallelTemperingMonteCarlo.Multihistogram.multihistogram — Method
multihistogram(xdir::String; NPoints = 1000)
multihistogram(output::Output, Tvec::TempGrid; outdir = pwd(), NPoints = 1000)Function has two methods which vary only in how the initialise function is called: one takes a directory and writes the output of the multihistogram analysis to that directory, the other takes the output and temperature grid and writes to the current directory unless specified otherwise. The output of this function are the four files defined in run_multihistogram.
ParallelTemperingMonteCarlo.Multihistogram.nancheck — Method
nancheck(X::Vector)
nancheck(X::Matrix)Function to ensure no vector or matrix contains NaN as this ruins the linear algebra.
ParallelTemperingMonteCarlo.Multihistogram.processhist! — Method
processhist!(HistArray::Matrix{N}, energyvector::VorS, NBins::Int, NTraj::Int) where N <: NumberThis function normalises the histograms, collates the bins into their total counts and then deletes any energy bin containing no counts – this step is required to prevent NaN errors when doing the required calculations.
HistArray,energyvector are the total histograms and values of the energy bins respectively, they are only changed by normalisation and removal of unnecessary rows nsum is merely the total histogram count for each energy bin
ParallelTemperingMonteCarlo.Multihistogram.readfile — Method
readfile(xdir::String; debug = false)
readfile(output::Output, Tvals::TempGrid)Method 1: xdir::String -reads output files for the FORTRAN PTMC code written by Edison Florez. Method 2: output::Output, Tvals::TempGrid - designed to receive output data from the Julia PTMC program: as the beta vector and NBins are defined in the structs they can be directly unpacked as output.
xdir is the directory containing the histogram information usually /path/to/output/histograms
HistArray is the NTrajxNBins array containing all histogram counts energyvector is an NBins length vector containing the energy value of each bin beta is an NTraj length vector of 1/(kBT) NBins,NTraj,kB are constant values required throughout
ParallelTemperingMonteCarlo.Multihistogram.run_multihistogram — Method
run_multihistogram(HistArray::Matrix{N}, energyvector::VorS, beta::VorS, nsum::VorS, NTraj::Int, NBins::Int, kB::Float64, outdir::String, NPoints::Int; debug = false) where N <: NumberThis function completely determines the properties of a system given by the output of the initialise function and a specified directory to write to. It outputs four files with the following information:
histograms.dataThe top line are the corresponding energy values and the nextNTrajlines are the raw histogram data. This file can be used to plot the histograms if needed.Sol.Xcontaining the solution to the linear equationAx=B,S.datacontaining the energy values and corresponding entropiesanalysis.NVTcontaining the temperatures, partition function, heat capacity and its derivative. NB now includes the temperature dependent Entropy function.
ParallelTemperingMonteCarlo.Multihistogram.systemsolver — Method
systemsolver(HistArray::Matrix, energyvector::VorS, beta::VorS, nsum::VorS, NTraj::Int, NBins::Int; debug = false)systemsolver is used to determine the solution Alpha to the linear equation Ax = b where A and b are the A matrix and b vector described above. This is fundamentally how the multihistogram method works.