-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_dir_and_write_params_g4.py
192 lines (103 loc) · 3.82 KB
/
create_dir_and_write_params_g4.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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 24 10:54:50 2022
@author: ben
"""
from pathlib import Path
from directories import g4_output_basedir
from sys import argv
def create_dir_and_write_params_g4(Nres: int, Lbox: float, waveform: str, output_basedir: Path):
# create directory if it doesn't exist already
outputdir = output_basedir / f"{waveform}_{Nres}_{Lbox:.0f}"
if outputdir.exists():
print(outputdir, "already exists. Skipping...")
else:
print("creating", outputdir)
outputdir.mkdir()
# write param file there:
param_script = f"""
%---- Relevant files
InitCondFile \t \t /gpfs/data/fs71636/fglatter/PBH_EFD/monofonic_tests/output/{waveform}_{Nres}_{Lbox:.0f}/ics_{waveform}_{Nres}_{Lbox:.0f}
OutputDir \t \t /gpfs/data/fs71636/fglatter/PBH_EFD/monofonic_tests/output/{waveform}_{Nres}_{Lbox:.0f}
SnapshotFileBase \t snapshot
OutputListFilename \t /gpfs/data/fs71636/fglatter/PBH_EFD/monofonic_tests/outputs.txt
%---- File formats
ICFormat \t 3
SnapFormat \t 3
%---- CPU-time limits
TimeLimitCPU \t \t 86400 \t % 24h, in seconds
CpuTimeBetRestartFile \t 7200 \t % 2h, in seconds
%---- Memory allocation
MaxMemSize \t 1800 \t % in MByte
%---- Characteristics of run
TimeBegin \t 0.02 \t % Begin of the simulation, z=49
TimeMax \t 1.0 \t % End of the simulation, z=0
%---- Basic code options that set the type of simulation
ComovingIntegrationOn \t 1
%---- Cosmological parameters #update according to monofonic output
Omega0 \t \t \t \t 0.3099
OmegaLambda \t \t \t \t 0.690021
OmegaBaryon \t \t \t \t 0.0488911
HubbleParam \t \t \t \t 0.67742
Hubble \t \t \t \t 100.0
BoxSize \t \t \t \t {Lbox}
#
# MeanPBHScatteringCrossSection \t 1.73189e-13
#
# AveragePBHMass \t \t \t 3.086978e-10
#
# SigmaOverM \t \t \t \t 5.6103e-4
%---- Output frequency and output parameters
OutputListOn \t \t \t 1
TimeBetSnapshot \t \t \t 0.0
TimeOfFirstSnapshot \t \t 0.0
TimeBetStatistics \t \t 0.01
NumFilesPerSnapshot \t \t 1
MaxFilesWithConcurrentIO \t 1
%---- Accuracy of time integration
ErrTolIntAccuracy \t \t 0.025
CourantFac \t \t \t 0.7
MaxSizeTimestep \t \t 0.025
MinSizeTimestep \t \t 0.0
%---- Tree algorithm, force accuracy, domain update frequency
TypeOfOpeningCriterion \t \t 1
ErrTolTheta \t \t \t \t 0.5
ErrTolThetaMax \t \t \t 1.0
ErrTolForceAcc \t \t \t 0.002
TopNodeFactor \t \t \t \t 3.0
ActivePartFracForNewDomainDecomp \t 0.01
ActivePartFracForPMinsteadOfEwald \t 0.05
%---- Initial density estimate
DesNumNgb \t \t 64
MaxNumNgbDeviation \t 1
%---- Subfind parameters
DesLinkNgb \t \t 20
%---- System of units
UnitLength_in_cm \t \t 3.086578e24 \t ; Mpc/h
UnitMass_in_g \t \t \t 1.989e43 \t ; 1.0e10 Msun/h
UnitVelocity_in_cm_per_s \t 1e5 \t ; 1km/s
GravityConstantInternal \t 0
%---- Gravitational softening length
SofteningComovingClass0 \t {Lbox / Nres / 30}
SofteningMaxPhysClass0 \t {Lbox / Nres / 30}
SofteningClassOfPartType0 \t 0
SofteningClassOfPartType1 \t 0
SofteningClassOfPartType2 \t 0
SofteningClassOfPartType3 \t 0
SofteningClassOfPartType4 \t 0
SofteningClassOfPartType5 \t 0
%---- SPH
ArtBulkViscConst \t 1.0
MinEgySpec \t \t 0
InitGasTemp \t \t 10
"""
with (outputdir / f"{waveform}_{Nres}_{Lbox:.0f}_param.txt").open("w") as f:
f.write(param_script)
if __name__ == "__main__":
create_dir_and_write_params_g4(
Nres=int(argv[1]),
Lbox=float(argv[2]),
waveform=argv[3],
output_basedir=g4_output_basedir
)