def _create_grids(self, intensity): soliton_grid = f.Grid(self.nx, dx=self.dx, courant=0.5) #12mm 550000 # Step 1: init media soliton_grid[5:self.nx-10] = f.CentroRamanMedium(name='Varin', chi_1=[0.69617, 0.40794, 0.89748], w0=[2.7537e16, 1.6205e16, 1.9034e14], chi_3=[1.94e-22, 0, 0], alpha=[0.7, 0, 0], wr=[8.7722e13, 0, 0], gamma_K=[0, 0, 0], gamma_R=[3.1250e13, 0, 0], permeability=1, conductivity=0, eps_inf=1) # Step 2: init src soliton_grid[3] = f.SechEnveloped(name='Varin', wavelength=1.5e-06, pulse_duration=self.pulse_duration, Intensity=intensity, peak_timestep=self.peak_timestep, tfsf=False) # Step 3: init frame soliton_grid[5:(6+self.frame_width)] = f.MovingFrame(x_to_snapshot=self.x_to_snapshot, central_wavelength=self.central_wavelength) # Step 4: init boundaries soliton_grid[0] = f.LeftSideGridBoundary() soliton_grid[self.nx - 1] = f.RightSideGridBoundary() soliton_grid.local_observers[0]._allocate_memory() timesteps = soliton_grid.local_observers[0].timesteps_to_store[-1] + 5000 # Step 5: start benchmark soliton_grid.run_timesteps(timesteps, vis=False) # due to multiprocessing it is more convenient to store data by process (nobody loves waiting) observed_process_data = soliton_grid.local_observers[0].stored_data return observed_process_data
def _grids_w_slab(self): position_src = self.start_media - 1 position_obs = self.Nx - 3 end_mur = self.Nx - 1 for ind in self.indices: # Step 1: init grid w_grid = 'slab' + str(ind) w_grid = f.Grid(nx=self.Nx, dx=self.dx) # Step 2: init media w_grid[self.start_media:ind] = f.NonDispersiveMedia(name='media', permeability=1, permittivity=self.eps, conductivity=0) # Step 3: init source w_grid[position_src] = f.ActivatedSinus(name='SinsquaredActivated', wavelength=self.lamb, carrier_wavelength=10000.e-09, phase_shift=0, amplitude=self.ampl, tfsf=True) # Step 4: add observer w_grid[position_obs] = f.QuasiHarmonicObserver(name='firstobserver', first_timestep=self.timesteps-200) # Step 5: add boundaries w_grid[0] = f.LeftSideMur() w_grid[end_mur] = f.RightSideMur() # Step 6: run simulation w_grid.run_timesteps(timesteps=self.timesteps, vis=False) # Step 7: misc self.exp_amplitude.append(w_grid.local_observers[0].amplitude) self.exp_phase.append(w_grid.local_observers[0].phase) self.theo_amplitude.append(theory_dielectric_slab_complex(w_grid)[0]) self.theo_phasenunterschied.append(theory_dielectric_slab_complex(w_grid)[1])
def _create_grid(self): self.position_P_obs = self.nx - 9 self.position_E_obs = self.nx - 8 # step 1: init grid qpm_grid = f.Grid(nx=self.nx, dx=self.dx, benchmark='qpm_harmonic', courant=0.5) self.grids.append(qpm_grid) for indices in range(len(self.ending_indices) - 1): if indices % 2 == 0: qpm_grid[self.ending_indices[indices]:self.ending_indices[indices + 1]] = f.LorentzMedium( name='Varin', permeability=1, eps_inf=1.0, chi_1=[2.42, 9.65, 1.46], chi_2=[30.e-12, 0, 0], chi_3=[0, 0, 0], conductivity=0, w0=[1.5494e16, 9.776e13, 7.9514e15], gamma=[0, 0, 0]) else: qpm_grid[self.ending_indices[indices]:self.ending_indices[indices + 1]] = f.LorentzMedium( name='Varin', permeability=1, eps_inf=1.0, chi_1=[2.42, 9.65, 1.46], chi_2=[-30.e-12, 0, 0], chi_3=[0, 0, 0], conductivity=0, w0=[1.5494e16, 9.776e13, 7.9514e15], gamma=[0, 0, 0]) qpm_grid[3] = f.GaussianImpulseWithFrequency(name='Varin', Intensity=10e12, wavelength=1.064e-06, pulse_duration=self.pulse_duration, peak_timestep=self.peak_timestep, tfsf=True) qpm_grid[self.position_E_obs] = f.E_FFTObserver(name='Varin', first_timestep=0, second_timestep=self.timesteps - 1) qpm_grid[self.position_P_obs] = f.P_FFTObserver(name='Varin', first_timestep=0, second_timestep=self.timesteps - 1) qpm_grid[0] = f.LeftSideGridBoundary() qpm_grid[self.nx - 1] = f.RightSideGridBoundary() #qpm_grid[0] = f.LeftSideMur() #qpm_grid[self.nx - 1] = f.RightSideMur() # step 6: run simulation qpm_grid.run_timesteps(timesteps=self.timesteps, vis=True)
def _create_grids(self, chi2): print('process initiated') qpm_grid = f.Grid(nx=self.nx, dx=self.dx, benchmark='qpm_harmonic_length_multiple', courant=0.5) for indices in range(len(self.ending_indices) - 1): if indices % 2 == 0: qpm_grid[self.ending_indices[indices]:self.ending_indices[indices + 1]] = f.LorentzMedium( name='Varin', permeability=1, eps_inf=1.0, chi_1=[2.42, 9.65, 1.46], chi_2=[30.e-12, 0, 0], chi_3=[0, 0, 0], conductivity=0, w0=[1.5494e16, 9.776e13, 7.9514e15], gamma=[0, 0, 0]) else: qpm_grid[self.ending_indices[indices]:self.ending_indices[indices + 1]] = f.LorentzMedium( name='Varin', permeability=1, eps_inf=1.0, chi_1=[2.42, 9.65, 1.46], chi_2=[chi2, 0, 0], chi_3=[0, 0, 0], conductivity=0, w0=[1.5494e16, 9.776e13, 7.9514e15], gamma=[0, 0, 0]) qpm_grid[3] = f.GaussianImpulseWithFrequency(name='Varin', Intensity=5*10e12, wavelength=1.064e-06, pulse_duration=self.pulse_duration, peak_timestep=self.peak_timestep, tfsf=False) for pos in self.obs_positions: qpm_grid[int(pos)] = f.E_FFTObserver(name='Varin', first_timestep=0, second_timestep=self.timesteps - 1) qpm_grid[0] = f.LeftSideGridBoundary() qpm_grid[self.nx - 1] = f.RightSideGridBoundary() # step 6: run simulation qpm_grid.run_timesteps(timesteps=self.timesteps, vis=False) observed_grid_data = bd.zeros(shape=(self.no_observer, self.timesteps)) for obs in range(self.no_observer): observed_grid_data[obs] = qpm_grid.local_observers[obs].observed_E return observed_grid_data
def _grid_wo_slab(self): position_src = self.start_media - 1 for grid in range(len(self.dx)): position_obs = self.Nx[grid] - 3 end_mur = self.Nx[grid] - 1 wo_grid = f.Grid(self.Nx[grid], dx=self.dx[grid], courant=self.courant) if wo_grid.courant == 1: wo_grid[position_src] = f.ActivatedSinus(name='SinsquaredActivated', wavelength=self.lamb, carrier_wavelength=(self.lamb * 30), phase_shift=0, amplitude=self.ampl, tfsf=True) else: wo_grid[position_src] = f.ActivatedSinus(name='SinsquaredActivated', wavelength=self.lamb, carrier_wavelength=(self.lamb * 30), phase_shift=0, amplitude=self.ampl, tfsf=False) wo_grid[position_obs] = f.QuasiHarmonicObserver(name='firstobserver', first_timestep=self.timesteps[grid]-200) if wo_grid.courant == 0.5: wo_grid[0] = f.LeftSideGridBoundary() wo_grid[end_mur] = f.RightSideGridBoundary() else: wo_grid[0] = f.LeftSideMur() wo_grid[end_mur] = f.RightSideMur() wo_grid.run_timesteps(self.timesteps[grid], vis=False) self.wo_phase_merged[grid] = wo_grid.local_observers[0].phase
def _grid_wo_slab(self): position_src = self.start_media - 1 position_obs = self.Nx - 3 end_mur = self.Nx - 1 wo_grid = f.Grid(self.Nx, dx=self.dx) wo_grid[position_src] = f.ActivatedSinus(name='SinsquaredActivated', wavelength=self.lamb, carrier_wavelength=10000.e-09, phase_shift=0, amplitude=self.ampl, tfsf=True) wo_grid[position_obs] = f.QuasiHarmonicObserver(name='firstobserver', first_timestep=self.timesteps-200) wo_grid[0] = f.LeftSideMur() wo_grid[end_mur] = f.RightSideMur() wo_grid.run_timesteps(self.timesteps, vis=False) self.wo_phase.append(wo_grid.local_observers[0].phase)
def _grids_w_slab(self): position_src = self.start_media - 1 for grid in range(len(self.dx)): position_obs = self.Nx[grid] - 3 end_mur = self.Nx[grid] - 1 for ind_media, ind_array in zip(self.indices[grid], range(self.length_media[grid])): # Step 1: init grid w_grid = 'slab' + str(ind_media) w_grid = f.Grid(nx=self.Nx[grid], dx=self.dx[grid], courant=self.courant) # Step 2: init media w_grid[self.start_media:ind_media] = f.LorentzMedium(name='media', permeability=1, eps_inf=self.eps_inf, conductivity=self.conductivity, gamma=self.gamma, chi_1=self.chi_1, chi_2=self.chi_2, chi_3=self.chi_3, w0=self.w0) # Step 3: init source if w_grid.courant == 1: w_grid[position_src] = f.ActivatedSinus(name='SinsquaredActivated', wavelength=self.lamb, carrier_wavelength=(self.lamb * 30), phase_shift=0, amplitude=self.ampl, tfsf=True) else: w_grid[position_src] = f.ActivatedSinus(name='SinsquaredActivated', wavelength=self.lamb, carrier_wavelength=(self.lamb * 30), phase_shift=0, amplitude=self.ampl, tfsf=False) # Step 4: add observer w_grid[position_obs] = f.QuasiHarmonicObserver(name='firstobserver', first_timestep=self.timesteps[grid]-200) # Step 5: add boundaries if w_grid.courant == 0.5: w_grid[0] = f.LeftSideGridBoundary() w_grid[end_mur] = f.RightSideGridBoundary() else: w_grid[0] = f.LeftSideMur() w_grid[end_mur] = f.RightSideMur() # Step 6: run simulation w_grid.run_timesteps(timesteps=self.timesteps[grid], vis=False) # Step 7: misc self.exp_amplitude_merged[grid][ind_array] = w_grid.local_observers[0].amplitude self.exp_phase_merged[grid][ind_array] = w_grid.local_observers[0].phase self.theo_amplitude_merged[grid][ind_array] = theory_dielectric_slab_complex(w_grid)[0] self.theo_phasenunterschied_merged[grid][ind_array] = theory_dielectric_slab_complex(w_grid)[1] # if list self.eps_real is empty: if self.eps_real is None: self.eps_real = w_grid.materials[0].epsilon_real(w_grid.sources[0].omega) self.eps_imag = w_grid.materials[0].epsilon_imag(w_grid.sources[0].omega) self.eps_complex = w_grid.materials[0].epsilon_complex(w_grid.sources[0].omega) self.n_real = np.sqrt((np.abs(self.eps_complex) + self.eps_real)/2)
def _construct_non_vary_grid(self): end_mur = self.Nx - 1 grid_non_vary = f.Grid(dx=self.dx, nx=self.Nx) grid_non_vary[0] = f.LeftSideMur() grid_non_vary[end_mur] = f.RightSideMur() grid_non_vary[self.position_src] = f.ActivatedSinus(name='Laser', wavelength=self.lamb, carrier_wavelength=6000e-09, tfsf=True, amplitude=self.ampl, phase_shift=0) grid_non_vary[self.position_obs] = f.QuasiHarmonicObserver(name='Observer', first_timestep=self.timesteps - 200) for layer_pair in self.layer_number: ti_start = self.starting_locations_ti[layer_pair] si_start = self.starting_locations_si[layer_pair] grid_non_vary[ti_start:si_start] = f.NonDispersiveMedia('TiO2', permittivity=self.ti_n**2, permeability=1, conductivity=0) grid_non_vary[si_start:(si_start+self.d_si)] = f.NonDispersiveMedia('SiO2', permittivity=self.si_n**2, permeability=1, conductivity=0) grid_non_vary.run_timesteps(self.timesteps) self.refl_ampl.append(grid_non_vary.local_observers[0].amplitude)
def _construct_vary_grid(self): for layer in self.layer_number: Nx = (layer + 1) * (self.d_si + self.d_ti) + 12 end_mur = Nx - 1 grid_vary = f.Grid(dx=self.dx, nx=Nx) grid_vary[end_mur] = f.RightSideMur() grid_vary[0] = f.LeftSideMur() grid_vary[self.position_obs] = f.QuasiHarmonicObserver(name='Observer', first_timestep=self.timesteps - 300) grid_vary[self.position_src] = f.ActivatedSinus(name='Laser', wavelength=self.lamb, carrier_wavelength=6000e-09, tfsf=True, amplitude=self.ampl, phase_shift=0) for layers in range(0, layer + 1): ti_start = self.starting_locations_ti[layers] si_start = self.starting_locations_si[layers] grid_vary[ti_start:si_start] = f.NonDispersiveMedia('TiO2', permittivity=self.ti_n**2, permeability=1, conductivity=0) grid_vary[si_start:(si_start + self.d_si)] = f.NonDispersiveMedia('SiO2', permittivity=self.si_n**2, permeability=1, conductivity=0) grid_vary.run_timesteps(self.timesteps, vis=False) self.refl_ampl.append(grid_vary.local_observers[0].amplitude) self.theory_R.append(((self.si_n**(2*(layer+1))-self.ti_n**(2*(layer+1)))/(self.si_n**(2*(layer+1))+self.ti_n**(2*(layer+1))))**2)