コード例 #1
0
ファイル: slope.py プロジェクト: mccbc/lya_analytic
from solutions.util import Line, Params, scinot, voigtx, midpoint_diff
import solutions.ftsoln as ftsoln
import numpy as np
import matplotlib.pyplot as plt
import pdb


# Line parameters object
lya = Line(1215.6701, 0.4164, 6.265e8)
p = Params(line=lya, temp=1e4, tau0=1e7, energy=1., R=1e11, sigma_source=0.0, n_points=1e4)

fig, ax = plt.subplots(1, 1, figsize=(7, 5))

for i, tau in enumerate([1e7]):
    tau0, xinit, temp, radius, L = (tau, 0.0, 1e4, 1e11, 1.)
    x_ft, sigma_ft, Jp_ft, Hp_ft, Jsp_ft, Hsp_ft, Jh_ft, Hh_ft = ftsoln.ftsoln_wrapper(tau0, xinit, temp, radius, L)
    norm = 4.0 * np.pi * radius**2 * p.delta * 4.0 * np.pi / L
    Hsp = norm*Hsp_ft
    deriv = midpoint_diff(Hsp)#dH0_dsigma(radius, sigma_ft, x_ft, p) * np.diff(sigma_ft)[0]

    ax.plot(x_ft, norm*Hh_ft, label='Hbc')
    ax.plot(x_ft, Hsp, label='H0')
    ax.plot(x_ft, deriv, label='dH0/dsigma')

plt.xlabel('x')
plt.ylabel('P(x)')
plt.legend()
plt.show()


コード例 #2
0
import numpy as np
import h5py
import matplotlib.pyplot as plt
import matplotlib.pylab as pl
import matplotlib
matplotlib.rcParams['text.usetex'] = True
from solutions.util import Line, Params

data = h5py.File('./outputs/Jnso/n8_sigma10000_omega64_rk_debug.hdf5', 'r')
c = 29979245800.0



# Physical parameters
lya = Line(1215.6701, 0.4164, 6.265e8)
p = Params(line=lya, temp=1e4, tau0=1e7, num_dens=1701290465.5139434, 
           energy=1., R=1e11, sigma_source=0., n_points=1e4)

# Diffusion time
tdiff = p.R / c * (p.a * p.tau0)**(1./3) # Diffusion time
dt = 0.1*tdiff/4.#TODO: Do a run with dt = 0.1*tdiff/4

# Number of omega points in grid
N_omegas = 64 # TODO: Do a run with 512 omegas, with dt = 0.1*tdiff/4. Reduce sigma max if needed
N_ns = 8

# Create grids
omega = np.linspace(0, 2*np.pi/dt, N_omegas)
#omega_grid = np.logspace(np.log(1e-3), np.log10(2*np.pi/dt), N_omegas-1)
#omega_grid = np.insert(omega_grid, 0, 0.)
n = np.arange(1, N_ns+1, 1)
sigma = p.sigma_grid
コード例 #3
0
ファイル: check_norm.py プロジェクト: mccbc/lya_analytic
import h5py
import numpy as np
import pdb
from solutions.util import Params, Line
'''
Calculates the sum of the surface flux over frequency and time.
'''

# Physical parameters
lya = Line(1215.6701, 0.4164, 6.265e8)
p = Params(line=lya,
           temp=1e4,
           tau0=1e7,
           num_dens=1701290465.5139434,
           energy=1.,
           R=1e11,
           sigma_source=0.,
           n_points=1e5)

n_r, n_sigma, n_t = 1, 1001, 100
a = h5py.File('./outputs/r{}_sigma{}_t{}.hdf5'.format(n_r, n_sigma, n_t), 'r')

r = a['r'][:]
sigma = a['sigma'][:]
t = a['t'][:]

H_sigma = np.zeros(len(sigma))
dt = np.diff(t)[0]

for j in range(len(t)):
    H_dump = a['H_r0_t{}'.format(j)][:]
コード例 #4
0
ファイル: overflow_test.py プロジェクト: mccbc/lya_analytic
#ax.plot(sol.t, logx, marker='o', ms=2, alpha=0.5, label='{:.1f}s, tol={}'.format(end-start, tol))
#pickle.dump(ax, open('./plotting/rk_converge_noeval.p', 'wb'))






### MATRIX SOLVER

n = 8
omega = 1.12

# Create params object
lya = Line(1215.6701, 0.4164, 6.265e8)
p = Params(line=lya, temp=1e4, tau0=1e7, num_dens=1e6, energy=1., 
           sigma_source=0., n_points=1e5, R=1e11)

a, b, c, d, e, f, g, h = m.mpf('1e310') * np.random.random(8)
A, B, C, D, E, F, G, H = m.mpf('1e310') * np.random.random(8)

matrix = np.array([[a, b, -A, -B],
                   [c, d, -C, -D],
                   [-e, -f, E, F],
                   [g, h, -G, -H]])

scales = np.mean(np.abs(matrix), axis=1)
matrix = np.array([row/scales[i] for i, row in enumerate(matrix)], dtype=float)
solution_vector = np.array([0.,
                            0.,
                            -np.sqrt(6.) / 8. * n**2. * p.energy / p.k / p.R**3. / scales[2],
                            0.], dtype=float)
コード例 #5
0
    colorlegend = []

    for i, filename in enumerate(filenames):
        # Load input parameters for the monte carlo data
        tau0, temp, xinit, prob_abs, radius = get_input_info(data_dir +
                                                             filename +
                                                             '/input')
        vth = np.sqrt(2.0 * c.k_B.cgs.value * temp / c.m_p.cgs.value)
        delta = lya.nu0 * vth / c.c.cgs.value
        a = lya.gamma / (4.0 * np.pi * delta)

        # Create parameters object for binning data
        p = Params(line=lya,
                   temp=temp,
                   tau0=tau0,
                   energy=1.,
                   R=radius,
                   sigma_source=0.,
                   n_points=1e4)
        L = 1.0

        # Plot title
        mytitle = r'$\tau_0=${}'.format(
            scinot(tau0)) + '\n' + r'$x_{{\rm init}}={:.1f}$'.format(
                xinit) + '\n' + '$T=${}'.format(scinot(temp))

        if generate_new:
            # Load the monte carlo outputs
            mu, x, time = np.load(data_dir + filename + '/mu_x_time.npy')

            # Bin the data