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

Adding a simple test to run a full calculation #92

Merged
merged 8 commits into from
Mar 24, 2014
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ rapid spectral modelling of supernovae. The code is described in this documentat
gui
uses
examples/examples
testing
atomic
plasma
montecarlo
Expand Down
15 changes: 15 additions & 0 deletions docs/testing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Testing TARDIS
--------------

Testing a code like TARDIS is an important step to making sure that the output is trustworthy. The TARDIS team has opted
to use the py.test testing framework for use with TARDIS (and some astropy extensions of it). To run the tests download
the desired version of TARDIS and run it with::

python setup.py test

This will run the currently implemented tests (which are not as many as there should be)

To quickly test TARDIS with any atomic dataset (it will only see if it in general runs)::

python setup.py test --args="--atomic-dataset=<path_to_dataset> -s"

47 changes: 47 additions & 0 deletions tardis/io/tests/data/tardis_configv1_verysimple.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
tardis_config_version: v1.0

supernova:
luminosity_requested: 2.8e9 Lsun
time_explosion: 13 day

atom_data: kurucz_atom_pure_simple.h5

model:

structure:
type: specific

velocity:
start: 1.1e4 km/s
stop: 2.0e4 km/s
num: 20

density:
type: branch85_w7

abundances:
type: uniform
O: 0.19
Mg: 0.03
Si: 0.52
S: 0.19
Ar: 0.04
Ca: 0.03

plasma:
ionization: lte
excitation: lte
radiative_rates_type: dilute-blackbody
line_interaction_type: macroatom

montecarlo:
seed: 23111963
no_of_packets : 2.0e+5
iterations: 5
last_no_of_packets: 5.0e+5
no_of_virtual_packets: 5

spectrum:
start: 500 angstrom
stop: 20000 angstrom
num: 10000
5 changes: 4 additions & 1 deletion tardis/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# file for setting up tests
#py.test configuration

def pytest_addoption(parser):
parser.addoption("--atomic-dataset", dest='atomic-dataset', default=None, help="filename for atomic dataset")
29 changes: 29 additions & 0 deletions tardis/tests/test_tardis_full.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import pytest
import os
import yaml
from tardis import io, model, simulation
from tardis.io.config_reader import TARDISConfiguration
from numpy.testing import assert_array_almost_equal

@pytest.mark.skipif(not pytest.config.getvalue("atomic-dataset"),
reason='--atomic_database was not specified')
class TestSimpleRun():
"""
Very simple run
"""

@classmethod
@pytest.fixture(scope="class", autouse=True)
def setup(self):
self.atom_data_filename = pytest.config.getvalue('atomic-dataset')
assert os.path.exists(self.atom_data_filename)
self.config_yaml = yaml.load(open('tardis/io/tests/data/tardis_configv1_verysimple.yml'))
self.config_yaml['atom_data'] = self.atom_data_filename

self.config = TARDISConfiguration.from_config_dict(self.config_yaml)
self.model = model.Radial1DModel(self.config)
simulation.run_radial1d(self.model)


def test_structure(self):
pass