4 from numpy
import dtype, zeros, linspace, pi, cos, sin, sqrt
6 from argparse
import ArgumentParser
8 parser = ArgumentParser()
9 parser.add_argument(
"config_filename")
10 parser.add_argument(
"--id", nargs=
'?', default=
"tmp")
11 args = parser.parse_args()
13 output_dir = os.path.abspath(
"tmp")
17 from sumatra.projects
import load_project
18 output_dir = os.path.join(os.path.abspath(load_project().data_store.root), args.id)
22 if not os.path.exists(output_dir):
23 os.makedirs(output_dir)
25 config_file = open(args.config_filename,
"r")
26 config = yaml.load(config_file)
28 output_file_name = os.path.join(output_dir, "three_particle_states.h5")
30 f = h5py.File(output_file_name,
"w")
32 atomType = dtype([(
"x", float), (
"y", float), (
"z", float)])
33 atoms = zeros(3, dtype=atomType)
35 atomMetaType = dtype([(
"type", int), (
"basisName",
"S64")])
36 atomMeta = zeros(3, dtype=atomMetaType)
38 atomMeta[0][
"type"] = config[
"type1"]
39 atomMeta[0][
"basisName"] = config[
"basisName"]
40 atomMeta[1][
"type"] = config[
"type2"]
41 atomMeta[1][
"basisName"] = config[
"basisName"]
42 atomMeta[2][
"type"] = config[
"type3"]
43 atomMeta[2][
"basisName"] = config[
"basisName"]
45 dataset2 = f.create_dataset(
"atomMeta", data=atomMeta)
47 angles = linspace(config[
"angleMin"], config[
"angleMax"], config[
"angleCount"])
48 r12s = linspace(config[
"r12Min"], config[
"r12Max"], config[
"r12Count"])
49 r13s = linspace(config[
"r13Min"], config[
"r13Max"], config[
"r13Count"])
51 dataset2.attrs[
"description"] =
"Variation of angles and distances"
52 dataset2.attrs[
"angleMin"] = angles.min()
53 dataset2.attrs[
"angleMax"] = angles.max()
54 dataset2.attrs[
"r12Min"] = r12s.min()
55 dataset2.attrs[
"r12Max"] = r12s.max()
56 dataset2.attrs[
"r13Min"] = r13s.min()
57 dataset2.attrs[
"r13Max"] = r13s.max()
58 dataset2.attrs[
"method"] = config[
"method"]
61 ground_state_angle = config[
"groundState"][
"angle"]
62 atoms = zeros(3, dtype=atomType)
67 atoms[1][
"x"] = config[
"groundState"][
"r12"]
71 atoms[2][
"x"] = config[
"groundState"][
"r13"] * cos(ground_state_angle)
72 atoms[2][
"y"] = config[
"groundState"][
"r13"] * sin(ground_state_angle)
74 gound_state_dataset = f.create_dataset(
"groundState", data=atoms)
75 gound_state_dataset.attrs[
"r12"] = config[
"groundState"][
"r12"]
76 gound_state_dataset.attrs[
"r13"] = config[
"groundState"][
"r13"]
77 gound_state_dataset.attrs[
"angle"] = config[
"groundState"][
"angle"]
79 statesGroup = f.create_group(
"states")
82 for j
in range(len(r12s)):
83 for k
in range(len(r13s)):
84 for i
in range(len(angles)):
85 atoms = zeros(3, dtype=atomType)
90 atoms[1][
"x"] = r12s[j]
94 atoms[2][
"x"] = cos(angles[i]) * r13s[k]
95 atoms[2][
"y"] = sin(angles[i]) * r13s[k]
98 dataset = statesGroup.create_dataset(
"state%010d" % stateCounter, data=atoms)
100 dataset.attrs[
"angle"] = angles[i]
101 dataset.attrs[
"r12"] = r12s[j]
102 dataset.attrs[
"r13"] = r13s[k]
108 print "State file saved to\n", output_file_name