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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
006ba69
Add function for sampling frequency of free-free emission
chvogl Oct 18, 2016
0ca9e48
Add test for sampling the frequency of free-free emission
chvogl Oct 18, 2016
43b1b00
Add function for sampling frequency of bound-free emission
chvogl Oct 18, 2016
6b9b45f
Add function for sampling of an individual cooling process
chvogl Oct 18, 2016
734493b
Add function to calculate the free-free opacity
chvogl Oct 24, 2016
f1f3874
Move data for C continuum tests into single hdf file
chvogl Oct 26, 2016
588e755
Add test for sampling of individual cooling processes
chvogl Oct 28, 2016
7904bbc
Add test for calculation of free-free opacity
chvogl Oct 31, 2016
ae8e9ed
Add test for montecarlo_continuum_event_handler
chvogl Oct 31, 2016
6e21e33
Restructure compute_distance2continuum
chvogl Oct 31, 2016
8f58233
Make chi_bf_tmp_partial a packet property
chvogl Nov 2, 2016
1e038fb
Add better treatment of bound-free cross-sections and opacities
chvogl Nov 3, 2016
f8ece86
Add estimators for continuum processes
chvogl Nov 7, 2016
7b0a855
Add k_packets
chvogl Nov 8, 2016
d04addf
Add function to handle continuum emission events
chvogl Nov 14, 2016
31ae2f0
Add test for cmontecarlo function get_event_handler
chvogl Nov 14, 2016
56804a8
Add test for cmontecarlo function macro_atom
chvogl Nov 15, 2016
4b16fd6
Restructure montecarlo_line_scatter function
chvogl Nov 21, 2016
0af724e
Remove k_packet and associated content
chvogl Nov 21, 2016
0d8ee37
Add test for test_for_close_line
chvogl Nov 21, 2016
e960386
Rename next_interaction2process enum and remove deprecated items
chvogl Nov 22, 2016
159d839
Adapt macro_atom to handle continuum processes
chvogl Nov 22, 2016
801a025
Add correct handling of free-free absorption events
chvogl Nov 22, 2016
51ef965
Fix formatting
chvogl Nov 22, 2016
ceece25
Add correct handling of bound-free absorption events
chvogl Nov 22, 2016
70a29c5
Add test for montecarlo_bound_free_scatter
chvogl Nov 22, 2016
ecfefbf
Register continuum_compare_data.hdf as package_data
chvogl Nov 29, 2016
a202ff0
Add adiabatic cooling
chvogl Dec 5, 2016
515f49f
Add hydrogenic approximation for bound-free cross sections
chvogl Dec 5, 2016
66db9c8
Remove deprecated attributes from model fixture
chvogl Dec 5, 2016
b46ff14
Remove unnecessary padding of chi_bf_tmp_partial
chvogl Dec 6, 2016
0062c62
Extend packet logging to continuum interactions
chvogl Dec 19, 2016
ad60e1c
Remove not yet relevant tests section
chvogl Dec 20, 2016
0770724
Restructure montecarlo_continuum_event_handler
chvogl Dec 23, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions tardis/montecarlo/montecarlo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ cdef extern from "src/cmontecarlo.h":

cdef int LOG_VPACKETS

ctypedef struct photo_xsect_1level:
double *nu
double *x_sect
int_type_t no_of_points

ctypedef struct storage_model_t:
double *packet_nus
double *packet_mus
Expand All @@ -36,6 +41,7 @@ cdef extern from "src/cmontecarlo.h":
int_type_t *last_line_interaction_out_id
int_type_t *last_line_interaction_shell_id
int_type_t *last_interaction_type
int_type_t *last_interaction_out_type
int_type_t no_of_packets
int_type_t no_of_shells
double *r_inner
Expand Down Expand Up @@ -74,7 +80,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.

double *chi_ff_factor
double *t_electrons
double *l_pop
double *l_pop_r
Expand All @@ -87,6 +94,14 @@ cdef extern from "src/cmontecarlo.h":
int_type_t *virt_packet_last_line_interaction_out_id
int_type_t virt_packet_count
int_type_t virt_array_size
int_type_t kpacket2macro_level
int_type_t *cont_edge2macro_level
double *photo_ion_estimator
double *stim_recomb_estimator
int_type_t *photo_ion_estimator_statistics
double *bf_heating_estimator
double *ff_heating_estimator
double *stim_recomb_cooling_estimator

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

Expand Down Expand Up @@ -130,16 +145,13 @@ cdef initialize_storage_model(model, runner, storage_model_t *storage):
storage.cont_status = CONTINUUM_OFF
# Continuum data
cdef np.ndarray[double, ndim=1] continuum_list_nu
cdef np.ndarray[double, ndim =1] chi_bf_tmp_partial
cdef np.ndarray[double, ndim=1] l_pop
cdef np.ndarray[double, ndim=1] l_pop_r

if storage.cont_status == CONTINUUM_ON:
continuum_list_nu = np.array([9.0e14, 8.223e14, 6.0e14, 3.5e14, 3.0e14]) # sorted list of threshold frequencies
storage.continuum_list_nu = <double*> continuum_list_nu.data
storage.no_of_edges = continuum_list_nu.size
chi_bf_tmp_partial = np.zeros(continuum_list_nu.size)
storage.chi_bf_tmp_partial = <double*> chi_bf_tmp_partial.data
l_pop = np.ones(storage.no_of_shells * continuum_list_nu.size, dtype=np.float64)
storage.l_pop = <double*> l_pop.data
l_pop_r = np.ones(storage.no_of_shells * continuum_list_nu.size, dtype=np.float64)
Expand Down
2 changes: 1 addition & 1 deletion tardis/montecarlo/setup_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ def get_extensions():


def get_package_data():
return {'tardis.montecarlo.tests':['data/*.npy']}
return {'tardis.montecarlo.tests':['data/*.npy', 'data/*.hdf']}
Loading