-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSnakefile
More file actions
165 lines (146 loc) · 6.23 KB
/
Snakefile
File metadata and controls
165 lines (146 loc) · 6.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import functions
import concurrent
import numpy as np
qmc_threads=2
partition="wagner"
import json
#The sequence of numbers of configurations to use in optimization.
#You should check that the energy does not change as you increase this
#number.
nconfigs = [400,800,1600,3200,6400,12800,25600]
# This is how many excited states you would like to access
nroots = 4
rule DEFAULT_SETTINGS:
input:
output: "{dir}/settings.json"
run:
json.dump(dict(spin=0), open(output[0],'w'))
rule MEAN_FIELD:
input: "{dir}/geom.xyz", "{dir}/settings.json"
output: "{dir}/{functional}/{basis}/mf.chk"
resources:
walltime="4:00:00", partition=partition
run:
with open(input[0]) as f:
xyz=f.read()
functions.mean_field(xyz, output[0], settings=json.load(open(input[1])), basis=wildcards.basis, functional=wildcards.functional)
rule HCI:
input: "{dir}/mf.chk"
output: "{dir}/hci{tol}.chk"
resources:
walltime="4:00:00", partition=partition
run:
functions.run_hci(input[0],output[0], float(wildcards.tol), nroots=nroots)
rule CC:
input: "{dir}/mf.chk"
output: "{dir}/cc.chk"
threads: qmc_threads
resources:
walltime="48:00:00", partition=partition
run:
functions.run_ccsd(input[0],output[0])
rule FCI:
input: "{dir}/mf.chk"
output: "{dir}/fci.chk"
run:
functions.fci(input[0], output[0], nroots=nroots)
def opt_dependency(wildcards):
d={}
basedir = f"{wildcards.dir}/"
nconfig = int(wildcards.nconfig)
ind = nconfigs.index(nconfig)
if hasattr(wildcards,'hci_tol'):
startingwf = f'hci{wildcards.hci_tol}'
else:
startingwf = "mf"
if hasattr(wildcards, 'hci_tol'):
basefile = basedir+f"opt_hci{wildcards.hci_tol}_{wildcards.determinant_cutoff}_{wildcards.orbitals}_"
else:
basefile = basedir+f"opt_mf_{wildcards.orbitals}_"
if ind > 0:
d['start_from'] = basefile+f"{wildcards.statenumber}_{nconfigs[ind-1]}.chk"
for i in range(int(wildcards.statenumber)):
d[f'anchor_wf{i}'] = basefile+f"{i}_{nconfigs[-1]}.chk"
return d
rule OPTIMIZE_MF:
input: unpack(opt_dependency), mf = "{dir}/mf.chk"
output: "{dir}/opt_mf_{orbitals}_{statenumber}_{nconfig}.chk"
threads: qmc_threads
resources:
walltime="72:00:00", partition=partition
run:
n = int(wildcards.statenumber)
start_from = None
if hasattr(input, 'start_from'):
start_from=input.start_from
if wildcards.orbitals=='orbitals':
slater_kws={'optimize_orbitals':True}
elif wildcards.orbitals=='fixed':
slater_kws={'optimize_orbitals':False}
elif wildcards.orbitals=='large':
slater_kws={'optimize_orbitals':True, 'optimize_zeros':False}
else:
raise Exception("Did not expect",wildcards.orbitals)
if n==0:
with concurrent.futures.ProcessPoolExecutor(max_workers=qmc_threads) as client:
functions.optimize_gs(input.mf, None, output[0], start_from=start_from, nconfig = int(wildcards.nconfig), slater_kws=slater_kws,
client=client, npartitions=qmc_threads)
if n > 0:
raise Exception("Don't support excited states just yet for mean-field wfs")
rule OPTIMIZE_HCI:
input: unpack(opt_dependency), mf = "{dir}/mf.chk", hci="{dir}/hci{hci_tol}.chk"
output: "{dir}/opt_hci{hci_tol}_{determinant_cutoff}_{orbitals}_{statenumber}_{nconfig}.chk"
threads: qmc_threads
resources:
walltime="72:00:00", partition=partition
run:
n = int(wildcards.statenumber)
start_from = None
if hasattr(input, 'start_from'):
start_from=input.start_from
if wildcards.orbitals=='orbitals':
slater_kws={'optimize_orbitals':True}
elif wildcards.orbitals=='fixed':
slater_kws={'optimize_orbitals':False}
elif wildcards.orbitals=='large':
slater_kws={'optimize_orbitals':True, 'optimize_zeros':False}
else:
raise Exception("Did not expect",wildcards.orbitals)
slater_kws['tol'] = float(wildcards.determinant_cutoff)
if n==0:
with concurrent.futures.ProcessPoolExecutor(max_workers=qmc_threads) as client:
functions.optimize_gs(input.mf, input.hci, output[0], start_from=start_from,
nconfig = int(wildcards.nconfig), slater_kws=slater_kws, client=client, npartitions=qmc_threads)
if n > 0:
anchor_wfs = [input[f'anchor_wf{i}'] for i in range(n)]
with concurrent.futures.ProcessPoolExecutor(max_workers=qmc_threads) as client:
functions.orthogonal_opt(input.mf, input.hci, anchor_wfs, output[0], start_from=start_from,
slater_kws=slater_kws, nconfig=int(wildcards.nconfig), client=client, npartitions=qmc_threads)
rule VMC:
input: mf = "{dir}/mf.chk", opt = "{dir}/opt_{variables}.chk"
output: "{dir}/vmc_{variables}.chk"
threads: qmc_threads
resources:
walltime="24:00:00", partition=partition
run:
multideterminant = None
startingwf = input.opt.split('/')[-1].split('_')[1]
if 'hci' in startingwf:
multideterminant = wildcards.dir+"/"+startingwf+".chk"
with concurrent.futures.ProcessPoolExecutor(max_workers=qmc_threads) as client:
functions.evaluate_vmc(input.mf, multideterminant, input.opt, output[0], nconfig=8000, nblocks=60, client=client, npartitions=qmc_threads)
rule DMC:
input: mf = "{dir}/mf.chk", opt = "{dir}/opt_{variables}.chk"
output: "{dir}/dmc_{variables}_{tstep}.chk"
threads: qmc_threads
resources:
walltime="24:00:00", partition=partition
run:
multideterminant = None
startingwf = input.opt.split('/')[-1].split('_')[1]
if 'hci' in startingwf:
multideterminant = wildcards.dir+"/"+startingwf+".chk"
tstep = float(wildcards.tstep)
nsteps = int(30/tstep)
with concurrent.futures.ProcessPoolExecutor(max_workers=qmc_threads) as client:
functions.evaluate_dmc(input.mf, multideterminant, input.opt, output[0], tstep=tstep, nsteps=nsteps, nconfig=8000, client=client, npartitions=qmc_threads)