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
Merge requests
!9
New implementation
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
New implementation
new_implementation
into
master
Overview
0
Commits
6
Changes
7
Merged
Loic Hausammann
requested to merge
new_implementation
into
master
6 years ago
Overview
0
Commits
6
Changes
7
Expand
Add the temporary file and start working on the stellar physics.
0
0
Merge request reports
Viewing commit
f1be5083
Prev
Next
Show latest version
7 files
+
248
−
5
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
7
Search (e.g. *.vue) (Ctrl+P)
f1be5083
Lifetime working
· f1be5083
Loic Hausammann
authored
6 years ago
examples/lifetime/plot_lifetime.py
0 → 100644
+
57
−
0
Options
#!/usr/bin/env python3
# ########################################################################
# This file is part of PYSWIFT.
# Copyright (c) 2019 Loic Hausammann (loic.hausammann@epfl.ch)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ########################################################################
from
pyswiftsim
import
libstellar
import
pyswiftsim
import
numpy
as
np
import
matplotlib.pyplot
as
plt
plt
.
rc
(
'
text
'
,
usetex
=
True
)
N
=
1000
solar_metallicity
=
0.02041
if
__name__
==
"
__main__
"
:
with
pyswiftsim
.
ParameterFile
()
as
filename
:
parser
=
pyswiftsim
.
parseYamlFile
(
filename
)
# Get masses
imf
=
parser
[
"
GEARInitialMassFunction
"
]
mass_limits
=
imf
[
"
mass_limits
"
]
mass_min
=
np
.
log10
(
mass_limits
[
0
])
mass_max
=
np
.
log10
(
mass_limits
[
-
1
])
mass
=
np
.
logspace
(
mass_min
,
mass_max
,
N
,
dtype
=
np
.
float32
)
# get metallicity
Z
=
solar_metallicity
*
np
.
ones
(
N
,
dtype
=
np
.
float32
)
print
(
"
Computing lifetime...
"
)
lifetime
=
libstellar
.
lifetimeFromMass
(
filename
,
mass
,
Z
)
lifetime
/=
1e6
plt
.
loglog
(
mass
,
lifetime
)
plt
.
xlabel
(
"
Mass [Msun]
"
)
plt
.
ylabel
(
"
Lifetime [Myr]
"
)
plt
.
show
()
Loading