Exemple #1
0
 def get_fxs_photons_slices(self,
                            particles,
                            beam_focus_radius,
                            jet_radius,
                            mesh_length,
                            device=None):
     mesh, voxel_length = self.get_reciprocal_mesh(
         voxel_number_1d=mesh_length)
     state, coords = distribute_particles(particles, beam_focus_radius,
                                          jet_radius)
     count = 0
     field_acc = xp.zeros(self.pixel_position_reciprocal.shape[:3],
                          dtype=xp.complex128)
     for particle in particles:
         if particles[particle] > 0:
             volume = pgd.calculate_diffraction_pattern_gpu(
                 mesh, particle, return_type="complex_field")
             orientations = ps.geometry.get_random_quat(
                 num_pts=particles[particle])
             slices = ps.geometry.take_n_slices(
                 volume=volume,
                 voxel_length=voxel_length,
                 pixel_momentum=self.pixel_position_reciprocal,
                 orientations=orientations)
             for i in range(particles[particle]):
                 field_acc += self.add_phase_shift(slices[i], coords[count])
                 count += 1
     return self.add_correction_and_quantization(
         xp.square(xp.abs(field_acc)))
Exemple #2
0
    def get_intensity_field(self, particle, device=None):
        """
        Generate a single diffraction pattern without any correction from the particle object.

        :param particle: The particle object.
        :return: A diffraction pattern.
        """
        if device:
            deprecation_message("Device option is deprecated. "
                                "Everything now runs on the GPU.")

        diffraction_pattern = pgd.calculate_diffraction_pattern_gpu(
            self.pixel_position_reciprocal, particle, "intensity")

        return np.multiply(diffraction_pattern, self.linear_correction)
Exemple #3
0
    def get_pattern_without_corrections(self, particle, beam, device="cpu"):

        if device == "cpu":
            diffraction_pattern = pd.calculate_molecularFormFactorSq(
                particle, self.pixel_distance_reciprocal,
                self.pixel_position_reciprocal)
        elif device == "gpu":
            import pysingfel.gpu.diffraction as pgd
            diffraction_pattern = pgd.calculate_diffraction_pattern_gpu(
                self.pixel_position_reciprocal, particle, "intensity")
        else:
            print(
                " The device parameter can only be set as \"gpu\" or \"cpu\" ")
            raise Exception(
                'Wrong parameter value. device can only be set as \"gpu\" or \"cpu\" '
            )

        return diffraction_pattern
Exemple #4
0
    def get_pattern_without_corrections(self,
                                        particle,
                                        device=None,
                                        return_type="intensity"):
        """
        Generate a single diffraction pattern without any correction from the particle object.

        :param particle: The particle object.
        :return: A diffraction pattern.
        """
        if device:
            deprecation_message("Device option is deprecated. "
                                "Everything now runs on the GPU.")

        diffraction_pattern = pgd.calculate_diffraction_pattern_gpu(
            self.pixel_position_reciprocal, particle, return_type)

        return diffraction_pattern