long  AT_n_bins_for_single_impact_local_dose_distrib(
		const long    n,
		const double  E_MeV_u[],
		const long    particle_no[],
		const long    material_no,
		const long    rdd_model,
		const double  rdd_parameter[],
		const long    er_model,
		const long    N2,
		const long    stopping_power_source_no)
{
	/* get lowest and highest dose */
	double d_max_Gy    =  0.0;
	double d_min_Gy    =  0.0;

	// TODO think if d_min calculations can be done in smarter way. LET is only needed for Geiss RDD

	long  i;
	for (i = 0; i < n; i++){

		double max_electron_range_m = AT_max_electron_range_m( E_MeV_u[i], (int)material_no, (int)er_model);
		double LET_MeV_cm2_g        = AT_Stopping_Power_MeV_cm2_g_single( stopping_power_source_no, E_MeV_u[i], particle_no[i], material_no);
		double norm_constant_Gy     = AT_RDD_precalculated_constant_Gy(max_electron_range_m, LET_MeV_cm2_g, E_MeV_u[i], particle_no[i], material_no, rdd_model, rdd_parameter, er_model);
		double current_d_min_Gy     = AT_RDD_d_min_Gy( E_MeV_u[i], particle_no[i], material_no, rdd_model, rdd_parameter, er_model, norm_constant_Gy);
		double current_d_max_Gy     = AT_RDD_d_max_Gy( E_MeV_u[i], particle_no[i], material_no, rdd_model, rdd_parameter, er_model, stopping_power_source_no);

		if(i == 0){
			d_min_Gy      =  current_d_min_Gy;
			d_max_Gy      =  current_d_max_Gy;
		}
		else{
			d_min_Gy      =  GSL_MIN(d_min_Gy, current_d_min_Gy);
			d_max_Gy      =  GSL_MAX(d_max_Gy, current_d_max_Gy);
		}
	}

	long n_bins_for_singe_impact_local_dose_ditrib = 0;
	// get number of bins needed to span that dose range
	if( (d_min_Gy > 0) && (d_max_Gy >0) ){
		// OLD:
		//		double tmp        =  log10(d_max_Gy/d_min_Gy) / log10(2.0) * ((double)N2);
		//		n_bins_for_singe_impact_local_dose_ditrib        =  (long)(floor(tmp) + 1.0);
		AT_histo_n_bins(     d_min_Gy,
				d_max_Gy,
				AT_N2_to_step(N2),
				AT_histo_log,
				&n_bins_for_singe_impact_local_dose_ditrib);
	} else {
#ifndef NDEBUG
		printf("AT_n_bins_for_singe_impact_local_dose_ditrib: problem in evaluating n_bins_for_singe_impact_local_dose_ditrib: d_min = %g [Gy], d_max = %g [Gy] \n", d_min_Gy, d_max_Gy);
		exit(EXIT_FAILURE);
#endif
	}
	return n_bins_for_singe_impact_local_dose_ditrib + 1;
}
Esempio n. 2
0
int AT_KatzModel_inactivation_cross_section_m2(
    const long   n,
    const double E_MeV_u[],
    const long   particle_no,
    const long   material_no,
    const long   rdd_model,
    const double rdd_parameters[],
    const long   er_model,
    const double gamma_parameters[],
    const long   stop_power_source,
    double inactivation_cross_section_m2[]){

  const double D0_characteristic_dose_Gy  =  gamma_parameters[1];
  const double c_hittedness               =  gamma_parameters[2];
  const double m_number_of_targets        =  gamma_parameters[3];

  if( rdd_model == RDD_KatzExtTarget ){
    long i;
    for( i = 0 ; i < n ; i++){

      const double max_electron_range_m  =  AT_max_electron_range_m( E_MeV_u[i], (int)material_no, (int)er_model);
      const double a0_m                  =  rdd_parameters[1];
      const double KatzPoint_r_min_m     =  AT_RDD_r_min_m( max_electron_range_m, rdd_model, rdd_parameters );
      const double Katz_point_coeff_Gy   =  AT_RDD_Katz_coeff_Gy_general( E_MeV_u[i], particle_no, material_no, er_model);
      const double r_max_m               =  GSL_MIN(a0_m, max_electron_range_m);

      double Katz_plateau_Gy  =  0.0;
      double alpha                       =  0.0;
      if( (er_model == ER_Waligorski) || (er_model == ER_Edmund) ){ // "new" Katz RDD
        alpha            =  AT_ER_PowerLaw_alpha(E_MeV_u[i]);
        Katz_plateau_Gy  =  AT_RDD_Katz_PowerLawER_Daverage_Gy( KatzPoint_r_min_m, r_max_m, max_electron_range_m, alpha, Katz_point_coeff_Gy );
      } else if (er_model == ER_ButtsKatz){ // "old" Katz RDD
        Katz_plateau_Gy  =  AT_RDD_Katz_LinearER_Daverage_Gy( KatzPoint_r_min_m, r_max_m, max_electron_range_m, Katz_point_coeff_Gy );
      }

      inactivation_cross_section_m2[i] = AT_KatzModel_KatzExtTarget_inactivation_cross_section_m2(
          a0_m,
          KatzPoint_r_min_m,
          max_electron_range_m,
          er_model,
          alpha,
          Katz_plateau_Gy,
          Katz_point_coeff_Gy,
          D0_characteristic_dose_Gy,
          c_hittedness,
          m_number_of_targets);
    }

    return EXIT_SUCCESS;
  }

  if( rdd_model == RDD_CucinottaExtTarget ){
    long i;
    const double  density_g_cm3        =  AT_density_g_cm3_from_material_no( material_no );
    const double  density_kg_m3        =  density_g_cm3 * 1000.0;


    for( i = 0 ; i < n ; i++){

      const double max_electron_range_m  =  AT_max_electron_range_m( E_MeV_u[i], (int)material_no, (int)er_model);
      const double a0_m                  =  rdd_parameters[1]; // AT_RDD_a0_m( max_electron_range_m, rdd_model, rdd_parameters );
      const double KatzPoint_r_min_m     =  AT_RDD_r_min_m( max_electron_range_m, rdd_model, rdd_parameters );
      const double Katz_point_coeff_Gy   =  AT_RDD_Katz_coeff_Gy_general( E_MeV_u[i], particle_no, material_no, er_model);
      const double r_max_m               =  GSL_MIN(a0_m, max_electron_range_m);
      double  LET_MeV_cm2_g;
          AT_Mass_Stopping_Power_with_no( stop_power_source,
          		n,
      			&E_MeV_u[i],
      			&particle_no,
      			material_no,
      			&LET_MeV_cm2_g);
      const double  LET_J_m              =  LET_MeV_cm2_g * density_g_cm3 * 100.0 * MeV_to_J; // [MeV / cm] -> [J/m]
      const double  beta                 =  AT_beta_from_E_single( E_MeV_u[i] );
      const double  C_norm               =  AT_RDD_Cucinotta_Cnorm(KatzPoint_r_min_m, max_electron_range_m, beta, density_kg_m3, LET_J_m, Katz_point_coeff_Gy);
      double Cucinotta_plateau_Gy        =  AT_RDD_Cucinotta_Ddelta_average_Gy( KatzPoint_r_min_m, r_max_m, max_electron_range_m, beta, Katz_point_coeff_Gy);
      Cucinotta_plateau_Gy              +=  C_norm * AT_RDD_Cucinotta_Dexc_average_Gy( KatzPoint_r_min_m, r_max_m, max_electron_range_m, beta, Katz_point_coeff_Gy);

      inactivation_cross_section_m2[i] = AT_KatzModel_CucinottaExtTarget_inactivation_cross_section_m2(
          a0_m,
          KatzPoint_r_min_m,
          max_electron_range_m,
          beta,
          C_norm,
          Cucinotta_plateau_Gy,
          Katz_point_coeff_Gy,
          D0_characteristic_dose_Gy,
          c_hittedness,
          m_number_of_targets);
    }

    return EXIT_SUCCESS;
  }

  char rdd_name[200];
  AT_RDD_name_from_number(rdd_model, rdd_name);
#ifndef NDEBUG
  fprintf(stderr, "RDD model %ld [%s] not supported\n", rdd_model, rdd_name);
#endif
  return EXIT_FAILURE;
}