/
make_doc_images_bgnd_sphere.py
143 lines (93 loc) · 3.02 KB
/
make_doc_images_bgnd_sphere.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import time
import numpy as np
import pylab as plt
import rabacus as ra
def plot_sphere_x( s, fname ):
""" put plot of ionization fractions from sphere `s` into fname """
plt.figure()
s.Edges.units = 'kpc'
s.r_c.units = 'kpc'
xx = s.r_c
L = s.Edges[-1]
plt.plot( xx, np.log10( s.xHe1 ),
color='green', ls='-', label = r'$x_{\rm HeI}$' )
plt.plot( xx, np.log10( s.xHe2 ),
color='green', ls='--', label = r'$x_{\rm HeII}$' )
plt.plot( xx, np.log10( s.xHe3 ),
color='green', ls=':', label = r'$x_{\rm HeIII}$' )
plt.plot( xx, np.log10( s.xH1 ),
color='red', ls='-', label = r'$x_{\rm HI}$' )
plt.plot( xx, np.log10( s.xH2 ),
color='red', ls='--', label = r'$x_{\rm HII}$' )
plt.xlim( -L/20, L+L/20 )
plt.xlabel( 'r_c [kpc]' )
plt.ylim( -4.5, 0.2 )
plt.ylabel( 'log 10 ( x )' )
plt.grid()
plt.legend(loc='best', ncol=2)
plt.tight_layout()
plt.savefig( 'doc/img/x_' + fname )
def plot_sphere_T( s, fname ):
""" put plot of temperature from sphere `s` into fname """
plt.figure()
s.Edges.units = 'kpc'
s.r_c.units = 'kpc'
xx = s.r_c
L = s.Edges[-1]
plt.plot( xx, s.T,
color='black', ls='-', label = r'$T$' )
plt.xlim( -L/20, L+L/20 )
plt.xlabel( 'r_c [kpc]' )
plt.ylim( 0.0, 3.0e4 )
plt.ylabel( 'T [K]' )
plt.grid()
plt.legend(loc='best')
plt.tight_layout()
plt.savefig( 'doc/img/T_' + fname )
z = 3.0
q_min = 1.0
q_max = 4.0e2
src_hm12 = ra.BackgroundSource( q_min, q_max, 'hm12', z=z )
q_mono = src_hm12.grey.E.H1 / src_hm12.th.E_H1
q_min = q_mono
q_max = q_mono
src_mono = ra.BackgroundSource( q_min, q_max, 'monochromatic' )
src_mono.normalize_H1i( src_hm12.thin.H1i )
spheres = {}
Nl = 512
Yp = 0.24
T = np.ones(Nl) * 1.0e4 * ra.u.K
Rsphere = 20.0 * ra.u.kpc
Edges = np.linspace( 0.0 * ra.u.kpc, Rsphere, Nl+1 )
dr = Edges[1:] - Edges[0:-1]
r_c = Edges[0:-1] + 0.5 * dr
nH0 = 1.0e1 / ra.u.cm**3
r0 = 1.0e-2 * Edges[-1]
nH = nH0 * ( r_c / r0 )**(-2)
indx = np.where( r_c < r0 )
nH[indx] = nH0
nHe = nH * 0.25 * Yp / (1-Yp)
nHe_null = np.ones(Nl) * 1.0e-15 / ra.u.cm**3
key = 'thin_caseA_mono_fixT'
spheres[key] = ra.SphereBgnd(
Edges, T, nH, nHe, src_mono, thin=True )
s = spheres[key]
plot_sphere_x( spheres[key], 'bgnd_' + key + '.png' )
key = 'rt_caseA_mono_fixT'
spheres[key] = ra.SphereBgnd(
Edges, T, nH, nHe, src_mono )
plot_sphere_x( spheres[key], 'bgnd_' + key + '.png' )
key = 'rt_caseA_poly_fixT'
spheres[key] = ra.SphereBgnd(
Edges, T, nH, nHe, src_hm12 )
plot_sphere_x( spheres[key], 'bgnd_' + key + '.png' )
key = 'rt_caseA_poly_evoT'
spheres[key] = ra.SphereBgnd(
Edges, T, nH, nHe, src_hm12, find_Teq=True, z=3.0 )
plot_sphere_x( spheres[key], 'bgnd_' + key + '.png' )
plot_sphere_T( spheres[key], 'bgnd_' + key + '.png' )
key = 'rt_isotropic_poly_evoT'
spheres[key] = ra.SphereBgnd( Edges, T, nH, nHe, src_hm12,
find_Teq=True, z=3.0, rec_meth='isotropic' )
plot_sphere_x( spheres[key], 'bgnd_' + key + '.png' )
plot_sphere_T( spheres[key], 'bgnd_' + key + '.png' )