diff --git a/MCMC/MCMC-flow/init.py b/MCMC/MCMC-flow/init.py index 15a4142..2b6dcdc 100644 --- a/MCMC/MCMC-flow/init.py +++ b/MCMC/MCMC-flow/init.py @@ -34,13 +34,13 @@ def get_parameters(): parameters["m"] = [6] # logging parameters - parameters["energy_write_freq"] = [1000] + parameters["energy_write_freq"] = [20000] parameters["trajectory_write_freq"] = [10000] # run parameters - parameters["n_steps"] = [[1e7, 1e8]] - parameters["kT"] = [[10, 1.5]] - parameters["max_trans"] = [[3.0, 0.5]] + parameters["n_steps"] = [[1e7, 2e8]] + parameters["kT"] = [[10, 1.0]] + parameters["max_trans"] = [[3.0, 0.3]] parameters["seed"] = [20] return list(parameters.keys()), list(product(*parameters.values())) @@ -59,6 +59,7 @@ def main(): parent_job.init() parent_job.doc.setdefault("done", False) parent_job.doc.setdefault("timestep", []) + parent_job.doc.setdefault("analyzed", False) parent_job.doc.setdefault("accepted_moves", []) parent_job.doc.setdefault("rejected_moves", []) parent_job.doc.setdefault("acceptance_ratio", []) diff --git a/MCMC/MCMC-flow/project.py b/MCMC/MCMC-flow/project.py index 22b0018..6d7b0f7 100644 --- a/MCMC/MCMC-flow/project.py +++ b/MCMC/MCMC-flow/project.py @@ -81,6 +81,9 @@ def sampled(job): def initialized(job): return job.isfile("trajectory.gsd") +@MyProject.label +def analyzed(job): + return job.doc.get("analyzed") @directives(executable="python -u") @MyProject.operation @@ -131,6 +134,33 @@ def sample(job): print("Simulation finished completed") print("-----------------------------") +@MyProject.operation +@MyProject.pre(sampled) +@MyProject.post(analyzed) +def analysis(job): + from utils import avg_nn, rdf + import numpy as np + os.makedirs(os.path.join(job.ws, "analysis/rdf")) + gsdfile = job.fn('trajectory_1.gsd') + rdf = rdf(gsdfile, start=-30) + x = rdf.bin_centers + y = rdf.rdf + peakx = max(x) + peaky = max(y) + logfile = job.fn('log.txt') + energy = np.genfromtxt(logfile, delimiter=",") + mean = np.mean(energy[:,0]) + sd = np.std(energy[:,0]) + save_path = os.path.join(job.ws, "analysis/rdf/rdf.txt") + np.savetxt(save_path, np.transpose([x,y]), delimiter=',', header ="bin_centers, rdf") + save_peak = os.path.join(job.ws, "analysis/rdf/peak.txt") + np.savetxt(save_peak, np.transpose([peakx, peaky]), delimiter=',', header="max_x, max_y") + job.doc['avg_PE'] = mean + job.doc['sd_PE'] = sd + nn = avg_nn(gsdfile, frame=-1) + job.doc['average_nn'] = nn + job.doc["analyzed"] = True + if __name__ == "__main__": MyProject().main() diff --git a/MCMC/log.txt b/MCMC/log.txt new file mode 100644 index 0000000..a6ce304 --- /dev/null +++ b/MCMC/log.txt @@ -0,0 +1,10 @@ +344.14088824424385,1.0 +344.14088824424385,1.0 +341.59388377626556,1.0 +338.6685686445551,1.0 +337.94650985867054,1.0 +337.9376561616747,1.0 +336.81233332171166,1.0 +333.6200195542917,1.0 +332.86849037229774,1.0 +331.1718868176446,1.0