Commit 44fb1bf8 authored by NUNEZ Arturo's avatar NUNEZ Arturo
Browse files

Automatic commit mardi 12 juin 2018, 18:06:56 (UTC+0200)

parent 7d81f539
%% 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{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}) $.
```
%% 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 = 16
levelmax = 15
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 = 183.10546875 as in Roskar 2013 we reproduce the value for p_j = n_h = 2.03785240919
and Teq = 3502.54433084
With Delta_x = 366.2109375 as in Roskar 2013 we reproduce the value for p_j = n_h = 0.808766896752
and Teq = 5559.78913905
%% 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
```
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment