3 from numpy
import dtype, zeros, linspace, pi, cos, sin
7 from argparse
import ArgumentParser
9 parser = ArgumentParser()
10 parser.add_argument(
"config_filename")
11 parser.add_argument(
"--id", nargs=
'?', default=
"tmp")
12 args = parser.parse_args()
14 output_dir = os.path.abspath(
"tmp")
18 from sumatra.projects
import load_project
19 output_dir = os.path.join(os.path.abspath(load_project().data_store.root), args.id)
23 if not os.path.exists(output_dir):
24 os.makedirs(output_dir)
26 config_file = open(args.config_filename,
"r")
27 config = yaml.load(config_file)
29 atom_type_1 = config["type1"]
30 atom_type_2 = config[
"type2"]
31 basis_name = config[
"basisName"]
33 r12_min = config[
"r12Min"]
34 r12_max = config[
"r12Max"]
35 configuration_count = config[
"n"]
36 r12_ground_state = config[
"r12GroundState"]
39 file_name =
"states_atom_%d_atom_%d_basis_%s.h5" % (atom_type_1, atom_type_2, basis_name)
40 file_path = os.path.join(output_dir, file_name)
41 f = h5py.File(file_path,
"w")
43 atom_type = dtype([(
"x", float), (
"y", float), (
"z", float)])
44 atoms = zeros(2, dtype=atom_type)
46 atom_metaType = dtype([(
"type", int), (
"basisName",
"S64")])
47 atom_meta = zeros(2, dtype=atom_metaType)
49 atom_meta[0][
"type"] = atom_type_1
50 atom_meta[0][
"basisName"] = basis_name
51 atom_meta[1][
"type"] = atom_type_2
52 atom_meta[1][
"basisName"] = basis_name
54 atom_meta_dataset = f.create_dataset(
"atomMeta", data = atom_meta)
55 atom_meta_dataset.attrs[
"r12Min"] = r12_min
56 atom_meta_dataset.attrs[
"r12Max"] = r12_max
57 atom_meta_dataset.attrs[
"method"] = config[
"method"]
59 r12s = linspace(r12_min, r12_max, configuration_count)
61 if r12_ground_state > 0.0:
62 atoms[0][
"x"] = -r12_ground_state / 2
66 atoms[1][
"x"] = r12_ground_state / 2
69 dataset = f.create_dataset(
"groundState", data=atoms)
70 dataset.attrs[
"r12"] = r12_ground_state
73 states_group = f.create_group(
"states")
74 for j
in range(len(r12s)):
75 atoms[0][
"x"] = -r12s[j] / 2
79 atoms[1][
"x"] = r12s[j] / 2
83 dataset = states_group.create_dataset(
"state%010d" % stateCounter, data=atoms)
84 dataset.attrs[
"r12"] = r12s[j]
88 print "States saved to:\n", os.path.abspath(file_path)