예제 #1
0
파일: Carrier.cpp 프로젝트: UrbSen/TRACS
/*
 ******************** CARRIER DRIF SIMULATION METHOD**************************
 * --Overloaded--
 *
 * Simulates how the CC drifts inside the detector in the 
 * desired number of steps
 *
 */
std::valarray<double> Carrier::simulate_drift(double dt, double max_time, double x_init, double y_init )
{
  _x[0] = x_init;
  _x[1] = y_init;

  // get number of steps from time
  int max_steps = (int) std::floor(max_time / dt);

  std::valarray<double>  i_n(max_steps); // valarray to save intensity

  runge_kutta4<std::array< double,2>> stepper;

  // wrapper for the arrays using dolphin array class
  Array<double> wrap_x(2, _x.data());
  Array<double> wrap_e_field(2, _e_field.data());
  Array<double> wrap_w_field(2, _w_field.data());

  double t=0.0; // Start at time = 0

  for ( int i = 0 ; i < max_steps; i++)
  {

    if (t < _gen_time) // If CC not yet generated
    {
      i_n[i] = 0;
    }
    else if (_detector->is_out(_x)) // If CC outside detector
    {
      i_n[i] = 0;
      break; // Finish (CC gone out)
    }
    else
    {
//std::lock_guard<std::mutex> lock(safeRead);
			safeRead.lock();
			//_detector->get_mesh()->bounding_box_tree();
      _detector->get_d_f_grad()->eval(wrap_e_field, wrap_x);
      _detector->get_w_f_grad()->eval(wrap_w_field, wrap_x);
			//_weightingField->eval(wrap_w_field, wrap_x);
			//_electricField->eval(wrap_w_field, wrap_x); 
			safeRead.unlock();
      _e_field_mod = sqrt(_e_field[0]*_e_field[0] + _e_field[1]*_e_field[1]);
      i_n[i] = _q *_sign* _mu.obtain_mobility(_e_field_mod) * (_e_field[0]*_w_field[0] + _e_field[1]*_w_field[1]);
      stepper.do_step(_drift, _x, t, dt);
      // Trapping effects due to radiation-induced defects (traps) implemented in CarrierColleciton.cpp
    }
    t+=dt;
  }
	  return i_n;
}
예제 #2
0
파일: blobs.cpp 프로젝트: josegutab/scipion
/* Volume integral of a blob ----------------------------------------------- */
double  basvolume(double a, double alpha, int m, int n)
{
    double  hn, tpi, v;
    hn = 0.5 * n;
    tpi = 2.0 * PI;

    if (alpha == 0.0)
    {
        if ((n / 2)*2 == n)           /* n even                               */
            v = pow(tpi, hn) * in_zeroarg(n / 2 + m) / in_zeroarg(m);
        else                        /* n odd                                */
            v = pow(tpi, hn) * inph_zeroarg(n / 2 + m) / in_zeroarg(m);

    }
    else
    {                        /* alpha > 0.0                          */
        if ((n / 2)*2 == n)           /* n even                               */
            v = pow(tpi / alpha, hn) * i_n(n / 2 + m, alpha) / i_n(m, alpha);
        else                        /* n odd                                */
            v = pow(tpi / alpha, hn) * i_nph(n / 2 + m, alpha) / i_n(m, alpha);
    }

    return v * pow(a, (double)n);
}
예제 #3
0
파일: Carrier.cpp 프로젝트: UrbSen/TRACS
/*
 ******************** CARRIER DRIF SIMULATION METHOD**************************
 * --Overloaded--
 *
 * Simulates how the CC drifts inside the detector in the 
 * desired number of steps
 *
 */
std::valarray<double> Carrier::simulate_drift(double dt, double max_time)
{
  // get number of steps from time
  int max_steps = (int) std::floor(max_time / dt);

  std::valarray<double>  i_n(max_steps); // valarray to save intensity

  runge_kutta4<std::array< double,2>> stepper;

  // wrapper for the arrays using dolphin array class
  Array<double> wrap_x(2, _x.data());
  Array<double> wrap_e_field(2, _e_field.data());
  Array<double> wrap_w_field(2, _w_field.data());

  double t=0.0;

  for ( int i = 0 ; i < max_steps; i++) // Simulate for the desired number of steps
  {

    if (t < _gen_time)
    {
      i_n[i] = 0;
    }
    else if (_detector->is_out(_x)) // if outside of the detector
    {
      i_n[i] = 0;
      break;
    }
    else
    {
      _detector->get_d_f_grad()->eval(wrap_e_field, wrap_x);
      _detector->get_w_f_grad()->eval(wrap_w_field, wrap_x);
			//_weightingField->eval(wrap_w_field, wrap_x);
			//_electricField->eval(wrap_w_field, wrap_x); 
      _e_field_mod = sqrt(_e_field[0]*_e_field[0] + _e_field[1]*_e_field[1]);
      i_n[i] = _q *_sign*_mu.obtain_mobility(_e_field_mod) * (_e_field[0]*_w_field[0] + _e_field[1]*_w_field[1]);
      // Trapping effects due to radiation-induced defects (traps) implemented in CarrierColleciton.cpp
      stepper.do_step(_drift, _x, t, dt);
    }
    t+=dt;
  }
  return i_n;
}