Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
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
SWIFTsim
Commits
f03bee4c
Commit
f03bee4c
authored
6 years ago
by
Loic Hausammann
Browse files
Options
Downloads
Patches
Plain Diff
CoolingBox: improve labels
parent
7749c5f3
No related branches found
No related tags found
1 merge request
!740
Grackle cosmo
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/Cooling/CoolingBox/plotTemperature.py
+13
-16
13 additions, 16 deletions
examples/Cooling/CoolingBox/plotTemperature.py
with
13 additions
and
16 deletions
examples/Cooling/CoolingBox/plotTemperature.py
+
13
−
16
View file @
f03bee4c
...
...
@@ -13,7 +13,7 @@ params = {
'
xtick.labelsize
'
:
10
,
'
ytick.labelsize
'
:
10
,
'
text.usetex
'
:
True
,
'
figure.figsize
'
:
(
3.15
,
3.1
5
),
'
figure.figsize
'
:
(
5
,
5
),
'
figure.subplot.left
'
:
0.145
,
'
figure.subplot.right
'
:
0.99
,
'
figure.subplot.bottom
'
:
0.11
,
...
...
@@ -29,9 +29,6 @@ plt.rcParams.update(params)
# Some constants in cgs units
k_b_cgs
=
1.38e-16
# boltzmann
m_h_cgs
=
1.67e-24
# proton mass
# need to be changed in makeIC.py too
h_frac
=
0.76
mu
=
4.
/
(
1.
+
3.
*
h_frac
)
# File containing the total energy
...
...
@@ -53,10 +50,10 @@ unit_time = units.attrs["Unit time in cgs (U_t)"]
gamma
=
float
(
f
[
"
HydroScheme
"
].
attrs
[
"
Adiabatic index
"
])
def
Temperature
(
u
):
def
energyUnits
(
u
):
"""
Compute the temperature from the internal energy.
"""
u
*=
(
unit_length
/
unit_time
)
**
2
return
u
*
(
gamma
-
1.
)
*
m_h_cgs
/
(
mu
*
k_b_cgs
)
return
u
*
m_h_cgs
/
k_b_cgs
# Read energy and time arrays
...
...
@@ -71,16 +68,16 @@ initial_energy = total_energy[0]
# Conversions to cgs
total_energy_cgs
=
total_energy
/
total_mass
[
0
]
total_energy_cgs
=
Temperature
(
total_energy_cgs
)
total_energy_cgs
=
energyUnits
(
total_energy_cgs
)
kinetic_energy_cgs
=
kinetic_energy
/
total_mass
[
0
]
kinetic_energy_cgs
=
Temperature
(
kinetic_energy_cgs
)
kinetic_energy_cgs
=
energyUnits
(
kinetic_energy_cgs
)
internal_energy_cgs
=
internal_energy
/
total_mass
[
0
]
internal_energy_cgs
=
Temperature
(
internal_energy_cgs
)
internal_energy_cgs
=
energyUnits
(
internal_energy_cgs
)
radiated_energy_cgs
=
radiated_energy
/
total_mass
[
0
]
radiated_energy_cgs
=
Temperature
(
radiated_energy_cgs
)
radiated_energy_cgs
=
energyUnits
(
radiated_energy_cgs
)
# Read snapshots
temp_snap
=
np
.
zeros
(
25
)
...
...
@@ -89,22 +86,22 @@ for i in range(25):
snap
=
File
(
"
coolingBox_%0.4d.hdf5
"
%
i
,
'
r
'
)
u
=
snap
[
"
/PartType0/InternalEnergy
"
][:]
*
snap
[
"
/PartType0/Masses
"
][:]
u
=
sum
(
u
)
/
total_mass
[
0
]
temp_snap
[
i
]
=
Temperature
(
u
)
temp_snap
[
i
]
=
energyUnits
(
u
)
time_snap_cgs
[
i
]
=
snap
[
"
/Header
"
].
attrs
[
"
Time
"
]
*
unit_time
plt
.
figure
()
Myr_in_yr
=
3.15e13
plt
.
plot
(
time
,
total_energy_cgs
,
'
r-
'
,
lw
=
1.6
,
label
=
"
Gas total
temperature
"
)
plt
.
plot
(
time
,
total_energy_cgs
,
'
r-
'
,
lw
=
1.6
,
label
=
"
Gas total
energy
"
)
plt
.
plot
(
time_snap_cgs
,
temp_snap
,
'
rD
'
,
ms
=
3
)
plt
.
plot
(
time
,
radiated_energy_cgs
,
'
g-
'
,
lw
=
1.6
,
label
=
"
Radiated
temperature
"
)
plt
.
plot
(
time
,
radiated_energy_cgs
,
'
g-
'
,
lw
=
1.6
,
label
=
"
Radiated
energy
"
)
plt
.
plot
(
time
,
total_energy_cgs
+
radiated_energy_cgs
,
'
b-
'
,
lw
=
0.6
,
label
=
"
Gas total + radiated
"
)
plt
.
legend
(
loc
=
"
upper
right
"
,
fontsize
=
8
,
frameon
=
False
,
plt
.
legend
(
loc
=
"
right
"
,
fontsize
=
8
,
frameon
=
False
,
handlelength
=
3
,
ncol
=
1
)
plt
.
xlabel
(
"
${
\\
rm{Time~[Myr]}}$
"
,
labelpad
=
0
)
plt
.
ylabel
(
"
${
\\
rm{
Temperature
~[K]}}$
"
)
plt
.
ylabel
(
"
${
\\
rm{
Internal ~Energy ~(u ~m_H / k_B)
~[K]}}$
"
)
plt
.
savefig
(
"
temperature
.png
"
,
dpi
=
200
)
plt
.
savefig
(
"
energy
.png
"
,
dpi
=
200
)
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