Ejemplo n.º 1
0
    def default_f_with_ss_and_rs(self, A, z):
        """ Use self-steepening and Raman-scattering terms. """
        term_spm = np.abs(A) ** 2
        term_ss = self.ss_factor * ifft(self.omega * fft(term_spm * A))
        term_rs = self.rs_factor * ifft(1j * self.omega * fft(term_spm))

        return self.factor * (term_spm + term_rs) * A + term_ss
Ejemplo n.º 2
0
    def default_f_with_ss_and_rs(self, A, z):
        """ Use self-steepening and Raman-scattering terms. """
        term_spm = np.abs(A)**2
        term_ss = self.ss_factor * ifft(self.omega * fft(term_spm * A))
        term_rs = self.rs_factor * ifft(1j * self.omega * fft(term_spm))

        return self.factor * (term_spm + term_rs) * A + term_ss
Ejemplo n.º 3
0
    def default_f_all(self, A, z):
        """ Set all nonlinear terms. """
        term_spm = np.abs(A) ** 2
        convolution = ifft(self.h_R * fft(term_spm))
        p = fft(A * (1.0 - self.f_R) * term_spm + self.f_R * A * convolution)

        return ifft(self.factor * (1.0 + self.omega * self.ss_factor) * p)
Ejemplo n.º 4
0
    def default_exp_f_with_ss_and_rs(self, A, h, B):
        " Use self-steepening and Raman-scattering within exponential term. " ""
        term_spm = np.abs(A)**2
        term_ss = (self.ss_factor / B) * ifft(self.omega * fft(term_spm * A))
        term_rs = self.rs_factor * ifft(1j * self.omega * fft(term_spm))

        return np.exp(h * self.factor * (term_spm + term_ss + term_rs)) * B
Ejemplo n.º 5
0
    def default_exp_f_with_ss_and_rs(self, A, h, B):
        " Use self-steepening and Raman-scattering within exponential term. """
        term_spm = np.abs(A) ** 2
        term_ss = (self.ss_factor / B) * ifft(self.omega * fft(term_spm * A))
        term_rs = self.rs_factor * ifft(1j * self.omega * fft(term_spm))

        return np.exp(h * self.factor * (term_spm + term_ss + term_rs)) * B
Ejemplo n.º 6
0
    def __call__(self, domain, field):

        if self.ind is None:
            self.ind = max(np.where(domain.nu < self.cutoff_nu)[0])

            if self.field_pump is not None:
                self.field_pump = ifftshift(fft(self.field_pump))
                if self.dir_to_up is True:
                    self.field_pump[self.ind:] = 0.0
                else:
                    self.field_pump[:self.ind] = 0.0
            else:
                self.field_pump = np.zeros(field.size, dtype=field.dtype)

        if not (len(self.field_pump) == len(field)):
            raise DiffArraysError(
                "arrays of fields is different lengths")

        self.field = ifftshift(fft(field))

        if self.dir_to_up is True:
            self.field[:self.ind] = 0.0
        else:
            self.field[self.ind:] = 0.0

        return ifft(fftshift(self.field + self.field_pump))
Ejemplo n.º 7
0
    def default_f_all(self, A, z):
        """ Set all nonlinear terms. """
        term_spm = np.abs(A)**2
        convolution = ifft(self.h_R * fft(term_spm))
        p = fft(A * (1.0 - self.f_R) * term_spm + self.f_R * A * convolution)

        return ifft(self.factor * (1.0 + self.omega * self.ss_factor) * p)
Ejemplo n.º 8
0
    def default_exp_f_all(self, A, h, B):
        """ Set all terms within an exponential factor. """
        term_spm = np.abs(A)**2
        convolution = ifft(self.h_R * fft(term_spm))
        p = fft((1.0 - self.f_R) * term_spm + self.f_R * convolution)

        return np.exp(h * ifft(self.factor *
                               (1.0 + self.omega * self.ss_factor) * p)) * B
Ejemplo n.º 9
0
 def wdm_exp_f(self, As, h):
     hf0 = h * self.factor[0]
     hf1 = h * self.factor[1]
     if self.phase_lim:
         hf0 = self._limit_imag_part(hf0)
         hf1 = self._limit_imag_part(hf1)
     return np.asarray([ifft(np.exp(hf0) * fft(As[0])),
                        ifft(np.exp(hf1) * fft(As[1]))])
Ejemplo n.º 10
0
    def wdm_exp_f_cached(self, As, h):
        if self.cached_factor is None:
            print "Caching linear factor"
            self.cached_factor = [np.exp(h * self.factor[0]),
                                  np.exp(h * self.factor[1])]

        return np.asarray([ifft(self.cached_factor[0] * fft(As[0])),
                           ifft(self.cached_factor[1] * fft(As[1]))])
Ejemplo n.º 11
0
    def default_exp_f_all(self, A, h, B):
        """ Set all terms within an exponential factor. """
        term_spm = np.abs(A) ** 2
        convolution = ifft(self.h_R * fft(term_spm))
        p = fft((1.0 - self.f_R) * term_spm + self.f_R * convolution)

        return np.exp(h * ifft(self.factor *
                      (1.0 + self.omega * self.ss_factor) * p)) * B
Ejemplo n.º 12
0
    def wdm_exp_f_cached(self, As, h):
        if self.cached_factor is None:
            print "Caching linear factor"
            self.cached_factor = [
                np.exp(h * self.factor[0]),
                np.exp(h * self.factor[1])
            ]

        return np.asarray([
            ifft(self.cached_factor[0] * fft(As[0])),
            ifft(self.cached_factor[1] * fft(As[1]))
        ])
Ejemplo n.º 13
0
    def __call__(self, domain, field):
        """
        :param object domain: A domain
        :param object field: Current field
        :return: Field after modification by Gaussian filter
        :rtype: Object
        """
        # Convert field to spectral domain:
        self.field = fft(field)

        delta_nu = domain.nu - domain.centre_nu - self.offset_nu
        factor = power(delta_nu / self.width_nu, (2 * self.m))
        # Frequency values are in order, inverse shift to put in fft order:
        self.shape = exp(-0.5 * ifftshift(factor))

        if domain.channels > 1:
            # Filter is applied only to one channel:
            self.field[self.channel] *= self.shape
        else:
            self.field *= self.shape

        # convert field back to temporal domain:
        if self.type is "reflected":
            return ifft(self.field)
        else:
            return field - ifft(self.field)
Ejemplo n.º 14
0
    def __call__(self, domain, field):
        # Convert field to spectral domain:
        self.field = fft(field[self.numb_ch - 1])

        self.field *= self.ampl_main.sqrt_G
        if self.numb_ch > 1:
            return [field[0], ifft(self.field)]
        else:
            return [ifft(self.field), field[1]]
Ejemplo n.º 15
0
    def __call__(self, domain, field):

        self.field = fft(field[0])

        factor = 1.0 / (np.exp(self.slope *
                               (domain.nu / self.centre_nu - 1.0)) + 1.0)
        self.field *= factor
        self.field = ifft(self.field)

        return [field[0] - self.field, self.field]
Ejemplo n.º 16
0
    def __call__(self, domain):
        self.centre_omega = domain.centre_omega
        self.omega = fftshift(domain.omega - domain.centre_omega)

        if self.self_steepening:
            self.ss_factor = 1.0 / self.centre_omega
        else:
            self.ss_factor = 0.0

        if self.use_all:
            # Require h_R in spectral domain, so take FFT of returned value:
            self.h_R = fft(calculate_raman_term(
                domain, self.tau_1, self.tau_2))
        else:
            self.h_R = 0.0

        self.generate_nonlinearity()
Ejemplo n.º 17
0
    def __call__(self, domain):
        self.centre_omega = domain.centre_omega
        self.omega = fftshift(domain.omega - domain.centre_omega)

        if self.self_steepening:
            self.ss_factor = 1.0 / self.centre_omega
        else:
            self.ss_factor = 0.0

        if self.use_all:
            # Require h_R in spectral domain, so take FFT of returned value:
            self.h_R = fft(calculate_raman_term(domain, self.tau_1,
                                                self.tau_2))
        else:
            self.h_R = 0.0

        self.generate_nonlinearity()
Ejemplo n.º 18
0
    def __call__(self, domain, field):
        # Convert field to spectral domain:
        self.field = fft(field)

        # Calculate linear gain from logarithmic gain (G_dB -> G_linear)
        G = power(10, 0.1 * self.gain)
        if self.E_sat is not None:
            E = energy(field, domain.t)
            G = G / (1.0 + E / self.E_sat)
        sqrt_G = sqrt(G)

        if domain.channels > 1:
            self.field[0] *= sqrt_G
            self.field[1] *= sqrt_G
        else:
            self.field *= sqrt_G

        # convert field back to temporal domain:
        return ifft(self.field)
Ejemplo n.º 19
0
    def __call__(self, domain, field):

        # Convert field to spectral domain:
        self.field = fft(field)

        if self.gain is not None:
            # Calculate linear gain from logarithmic gain (G_dB -> G_linear)
            G = power(10, 0.1 * self.gain)
            sqrt_G = sqrt(G)

            if domain.channels > 1:
                self.field[0] *= sqrt_G
                self.field[1] *= sqrt_G
            else:
                self.field *= sqrt_G

        if self.power is not None:
            pass

        # convert field back to temporal domain:
        return ifft(self.field)
Ejemplo n.º 20
0
    def __call__(self, domain, field):

        # Convert field to spectral domain:
        self.field = fft(field)

        if self.gain is not None:
            # Calculate linear gain from logarithmic gain (G_dB -> G_linear)
            G = power(10, 0.1 * self.gain)
            sqrt_G = sqrt(G)

            if domain.channels > 1:
                self.field[0] *= sqrt_G
                self.field[1] *= sqrt_G
            else:
                self.field *= sqrt_G

        if self.power is not None:
            pass

        # convert field back to temporal domain:
        return ifft(self.field)
Ejemplo n.º 21
0
    def __call__(self, domain, field):
        """
        :param object domain: A domain
        :param object field: Current field
        :return: Field after modification by Gaussian filter
        :rtype: Object
        """
        # Convert field to spectral domain:
        self.field = fft(field)

        delta_nu = domain.nu - domain.centre_nu - self.offset_nu
        factor = power(delta_nu / self.width_nu, (2 * self.m))
        # Frequency values are in order, inverse shift to put in fft order:
        self.shape = exp(-0.5 * ifftshift(factor))

        if domain.channels > 1:
            # Filter is applied only to one channel:
            self.field[self.channel] *= self.shape
        else:
            self.field *= self.shape

        # convert field back to temporal domain:
        return ifft(self.field)
Ejemplo n.º 22
0
    def default_f_with_rs(self, A, z):
        """ Use Raman-scattering term. """
        term_spm = np.abs(A) ** 2
        term_rs = self.rs_factor * ifft(1j * self.omega * fft(term_spm))

        return self.factor * (term_spm + term_rs) * A
Ejemplo n.º 23
0
    def default_exp_f_with_rs(self, A, h, B):
        """ Use Raman-scattering in exponential term. """
        term_spm = np.abs(A) ** 2
        term_rs = self.rs_factor * ifft(1j * self.omega * fft(term_spm))

        return np.exp(h * self.factor * (term_spm + term_rs)) * B
Ejemplo n.º 24
0
 def default_exp_f(self, A, h):
     return ifft(np.exp(h * self.factor) * fft(A))
Ejemplo n.º 25
0
 def __call__(self, domain, field):
     self.field = fft(field)
     self.field = ifft(self.matrix_oper(self.field[0], self.field[1]))
     return self.field
Ejemplo n.º 26
0
    def default_exp_f_with_rs(self, A, h, B):
        """ Use Raman-scattering in exponential term. """
        term_spm = np.abs(A)**2
        term_rs = self.rs_factor * ifft(1j * self.omega * fft(term_spm))

        return np.exp(h * self.factor * (term_spm + term_rs)) * B
Ejemplo n.º 27
0
 def default_exp_f(self, A, h):
     hf = self.factor * h
     if self.phase_lim:
         hf = self._limit_imag_part(hf)
     return ifft(np.exp(hf) * fft(A))
Ejemplo n.º 28
0
 def default_exp_f_with_ss(self, A, h, B):
     """ Use self-steepening in exponential term. """
     term_spm = np.abs(A)**2
     term_ss = (self.ss_factor / B) * ifft(self.omega * fft(term_spm * A))
     return np.exp(h * self.factor * (term_spm + term_ss)) * B
Ejemplo n.º 29
0
    def default_exp_f_cached(self, A, h):
        if self.cached_factor is None:
            print "Caching linear factor"
            self.cached_factor = np.exp(h * self.factor)

        return ifft(self.cached_factor * fft(A))
Ejemplo n.º 30
0
 def default_f(self, A, z):
     return ifft(self.factor * fft(A))
Ejemplo n.º 31
0
 def wdm_exp_f(self, As, h):
     return np.asarray([ifft(np.exp(h * self.factor[0]) * fft(As[0])),
                        ifft(np.exp(h * self.factor[1]) * fft(As[1]))])
Ejemplo n.º 32
0
 def wdm_f(self, As, z):
     return np.asarray([ifft(self.factor[0] * fft(As[0])),
                        ifft(self.factor[1] * fft(As[1]))])
Ejemplo n.º 33
0
 def wdm_exp_f(self, As, h):
     return np.asarray([
         ifft(np.exp(h * self.factor[0]) * fft(As[0])),
         ifft(np.exp(h * self.factor[1]) * fft(As[1]))
     ])
Ejemplo n.º 34
0
 def default_exp_f_with_ss(self, A, h, B):
     """ Use self-steepening in exponential term. """
     term_spm = np.abs(A) ** 2
     term_ss = (self.ss_factor / B) * ifft(self.omega * fft(term_spm * A))
     return np.exp(h * self.factor * (term_spm + term_ss)) * B
Ejemplo n.º 35
0
 def default_exp_f_cached(self, A, h):
     if self.cached_factor is None:
         self.cache(h)
     return ifft(self.cached_factor * fft(A))
Ejemplo n.º 36
0
    def default_f_with_ss(self, A, z):
        """ Use self-steepening only. """
        term_spm = np.abs(A)**2 * A
        term_ss = self.ss_factor * ifft(self.omega * fft(term_spm))

        return self.factor * (term_spm + term_ss)
Ejemplo n.º 37
0
 def wdm_f(self, As, z):
     return np.asarray([ifft(self.factor[0] * fft(As[0])),
                        ifft(self.factor[1] * fft(As[1]))])
Ejemplo n.º 38
0
    def default_f_with_rs(self, A, z):
        """ Use Raman-scattering term. """
        term_spm = np.abs(A)**2
        term_rs = self.rs_factor * ifft(1j * self.omega * fft(term_spm))

        return self.factor * (term_spm + term_rs) * A
Ejemplo n.º 39
0
 def default_exp_f(self, A, h):
     return ifft(np.exp(h * self.factor) * fft(A))
Ejemplo n.º 40
0
    def default_f_with_ss(self, A, z):
        """ Use self-steepening only. """
        term_spm = np.abs(A) ** 2 * A
        term_ss = self.ss_factor * ifft(self.omega * fft(term_spm))

        return self.factor * (term_spm + term_ss)
Ejemplo n.º 41
0
 def wdm_exp_f_cached(self, As, h):
     if self.cached_factor is None:
         self.cache(h)
     return np.asarray([ifft(self.cached_factor[0] * fft(As[0])),
                        ifft(self.cached_factor[1] * fft(As[1]))])
Ejemplo n.º 42
0
    def __call__(self, domain, field):

        self.Domega = domain.omega - domain.centre_omega
        self.factor = 1j * fftshift(self.time * self.Domega)

        return ifft(np.exp(self.factor) * fft(field))
Ejemplo n.º 43
0
 def __call__(self, domain, field):
     factor = self.linearity(domain)
     return ifft(np.exp(factor) * fft(field))
Ejemplo n.º 44
0
    def default_exp_f_cached(self, A, h):
        if self.cached_factor is None:
            print "Caching linear factor"
            self.cached_factor = np.exp(h * self.factor)

        return ifft(self.cached_factor * fft(A))
Ejemplo n.º 45
0
 def default_f(self, A, z):
     return ifft(self.factor * fft(A))