Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Plasma restructure" #371

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions conda-requirements
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ astropy>=0.4
PyYAML>=3.0
numexpr>=2.0.0
Cython>=0.21
jinja2
networkx
jinja2
12 changes: 2 additions & 10 deletions tardis/atomic.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,20 +358,12 @@ def from_hdf5(cls, fname=None):
def __init__(self, atom_data, ionization_data, levels_data, lines_data, macro_atom_data=None, zeta_data=None,
collision_data=None, synpp_refs=None, ion_cx_data=None):

if levels_data is not None:
self.has_levels = True
else:
self.has_levels = False

if lines_data is not None:
self.has_lines = True
else:
self.has_lines = False

if macro_atom_data is not None:
self.has_macro_atom = True
self.macro_atom_data_all = DataFrame(macro_atom_data[0].__array__())
self.macro_atom_references_all = DataFrame(macro_atom_data[1].__array__())

else:
self.has_macro_atom = False

Expand Down Expand Up @@ -439,7 +431,7 @@ def __init__(self, atom_data, ionization_data, levels_data, lines_data, macro_at



self.ion_cx_data = ion_cx_data




Expand Down
33 changes: 1 addition & 32 deletions tardis/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,35 +139,4 @@ def pytest_report_header(config):
if not six.PY3:
s = s.encode(stdoutencoding, 'replace')

return s


import os

@pytest.fixture
def atomic_data_fname():
atomic_data_fname = pytest.config.getvalue("atomic-dataset")
if atomic_data_fname is None:
pytest.skip('--atomic_database was not specified')
else:
return os.path.expandvars(os.path.expanduser(atomic_data_fname))

from tardis.atomic import AtomData

@pytest.fixture
def kurucz_atomic_data(atomic_data_fname):
atomic_data = AtomData.from_hdf5(atomic_data_fname)

if atomic_data.md5 != '21095dd25faa1683f4c90c911a00c3f8':
pytest.skip('Need default Kurucz atomic dataset '
'(md5="21095dd25faa1683f4c90c911a00c3f8"')
else:
return atomic_data

@pytest.fixture
def included_he_atomic_data():
import os, tardis
atomic_db_fname = os.path.join(tardis.__path__[0], 'tests', 'data',
'chianti_he_db.h5')
return AtomData.from_hdf5(atomic_db_fname)

return s
Binary file added tardis/data/density_sets.h5
Binary file not shown.
12 changes: 12 additions & 0 deletions tardis/data/lucy99_general_default.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[general]
max_atom=30
max_ion=30
time_exp=13
v_inner=11000.0
v_outer=30000.0
log_l_lsun=9.44
zones=20
calibration_packets=2e4
spectrum_packets=1e5
iterations=10
density_model=lucy99_w7
2 changes: 1 addition & 1 deletion tardis/data/tardis_config_definition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ plasma:
property_type: string
mandatory: True
default: None
allowed_value: dilute-blackbody detailed blackbody
allowed_value: dilute-blackbody detailed
help: radiative rates treatment mode

line_interaction_type:
Expand Down
21 changes: 12 additions & 9 deletions tardis/io/tests/test_model_reader.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
import os
import tardis
from tardis.io.model_reader import (read_artis_density,
read_simple_ascii_abundances)

from astropy import units as u
import numpy as np

import pytest

import tardis
from tardis.io.model_reader import (read_artis_density,
read_simple_ascii_abundances)
import os

data_path = os.path.join(tardis.__path__[0], 'io', 'tests', 'data')

@pytest.fixture
def artis_density_fname():
return os.path.join(data_path, 'artis_model.dat')

@pytest.fixture
def artis_abundances_fname():
return os.path.join(data_path, 'artis_abundances.dat')

def test_simple_read_artis_density(artis_density_fname):
(time_of_model, index, v_inner, v_outer,
mean_density) = read_artis_density(artis_density_fname)
mean_density) = read_artis_density(artis_density_fname)

assert np.isclose(0.00114661 * u.day, time_of_model, atol=1e-7 * u.day)
assert np.isclose(mean_density[23], 0.2250048 * u.g / u.cm**3, atol=1.e-6
* u.g / u.cm**3)
assert np.isclose(mean_density[23], 0.2250048 * u.g / u.cm**3, atol=1.e-6 *
u.g / u.cm**3)
assert len(mean_density) == 69
assert len(mean_density) == len(v_inner)

# Artis files are currently read with read ascii files function
#Artis files are currently read with read ascii files function
def test_read_simple_ascii_abundances(artis_abundances_fname):
index, abundances = read_simple_ascii_abundances(artis_abundances_fname)
assert len(abundances.columns) == 69
assert np.isclose(abundances[23].ix[2], 2.672351e-08 , atol=1.e-12)



23 changes: 13 additions & 10 deletions tardis/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
import scipy.special

from util import intensity_black_body
from tardis import packet_source
from tardis import packet_source, plasma_array
from tardis.montecarlo import montecarlo
from tardis.montecarlo.base import MontecarloRunner
from tardis.plasma.standard_plasmas import LegacyPlasmaArray



Expand Down Expand Up @@ -122,14 +121,16 @@ def __init__(self, tardis_config):
self.ws = (0.5 * (1 - np.sqrt(1 -
(tardis_config.structure.r_inner[0] ** 2 / tardis_config.structure.r_middle ** 2).to(1).value)))

self.plasma_array = LegacyPlasmaArray(tardis_config.number_densities, tardis_config.atom_data,

self.plasma_array = plasma_array.BasePlasmaArray(tardis_config.number_densities, tardis_config.atom_data,
tardis_config.supernova.time_explosion.to('s').value,
nlte_config=tardis_config.plasma.nlte,
delta_treatment=tardis_config.plasma.delta_treatment,
ionization_mode=tardis_config.plasma.ionization,
excitation_mode=tardis_config.plasma.excitation,
line_interaction_type=tardis_config.plasma.line_interaction_type,
link_t_rad_t_electron=0.9)
excitation_mode=tardis_config.plasma.excitation)




self.spectrum = TARDISSpectrum(tardis_config.spectrum.frequency, tardis_config.supernova.distance)
self.spectrum_virtual = TARDISSpectrum(tardis_config.spectrum.frequency, tardis_config.supernova.distance)
Expand Down Expand Up @@ -176,7 +177,7 @@ def calculate_j_blues(self, init_detailed_j_blues=False):
radiative_rates_type = self.tardis_config.plasma.radiative_rates_type
w_epsilon = self.tardis_config.plasma.w_epsilon

if radiative_rates_type == 'blackbody':
if radiative_rates_type == 'lte':
logger.info('Calculating J_blues for radiative_rates_type=lte')
j_blues = intensity_black_body(nus[np.newaxis].T, self.t_rads.value)
self.j_blues = pd.DataFrame(j_blues, index=self.atom_data.lines.index, columns=np.arange(len(self.t_rads)))
Expand All @@ -200,11 +201,12 @@ def calculate_j_blues(self, init_detailed_j_blues=False):

def update_plasmas(self, initialize_nlte=False):

self.plasma_array.update_radiationfield(self.t_rads.value, self.ws, self.j_blues,
self.tardis_config.plasma.nlte, initialize_nlte=initialize_nlte, n_e_convergence_threshold=0.05)
self.plasma_array.update_radiationfield(self.t_rads.value, self.ws, j_blues=self.j_blues,
initialize_nlte=initialize_nlte)


if self.tardis_config.plasma.line_interaction_type in ('downbranch', 'macroatom'):
self.transition_probabilities = self.plasma_array.transition_probabilities
self.transition_probabilities = self.plasma_array.calculate_transition_probabilities()


def update_radiationfield(self, log_sampling=5):
Expand Down Expand Up @@ -283,6 +285,7 @@ def update_radiationfield(self, log_sampling=5):
self.tardis_config.supernova.luminosity_requested.value)
logger.info('Calculating new t_inner = %.3f', updated_t_inner.value)


return t_inner_new


Expand Down
2 changes: 0 additions & 2 deletions tardis/plasma/__init__.py

This file was deleted.

Loading