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

Integrate continuum interactions into cmontecarlo #670

Merged
merged 34 commits into from
Jan 9, 2017

Conversation

chvogl
Copy link
Contributor

@chvogl chvogl commented Nov 24, 2016

This PR imports the core routines of the continuum interaction procedure developed by @chvogl during his master's project. This PR constitutes only the first step, thus the immediate goal is not yet to have a fully fledged Tardis-continuum version but to import the necessary changes step by step in a series of PRs. The goal of the current one can be summarized as follows:

  • include core C routines of continuum interaction scheme
  • add necessary C unit tests for new additions and update and complete existing C unit tests
  • ensure that normal Tardis operation is not affected by changes

chvogl added 26 commits October 18, 2016 13:47
For example for cooling by free-bound emission a continuum
for emission is selected (i.e. a continuum_id).
- remove deprecated npz files with free-free emissivities
- refactor test_sample_nu_free_free and related fixtures
   to adjust to new data format
To allow easier testing the fixture get_rkstate is added.
This fixture allows to prepare the mt_state of the random number
generator such that requested random numbers are generated.
In addition the flag compute_chi_bf is added to prevent the recomputation of the
continuum opacities in cases where no physical interaction occurs
(e.g. passing a line).
The previous implementation of the temporary bf-opacity
storage (chi_bf_tmp_partial) as a member of the storage
structure is not thread safe. This can be solved by assigning
an individual temporary bf-opacity storage to each packet.
- add data structure for saving bound-free cross sections
- function bf_cross_section returns bound-free
  cross sections using linear interpolation on tabulated data
- add test for the calculation of bound-free opacities
Includes estimators for:
-photoionization and stimulated recombination
 rate coefficients
-bound-free heating rate coefficients
-free-free heating rate coefficients
-stimulated recombination cooling coefficients
A k_packet represents a packet of thermal energy.
Assuming radiative equilibrium k_packets are converted
in situ back to r_packets. This involves selecting the type
of the cooling process (ff- or bf-emission, collisional excitation
or ionization), as well as selecting the individual cooling
process (e.g collisional excitation to level i).
The fixture model_3lvlatom is added, which provides
macro atom data (references, transition probabilities etc.)
for a simple 3 level atom (including internal jumps and
branching).
-move testing for close lines into a function of
 its own
-move handling of line emission events into a
 a function of its own
K-packets can be treated as a macro atom level.
Having two frameworks for sampling from discrete
probabilities is redundant.
Tests the correct selection of a bound-free continuum
for absorption.
@@ -114,6 +135,18 @@ class StorageModel(Structure):
CONTINUUM_OFF = 0
CONTINUUM_ON = 1

# Variables corresponding to `emission_type` enum.
BB_EMISSION = -1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a Python Enum package that does that. Maybe we want to use it here: https://pypi.python.org/pypi/enum34 - it will become a built-in with python 3.4

@@ -94,6 +94,51 @@ line_search (const double *nu, double nu_insert, int64_t number_of_lines,
return ret_val;
}

tardis_error_t
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see if this is needed.

@@ -74,7 +79,8 @@ cdef extern from "src/cmontecarlo.h":
double inverse_sigma_thomson
double inner_boundary_albedo
int_type_t reflective_inner_boundary
double *chi_bf_tmp_partial
photo_xsect_1level ** photo_xsect
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm - double pointers. Do we really want these?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with the exact usecase but I think double pointers can easily and should be avoided here.

Copy link
Contributor Author

@chvogl chvogl Dec 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using double pointers can be easily avoided by using an array of structures instead of an array of pointers to structures. Do you think this is preferable? Since the structures are small (two pointers and an integer) this should be ok. Alternatively it is possible to store the cross section data (frequencies and cross sections) consecutively in two arrays. In this case a reference array is needed to know where the data for a certain level starts and ends.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, you should store the data as a structure of arrays.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an example this would change double *nu = storage->photo_xsect[continuum_id]->nu; to double *nu = storage->photo_xsect->nu[continuum_id];

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave this for now! Minor issue, which we can address later on if we want.

/ (storage->photo_xsect[continuum_id]->nu[result] - storage->photo_xsect[continuum_id]->nu[result-1])
* (storage->photo_xsect[continuum_id]->x_sect[result] - storage->photo_xsect[continuum_id]->x_sect[result-1]);
return bf_xsect;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hydrogenic approximation should be included

@unoebauer
Copy link
Contributor

Would be nice to have a brief description and list of milestone, so people see where this PR is heading to.

@unoebauer
Copy link
Contributor

I'd like this PR to get merged before the Christmas break! Can you identify the missing parts for doing so, @chvogl?

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

Successfully merging this pull request may close these issues.

4 participants