예제 #1
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
예제 #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
예제 #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)
예제 #4
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
예제 #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
예제 #6
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)
예제 #7
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)
예제 #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
예제 #9
0
파일: linearity.py 프로젝트: LeiDai/pyofss
    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]))])
예제 #10
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]))])
예제 #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
예제 #12
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]]
예제 #13
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]))
        ])
예제 #14
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))
예제 #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]
예제 #16
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)
예제 #17
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)
예제 #18
0
파일: amplifier.py 프로젝트: LeiDai/pyofss
    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)
예제 #19
0
파일: filter.py 프로젝트: LeiDai/pyofss
    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)
예제 #20
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
예제 #21
0
 def __call__(self, domain, field):
     factor = self.linearity(domain)
     return ifft(np.exp(factor) * fft(field))
예제 #22
0
파일: linearity.py 프로젝트: LeiDai/pyofss
 def default_f(self, A, z):
     return ifft(self.factor * fft(A))
예제 #23
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
예제 #24
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
예제 #25
0
 def default_f(self, A, z):
     return ifft(self.factor * fft(A))
예제 #26
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
예제 #27
0
파일: linearity.py 프로젝트: LeiDai/pyofss
 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]))])
예제 #28
0
 def default_exp_f(self, A, h):
     return ifft(np.exp(h * self.factor) * fft(A))
예제 #29
0
파일: linearity.py 프로젝트: LeiDai/pyofss
 def wdm_f(self, As, z):
     return np.asarray([ifft(self.factor[0] * fft(As[0])),
                        ifft(self.factor[1] * fft(As[1]))])
예제 #30
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))
예제 #31
0
파일: linearity.py 프로젝트: LeiDai/pyofss
 def default_exp_f(self, A, h):
     return ifft(np.exp(h * self.factor) * fft(A))
예제 #32
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
예제 #33
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))
예제 #34
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)
예제 #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))
예제 #36
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
예제 #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]))])
예제 #38
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)
예제 #39
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
예제 #40
0
파일: delay.py 프로젝트: galilley/pyofss
    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))
예제 #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]))])
예제 #42
0
파일: linearity.py 프로젝트: LeiDai/pyofss
    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))
예제 #43
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]))
     ])