예제 #1
0
void calculate_chi_bf(rpacket_t * packet, storage_model_t * storage)
{
  double doppler_factor = rpacket_doppler_factor (packet, storage);
  double comov_nu = rpacket_get_nu (packet) * doppler_factor;

  int64_t no_of_continuum_edges = storage->no_of_edges;
  int64_t current_continuum_id;
  line_search(storage->continuum_list_nu, comov_nu, no_of_continuum_edges, &current_continuum_id);
  rpacket_set_current_continuum_id(packet, current_continuum_id);

  int64_t shell_id = rpacket_get_current_shell_id(packet);
  double T = storage->t_electrons[shell_id];
  double boltzmann_factor = exp(-(H * comov_nu) / (KB*T));

  double bf_helper = 0;
  for(int64_t i = current_continuum_id; i < no_of_continuum_edges; i++)
    {
      // get the levelpopulation for the level ijk in the current shell:
      double l_pop = storage->l_pop[shell_id * no_of_continuum_edges + i];
      // get the levelpopulation ratio \frac{n_{0,j+1,k}}{n_{i,j,k}} \frac{n_{i,j,k}}{n_{0,j+1,k}}^{*}:
      double l_pop_r = storage->l_pop_r[shell_id * no_of_continuum_edges + i];
      bf_helper += l_pop * bf_cross_section(storage, i, comov_nu) * (1 - l_pop_r * boltzmann_factor);

      // FIXME MR: Is this thread-safe? It doesn't look like it to me ...
      storage->chi_bf_tmp_partial[i] = bf_helper;
    }

  rpacket_set_chi_boundfree(packet, bf_helper * doppler_factor);
}
예제 #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);
}