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
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Peter W. Draper
SWIFTsim
Commits
9414bba1
Commit
9414bba1
authored
Nov 2, 2021
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Applied python code formatting script
parent
94147269
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tools/create_perturb_file.py
+39
-38
39 additions, 38 deletions
tools/create_perturb_file.py
tools/spawn_neutrinos.py
+29
-18
29 additions, 18 deletions
tools/spawn_neutrinos.py
with
68 additions
and
56 deletions
tools/create_perturb_file.py
+
39
−
38
View file @
9414bba1
...
...
@@ -29,7 +29,7 @@ deg_ncdm = [1]
m_ncdm
=
[
0.06
]
# Maximum wavenumber and redshift
kmax
=
30.
kmax
=
30.
0
zmax
=
1e3
amin
=
1.0
/
(
zmax
+
1
)
...
...
@@ -55,7 +55,8 @@ params = {
"
reio_parametrization
"
:
"
reio_none
"
,
"
YHe
"
:
"
BBN
"
,
"
k_output_values
"
:
kmax
,
"
k_per_decade_for_pk
"
:
100
}
"
k_per_decade_for_pk
"
:
100
,
}
print
(
"
Running CLASS
"
)
...
...
This diff is collapsed.
Click to expand it.
tools/spawn_neutrinos.py
+
29
−
18
View file @
9414bba1
...
...
@@ -12,9 +12,9 @@ import sys
# Usage: ./spawn_neutrinos.py filename
# Constants
Mpc_cgs
=
3.08567758e
+
24
Mpc_cgs
=
3.08567758e24
Default_N_nu_per100Mpc
=
72
# 72^3 neutrinos for a (100 Mpc)^3 box
Default_nr_neutrinos_per_Mpc3
=
(
Default_N_nu_per100Mpc
/
100.
)
**
3
Default_nr_neutrinos_per_Mpc3
=
(
Default_N_nu_per100Mpc
/
100.
0
)
**
3
# Read command line arguments
if
len
(
sys
.
argv
)
<=
1
or
sys
.
argv
[
1
]
==
"
--help
"
or
sys
.
argv
[
1
]
==
"
-h
"
:
...
...
@@ -47,20 +47,31 @@ if nparts[6] != 0 or "PartType6" in f.keys():
raise
IOError
(
"
This file already has neutrinos.
"
)
# Compute the default number of neutrinos (round to nearest cubic number)
Default_N_nu
=
round
((
Default_nr_neutrinos_per_Mpc3
*
V
)
**
(
1.
/
3.
))
Default_N_nu
=
round
((
Default_nr_neutrinos_per_Mpc3
*
V
)
**
(
1.
0
/
3.
0
))
Default_Nr_neutrinos
=
int
(
Default_N_nu
**
3
)
print
(
"
The box dimensions are
"
+
str
(
L
)
+
"
Mpc.
"
)
print
(
"
The default number of neutrinos is
"
+
"
%g
"
%
Default_N_nu_per100Mpc
+
"
^3 per (100 Mpc)^3.
"
)
print
(
"
The default number of neutrinos is
"
+
"
%g
"
%
Default_N_nu
+
"
^3 =
"
+
str
(
Default_Nr_neutrinos
)
+
"
.
"
)
print
(
"
The default number of neutrinos is
"
+
"
%g
"
%
Default_N_nu_per100Mpc
+
"
^3 per (100 Mpc)^3.
"
)
print
(
"
The default number of neutrinos is
"
+
"
%g
"
%
Default_N_nu
+
"
^3 =
"
+
str
(
Default_Nr_neutrinos
)
+
"
.
"
)
print
(
""
)
# Request the number of neutrino particles to be spawned (with default option)
Nr_neutrinos
=
int
(
input
(
"
Enter the number of neutrinos (default
"
+
"
%d
"
%
Default_Nr_neutrinos
+
"
):
"
)
or
"
%d
"
%
Default_Nr_neutrinos
)
Nr_neutrinos
=
int
(
input
(
"
Enter the number of neutrinos (default
"
+
"
%d
"
%
Default_Nr_neutrinos
+
"
):
"
)
or
"
%d
"
%
Default_Nr_neutrinos
)
nparts
[
6
]
=
Nr_neutrinos
...
...
@@ -80,7 +91,7 @@ print("The first particle ID of the first neutrino will be: " + str(firstID))
print
(
""
)
confirm
=
input
(
"
Enter y to confirm:
"
)
if
(
confirm
!=
"
y
"
)
:
if
confirm
!=
"
y
"
:
print
(
"
Not confirmed. Done for now.
"
)
exit
(
0
)
...
...
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
sign in
to comment