def adjust_second_divergence_and_intensity(self, beam_out): reduction_factor = numpy.sqrt(self.transmittance / 100) for index in range(len(beam_out._beam.rays)): if beam_out._beam.rays[index, 9] == 1: beam_out._beam.rays[index, 6] = beam_out._beam.rays[index, 6] * reduction_factor beam_out._beam.rays[index, 7] = beam_out._beam.rays[index, 7] * reduction_factor beam_out._beam.rays[index, 8] = beam_out._beam.rays[index, 8] * reduction_factor beam_out._beam.rays[index, 15] = beam_out._beam.rays[index, 15] * reduction_factor beam_out._beam.rays[index, 16] = beam_out._beam.rays[index, 16] * reduction_factor beam_out._beam.rays[index, 17] = beam_out._beam.rays[index, 17] * reduction_factor x_ray = beam_out._beam.rays[index, 0] z_ray = beam_out._beam.rays[index, 2] sigma = self.focus_dimension * 1e-4 distance = numpy.random.normal(scale=sigma) x_spot = numpy.random.random() * distance * self.get_random_sign() z_spot = numpy.sqrt(distance ** 2 - x_spot ** 2) * self.get_random_sign() v_director = ShadowMath.vector_difference([x_ray, 0.0, z_ray], [x_spot, self.focal_length + self.get_second_slits_distance(), z_spot]) v_director = v_director / ShadowMath.vector_modulus(v_director) # versor beam_out._beam.rays[index, 3] = v_director[0] beam_out._beam.rays[index, 4] = v_director[1] beam_out._beam.rays[index, 5] = v_director[2] return beam_out
def adjust_second_divergence_and_intensity(self, beam_out): reduction_factor = numpy.sqrt(self.transmittance / 100) for index in range(len(beam_out.beam.rays)): if beam_out.beam.rays[index, 9] == 1: beam_out.beam.rays[index, 6] = beam_out.beam.rays[index, 6] * reduction_factor beam_out.beam.rays[index, 7] = beam_out.beam.rays[index, 7] * reduction_factor beam_out.beam.rays[index, 8] = beam_out.beam.rays[index, 8] * reduction_factor beam_out.beam.rays[index, 15] = beam_out.beam.rays[index, 15] * reduction_factor beam_out.beam.rays[index, 16] = beam_out.beam.rays[index, 16] * reduction_factor beam_out.beam.rays[index, 17] = beam_out.beam.rays[index, 17] * reduction_factor x_ray = beam_out.beam.rays[index, 0] z_ray = beam_out.beam.rays[index, 2] sigma = self.focus_dimension * 1e-4 distance = numpy.random.normal(scale=sigma) x_spot = numpy.random.random() * distance * self.get_random_sign() z_spot = numpy.sqrt(distance ** 2 - x_spot ** 2) * self.get_random_sign() v_director = ShadowMath.vector_difference([x_ray, 0.0, z_ray], [x_spot, self.focal_length + self.get_second_slits_distance(), z_spot]) v_director = v_director / ShadowMath.vector_modulus(v_director) # versor beam_out.beam.rays[index, 3] = v_director[0] beam_out.beam.rays[index, 4] = v_director[1] beam_out.beam.rays[index, 5] = v_director[2] return beam_out
def adjust_divergence_and_intensity(self, beam_out): image_plane_distance = self.image_plane_distance + ( self.lens_length - self.get_slits_distance()) reduction_factor = numpy.sqrt(self.transmittance / 100) for index in range(len(beam_out.beam.rays)): if beam_out.beam.rays[index, 9] == 1: beam_out.beam.rays[ index, 6] = beam_out.beam.rays[index, 6] * reduction_factor beam_out.beam.rays[ index, 7] = beam_out.beam.rays[index, 7] * reduction_factor beam_out.beam.rays[ index, 8] = beam_out.beam.rays[index, 8] * reduction_factor beam_out.beam.rays[ index, 15] = beam_out.beam.rays[index, 15] * reduction_factor beam_out.beam.rays[ index, 16] = beam_out.beam.rays[index, 16] * reduction_factor beam_out.beam.rays[ index, 17] = beam_out.beam.rays[index, 17] * reduction_factor direction = [0.0, 1.0, 0.0] if self.residual_divergence > 0.0: rotation_axis = [1.0, 0.0, 0.0] rotation_angle = numpy.random.normal( scale=self.residual_divergence) # random rotation around x with a random gaussian angle residual divergence=sigma direction = ShadowMath.vector_rotate( rotation_axis, rotation_angle, direction) rotation_axis = [0.0, 1.0, 0.0] rotation_angle = 2 * numpy.pi * numpy.random.random() # random rotation around y with a random angle from 0 to 2pi direction = ShadowMath.vector_rotate( rotation_axis, rotation_angle, direction) E_s_modulus = ShadowMath.vector_modulus([ beam_out.beam.rays[index, 6], beam_out.beam.rays[index, 7], beam_out.beam.rays[index, 8] ]) E_p_modulus = ShadowMath.vector_modulus([ beam_out.beam.rays[index, 15], beam_out.beam.rays[index, 16], beam_out.beam.rays[index, 17] ]) beam_out.beam.rays[index, 3] = direction[0] beam_out.beam.rays[index, 4] = direction[1] beam_out.beam.rays[index, 5] = direction[2] beam_out.beam.retrace(image_plane_distance) return beam_out
def adjust_divergence_and_intensity(self, beam_out): image_plane_distance = self.image_plane_distance + (self.lens_length - self.get_slits_distance()) reduction_factor = numpy.sqrt(self.transmittance / 100) for index in range(len(beam_out.beam.rays)): if beam_out.beam.rays[index, 9] == 1: beam_out.beam.rays[index, 6] = beam_out.beam.rays[index, 6] * reduction_factor beam_out.beam.rays[index, 7] = beam_out.beam.rays[index, 7] * reduction_factor beam_out.beam.rays[index, 8] = beam_out.beam.rays[index, 8] * reduction_factor beam_out.beam.rays[index, 15] = beam_out.beam.rays[index, 15] * reduction_factor beam_out.beam.rays[index, 16] = beam_out.beam.rays[index, 16] * reduction_factor beam_out.beam.rays[index, 17] = beam_out.beam.rays[index, 17] * reduction_factor direction = [0.0, 1.0, 0.0] if self.residual_divergence > 0.0: rotation_axis = [1.0, 0.0, 0.0] rotation_angle = numpy.random.normal(scale=self.residual_divergence) # random rotation around x with a random gaussian angle residual divergence=sigma direction = ShadowMath.vector_rotate(rotation_axis, rotation_angle, direction) rotation_axis = [0.0, 1.0, 0.0] rotation_angle = 2 * numpy.pi * numpy.random.random() # random rotation around y with a random angle from 0 to 2pi direction = ShadowMath.vector_rotate(rotation_axis, rotation_angle, direction) E_s_modulus = ShadowMath.vector_modulus([beam_out.beam.rays[index, 6], beam_out.beam.rays[index, 7], beam_out.beam.rays[index, 8]]) E_p_modulus = ShadowMath.vector_modulus([beam_out.beam.rays[index, 15], beam_out.beam.rays[index, 16], beam_out.beam.rays[index, 17]]) beam_out.beam.rays[index, 3] = direction[0] beam_out.beam.rays[index, 4] = direction[1] beam_out.beam.rays[index, 5] = direction[2] beam_out.beam.retrace(image_plane_distance) return beam_out