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

legacy_run_simulation of Simulation restructure breaks to_hdf5 in radial1d_model #436

Closed
unoebauer opened this issue Nov 13, 2015 · 1 comment

Comments

@unoebauer
Copy link
Contributor

Summary

It seems that with the separation of the simulation and model aspects in PR #426, some inconsistencies were introduced in the radial1d_model handling, in particular when the legacy_run_simulation is used.

Details

Running the tradis_example interactively in an ipython session using the run_tardis method, the simulation runs smoothly.

from tardis import run_tardis
import yaml
config = yaml.load(open("tardis_example.yml"))
mdl = run_tardis(config)

However, some features of the radial1d_model do not work properly:

In [8]: mdl.line_interaction_type
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-8-f0a32236c03b> in <module>()
----> 1 mdl.line_interaction_type

/home/ulrich/python-virtualenv/tardis/lib/python2.7/site-packages/tardis_sn-1.5.dev1998-py2.7-linux-x86_64.egg/tardis/model.pyc in line_interaction_type(self)
    131     @property
    132     def line_interaction_type(self):
--> 133         return self._line_interaction_type
    134 
    135     @line_interaction_type.setter

AttributeError: 'Radial1DModel' object has no attribute '_line_interaction_type'

In [9]: 

For similar reasons, the to_hdf5 method is also broken:

In [5]: mdl.to_hdf5("test_model.hdf5")
tardis.model - INFO - Writing to path 
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-798e8648cb46> in <module>()
----> 1 mdl.to_hdf5("test_model.hdf5")

/home/ulrich/python-virtualenv/tardis/lib/python2.7/site-packages/tardis_sn-1.5.dev1998-py2.7-linux-x86_64.egg/tardis/model.pyc in to_hdf5(self, buffer_or_fname, path, close_h5)
    327         for key in include_from_model_in_hdf5:
    328             if include_from_model_in_hdf5[key] is None:
--> 329                 _save_model_property(getattr(self, key), key, path, hdf_store)
    330             elif callable(include_from_model_in_hdf5[key]):
    331                 include_from_model_in_hdf5[key](key, path, hdf_store)

AttributeError: 'Radial1DModel' object has no attribute 'last_line_interaction_in_id'

In addition, the radial1d_model does not have a runner attribute anymore (which is in clear conflict with to_hdf5):

        include_from_runner_ = {'virt_packet_last_interaction_type': None, 'virt_packet_last_line_interaction_in_id': None,
                                'virt_packet_last_line_interaction_out_id': None, 'virt_packet_last_interaction_in_nu': None,
                                'virt_packet_nus': None, 'virt_packet_energies': None}
        include_from_model_in_hdf5 = {'plasma_array': include_from_plasma_, 'j_blues': None,

Potential Solution Strategy

The runner now lives within the Simulation class, which is completely fine. However, in view of legacy support and of compatibility of the current radial1d_model layout, the Simulation models should have a methode like lecacy_add_runner, which adds the runner as an attribute to the radial1d_model and also performs all other omitted assignments.

unoebauer pushed a commit to unoebauer/tardis that referenced this issue Nov 27, 2015
wkerzendorf added a commit that referenced this issue Nov 30, 2015
@unoebauer
Copy link
Contributor Author

Addressed by PR #440 - has been merged into master. Thus, I am closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant