Skip to content

Commit

Permalink
Merge pull request #398 from mreineck/more_cleanups
Browse files Browse the repository at this point in the history
More cleanups
  • Loading branch information
wkerzendorf committed Aug 26, 2015
2 parents 89f56fb + 11e3585 commit e686225
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
5 changes: 5 additions & 0 deletions tardis/montecarlo/setup_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ def get_extensions():
os.path.join(os.path.dirname(__file__), 'src', '*.c'))]
sources += [os.path.relpath(fname) for fname in glob(
os.path.join(os.path.dirname(__file__), 'src/randomkit', '*.c'))]
deps = [os.path.relpath(fname) for fname in glob(
os.path.join(os.path.dirname(__file__), 'src', '*.h'))]
deps += [os.path.relpath(fname) for fname in glob(
os.path.join(os.path.dirname(__file__), 'src/randomkit', '*.h'))]

return [Extension('tardis.montecarlo.montecarlo', sources,
include_dirs=['tardis/montecarlo/src',
'tardis/montecarlo/src/randomkit',
np.get_include()],
depends=deps,
extra_compile_args=compile_args,
extra_link_args=link_args,
define_macros=define_macros)]
19 changes: 7 additions & 12 deletions tardis/montecarlo/src/cmontecarlo.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,13 +380,6 @@ int64_t
montecarlo_one_packet (storage_model_t * storage, rpacket_t * packet,
int64_t virtual_mode)
{
int64_t i;
rpacket_t virt_packet;
double mu_bin;
double mu_min;
double doppler_factor_ratio;
double weight;
int64_t virt_id_nu;
int64_t reabsorbed=-1;
if (virtual_mode == 0)
{
Expand All @@ -396,9 +389,11 @@ montecarlo_one_packet (storage_model_t * storage, rpacket_t * packet,
{
if ((rpacket_get_nu (packet) > storage->spectrum_virt_start_nu) && (rpacket_get_nu(packet) < storage->spectrum_virt_end_nu))
{
for (i = 0; i < rpacket_get_virtual_packet_flag (packet); i++)
for (int64_t i = 0; i < rpacket_get_virtual_packet_flag (packet); i++)
{
virt_packet = *packet;
double weight;
rpacket_t virt_packet = *packet;
double mu_min;
if (rpacket_get_r(&virt_packet) > storage->r_inner[0])
{
mu_min =
Expand All @@ -410,7 +405,7 @@ montecarlo_one_packet (storage_model_t * storage, rpacket_t * packet,
{
mu_min = 0.0;
}
mu_bin = (1.0 - mu_min) / rpacket_get_virtual_packet_flag (packet);
double mu_bin = (1.0 - mu_min) / rpacket_get_virtual_packet_flag (packet);
rpacket_set_mu(&virt_packet,mu_min + (i + rk_double (&mt_state)) * mu_bin);
switch (virtual_mode)
{
Expand All @@ -433,7 +428,7 @@ montecarlo_one_packet (storage_model_t * storage, rpacket_t * packet,
// I'm adding an exit() here to inform the compiler about the impossible path
exit(1);
}
doppler_factor_ratio =
double doppler_factor_ratio =
rpacket_doppler_factor (packet, storage) /
rpacket_doppler_factor (&virt_packet, storage);
rpacket_set_energy(&virt_packet,
Expand Down Expand Up @@ -464,7 +459,7 @@ montecarlo_one_packet (storage_model_t * storage, rpacket_t * packet,
storage->virt_packet_last_line_interaction_in_id[storage->virt_packet_count] = storage->last_line_interaction_in_id[rpacket_get_id (packet)];
storage->virt_packet_last_line_interaction_out_id[storage->virt_packet_count] = storage->last_line_interaction_out_id[rpacket_get_id (packet)];
storage->virt_packet_count += 1;
virt_id_nu =
int64_t virt_id_nu =
floor ((rpacket_get_nu(&virt_packet) -
storage->spectrum_start_nu) /
storage->spectrum_delta_nu);
Expand Down

0 comments on commit e686225

Please sign in to comment.