Пример #1
0
    def calculateY( X_vect, coefficients, maximum, base_BP_positions, spectrum, scaling_factor, two_beams, m, D0, sigma, kappa, er_model):
      Y_vect = []
      from src import pyamtrack_SPC
      for x in X_vect:
        E_MeV_u_total = []
        particle_no_total = []
        fluence_cm2_total = []
        for i in range(len(coefficients)):
            shift = maximum - base_BP_positions[i]
            E_MeV_u, particle_no, fluence_cm2 = pyamtrack_SPC.spectrum_at_depth(x + shift, spectrum)
            fluence_cm2_coef = [f * coefficients[i] * scaling_factor for f in fluence_cm2]
            E_MeV_u_total += E_MeV_u
            particle_no_total += particle_no
            fluence_cm2_total += fluence_cm2_coef
            
            if two_beams:                
                plateau_dist = base_BP_positions[-1]
                plateau_prox = base_BP_positions[0]
                y = plateau_dist +  plateau_prox - x
                
                E_MeV_u_second, particle_no_second, fluence_cm2_second = pyamtrack_SPC.spectrum_at_depth(y + shift, spectrum)
                fluence_cm2_coef_second = [f * coefficients[i] * scaling_factor for f in fluence_cm2_second] # TODO check                                
                E_MeV_u_total += E_MeV_u_second
                particle_no_total += particle_no_second
                fluence_cm2_total += fluence_cm2_coef_second

            
        y = pyamtrack_SPC.survival(E_MeV_u_total, particle_no_total, fluence_cm2_total, m, D0, sigma, kappa, er_model)
        Y_vect.append(y)
      return Y_vect
Пример #2
0
		def partial_sum(spectrum, function_evaluation_mesh, value_at_plateau, local_max, positions, coefficients_of_base_BPs, plateau_dist, plateau_prox, two_beams, m, D0, sigma, kappa, er_model):
			"""Calculates partial sum"""
		
			from src import pyamtrack_SPC
			maximum = -100
			minimum = 100

			total = 0
			for x in function_evaluation_mesh:
				E_MeV_u_total, particle_no_total, fluence_cm2_total = prepareLists(x, spectrum, local_max, positions, coefficients_of_base_BPs)

			##	two opposite beams
				if two_beams:
					y = plateau_dist + plateau_prox - x
					E_MeV_u_total_second, particle_no_total_second, fluence_cm2_total_second = prepareLists(y, spectrum, local_max, positions, coefficients_of_base_BPs)
					E_MeV_u_total.extend(E_MeV_u_total_second)
					particle_no_total.extend(particle_no_total_second)
					fluence_cm2_total.extend(fluence_cm2_total_second)
						
				survival_at_depth_x = pyamtrack_SPC.survival(E_MeV_u_total, particle_no_total, fluence_cm2_total, m, D0, sigma, kappa, er_model)			
			
				if value_at_plateau > 0 and survival_at_depth_x > 0:
					total += (math.log10(value_at_plateau) - math.log10(survival_at_depth_x)) ** 2
				else:
					total = 1e100
			
				if survival_at_depth_x > maximum:
					 maximum = survival_at_depth_x
				if survival_at_depth_x < minimum:
					 minimum = survival_at_depth_x 

			return total, minimum, maximum
Пример #3
0
        def partial_sum(spectrum, function_evaluation_mesh, value_at_plateau,
                        local_max, positions, coefficients_of_base_BPs,
                        plateau_dist, plateau_prox, two_beams, m, D0, sigma,
                        kappa, er_model):
            """Calculates partial sum"""

            from src import pyamtrack_SPC
            maximum = -100
            minimum = 100

            total = 0
            for x in function_evaluation_mesh:
                E_MeV_u_total, particle_no_total, fluence_cm2_total = prepareLists(
                    x, spectrum, local_max, positions,
                    coefficients_of_base_BPs)

                ##	two opposite beams
                if two_beams:
                    y = plateau_dist + plateau_prox - x
                    E_MeV_u_total_second, particle_no_total_second, fluence_cm2_total_second = prepareLists(
                        y, spectrum, local_max, positions,
                        coefficients_of_base_BPs)
                    E_MeV_u_total.extend(E_MeV_u_total_second)
                    particle_no_total.extend(particle_no_total_second)
                    fluence_cm2_total.extend(fluence_cm2_total_second)

                survival_at_depth_x = pyamtrack_SPC.survival(
                    E_MeV_u_total, particle_no_total, fluence_cm2_total, m, D0,
                    sigma, kappa, er_model)

                if value_at_plateau > 0 and survival_at_depth_x > 0:
                    total += (math.log10(value_at_plateau) -
                              math.log10(survival_at_depth_x))**2
                else:
                    total = 1e100

                if survival_at_depth_x > maximum:
                    maximum = survival_at_depth_x
                if survival_at_depth_x < minimum:
                    minimum = survival_at_depth_x

            return total, minimum, maximum