示例#1
0
int64_t montecarlo_one_packet_loop(storage_model_t *storage, rpacket_t *packet, int64_t virtual_packet)
{
  rpacket_set_tau_event(packet, 0.0);
  rpacket_set_nu_line(packet, 0.0);
  rpacket_set_virtual_packet(packet, virtual_packet);
  rpacket_set_status(packet, TARDIS_PACKET_STATUS_IN_PROCESS);
  // Initializing tau_event if it's a real packet.
  if (virtual_packet == 0)
    {
      rpacket_reset_tau_event(packet);
    }
  // For a virtual packet tau_event is the sum of all the tau's that the packet passes.
  while (rpacket_get_status(packet) == TARDIS_PACKET_STATUS_IN_PROCESS)
    {
      // Check if we are at the end of line list.
      if (!rpacket_get_last_line(packet))
	{
	  rpacket_set_nu_line(packet, storage->line_list_nu[rpacket_get_next_line_id(packet)]);
	}
      double distance;
      get_event_handler(packet, storage, &distance)(packet, storage, distance);
      if (virtual_packet > 0 && rpacket_get_tau_event(packet) > 10.0)
	{
	  rpacket_set_tau_event(packet, 100.0);
	  rpacket_set_status(packet, TARDIS_PACKET_STATUS_EMITTED);
	}
    } 
  if (virtual_packet > 0)
    {
      rpacket_set_energy(packet, rpacket_get_energy(packet) * exp(-1.0 * rpacket_get_tau_event(packet)));
    }
  return rpacket_get_status(packet) == TARDIS_PACKET_STATUS_REABSORBED ? 1 : 0;
}
示例#2
0
/* initialise RPacket */
static void init_rpacket(rpacket_t *rp){
	double MU = 0.3;
	double R = 7.5e14;
	double ENERGY = 0.9;
	int NEXT_LINE_ID = 1;
	double NU = 0.4;
	double NU_LINE = 0.2;
	int CURRENT_SHELL_ID = 0;

	double TAU_EVENT = 2.9e13;

	rpacket_set_current_shell_id(rp, CURRENT_SHELL_ID);
	rpacket_set_next_shell_id(rp, CURRENT_SHELL_ID+1);
	rpacket_set_mu(rp, MU);
	rpacket_set_nu(rp, NU);
	rpacket_set_r(rp, R);
	rpacket_set_last_line(rp, false);
	rpacket_set_recently_crossed_boundary(rp, 1);

	rpacket_set_close_line(rp, false);
	rpacket_set_nu_line(rp, NU_LINE);

	rpacket_set_next_line_id(rp, NEXT_LINE_ID);

	rpacket_set_tau_event(rp, TAU_EVENT);
	rpacket_set_virtual_packet(rp, 0);
	rpacket_set_energy(rp, ENERGY);
	rpacket_set_virtual_packet_flag(rp, true);
	rpacket_set_status(rp, TARDIS_PACKET_STATUS_IN_PROCESS);
	rpacket_set_id(rp, 0);

	rpacket_set_current_continuum_id(rp, 1);
}
示例#3
0
bool
test_rpacket_get_virtual_packet(int value) {
    rpacket_t rp;
    rpacket_set_virtual_packet(&rp, value);
    return value==rpacket_get_virtual_packet(&rp);
}