def get_fragment_stats(self, block_size, cell_size, dims, box_center=mp.Vector3(), dft_vecs=None, def_mat=mp.air, sym=[]): mat = mp.Medium( epsilon=12, epsilon_offdiag=mp.Vector3(z=1), mu_offdiag=mp.Vector3(x=20), E_chi2_diag=mp.Vector3(1, 1), H_chi3_diag=mp.Vector3(z=1), E_susceptibilities=[mp.LorentzianSusceptibility(), mp.NoisyLorentzianSusceptibility()], H_susceptibilities=[mp.DrudeSusceptibility()], D_conductivity_diag=mp.Vector3(y=1), B_conductivity_diag=mp.Vector3(x=1, z=1) ) geom = [mp.Block(size=block_size, center=box_center, material=mat)] sim = mp.Simulation(cell_size=cell_size, resolution=10, geometry=geom, dimensions=dims, default_material=def_mat, symmetries=sym) if dft_vecs: if dft_vecs['flux_regions']: sim.add_flux(1, 0.5, 5, *dft_vecs['flux_regions']) if dft_vecs['n2f_regions']: sim.add_near2far(1, 0.5, 7, *dft_vecs['n2f_regions']) if dft_vecs['force_regions']: sim.add_force(1, 0.5, 9, *dft_vecs['force_regions']) if dft_vecs['fields_components']: sim.add_dft_fields(dft_vecs['fields_components'], 0, 1, 5, where=dft_vecs['fields_where'], center=dft_vecs['fields_center'], size=dft_vecs['fields_size']) gv = sim._create_grid_volume(False) stats = sim._compute_fragment_stats(gv) return stats
def test_no_geometry(self): mat = mp.Medium(epsilon=12, epsilon_offdiag=mp.Vector3(x=1), mu_offdiag=mp.Vector3(x=20), E_chi2_diag=mp.Vector3(1, 1), H_chi3_diag=mp.Vector3(x=1), E_susceptibilities=[ mp.LorentzianSusceptibility(), mp.NoisyLorentzianSusceptibility() ], H_susceptibilities=[mp.DrudeSusceptibility()], D_conductivity_diag=mp.Vector3(y=1), B_conductivity_diag=mp.Vector3(x=1, z=1)) fs = self.get_fragment_stats(mp.Vector3(), mp.Vector3(10, 10), 2, def_mat=mat, geom=[]) self.assertEqual(len(fs), 1) self.check_stats(fs[0], a_eps=10000, a_mu=10000, nonlin=30000, susc=30000, cond=30000)