Exemplo n.º 1
0
    def run(self, constrain):

        self.setup()

        rec = PotentialReconstruction(
            self.thickness + self.offset, self.precision,
            cutoff=self.pot_cutoff)
        reflcalc = ReflectionCalculation(
            None, 0, self.thickness + self.offset, 0.1)

        # plot the exact potential/refl/ for comparison
        self._plot_exact()

        # split the fourier transform up into two parts
        # f1 has the changing input
        # f2 has the non-changing input
        # since f2 contains much more data in general, we can save a lot of computation by
        # caching f2 and just
        # computing f1 each time.

        f1_index = slice(None, self.start_end[1]+1)
        f2_index = slice(self.start_end[1]+1, None)
        # self.real, self.imag contain the reflection coefficient
        f1 = FourierTransform(self.k_space[f1_index],
                              self.real[f1_index], self.imag[f1_index])
        f2 = FourierTransform(self.k_space[f2_index],
                              self.real[f2_index], self.imag[f2_index])

        if self.use_only_real_part:
            f1.method = f1.cosine_transform
            f2.method = f2.cosine_transform

        transform = UpdateableFourierTransform(f1, f2)


        # TODO: change the class name
        # Reconstruct the reflection using the fourier transform at  k =
        # k_interpolation_range (the low k range)
        # rec is used to reconstruct the potential
        # reflcalc is used to calculate the reflection coefficient
        # the constrain function constrains the potential
        interpolation = ReflectivityAmplitudeInterpolation(
            transform, self.k_interpolation_range, rec, reflcalc, constrain)

        interpolation.set_hook(self._plot_hook)
        if self.diagnostic_session:
            interpolation.set_hook(self._diagnostic_hook)

        solution = interpolation.interpolate(self.iterations, tolerance=self.tolerance)

        if self.plot_potential:
            self._potential_axes.legend()
        if self.plot_phase:
            self._phase_axes.legend()
        if self.plot_reflectivity:
            self._reflectivity_axes.legend()
        if self.show_plot:
            pylab.show()

        return solution
Exemplo n.º 2
0
    potential = load_potential("profile.dat")
    potential = shift_potential(potential, shift)

    reconstruction = PotentialReconstruction(shift + thickness,
                                             precision,
                                             cutoff=cutoff)
    reflection_calc = ReflectionCalculation(lambda x: 0, 0, shift + thickness)

    reflection_calc.set_potential(potential)

    refl = reflection_calc.refl(2 * k_space)
    refl_extrapolation = reflection_calc.refl(2 * k_extrapolation_space)
    #refl_extrapolation = (refl_extrapolation * exp(-1j * angle(refl_extrapolation))).real

    transform_left = FourierTransform(k_space, refl.real, refl.imag)
    transform_extrapolation = FourierTransform(k_extrapolation_space,
                                               refl_extrapolation.real,
                                               refl_extrapolation.imag)

    transform = UpdateableFourierTransform(transform_extrapolation,
                                           transform_left)

    w_space = linspace(-40, 60, 1000)

    transform_left.method = transform_left.cosine_transform
    transform_extrapolation.method = transform_extrapolation.cosine_transform

    pylab.plot(w_space, [transform(w) for w in w_space])

pylab.ylim(-0.4e-7, 0.4e-7)
pylab.show()