-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_all_params.py
100 lines (86 loc) · 3.91 KB
/
run_all_params.py
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
#!/usr/bin/python env
'''
Diffusion Maps: Submit jobs on SLURM
'''
import os
# Variables to run jobs
## basedir = os.path.abspath(os.getcwd())
output_dir='/scratch/users/tabakg/qsd_output/trajectory_data'
# Variables for each job
memory = 16000
partition = 'normal'
# Create subdirectories for job, error, and output files
job_dir = "%s/.job" %(output_dir)
out_dir = "%s/.out" %(output_dir)
for new_dir in [output_dir,job_dir,out_dir]:
if not os.path.exists(new_dir):
os.mkdir(new_dir)
OVERWRITE=False
NUM_SEEDS=8
REGIME='kerr_bistable'
ntraj=1
delta_t=1e-5
Nfock_a=50
Nfock_j=2
duration=30.0 ## try running longer ones? say 100. Make sure appropriate amount is being cut off
downsample=1000
num_systems=2
noise_amp=1.0 ## matters for two systems only
trans_phase=1.0 ## matters for two systems only
SEEDs=range(1, NUM_SEEDS + 1)
Rs=0.,0.6,0.8,1.0 ## matters for two systems only
EPSs=0.,0.3333333,0.5,1.0 ## matters for two systems only
DRIVES=True,False ##Driving second system? ## matters for two systems only
METHODS={(R,EPS):['itoSRI2'] for R,EPS in zip(Rs,EPSs)}
METHODS[(0.,0.)] += ['itoEuler','itoImplicitEuler']
for seed in SEEDs:
for R, EPS in zip(Rs, EPSs):
for drive in DRIVES:
for method in METHODS[(R,EPS)]:
param_str = ("%s-"*14)[:-1] %(seed,
ntraj,
delta_t,
Nfock_a,
Nfock_j,
duration,
downsample,
method,
num_systems,
R,
EPS,
noise_amp,
trans_phase,
drive)
file_name = 'QSD_%s_%s.pkl' %(REGIME,param_str)
file_loc = os.path.join(output_dir,file_name)
file_exists = os.path.isfile(file_loc)
print("OVERWRITE is %s and file %s existence is %s" %(OVERWRITE,file_name,file_exists))
print("If overwriting or file does not exist, going to process new seed.")
if OVERWRITE or not file_exists:
print "Processing seed %s" %(seed)
# Write job to file
filey = ".job/qsd_%s.job" %(seed)
filey = open(filey,"w")
filey.writelines("#!/bin/bash\n")
filey.writelines("#SBATCH --job-name=qsd_2s_%s\n" %(seed))
filey.writelines("#SBATCH --output=%s/qsd_%s.out\n" %(out_dir,seed))
filey.writelines("#SBATCH --error=%s/qsd_%s.err\n" %(out_dir,seed))
filey.writelines("#SBATCH --time=2-00:00\n")
filey.writelines("#SBATCH --mem=%s\n" %(memory))
filey.writelines("module load singularity\n")
filey.writelines("module load system\n")
filey.writelines("module load singularity/2.4\n")
if drive:
filey.writelines("singularity run --bind %s:/data qsd..img --output_dir /data "
"--seed %s --save2pkl --regime '%s' --num_systems 2 "
"--delta_t %s --duration %s --downsample %s --sdeint_method_name '%s' "
"--R %s --eps %s --noise_amp 1. --drive_second_system True"
"\n" %(output_dir,seed,REGIME,delta_t,duration,downsample,method,R,EPS))
else:
filey.writelines("singularity run --bind %s:/data qsd..img --output_dir /data "
"--seed %s --save2pkl --regime '%s' --num_systems 2 "
"--delta_t %s --duration %s --downsample %s --sdeint_method_name '%s' "
"--R %s --eps %s --noise_amp 1."
"\n"%(output_dir,seed,REGIME,delta_t,duration,downsample,method,R,EPS))
filey.close()
os.system("sbatch -p %s .job/qsd_%s.job" %(partition,seed))