Beispiel #1
0
void
move_packet (rpacket_t * packet, storage_model_t * storage, double distance)
{
  double doppler_factor = rpacket_doppler_factor (packet, storage);
  if (distance > 0.0)
    {
      double r = rpacket_get_r (packet);
      double new_r =
        sqrt (r * r + distance * distance +
              2.0 * r * distance * rpacket_get_mu (packet));
      rpacket_set_mu (packet,
                      (rpacket_get_mu (packet) * r + distance) / new_r);
      rpacket_set_r (packet, new_r);
      if (rpacket_get_virtual_packet (packet) <= 0)
        {
          double comov_energy = rpacket_get_energy (packet) * doppler_factor;
          double comov_nu = rpacket_get_nu (packet) * doppler_factor;
#ifdef WITHOPENMP
#pragma omp atomic
#endif
          storage->js[rpacket_get_current_shell_id (packet)] +=
            comov_energy * distance;
#ifdef WITHOPENMP
#pragma omp atomic
#endif
          storage->nubars[rpacket_get_current_shell_id (packet)] +=
            comov_energy * distance * comov_nu;
        }
    }
}
Beispiel #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);
}
Beispiel #3
0
tardis_error_t
rpacket_init (rpacket_t * packet, storage_model_t * storage, int packet_index,
              int virtual_packet_flag, double * chi_bf_tmp_partial)
{
  int64_t current_line_id;
  tardis_error_t ret_val = TARDIS_ERROR_OK;
  double current_nu = storage->packet_nus[packet_index];
  double current_energy = storage->packet_energies[packet_index];
  double current_mu = storage->packet_mus[packet_index];
  double comov_current_nu = current_nu;
  int current_shell_id = 0;
  double current_r = storage->r_inner[0];
  double beta = current_r * storage->inverse_time_explosion * INVERSE_C;

  if (storage->full_relativity)
    {
      current_nu = current_nu * (1 + beta * current_mu) / sqrt(1 - beta * beta);
      current_energy = current_energy * (1 + beta * current_mu) / sqrt(1 - beta * beta);
      current_mu = (current_mu + beta) / (1 + beta * current_mu);
    }
  else
    {
      current_nu = current_nu / (1 - beta * current_mu);
      current_energy = current_energy / (1 - beta * current_mu);
    }
  if ((ret_val =
       line_search (storage->line_list_nu, comov_current_nu,
                    storage->no_of_lines,
                    &current_line_id)) != TARDIS_ERROR_OK)
    {
      return ret_val;
    }
  bool last_line = (current_line_id == storage->no_of_lines);
  rpacket_set_nu (packet, current_nu);
  rpacket_set_mu (packet, current_mu);
  rpacket_set_energy (packet, current_energy);
  rpacket_set_r (packet, current_r);
  rpacket_set_current_shell_id (packet, current_shell_id);
  rpacket_set_next_line_id (packet, current_line_id);
  rpacket_set_last_line (packet, last_line);
  rpacket_set_close_line (packet, false);
  rpacket_set_virtual_packet_flag (packet, virtual_packet_flag);
  packet->chi_bf_tmp_partial = chi_bf_tmp_partial;
  packet->compute_chi_bf = true;
  packet->vpacket_weight = 1.0;
  return ret_val;
}
Beispiel #4
0
inline double move_packet(rpacket_t *packet, storage_model_t *storage, double distance)
{
  double new_r, doppler_factor, comov_energy, comov_nu;
  doppler_factor = rpacket_doppler_factor(packet, storage);
  if (distance > 0.0)
    {
      double r = rpacket_get_r(packet);
      new_r = sqrt(r * r + distance * distance + 2.0 * r * distance * rpacket_get_mu(packet));
      rpacket_set_mu(packet, (rpacket_get_mu(packet) * r + distance) / new_r);
      rpacket_set_r(packet, new_r);
      if (rpacket_get_virtual_packet(packet) <= 0)
	{
	  comov_energy = rpacket_get_energy(packet) * doppler_factor;
	  comov_nu = rpacket_get_nu(packet) * doppler_factor;
	  storage->js[rpacket_get_current_shell_id(packet)] += comov_energy * distance;
	  storage->nubars[rpacket_get_current_shell_id(packet)] += comov_energy * distance * comov_nu;
	}
    }
  return doppler_factor;
}
Beispiel #5
0
tardis_error_t rpacket_init(rpacket_t *packet, storage_model_t *storage, int packet_index, int virtual_packet_flag)
{
  double nu_line;
  double current_r;
  double current_mu;
  double current_nu;
  double comov_current_nu;
  double current_energy;
  int64_t current_line_id;
  int current_shell_id;
  bool last_line;
  bool close_line;
  int recently_crossed_boundary;
  tardis_error_t ret_val = TARDIS_ERROR_OK;
  current_nu = storage->packet_nus[packet_index];
  current_energy = storage->packet_energies[packet_index];
  current_mu = storage->packet_mus[packet_index];
  comov_current_nu = current_nu;
  current_shell_id = 0;
  current_r = storage->r_inner[0];
  current_nu = current_nu / (1 - (current_mu * current_r * storage->inverse_time_explosion * INVERSE_C));
  current_energy = current_energy / (1 - (current_mu * current_r * storage->inverse_time_explosion * INVERSE_C));
  if ((ret_val = line_search(storage->line_list_nu, comov_current_nu, storage->no_of_lines, &current_line_id)) != TARDIS_ERROR_OK)
    {
      return ret_val;
    }
  last_line = (current_line_id == storage->no_of_lines);
  recently_crossed_boundary = true;
  rpacket_set_nu(packet, current_nu);
  rpacket_set_mu(packet, current_mu);
  rpacket_set_energy(packet, current_energy);
  rpacket_set_r(packet, current_r);
  rpacket_set_current_shell_id(packet, current_shell_id);
  rpacket_set_next_line_id(packet, current_line_id);
  rpacket_set_last_line(packet, last_line);
  rpacket_set_close_line(packet, false);
  rpacket_set_recently_crossed_boundary(packet, recently_crossed_boundary);
  rpacket_set_virtual_packet_flag(packet, virtual_packet_flag);
  return ret_val;
}
Beispiel #6
0
bool
test_rpacket_get_r(double value) {
    rpacket_t rp;
    rpacket_set_r(&rp, value);
    return value==rpacket_get_r(&rp);
}