Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PySWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
PySWIFTsim
Commits
33810d61
Commit
33810d61
authored
6 years ago
by
Loic Hausammann
Browse files
Options
Downloads
Patches
Plain Diff
Use ParameterFile in scripts
parent
cdf5e10f
Branches
Branches containing commit
No related tags found
1 merge request
!9
New implementation
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pyswiftsim/__init__.py
+10
-2
10 additions, 2 deletions
pyswiftsim/__init__.py
scripts/pyswift_cooling_rate
+15
-13
15 additions, 13 deletions
scripts/pyswift_cooling_rate
tests/test_cooling.yml
+0
-25
0 additions, 25 deletions
tests/test_cooling.yml
with
25 additions
and
40 deletions
pyswiftsim/__init__.py
+
10
−
2
View file @
33810d61
...
...
@@ -144,11 +144,18 @@ class ParameterFile:
# add space between sections
print
()
def
__init__
(
self
,
overwrite
=
None
):
def
__init__
(
self
,
overwrite
=
None
,
existing
=
None
):
if
overwrite
is
not
None
and
existing
is
not
None
:
raise
Exception
(
"
Cannot overwrite default parameters and
"
"
use existing parameter file
"
)
self
.
overwrite
=
overwrite
self
.
d
=
self
.
default_parameters
self
.
existing
=
existing
def
__enter__
(
self
):
if
self
.
existing
is
not
None
:
return
self
.
existing
f
=
NamedTemporaryFile
(
delete
=
False
)
self
.
filename
=
f
.
name
...
...
@@ -158,4 +165,5 @@ class ParameterFile:
return
self
.
filename
def
__exit__
(
self
,
*
args
):
os
.
remove
(
self
.
filename
)
if
self
.
existing
is
None
:
os
.
remove
(
self
.
filename
)
This diff is collapsed.
Click to expand it.
scripts/pyswift_cooling_rate
+
15
−
13
View file @
33810d61
...
...
@@ -18,7 +18,7 @@
# ########################################################################
from
pyswiftsim.libcooling
import
coolingRate
from
pyswiftsim
import
downloadCoolingTable
import
pyswiftsim
from
copy
import
deepcopy
import
numpy
as
np
...
...
@@ -254,23 +254,25 @@ if __name__ == "__main__":
opt
=
parseArguments
()
if
opt
.
table
:
downloadCoolingTable
()
pyswiftsim
.
downloadCoolingTable
()
if
not
os
.
path
.
isfile
(
opt
.
params
):
if
opt
.
params
is
not
None
and
not
os
.
path
.
isfile
(
opt
.
params
):
raise
Exception
(
"
The parameter file
'
{}
'
does not exist
"
.
format
(
opt
.
params
))
parser
=
getParser
(
opt
.
params
)
us
=
parser
[
"
InternalUnitSystem
"
]
with
pyswiftsim
.
ParameterFile
(
existing
=
opt
.
params
)
as
filename
:
d
=
generate_initial_condition
(
us
,
opt
)
parser
=
getParser
(
filename
)
us
=
parser
[
"
InternalUnitSystem
"
]
# du / dt
print
(
"
Computing cooling...
"
)
d
=
generate_initial_condition
(
us
,
opt
)
rate
=
coolingRate
(
opt
.
params
,
d
[
"
density
"
].
astype
(
np
.
float32
),
d
[
"
energy
"
].
astype
(
np
.
float32
),
with_cosmo
,
d
[
"
time_step
"
])
# du / dt
print
(
"
Computing cooling...
"
)
plot_solution
(
rate
,
d
,
us
,
opt
)
rate
=
coolingRate
(
filename
,
d
[
"
density
"
].
astype
(
np
.
float32
),
d
[
"
energy
"
].
astype
(
np
.
float32
),
with_cosmo
,
d
[
"
time_step
"
])
plot_solution
(
rate
,
d
,
us
,
opt
)
This diff is collapsed.
Click to expand it.
tests/test_cooling.yml
deleted
100644 → 0
+
0
−
25
View file @
cdf5e10f
# Define the system of units to use internally.
InternalUnitSystem
:
UnitMass_in_cgs
:
1.989e43
# Grams
UnitLength_in_cgs
:
3.085e21
# Centimeters
UnitVelocity_in_cgs
:
1e5
# Centimeters per second
UnitCurrent_in_cgs
:
1
# Amperes
UnitTemp_in_cgs
:
1
# Kelvin
# Cooling with Grackle 3.0
GrackleCooling
:
CloudyTable
:
CloudyData_UVB=HM2012.h5
# Name of the Cloudy Table (available on the grackle bitbucket repository)
WithUVbackground
:
1
# Enable or not the UV background
Redshift
:
0
# Redshift to use (-1 means time based redshift)
WithMetalCooling
:
1
# Enable or not the metal cooling
ProvideVolumetricHeatingRates
:
0
# (optional) User provide volumetric heating rates
ProvideSpecificHeatingRates
:
0
# (optional) User provide specific heating rates
SelfShieldingMethod
:
0
# (optional) Grackle (<= 3) or Gear self shielding method
OutputMode
:
0
# (optional) Write in output corresponding primordial chemistry mode
MaxSteps
:
10000
# (optional) Max number of step when computing the initial composition
ConvergenceLimit
:
1e-2
# (optional) Convergence threshold (relative) for initial composition
# Parameters for the hydrodynamics scheme
SPH
:
resolution_eta
:
1.2348
# Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel).
CFL_condition
:
0.1
# Courant-Friedrich-Levy condition for time integration.
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