Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
NUNEZ Arturo
notebooks-wkbl
Commits
24a34757
Commit
24a34757
authored
Jul 01, 2018
by
NUNEZ Arturo
Browse files
Automatic commit dimanche 1 juillet 2018, 16:30:01 (UTC+0200)
parent
daab818a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Simulations/n_star (Roskar).ipynb
View file @
24a34757
...
...
@@ -104,7 +104,7 @@
},
{
"cell_type": "code",
"execution_count":
5
,
"execution_count":
10
,
"metadata": {
"collapsed": false
},
...
...
@@ -113,14 +113,14 @@
"name": "stdout",
"output_type": "stream",
"text": [
"With Delta_x =
366.21093
75 as in Roskar 2013 we reproduce the value for p_j = n_h =
0.808766896752
\n",
"and Teq =
5559.78913905
\n"
"With Delta_x =
183.105468
75 as in Roskar 2013 we reproduce the value for p_j = n_h =
2.03785240919
\n",
"and Teq =
3502.54433084
\n"
]
}
],
"source": [
"# reproducing Roskar 2013\n",
"levelmax = 1
5
\n",
"levelmax = 1
6
\n",
"Delta_x = (12e6 / 2.**levelmax)\n",
"\n",
"n_h, aux=5., 20.\n",
...
...
%% Cell type:code id: tags:
```
python
%
matplotlib
notebook
import
numpy
as
np
```
%% Cell type:code id: tags:
```
python
%%
latex
from
Roskar
2014
\
begin
{
equation
}
P_J
=
(
4
\
Delta
x_
{
min
})
^
2
\
frac
{
G
}{
\
pi
\
gamma
}
\
rho
^
2
\
end
{
equation
}
where
$
\
Delta
x_
{
min
}
=
l_
{
box
}
\
,
/
\
,
2
^
{
lmax
}
$
,
$
\
gamma
=
5
/
3
$
and
also
the
equilibrium
temperature
is
defined
as
:
\
begin
{
equation
}
T_
{
eq
}
=
\
frac
{
5000
}{
\
sqrt
n_H
}
\
end
{
equation
}
here
number
density
of
hydrogen
is
expressed
in
(
H
/
cm
^
3
).
Now
,
it
can
be
proved
that
the
n_star
of
a
hydro
run
is
given
by
:
\
begin
{
equation
}
n_
{
star
}
=
\
frac
{
2
k_b
T_
{
eq
}}
{
G
(
4
\
pi
\
Delta
x_
{
min
})}
\
end
{
equation
}
Most
of
the
heavy
lifting
is
inside
the
calculation
of
$
n_H
$
that
is
as
follows
\
begin
{
equation
}
n_H
=
\
frac
{
2
k_b
M_
{
\
%
}
^
{
-
1
}
(
3
n_H
^*
)
^
{
-
1
}}
{
G
(
4
\
Delta
x_
{
min
})
^
2
}
\
end
{
equation
}
thi
is
done
until
$
|
n_H
-
n_H
^*|/
n_H
$
>
0.0001
for
convergence
.
notice
that
here
the
is
a
molecular
gas
so
$
m_
{
\
%
}
=
(
0.76
m_p
+
0.24
m_
{
He
})
$
.
```
%% Output
from Roskar 2014
\begin{equation}
P_J = (4 \Delta x_{min})^2 \frac{G}{\pi \gamma}\rho^2
\end{equation}
where $\Delta x_{min} = l_{box} \,/ \,2^{lmax}$, $\gamma = 5/3$ and also the equilibrium temperature is defined as:
\begin{equation}
T_{eq} = \frac{5000}{\sqrt n_H}
\end{equation}
here number density of hydrogen is expressed in (H/cm^3).Now, it can be proved that the n_star of a hydro run is given by:
\begin{equation}
n_{star} = \frac{2k_b T_{eq}}
{G(4\pi \Delta x_{min})}
\end{equation}
Most of the heavy lifting is inside the calculation of $n_H$ that is as follows
\begin{equation}
n_H = \frac{2k_b M_{\%}^{-1} (3n_H^*)^{-1}} {G(4 \Delta x_{min})^2}
\end{equation}
thi is done until $|n_H-n_H^*|/n_H$>0.0001 for convergence. notice that here the is a molecular gas so $m_{\%} = (0.76m_p+0.24m_{He}) $.
%% Cell type:code id: tags:
```
python
# then
# constants
k_b
=
1.38e-23
# J K^-1
m_He
=
6.646468e-27
# kg
m_p
=
1.672e-27
# kg
G
=
6.67e-11
# m^3 kg^-1 s^-2
m_mg
=
(
0.76
*
m_p
+
0.24
*
m_He
)
pctocm
=
3.08567758e18
```
%% Cell type:markdown id: tags:
# Reproducing Roskar 2013 value of $p_J$
%% Cell type:code id: tags:
```
python
# reproducing Roskar 2013
levelmax
=
1
5
levelmax
=
1
6
Delta_x
=
(
12e6
/
2.
**
levelmax
)
n_h
,
aux
=
5.
,
20.
i
=
0
while
(
np
.
abs
(
n_h
-
aux
)
/
n_h
)
>
1e-4
:
aux
=
np
.
copy
(
n_h
)
n_h
=
(
2
*
np
.
pi
*
k_b
*
1e4
*
np
.
sqrt
(
0.3
))
/
\
(
G
*
m_mg
*
np
.
sqrt
(
aux
)
*
(
4
*
Delta_x
*
pctocm
/
100
)
**
2
)
n_h
/=
(
m_p
*
1e6
)
#
Teq
=
5000
/
np
.
sqrt
(
n_h
)
print
"With Delta_x = {0} as in Roskar 2013 we reproduce the value for p_j = n_h = {1}"
.
format
(
Delta_x
,
n_h
)
print
"and Teq = {0}"
.
format
(
Teq
)
```
%% Output
With Delta_x =
366.21093
75 as in Roskar 2013 we reproduce the value for p_j = n_h =
0.808766896752
and Teq =
5559.78913905
With Delta_x =
183.105468
75 as in Roskar 2013 we reproduce the value for p_j = n_h =
2.03785240919
and Teq =
3502.54433084
%% Cell type:markdown id: tags:
# My value
for levelmax =17 and boxlength = 25 Mpc
%% Cell type:code id: tags:
```
python
# my box
levelmax
=
18
# max reached by Zoom DMO
box_len
=
25e6
# parsec
Delta_x
=
(
box_len
/
2.
**
levelmax
)
n_h
,
aux
=
5.
,
20.
i
=
0
while
(
np
.
abs
(
n_h
-
aux
)
/
n_h
)
>
1e-4
:
aux
=
np
.
copy
(
n_h
)
n_h
=
(
2
*
np
.
pi
*
k_b
*
1e4
*
np
.
sqrt
(
0.3
))
/
\
(
G
*
m_mg
*
np
.
sqrt
(
aux
)
*
(
4
*
Delta_x
*
pctocm
/
100
)
**
2
)
# kg per cubic meter
n_h
/=
(
m_p
*
1e6
)
# H per cubic centimeter
# so my n_star is
n_star
=
(
2
*
np
.
pi
*
k_b
*
1e4
*
np
.
sqrt
(
0.3
/
n_h
))
/
\
(
G
*
m_p
*
(
4.
*
Delta_x
*
pctocm
/
100
)
**
2
)
n_star
/=
(
m_p
*
1e6
)
print
"the resulting values for my sim are: "
print
"p_j = {0:.3f} m_h / cc"
.
format
(
n_h
)
print
"n_star = {0:.3f} m_H / cc"
.
format
(
n_star
)
```
%% Output
the resulting values for my sim are:
p_j = 4.863 m_h / cc
n_star = 8.336 m_H / cc
%% Cell type:code id: tags:
```
python
mstar
=
n_star
*
(
1.
/
(
2.
**
levelmax
))
**
3.
/
n_h
```
%% Cell type:code id: tags:
```
python
(
n_star
/
n_h
)
*
(
1.
/
(
2.
**
levelmax
))
**
3.
```
%% Output
7.612191598560314e-16
%% Cell type:code id: tags:
```
python
mstar
```
%% Output
7.612191598560314e-16
%% Cell type:code id: tags:
```
python
Delta_x
```
%% Output
190.73486328125
%% Cell type:code id: tags:
```
python
```
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment