str(0.1 * args.num_procs * args.num_hours),
                "num_hours_terminate":
                str(0.9 * args.num_procs * args.num_hours)
            })))
    return mc


windows = fst.WindowExponential(
    fst.args({
        "alpha": "2.5",
        "num": str(args.num_procs),
        "maximum": str(args.max_particles)
    })).boundaries()
print(windows)

if args.task == 0:
    clones = fst.MakeClones()
    for proc, win in enumerate(windows):
        clones.add(mc(proc, win[0], win[1]))
    clones.set(fst.MakeCheckpoint(fst.args({"file_name": "checkpoint.fst"})))
else:
    clones = fst.MakeClones("checkpoint", args.num_procs)
#clones.initialize_and_run_until_complete()
clones.initialize_and_run_until_complete(
    fst.args({
        "ln_prob_file": "ln_prob.txt",
        "omp_batch": str(int(1e6))
    }))
print(clones.ln_prob().values())
open('clones.fst', 'w').write(clones.serialize())
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import feasst as fst
import pyfeasst

num_procs = 12
clones = fst.MakeClones('checkpoint', num_procs)
beta = clones.clone(0).thermo_params().beta()
volume = clones.clone(0).configuration().domain().volume()
plt.plot(clones.ln_prob().values(), label='T*=' + str(1. / beta))
sat = list()
for extrap_temp in np.arange(0.8, 1.201, 0.05):
    extrap = fst.ExtrapolateBetaGCE(
        clones,
        fst.args({
            "beta_new": str(1 / extrap_temp),
            "beta_original": str(beta)
        }))
    extrap = pyfeasst.find_equilibrium(extrap, beta_mu_guess=-6)
    plt.plot(extrap.ln_prob().values(),
             label='T*=' + str(round(extrap_temp, 2)))

    # tabulate saturation properties
    num_vapor = extrap.average_macrostate(0)
    num_liquid = extrap.average_macrostate(1)
    sat.append([
        extrap_temp, num_vapor / volume, num_liquid / volume,
        extrap.betaPV() / volume * extrap_temp,
        extrap.average(extrap.energy(), 0) / num_vapor,
        extrap.average(extrap.energy(), 1) / num_liquid