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
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
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)
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
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
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)
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)
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
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]))])
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]))])
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
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]]
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])) ])
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))
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]
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)
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)
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)
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
def __call__(self, domain, field): factor = self.linearity(domain) return ifft(np.exp(factor) * fft(field))
def default_f(self, A, z): return ifft(self.factor * fft(A))
def __call__(self, domain, field): self.field = fft(field) self.field = ifft(self.matrix_oper(self.field[0], self.field[1])) return self.field
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
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
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]))])
def default_exp_f(self, A, h): return ifft(np.exp(h * self.factor) * fft(A))
def wdm_f(self, As, z): return np.asarray([ifft(self.factor[0] * fft(As[0])), ifft(self.factor[1] * fft(As[1]))])
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))
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
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))
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)
def default_exp_f_cached(self, A, h): if self.cached_factor is None: self.cache(h) return ifft(self.cached_factor * fft(A))
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
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)
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
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))
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]))])
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])) ])