Skip to content

Commit

Permalink
Relativity (#697)
Browse files Browse the repository at this point in the history
* Add better treatment of relativistic effects

* Include angle aberration in virtual packet scheme

* Fix transformation of electron scattering opacity

* Move check of relativity flag into do_angle_aberration function

* Add test for relativistic calculation of distance2line

* Fix j_blue_estimator

* Rename angle_aberration functions for clarity

* Fix formatting

* Use the original relativistic treatment for full_relativity disabled

* Remove trailing whitespaces

* Fix cmontecarlo unit tests

* Remove deprecated distance attribute

* Use comoving distance in estimator update for full_relativity only

* Remove not needed j_blue_idx from get_increment_j_blue_estimator_energy

* Fix Edotlu estimator bug

* Raise Exception in FormalIntegrator for full relativity mode

* Raise Exception if config options for both full relativity and formal integral are set
  • Loading branch information
chvogl authored and wkerzendorf committed Mar 13, 2019
1 parent d209920 commit 592cc80
Show file tree
Hide file tree
Showing 10 changed files with 336 additions and 77 deletions.
12 changes: 12 additions & 0 deletions tardis/io/config_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,18 @@ def from_config_dict(cls, config_dict, validate=True, config_dirname=''):
raise ValueError('convergence_strategy is not "damped" '
'or "custom"')

enable_full_relativity = montecarlo_section['enable_full_relativity']
spectrum_integrated = (
validated_config_dict['spectrum']['method'] == 'integrated'
)
if enable_full_relativity and spectrum_integrated:
raise NotImplementedError(
"The spectrum method is set to 'integrated' and "
"enable_full_relativity to 'True'.\n"
"The FormalIntegrator is not yet implemented for the full "
"relativity mode. "
)

return cls(validated_config_dict)


Expand Down
6 changes: 6 additions & 0 deletions tardis/io/schemas/montecarlo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ properties:
- $ref: '#/definitions/convergence_strategy/custom'
default:
type: 'damped'
enable_full_relativity:
type: boolean
default: false
description: Enables a more complete treatment of relativitic effects. This includes
angle aberration as well as use of the fully general Doppler formula.

required:
- no_of_packets
- iterations
Expand Down
16 changes: 12 additions & 4 deletions tardis/montecarlo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class MontecarloRunner(HDFWriterMixin):

def __init__(self, seed, spectrum_frequency, virtual_spectrum_range,
sigma_thomson, enable_reflective_inner_boundary,
inner_boundary_albedo, line_interaction_type,
integrator_settings):
enable_full_relativity, inner_boundary_albedo,
line_interaction_type, integrator_settings):

self.seed = seed
self.packet_source = packet_source.BlackBodySimpleSource(seed)
Expand All @@ -52,6 +52,7 @@ def __init__(self, seed, spectrum_frequency, virtual_spectrum_range,
self.sigma_thomson = sigma_thomson
self.enable_reflective_inner_boundary = enable_reflective_inner_boundary
self.inner_boundary_albedo = inner_boundary_albedo
self.enable_full_relativity = enable_full_relativity
self.line_interaction_type = line_interaction_type
self.integrator_settings = integrator_settings
self._integrator = None
Expand Down Expand Up @@ -152,6 +153,13 @@ def integrator(self):
"The FormalIntegrator is not yet available."
"Please run the montecarlo simulation at least once.",
UserWarning)
if self.enable_full_relativity:
raise NotImplementedError(
"The FormalIntegrator is not yet implemented for the full "
"relativity mode. "
"Please run with config option enable_full_relativity: "
"False."
)
return self._integrator

def run(self, model, plasma, no_of_packets,
Expand Down Expand Up @@ -410,6 +418,6 @@ def from_config(cls, config):
sigma_thomson=sigma_thomson,
enable_reflective_inner_boundary=config.montecarlo.enable_reflective_inner_boundary,
inner_boundary_albedo=config.montecarlo.inner_boundary_albedo,
enable_full_relativity=config.montecarlo.enable_full_relativity,
line_interaction_type=config.plasma.line_interaction_type,
integrator_settings=config.spectrum.integrated
)
integrator_settings=config.spectrum.integrated)
2 changes: 2 additions & 0 deletions tardis/montecarlo/montecarlo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ cdef extern from "src/cmontecarlo.h":
double *bf_heating_estimator
double *ff_heating_estimator
double *stim_recomb_cooling_estimator
int full_relativity

void montecarlo_main_loop(storage_model_t * storage, int_type_t virtual_packet_flag, int nthreads, unsigned long seed)

Expand Down Expand Up @@ -252,6 +253,7 @@ cdef initialize_storage_model(model, plasma, runner, storage_model_t *storage):
storage.inverse_sigma_thomson = 1.0 / storage.sigma_thomson
storage.reflective_inner_boundary = runner.enable_reflective_inner_boundary
storage.inner_boundary_albedo = runner.inner_boundary_albedo
storage.full_relativity = runner.enable_full_relativity
# Data for continuum implementation
cdef np.ndarray[double, ndim=1] t_electrons = plasma.t_electrons
storage.t_electrons = <double*> t_electrons.data
Expand Down
Loading

0 comments on commit 592cc80

Please sign in to comment.