Beispiel #1
0
    def setUp(self):
        ad1 = atomic.element('carbon')
        ad2 = atomic.element('li')
        eq1 = atomic.CollRadEquilibrium(ad1)
        eq2 = atomic.CollRadEquilibrium(ad2)

        te = np.logspace(0, 3, 50)
        ne = 1e19
        self.y1 = eq1.ionisation_stage_distribution(te, ne)
        self.y2 = eq2.ionisation_stage_distribution(te, ne)
 def setUp(self):
     self.ad = atomic.element('lithium')
     self.temperature = np.logspace(0, 3, 50)
     self.density = 1e19
     self.times = np.logspace(-7, 0, 120)
     self.times -= self.times[0]
     self.rt = atomic.RateEquations(self.ad)
    def setUp(self):
        ad = atomic.element('li')
        eq = atomic.CollRadEquilibrium(ad)

        self.temperature = np.logspace(0, 3, 50)
        self.electron_density = 1e19
        # y is a FractionalAbundance object.
        y = eq.ionisation_stage_distribution(self.temperature,
                                             self.electron_density)
        self.elc = atomic.ElectronCooling(y, neutral_fraction=1e-2)
Beispiel #4
0
def netauplot(netau):
    """ Create a subplot for given ne * tau."""
    taus = netau / densities

    for i in range(len(densities)):
        density = densities[i]
        tau = taus[i]
        for e in elementColors:
            plotEps(atomic.element(e['el']),
                    density,
                    tau,
                    e['c'],
                    lw=linewidth[i])

    # make the titles and set boundaries
    netaustring = num2str(netau)
    title1 = r'$n_e \tau = 10^{' + netaustring + '} \; [\mathrm{s} \; \mathrm{m}^{-3}]$'
    plt.title(title1)
    plt.ylabel(r'$\epsilon_{cool} \; [\mathrm{eV}]$')
    plt.xlabel(r'$T_e \; [\mathrm{eV}]$')
    plt.ylim(ymin=1e-1, ymax=1e5)
    plt.xlim(xmin=0.4, xmax=2000)

    # create the two legends
    lh = []
    for e in elementColors:
        lh.append(
            mlines.Line2D([], [],
                          color=e['c'],
                          label=atomic.element(e['el']).element))

    elements_legend = plt.legend(handles=lh, loc=2)
    ax = plt.gca().add_artist(elements_legend)

    lh = []
    for i in range(len(densities)):
        d = num2str(densities[i])
        tau = num2str(taus[i])
        lab = r'$n_e = 10^{' + d + r'},\; \tau = 10^{' + tau + '}$'
        lh.append(mlines.Line2D([], [], color='k', label=lab, lw=linewidth[i]))

    plt.legend(handles=lh, loc=4)
    plt.grid(True)
 def test_diffusion(self):
     """Tests that the total number of particles stays constant at 1.0."""
     ad = atomic.element('carbon')
     temperature = np.logspace(0, 3, 100)
     density = 1e19
     tau = 1e-3
     times = np.logspace(-7, 0, 120)
     times -= times[0]
     rt = atomic.RateEquationsWithDiffusion(ad)
     yy = rt.solve(times, temperature, density, tau)
     expected = np.ones(len(times))
     result = [
         np.sum(yy.abundances[i].y) / len(temperature)
         for i in range(len(times))
     ]
     np.testing.assert_array_almost_equal(expected, result)
 def setUp(self):
     """This is more of an Integration Test than a unit test."""
     self.ad = atomic.element('Li')
     self.eq = atomic.CollRadEquilibrium(self.ad)
Beispiel #7
0
from ensemble_average import annotate_lines

def parabolic_profile(y0):
    x = np.linspace(1., 0, 50)
    y = 1 - x**2
    y *= y0
    return x, y

r, temperature = parabolic_profile(3e3)
r, density = parabolic_profile(1e19)

try:
    ad
except NameError:
    from atomic.pec import TransitionPool
    ad = atomic.element('argon')
    tp = TransitionPool.from_adf15('adas_data/pec/transport_llu#ar*.dat')
    ad = tp.filter_energy(2e3, 20e3, 'eV').create_atomic_data(ad)

eq = atomic.CoronalEquilibrium(ad)
y = eq.ionisation_stage_distribution(temperature, density)

ne_tau = np.array([1e-1, 1e-2, 1e-3])
impurity_fraction = 0.05


texts = ['$10^{%d}$' % i for i in np.log10(ne_tau)]

try:
    tau_ss
except NameError:
Beispiel #8
0
    else:
        colors = [''] * 3

    for i, key in enumerate(['line_power', 'continuum_power', 'cx_power']):
        if label:
            label_str = key
        else:
            label_str = None
        c= ad.coeffs[key](charge, te, ne)
        ax.loglog(te, c, colors[i], label=label_str, **kwargs)

    ax.set_ylabel('$P/n_\mathrm{e} n_\mathrm{I}\ [\mathrm{W m^3}]$')


if __name__ == '__main__':
    ad = atomic.element('carbon')

    tp = TransitionPool.from_adf15('adas_data/pec/pec96#c_pju*.dat')
    #tp = tp.filter_energy(2e3, 20e3, 'eV')
    ad_filtered = tp.create_atomic_data(ad)

    te = np.logspace(0, 3)

    f = plt.figure(1); f.clf()

    for i, charge in enumerate([1, 2, 5]):
        ax = f.add_subplot(3, 1, i+1)
        plot_coeffs(ad, te, charge)
        plot_coeffs(ad_filtered, te, charge, marker='x', ls='', label=None)
        ax.set_ylim(1e-35, 1e-30)
        label = '$\mathrm{%s}^{%d+}$' % (ad.element, charge)
Beispiel #9
0
    annotate_lines(
        ['$10^{%d}$' % i for i in np.log10(times * solution.density)])

    power_coronal = atomic.Radiation(
        solution.y_coronal).specific_power['total']
    ax.loglog(solution.temperature, power_coronal, color='black')

    ax.set_title(title)


if __name__ == '__main__':
    times = np.logspace(-7, 0, 100)
    temperature = np.logspace(0, 3, 100)
    density = 1e19

    rt = atomic.RateEquations(atomic.element('carbon'))
    y = rt.solve(times, temperature, density)

    taus = np.array([1e14, 1e15, 1e16, 1e17, 1e18]) / density

    plt.figure(1)
    plt.clf()
    time_dependent_z(y, taus)
    plt.draw()

    plt.figure(2)
    plt.clf()
    time_dependent_power(y, taus)
    plt.draw()

    plt.figure(3)
Beispiel #10
0
import numpy as np
import atomic

ad = atomic.element('carbon')
eq = atomic.CoronalEquilibrium(ad)

temperature = np.logspace(0, 3, 50)
electron_density = 1e19
y = eq.ionisation_stage_distribution(temperature, electron_density)

rad = atomic.Radiation(y, neutral_fraction=1e-2)

import matplotlib.pyplot as plt

plt.figure(10)
plt.clf()

customize = True

lines = rad.plot()

if customize:
    plt.ylabel(r'$P/n_\mathrm{i} n_\mathrm{e}\ [\mathrm{W m^3}]$')
    plt.ylim(ymin=1e-35)

    # annotation
    s = '$n_0/n_\mathrm{e}$\n'
    if rad.neutral_fraction == 0:
        s += '$0$'
    else:
        ne = rad.electron_density
import numpy as np
import matplotlib.pyplot as plt

import atomic

elements = ['C', 'Ne', 'Ar']

temperature_ranges = {
    'C': np.logspace(0, 3, 300),
    'Ne': np.logspace(0, 4, 300),
    'Ar': np.logspace(0, 5, 300),
}

for element in elements:
    ad = atomic.element(element)
    coronal = atomic.CoronalEquilibrium(ad)

    temperature = temperature_ranges.get(element, np.logspace(0, 3, 300))
    y = coronal.ionisation_stage_distribution(temperature, density=1e19)

    plt.figure()
    y.plot_vs_temperature()
    #plt.savefig('coronal_equilibrium_%s.pdf' % element)

plt.show()
Beispiel #12
0
import numpy as np
import matplotlib.pyplot as plt

import atomic

elements = ['C', 'Ne', 'Ar']

temperature_ranges = {
    'C'  : np.logspace(0,3, 300),
    'Ne' : np.logspace(0,4, 300),
    'Ar' : np.logspace(0,5, 300),
}

for element in elements:
    ad = atomic.element(element)
    coronal = atomic.CoronalEquilibrium(ad)

    temperature = temperature_ranges.get(element, np.logspace(0, 3, 300))
    y = coronal.ionisation_stage_distribution(temperature, density=1e19)

    plt.figure();
    y.plot_vs_temperature()
    #plt.savefig('coronal_equilibrium_%s.pdf' % element)

plt.show()
Beispiel #13
0
def parabolic_profile(y0):
    x = np.linspace(1.0, 0, 50)
    y = 1 - x ** 2
    y *= y0
    return x, y


r, temperature = parabolic_profile(3e3)
r, density = parabolic_profile(1e19)

try:
    ad
except NameError:
    from atomic.pec import TransitionPool

    ad = atomic.element("argon")
    tp = TransitionPool.from_adf15("adas_data/pec/transport_llu#ar*.dat")
    ad = tp.filter_energy(2e3, 20e3, "eV").create_atomic_data(ad)

eq = atomic.CoronalEquilibrium(ad)
y = eq.ionisation_stage_distribution(temperature, density)

ne_tau = np.array([1e-1, 1e-2, 1e-3])
impurity_fraction = 0.05


texts = ["$10^{%d}$" % i for i in np.log10(ne_tau)]

try:
    tau_ss
except NameError:
Beispiel #14
0
def plotEps(ad, color):
    rt = atomic.RateEquationsWithDiffusion(ad)
    min_log_temp = ad.coeffs['ionisation'].log_temperature[0]
    temperature = np.logspace(min_log_temp, np.log10(2000), 40)
    yy = rt.solve(times, temperature, density, tau)
    elc = atomic.ElectronCooling(yy.abundances[-1])
    eps = elc.epsilon(tau)
    y1 = eps['total']
    lab = ad.element
    line, = plt.loglog(temperature, y1, color, label=lab)


tau = 1e-5
density = 1e20
times = np.logspace(-7, np.log10(tau) + 1, 120)

for el, c in list(elementColors.items()):
    print(el)
    plotEps(atomic.element(el), c)

plt.title(r'$n_e = \; ' + str(density) + r'\; [m^{-3}]$, $ \tau = 1e' +
          str(int(np.log10(tau))) +
          '\;[s]$, dashed=rad only, solid=with ionization')
plt.ylabel(r'$\epsilon_{cool} \; [\mathrm{eV}]$')
plt.xlabel(r'$T_e \; [\mathrm{eV}]$')
plt.ylim(ymin=1e-0, ymax=1e5)
plt.xlim(xmin=0.4, xmax=2000)
plt.legend(loc='best')
plt.grid(True)
plt.show()
Beispiel #15
0
 def setUp(self):
     self.ad = atomic.element('Li')
Beispiel #16
0
    ax.set_xlabel(r'$T_\mathrm{e}\ \mathrm{(eV)}$')
    ax.set_ylabel(r'$P/n_\mathrm{i} n_\mathrm{e}\ [\mathrm{W m^3}]$')
    annotate_lines(['$10^{%d}$' % i for i in np.log10(times * solution.density)])

    power_coronal = atomic.Radiation(solution.y_coronal).specific_power['total']
    ax.loglog(solution.temperature, power_coronal, color='black')

    ax.set_title(title)


if __name__ == '__main__':
    times = np.logspace(-7, 0, 100)
    temperature = np.logspace(0, 3, 100)
    density = 1e19

    rt = atomic.RateEquations(atomic.element('carbon'))
    y = rt.solve(times, temperature, density)

    taus = np.array([ 1e14, 1e15, 1e16, 1e17, 1e18])/density

    plt.figure(1); plt.clf()
    time_dependent_z(y, taus)
    plt.draw()

    plt.figure(2); plt.clf()
    time_dependent_power(y, taus)
    plt.draw()

    plt.figure(3); plt.clf()
    time_dependent_z(y, taus, ensemble_average=True)
    plt.draw()
import numpy as np
import matplotlib.pyplot as plt
import atomic

from ensemble_average import time_dependent_power


if __name__ == '__main__':
    times = np.logspace(-7, 0, 50)
    temperature = np.logspace(0, 3, 50)
    density = 1e19

    from atomic.pec import TransitionPool
    ad = atomic.element('argon')
    tp = TransitionPool.from_adf15('adas_data/pec/transport_llu#ar*.dat')
    ad = tp.filter_energy(2e3, 20e3, 'eV').create_atomic_data(ad)

    rt = atomic.RateEquations(ad)
    y = rt.solve(times, temperature, density)

    taus = np.array([ 1e14, 1e15, 1e16, 1e17, 1e18])/density

    plt.figure(2); plt.clf()
    time_dependent_power(y, taus)
    plt.ylim(ymin=1e-35)
    plt.draw()

    plt.figure(3); plt.clf()
    time_dependent_power(y, taus, ensemble_average=True)
    plt.ylim(ymin=1e-35)
    plt.draw()
        y = rt.solve(times, temperature, density, tau)
        rad = atomic.Radiation(y.abundances[-1])
        plt.loglog(temperature,
                   rad.specific_power['total'],
                   color=color,
                   ls=linestyles[i])


if __name__ == '__main__':
    temperature = np.logspace(0, np.log10(2e2), 20)
    density = 1e20
    taus = np.array([0.2, 0.5, 2]) * 1e-3

    plt.figure(1)
    plt.clf()
    plt.xlim(xmin=1, xmax=2e2)
    plt.ylim(ymin=1e-35, ymax=1e-30)

    legend_handles = []
    for elem, col in list(elementColors.items()):
        rt = atomic.RateEquationsWithDiffusion(atomic.element(elem))
        Lz_radiated_power(rt, taus, col)
        legend_handles.append(
            mlines.Line2D([], [], color=col, label=rt.atomic_data.element))

    plt.xlabel(r'$T_e \; [\mathrm{eV}]$')
    plt.ylabel(r'$L_z [\mathrm{W m^3}]$')
    plt.legend(handles=legend_handles, loc='best')
    plt.grid(True)
    plt.show()