def time_dependent_power(solution, times, ensemble_average=False): element = solution.atomic_data.element if ensemble_average: solution = solution.ensemble_average() title = element + r' ensemble averaged power' else: title = element + r' time dependent power' ax = plt.gca() for y in solution.select_times(times): rad = atomic.Radiation(y) ax.loglog(solution.temperature, rad.specific_power['total'], color='black', ls='--') 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)
def Lz_radiated_power(rate_equations, taus, color): linestyles = ['dashed', 'solid', 'dashed'] for i, tau in enumerate(taus): print(tau * 1e3) times = np.logspace(-7, np.log10(tau * 10), 20) 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])
#lines_abundance = ax.semilogy(r, y.y.T*100) #ax.set_ylim(0.3, 400) #yy.y_coronal.replot_colored(line, lines_abundance) def normalized_gradient(x, y): return -np.gradient(y)/np.gradient(x)/y # fractional abundance, Zeff, Zmean y_selected = y_bar.select_times(ne_tau) for y in y_selected: #ax3.semilogy(r, y.y[-1,:].T*100, color='black') #lines = ax4.plot(r, y.effective_charge(impurity_fraction), # color='black', ls='--') rad = atomic.Radiation(y, impurity_fraction=impurity_fraction) total_power = rad.power['total'] ax4.plot(r, total_power) radiation_parameter = total_power / (impurity_fraction * density) line, = ax5.plot(r, radiation_parameter) rlte = normalized_gradient(r, temperature) rlrad = normalized_gradient(r, total_power) ax6.plot(r, rlrad) ax6.plot(r, rlte, 'k--') ax6.set_ylim(0,10) #from matplotlib.ticker import FormatStrFormatter #ax = ax3
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
def test_power(self): rad = atomic.Radiation(self.y1) power = rad.power
def test_get_neutral_density_default_zero(self): rad = atomic.Radiation(self.y1) expected = 0. result = rad.get_neutral_density() self.assertEqual(expected, result)
def test_get_neutral_density(self): rad = atomic.Radiation(self.y1, neutral_fraction=1e-2) expected = 1e17 result = rad.get_neutral_density() self.assertEqual(expected, result)
def test_get_impurity_density_zero(self): rad = atomic.Radiation(self.y1, impurity_fraction=0) expected = 0 result = rad.get_impurity_density() self.assertEqual(expected, result)
def test_get_impurity_density_default_1(self): rad = atomic.Radiation(self.y1) expected = 1e19 result = rad.get_impurity_density() self.assertEqual(expected, result)
def test_get_impurity_density_finite2(self): """There are 10 times as many impurities as main ions.""" rad = atomic.Radiation(self.y1, impurity_fraction=10) expected = 1e20 result = rad.get_impurity_density() self.assertEqual(expected, result)
def test_get_impurity_density_finite(self): rad = atomic.Radiation(self.y1, impurity_fraction=0.1) expected = 1e18 result = rad.get_impurity_density() self.assertEqual(expected, result)