def open(self, domain: Domain, *fields: List[Field]) -> None: """This function is called once before a stepper began the computation. Pass the time, wavelength and center wavelength to all the effects in the equation. """ # Counters and flags ------------------------------------------- self._call_counter = 0 # Sub-equations open ------------------------------------------- for i in range(len(self.__eqs)): for eq in self.__eqs[i]: eq.open(domain, fields[i]) self._id_tracker.initialize(list(fields)) # Attributes definitions --------------------------------------- self._center_omega = np.array([]) self._abs_omega = np.zeros((0, domain.samples)) self._rep_freq = np.array([]) for field_list in fields: for field in field_list: self._center_omega = np.hstack((self._center_omega, field.center_omega)) self._abs_omega = np.vstack((self._abs_omega, FFT.fftshift(field.omega))) self._rep_freq = np.hstack((self._rep_freq, field.rep_freq)) self._omega = FFT.fftshift(domain.omega) self._domega = domain.domega self._time = domain.time self._dtime = domain.dtime effects = ["lin", "non_lin", "ind"] for effect in effects: effect_list = getattr(self, "_{}_effects".format(effect)) for i in range(len(effect_list)): for j in range(len(effect_list[i])): for k in range(len(effect_list[i][j])): effect_list[i][j][k].omega = self._omega effect_list[i][j][k].time = self._time effect_list[i][j][k].domega = self._domega effect_list[i][j][k].dtime = self._dtime effect_list[i][j][k].rep_freq = self._rep_freq # Init variables ----------------------------------------------- if (not self.STEP_UPDATE): # otherwise do it at each step in set() self._update_variables() # Delays ------------------------------------------------------- self._init_delays = np.zeros(0) for field_list in fields: for field in field_list: self._init_delays = np.hstack((self._init_delays, field.delays)) self._step_delay = np.zeros(len(self._center_omega)) if (self.is_master()): self._total_delays = np.zeros((len(self._center_omega), 0)) self._synchroniser.initialize(self._init_delays, self._rep_freq, self._id_tracker, self._dtime) # Noise -------------------------------------------------------- self._noise_omega = domain.noise_omega self._noise_domega = domain.noise_domega self._noise_samples = domain.noise_samples
def open(self, domain: Domain, *fields: List[Field]) -> None: for i in range(len(self._eqs)): for eq in self._eqs[i]: eq.open(domain, fields[i]) self._init_eq_ids(list(fields)) self._center_omega = np.array([]) self._omega_all = np.zeros((0, domain.samples)) for field_list in fields: for field in field_list: self._center_omega = np.hstack((self._center_omega, field.center_omega)) self._omega_all = np.vstack((self._omega_all, field.omega)) self._omega = FFT.fftshift(domain.omega) effects = ["lin", "non_lin", "all"] for effect in effects: effect_list = getattr(self, "_effects_{}".format(effect)) for i in range(len(effect_list)): for j in range(len(effect_list[i])): for k in range(len(effect_list[i][j])): effect_list[i][j][k].omega = self._omega effect_list[i][j][k].time = domain.time effect_list[i][j][k].center_omega =\ self._center_omega
def term(self, waves: np.ndarray, id: int, corr_wave: Optional[np.ndarray] = None) -> np.ndarray: """The operator of the emission effect.""" power = FFT.fftshift(Field.spectral_power(waves[id])) power_sum = np.sum(power) power = (power / power_sum) if (power_sum) else (power * 0.0) power *= Field.average_power(waves[id], self.dtime, self.rep_freq[id]) return np.real(np.sum(self.op(waves, id, corr_wave) * power))
def open(self, domain: Domain, *fields: List[Field]) -> None: """This function is called once before a Stepper began the computation. Pass the time, wavelength and center wavelength to all the effects in the equation. """ self._init_eq_ids(list(fields)) self._center_omega = np.array([]) for field_list in fields: for field in field_list: self._center_omega = np.hstack( (self._center_omega, field.center_omega)) self._omega = FFT.fftshift(domain.omega) effects = ["lin", "non_lin", "all"] for effect in effects: effect_list = getattr(self, "_effects_{}".format(effect)) for i in range(len(effect_list)): effect_list[i].omega = self._omega effect_list[i].time = domain.time effect_list[i].center_omega = self._center_omega