8 from argparse
import ArgumentParser
9 from scipy.optimize
import curve_fit
12 return 4 * epsilon * ((sigma / (a + x))**12 - (sigma/(a + x))**6)
14 parser = ArgumentParser()
15 parser.add_argument(
"states_files", nargs=
"+")
16 parser.add_argument(
"--id", default=
"tmp")
17 args = parser.parse_args()
19 output_dir = os.path.abspath(
"tmp")
23 from sumatra.projects
import load_project
24 output_dir = os.path.join(os.path.abspath(load_project().data_store.root), args.id)
28 states_files = args.states_files
29 if len(states_files) == 1:
30 states_files = glob(states_files[0])
32 if not os.path.exists(output_dir):
33 os.makedirs(output_dir)
35 output_file = os.path.join(output_dir,
"two_particle_plot.pdf")
43 for statesFile
in states_files:
44 f = h5py.File(statesFile,
"r")
45 atomsMeta = f.get("atomMeta")
46 energyOffset = atomsMeta.attrs[
"energyOffset"]
47 if len(atomsMeta) != 2:
48 raise Exception(
"Wrong number of atoms in atomsMeta. Found %d, should be 2." % len(atomsMeta))
49 states = f.get(
"/states")
50 for stateName
in states:
51 atoms = states.get(stateName)
55 r12 = atoms.attrs[
"r12"]
56 energy = atoms.attrs[
"energy"]
59 energies.append(energy)
61 energy_min = min(energy_min, energy)
62 energy_max = max(energy_max, energy)
66 r12s, energies = [list(x)
for x
in zip(*sorted(zip(r12s, energies), key=
lambda pair: pair[0]))]
69 energies = array(energies)
71 diffs = abs(diff(energies) / diff(r12s))
73 print "Plotting", len(r12s),
"data points."
85 savefig(output_file +
".png")
87 print "Results saved to", output_file