Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Setup galaxy simulations
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SoftenedJeansCriteria
Setup galaxy simulations
Commits
0376469c
Commit
0376469c
authored
1 year ago
by
Sylvia Plöckinger
Browse files
Options
Downloads
Patches
Plain Diff
Added setup_reruns script
parent
b73698e0
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
setup_reruns.py
+78
-0
78 additions, 0 deletions
setup_reruns.py
with
78 additions
and
0 deletions
setup_reruns.py
0 → 100644
+
78
−
0
View file @
0376469c
import
os
from
pathlib
import
Path
import
shutil
import
glob
import
re
from
data.create_ics_from_snapshot
import
ics_from_snapshot
##########################################
# Select mass resolution and snapshotnumber
##########################################
mass_resolution_levels
=
[
"
M5
"
]
snapshotnumber
=
100
##########################################
localdir
=
os
.
getcwd
()
for
mass
in
mass_resolution_levels
:
os
.
chdir
(
os
.
path
.
join
(
localdir
,
mass
))
for
runfolder
in
glob
.
glob
(
"
Galaxy*/
"
):
##########################################
# setting runfolder name and creating rerunfolder
##########################################
runfolder_absolute_path
=
os
.
path
.
join
(
localdir
,
mass
,
runfolder
)
rerunfolder_absolute_path
=
os
.
path
.
join
(
localdir
,
mass
+
"
_reruns_snap%4.4i
"
%
(
snapshotnumber
),
"
Rerun
"
+
runfolder
)
Path
(
rerunfolder_absolute_path
).
mkdir
(
parents
=
True
,
exist_ok
=
True
)
print
(
runfolder_absolute_path
)
##########################################
# change working directory to rerunfolder
##########################################
os
.
chdir
(
rerunfolder_absolute_path
)
##########################################
# copy files into rerunfolder
##########################################
shutil
.
copy2
(
os
.
path
.
join
(
runfolder_absolute_path
,
"
isolated_galaxy.yml
"
),
"
./
"
)
shutil
.
copy2
(
os
.
path
.
join
(
runfolder_absolute_path
,
"
swift
"
),
"
./
"
)
shutil
.
copy2
(
os
.
path
.
join
(
runfolder_absolute_path
,
"
output_%4.4i.hdf5
"
%
(
int
(
snapshotnumber
))),
"
./
"
)
##########################################
# create ICs for rerun
##########################################
ics_from_snapshot
(
os
.
path
.
join
(
rerunfolder_absolute_path
,
"
output_%4.4i.hdf5
"
%
(
int
(
snapshotnumber
))),
\
os
.
path
.
join
(
rerunfolder_absolute_path
,
"
ICs.hdf5
"
))
##########################################
# update yml file for rerun
##########################################
f
=
open
(
"
isolated_galaxy.yml
"
,
"
rt
"
)
data
=
f
.
read
()
data
=
re
.
sub
(
r
'
^.*disk\.hdf5.*$
'
,
'
file_name: ICs.hdf5
'
,
data
,
flags
=
re
.
MULTILINE
)
data
=
re
.
sub
(
r
'
^.*h_min_ratio.*$
'
,
'
h_min_ratio: 0.0001
'
,
data
,
flags
=
re
.
MULTILINE
)
data
=
re
.
sub
(
r
'
^.*time_end.*$
'
,
'
time_end: 0.00001025
'
,
data
,
flags
=
re
.
MULTILINE
)
data
=
re
.
sub
(
r
'
^.*delta_time\: 0.*$
'
,
'
delta_time: 0.00001023
'
,
data
,
flags
=
re
.
MULTILINE
)
data
=
re
.
sub
(
r
'
^.*dt_max\:.*$
'
,
'
dt_max: 1e-8
'
,
data
,
flags
=
re
.
MULTILINE
)
f
.
close
()
f
=
open
(
"
isolated_galaxy.yml
"
,
"
wt
"
)
f
.
write
(
data
)
f
.
close
()
##########################################
# start swift for one timestep
##########################################
os
.
system
(
"
./swift --threads=28 --external-gravity --self-gravity --stars --star-formation --cooling --temperature --hydro --feedback --limiter --sync -n 1 isolated_galaxy.yml
"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment