diff --git a/docs/index.rst b/docs/index.rst index 3ba68e6c65e..ec918f006c4 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -16,6 +16,7 @@ rapid spectral modelling of supernovae. The code is described in this documentat gui uses examples/examples + testing atomic plasma montecarlo diff --git a/docs/testing.rst b/docs/testing.rst new file mode 100644 index 00000000000..07b882a2402 --- /dev/null +++ b/docs/testing.rst @@ -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= -s" + diff --git a/tardis/io/tests/data/tardis_configv1_verysimple.yml b/tardis/io/tests/data/tardis_configv1_verysimple.yml new file mode 100644 index 00000000000..0f5c64ff930 --- /dev/null +++ b/tardis/io/tests/data/tardis_configv1_verysimple.yml @@ -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 \ No newline at end of file diff --git a/tardis/tests/conftest.py b/tardis/tests/conftest.py index a8e97da1527..9fac7635d19 100644 --- a/tardis/tests/conftest.py +++ b/tardis/tests/conftest.py @@ -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") diff --git a/tardis/tests/test_tardis_full.py b/tardis/tests/test_tardis_full.py new file mode 100644 index 00000000000..da812dbfbeb --- /dev/null +++ b/tardis/tests/test_tardis_full.py @@ -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 \ No newline at end of file