コード例 #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)
コード例 #2
0
 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)
コード例 #3
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)
コード例 #4
0
 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)
コード例 #5
0
 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)
コード例 #6
0
import numpy as np
import matplotlib.pyplot as plt

import atomic_neu.atomic as atomic

ad = atomic.element('carbon')

temperature = np.logspace(0, 3, 50)
density = 1e20
tau = 1e20 / density

t_normalized = np.logspace(-7, 0, 50)
t_normalized -= t_normalized[0]
times = t_normalized * tau

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

# time evolution of ionisation states at a certain temperature
y_fixed_temperature = yy.at_temperature(38)

# steady state time
tau_ss = yy.steady_state_time()

fig = plt.figure(1)
plt.clf()
ax = fig.add_subplot(111)
lines_ref = ax.semilogx(times / tau, y_fixed_temperature)
ax.set_xlabel(r'$t\ [\mathrm{s}]$')
ax.set_ylim(ymin=0)
ax.set_xlim(xmin=0)
コード例 #7
0
        ['$10^{%d}$' % i for i in np.log10(times * solution.density)])

    z_mean = solution.y_collrad.mean_charge()
    ax.loglog(solution.temperature, z_mean, color='black')

    ax.set_title(title)


if __name__ == '__main__':
    times = np.logspace(-7, 0, 100)
    temperature = np.logspace(np.log10(0.8), np.log10(100e3), 100)
    density = 1e20
    taus = np.logspace(14, 18, 3) / density
    element_str = 'carbon'

    rt = atomic.RateEquationsWithDiffusion(atomic.element(element_str))

    plt.close()
    plt.figure(1)
    plt.clf()
    plt.xlim(xmin=1., xmax=100e3)
    plt.ylim(ymin=1.e-35, ymax=1.e-30)
    linestyles = [
        'dashed', 'dotted', 'dashdot', (0, (3, 1)), (0, (1, 1)),
        (0, (3, 1, 1, 1, 1, 1))
    ]

    ax = plt.gca()

    for i, tau in enumerate(taus):
        y = rt.solve(times, temperature, density, tau)
コード例 #8
0
import numpy as np
import matplotlib.pyplot as plt

import atomic_neu.atomic as at
from atomic_neu.atomic.collisional_radiative import CollRadEquilibrium

elements = ['Li', 'C', 'N', 'Ne', 'Si']
elements = ['Si']

temperature_ranges = {
    'Li': np.logspace(-1, 3, 300),
    'C': np.logspace(0, 3, 300),
    'N': np.logspace(0, 3, 300),
    'Ne': np.logspace(0, 4, 300),
    'Si': np.logspace(0, 5, 300),
}

for element in elements:
    ad = at.element(element)
    collrad = CollRadEquilibrium(ad)

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

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

plt.show()
コード例 #9
0
import numpy as np
import matplotlib.pyplot as plt

import atomic_neu.atomic as at

ad = at.element('carbon')
temperature = np.logspace(0, 5, 100)
density = 1e19

S = ad.coeffs['ionisation']
alpha = ad.coeffs['recombination']


def annotate(element, lines, ind=-1):
    for i, l in enumerate(lines):
        ax = l.axes
        xy = l.get_xydata()[ind]
        s = '$\mathrm{%s}^{%d+}$' % (element, i)
        ax.annotate(s, xy, color=l.get_color(), va='center')


plt.figure(1)
plt.clf()
for i in range(ad.nuclear_charge):
    plt.loglog(temperature, S(i, temperature, density))
plt.xlabel(r'$T_\mathrm{e}\ [\mathrm{eV}]$')
plt.ylabel(r'$S\ [\mathrm{m^3 s^{-1}}]$')
plt.ylim(ymin=1e-20)

lines = plt.gca().lines
annotate(ad.element, lines)
コード例 #10
0
import numpy as np
import atomic_neu.atomic as atomic
import matplotlib.pyplot as plt

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

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

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


plt.figure()
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:
コード例 #11
0
 def setUp(self):
     self.ad = atomic.element('Li')
コード例 #12
0
import numpy as np
import matplotlib.pyplot as plt
import atomic_neu.atomic as 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)
コード例 #13
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()