def test_reflective_transparent_material(self): """Test shade_hit with a reflective, transparent material""" world = copy.deepcopy(self.default_scene) floor = shapes.Plane(material=materials.Material( reflective=0.5, transparency=0.5, refractive_index=1.5)) floor.set_transform(transforms.Translate(0, -1, 0)) ball = shapes.Sphere(material=materials.Material( color=colors.Color(1, 0, 0), ambient=0.5)) ball.set_transform(transforms.Translate(0, -3.5, -0.5)) r = rays.Ray(points.Point(0, 0, -3), vectors.Vector(0, -math.sqrt(2) / 2, math.sqrt(2) / 2)) xs = intersections.Intersections( intersections.Intersection(floor, math.sqrt(2))) world.add_object(floor) world.add_object(ball) comps = xs.intersections[0].precompute(r, all_intersections=xs) color, _ = world.shade_hit(comps, remaining=5) self.assertEqual(color, colors.Color(0.93391, 0.69643, 0.69243))
def test_refractive_index_intersections(self): """Test we can calculate the refractive indices between intersections""" # Set up a scene with three glass spheres. One at the origin with size # 2 then inside of that 2 that are offset along z by different amounts A = shapes.Sphere(material=materials.Material(refractive_index=1.5, transparency=1.0)) B = shapes.Sphere(material=materials.Material(refractive_index=2.0, transparency=1.0)) C = shapes.Sphere(material=materials.Material(refractive_index=2.5, transparency=1.0)) A.set_transform(transforms.Scale(2, 2, 2)) B.set_transform(transforms.Translate(0, 0, -0.25)) C.set_transform(transforms.Translate(0, 0, 0.25)) r = rays.Ray(points.Point(0, 0, -4), vectors.Vector(0, 0, 1)) xs = intersections.Intersections(intersections.Intersection(A, 2), intersections.Intersection(B, 2.75), intersections.Intersection(C, 3.25), intersections.Intersection(B, 4.75), intersections.Intersection(C, 5.25), intersections.Intersection(A, 6)) expected_results = [ { "n1": 1.0, "n2": 1.5 }, { "n1": 1.5, "n2": 2.0 }, { "n1": 2.0, "n2": 2.5 }, { "n1": 2.5, "n2": 2.5 }, { "n1": 2.5, "n2": 1.5 }, { "n1": 1.5, "n2": 1.0 }, ] for index, expected in enumerate(expected_results): comps = xs.intersections[index].precompute(r, all_intersections=xs) self.assertDictEqual(expected, {"n1": comps.n1, "n2": comps.n2})
def test_default_material(self): """Test we can initialize a material and set its properties""" mat1 = materials.Material() self.assertEqual(mat1.ambient, 0.1) self.assertEqual(mat1.shininess, 200) self.assertEqual(mat1.reflective, 0) self.assertEqual(mat1.refractive_index, 1.0) mat2 = materials.Material(ambient=0.2) self.assertEqual(mat2.ambient, 0.2) self.assertEqual(mat2.shininess, 200)
def add_material_izotropowy(self): global fdtd_materials material_name = str(QtGui.QInputDialog.getText(None, "Get text", "material = ")[0]) material_ρ = float(QtGui.QInputDialog.getText(None, "Get text", "ρ[kg/m3] = ")[0]) material_E = float(QtGui.QInputDialog.getText(None, "Get text", "Young E[GPa] = ")[0]) material_ν = float(QtGui.QInputDialog.getText(None, "Get text", "Poisson number (ν) = ")[0]) new_material = materials.Material( name = material_name, E = material_E*1e9, # GPa, Wiki mean ν = material_ν, # Wiki for copper ρ = material_ρ, # density, kg/m3 ) c11 = new_material.Obl_isotropowe_C11()/1.e9 c22 = new_material.Obl_isotropowe_C22()/1.e9 c12 = new_material.Obl_isotropowe_C12()/1.e9 c66 = new_material.Obl_isotropowe_C66()/1.e9 n = self.table.rowCount() self.table.setRowCount(n+1) self.table.setItem(n, 0, QtGui.QTableWidgetItem( new_material.name )) self.table.setItem(n, 1, QtGui.QTableWidgetItem( "%.1f" % new_material.ρ )) self.table.setItem(n, 2, QtGui.QTableWidgetItem( "%.1f" % c11 )) self.table.setItem(n, 3, QtGui.QTableWidgetItem( "%.1f" % c12 )) self.table.setItem(n, 4, QtGui.QTableWidgetItem( "%.1f" % c22 )) self.table.setItem(n, 5, QtGui.QTableWidgetItem( "%.1f" % c66 )) fdtd_materials[new_material.name] = [new_material.ρ, c11, c12, c22, c66]
def simulate_stack(light): ################ Evaluate each layer individually ############## sim_cover = cover.calc_modes(light) sim_NWs = NWs.calc_modes(light) # Loop over substrates stack_list = [] for s in sub_ns: sub = objects.ThinFilm(period=period, height_nm='semi_inf', material=materials.Material(s + 0.0j), loss=False) sim_sub = sub.calc_modes(light) # Loop over heights to wash out sharp FP resonances average_t = 0 average_r = 0 average_a = 0 num_h = 21 for h in np.linspace(2180, 2480, num_h): stackSub = Stack((sim_sub, sim_NWs, sim_cover), heights_nm=([h])) stackSub.calc_scat(pol='TE') average_t += stackSub.t_list[-1] / num_h average_r += stackSub.r_list[-1] / num_h average_a += stackSub.a_list[-1] / num_h stackSub.t_list[-1] = average_t stackSub.r_list[-1] = average_r stackSub.a_list[-1] = average_a stack_list.append(stackSub) return stack_list
def test_render_scene(self): """Test we can render a pixel in a simple scene""" # Inner sphere size 0.5, centered on the origin s1 = shapes.Sphere() s1.set_transform(transforms.Scale(0.5,0.5,0.5)) # Outer sphere centered on the origin, size 1.0 s2 = shapes.Sphere() s2.material = materials.Material( color=colors.Color(0.8, 1.0, 0.6), diffuse=0.7, specular=0.2) l1 = lights.Light( position=points.Point(-10, 10, -10), intensity=colors.Color(1, 1, 1) ) scene = scenes.Scene( objects = [s1, s2], lights = [l1] ) cam = cameras.Camera(11, 11, math.pi/2) from_point = points.Point(0, 0, -5) to_point = points.Point(0, 0, 0) up = vectors.Vector(0, 1, 0) cam.transform = transforms.ViewTransform(from_point, to_point, up) image = cam.render(scene) self.assertEqual(image.get(5, 5), colors.Color(0.3807, 0.4758, 0.2855))
def test_reflection__reflective(self): """Test the reflection color of a reflective material is not black""" p = shapes.Plane(material=materials.Material(reflective=0.5)) p.set_transform(transforms.Translate(0, -1, 0)) world = copy.deepcopy(self.default_scene) world.objects.append(p) r = rays.Ray(points.Point(0, 0, -3), vectors.Vector(0, -math.sqrt(2) / 2, math.sqrt(2) / 2)) i = intersections.Intersection(p, math.sqrt(2)) comps = i.precompute(r) # Test reflected color alone result, _ = world.reflected_color(comps) self.assertEqual(result, colors.Color(0.19032, 0.2379, 0.14274)) # Now test the reflected color is added to the surface color result, _ = world.shade_hit(comps) self.assertEqual(result, colors.Color(0.87677, 0.92436, 0.82918))
def test_shadows__full_scene(self): """Test that we identify a shadow in a full scene""" # First sphere is at z=10 s1 = shapes.Sphere() s1.set_transform(transforms.Translate(0, 0, 10)) # Second sphere is at the origin s2 = shapes.Sphere() s2.material = materials.Material() # Light is at z=-10 l1 = lights.Light(position=points.Point(0, 0, -10), intensity=colors.Color(1, 1, 1)) scene = scenes.Scene(objects=[s1, s2], lights=[l1]) # The ray is at z=5 (i.e. between the spheres), pointing at the further # out sphere ray = rays.Ray(points.Point(0, 0, 5), vectors.Vector(0, 0, 1)) isection = intersections.Intersection(s2, 4) comps = isection.precompute(ray) result, _ = scene.shade_hit(comps) self.assertEqual(result, colors.Color(0.1, 0.1, 0.1))
def test_pattern(self): """Test that the pattern of a material can change its color""" m = materials.Material(pattern=patterns.StripePattern( colors.Color( 0, 0, 0, ), colors.Color(1, 1, 1)), ambient=1, diffuse=0, specular=0) eyev = vectors.Vector(0, 0, -1) normalv = vectors.Vector(0, 0, -1) light = lights.PointLight(points.Point(0, 0, -10), colors.Color(1, 1, 1)) color_1 = m.lighting(light, points.Point(0.9, 0, 0), eyev, normalv, in_shadow=False) color_2 = m.lighting(light, points.Point(1.1, 0, 0), eyev, normalv, in_shadow=False) self.assertEqual(color_1, colors.Color(0, 0, 0)) self.assertEqual(color_2, colors.Color(1, 1, 1))
def limt_analysis(): from openfile import InputFile from inputdata import InputData import materials import mesh import libraries infile = InputFile() infile.open_file() infile.get_number_of_line() print('') print('***************Input file data***************') indata = InputData(infile) indata.get_title() indata.get_problem() indata.get_output_file_type() mat = materials.Material() mat.get_material_type(infile) mat.get_material_parameters() el = mesh.Element() el.get_element_type(infile) el.get_number_of_element(infile) el.get_node_of_element(infile) poi = mesh.Point() poi.get_number_of_point(infile) poi.get_coordinate(infile) poi.get_prescribed_velocity(infile) poi.get_prescribed_force(infile) poi.get_applied_force(infile) print('*********************************************') print('') primal = libraries.Primal(mesh, materials) print('') print('***************Primal problem****************') primal.assemble() primal.solve() print('*********************************************') print('') dual = libraries.Dual(mesh, materials) print('') print('****************Dual problem*****************') dual.assemble() dual.solve() print('*********************************************') print('') libraries.output(infile, mesh, mat) print('Finished!') return
def __init__(self, material: Union[materials.Material, None] = None): self.id = uuid.uuid4() self.set_transform(transforms.Identity(4)) if material is None: self.set_material(materials.Material()) else: self.set_material(material)
def new(self, fname): fe.openfemm() fe.newdocument(0) fe.mi_saveas(fname) self.fname = fname #add air to problem by default air = mat.Material('Air') air.add()
def test_reflection__infinite_recursion(self): """Test that we don't break if there is infinite recursion""" # Two parallel planes s1 = shapes.Plane(material=materials.Material(reflective=1)) s1.set_transform(transforms.Translate(0, -1, 0)) # Second sphere is at the origin s2 = shapes.Plane(material=materials.Material(reflective=1)) s2.set_transform(transforms.Translate(0, 1, 0)) # Light is at z=-10 l1 = lights.Light(position=points.Point(0, 0, 0), intensity=colors.Color(1, 1, 1)) scene = scenes.Scene(objects=[s1, s2], lights=[l1]) r = rays.Ray(points.Point(0, 0, 0), vectors.Vector(0, 1, 0)) # If this is working the following will NOT cause a stack trace scene.color_at(r)
def test_lighting__shadow(self): """Test that we get the ambient color if we're in shadow""" m = materials.Material() p = points.Point(0, 0, 0) eyev = vectors.Vector(0, 0, -1) normalv = vectors.Vector(0, 0, -1) light = lights.PointLight(points.Point(0, 0, -10), colors.Color(1, 1, 1)) result = m.lighting(light, p, eyev, normalv, in_shadow=True) self.assertEqual(result, colors.Color(0.1, 0.1, 0.1))
def test_lighting(self): """Tests on the lighting function for various angles and colors""" m = materials.Material() p = points.Point(0, 0, 0) #the eye is positioned directly between the light and the surface, with #the normal pointing at the eye. Expect ambient, diffuse, and specular #to all be at full strength. This means that the total intensity should #be 0.1 (the ambient value) + 0.9 (the diffuse value) + 0.9 (the #specular value), or 1.9 eyev = vectors.Vector(0, 0, -1) normalv = vectors.Vector(0, 0, -1) light = lights.PointLight(points.Point(0, 0, -10), colors.Color(1, 1, 1)) result = m.lighting(light, p, eyev, normalv) self.assertEqual(result, colors.Color(1.9, 1.9, 1.9)) eyev = vectors.Vector(0, math.sqrt(2) / 2, -math.sqrt(2) / 2) normalv = vectors.Vector(0, 0, -1) light = lights.PointLight(points.Point(0, 0, -10), colors.Color(1, 1, 1)) result = m.lighting(light, p, eyev, normalv) self.assertEqual(result, colors.Color(1.0, 1.0, 1.0)) eyev = vectors.Vector(0, 0, -1) normalv = vectors.Vector(0, 0, -1) light = lights.PointLight(points.Point(0, 10, -10), colors.Color(1, 1, 1)) result = m.lighting(light, p, eyev, normalv) self.assertEqual(result, colors.Color(0.7364, 0.7364, 0.7364)) eyev = vectors.Vector(0, -math.sqrt(2) / 2, -math.sqrt(2) / 2) normalv = vectors.Vector(0, 0, -1) light = lights.PointLight(points.Point(0, 10, -10), colors.Color(1, 1, 1)) result = m.lighting(light, p, eyev, normalv) self.assertEqual(result, colors.Color(1.6364, 1.6364, 1.6364)) # Light behind the object, its color should be the ambient value eyev = vectors.Vector(0, 0, -1) normalv = vectors.Vector(0, 0, -1) light = lights.PointLight(points.Point(0, 0, 10), colors.Color(1, 1, 1)) result = m.lighting(light, p, eyev, normalv) self.assertEqual(result, colors.Color(0.1, 0.1, 0.1))
def setUp(self): """Set up a default scene for quick testing""" # Inner sphere size 0.5, centered on the origin self.s1 = shapes.Sphere() self.s1.set_transform(transforms.Scale(0.5, 0.5, 0.5)) # Outer sphere centered on the origin, size 1.0 self.s2 = shapes.Sphere() self.s2.material = materials.Material(color=colors.Color( 0.8, 1.0, 0.6), diffuse=0.7, specular=0.2) self.l1 = lights.Light(position=points.Point(-10, 10, -10), intensity=colors.Color(1, 1, 1)) self.default_scene = scenes.Scene(objects=[self.s1, self.s2], lights=[self.l1])
def simulate_stack(Re): ################ Evaluate each layer individually ############## sim_superstrate = superstrate.calc_modes(light) sim_substrate = substrate.calc_modes(light) # Re_stack = [] # for Re in Re_n: Im_stack = [] for Im in Im_n: TF_1 = objects.ThinFilm(period, height_nm=10, material=materials.Material(Re + Im * 1j)) sim_TF_1 = TF_1.calc_modes(light) stack = Stack((sim_substrate, sim_TF_1, sim_superstrate)) stack.calc_scat(pol='TM') Im_stack.append(stack) # Re_stack.append(Im_stack) return Im_stack
height_nm='semi_inf', world_1d=True, material=materials.Air, loss=False) spacer = objects.ThinFilm(period, height_nm=200, world_1d=True, material=materials.SiO2_a, loss=True) grating = objects.NanoStruct('1D_array', period, int(round(0.7 * period)), height_nm=400, background=materials.Material(1.45 + 0.0j), inclusion_a=materials.Material(3.77 + 0.01j), loss=True, lc_bkg=0.005, plotting_fields=True) def simulate_stack(light): ################ Evaluate each layer individually ############## sim_superstrate = superstrate.calc_modes(light) sim_substrate = substrate.calc_modes(light) sim_grating = grating.calc_modes(light) sim_spacer = spacer.calc_modes(light) ###################### Evaluate structure ######################
################ Light parameters ##################### wl_1 = 900 wl_2 = 1200 no_wl_1 = 3 # Set up light objects wavelengths = np.linspace(wl_1, wl_2, no_wl_1) light_list = [objects.Light(wl, max_order_PWs=3) for wl in wavelengths] # period must be consistent throughout simulation!!! period = 120 num_BM = 90 superstrate = objects.ThinFilm(period, height_nm='semi_inf', material=materials.Material(3.5 + 0.0j), loss=True) homo_film = objects.ThinFilm(period, height_nm=5, material=materials.Material(3.6 + 0.27j), loss=True) substrate = objects.ThinFilm(period, height_nm='semi_inf', material=materials.Air, loss=False) grating_diameter = 100 grating = objects.NanoStruct('1D_array', period,
wavelengths = np.linspace(wl_1, wl_2, no_wl_1) # and also specifying angles of incidence and refractive medium of semi-infinite # layer that the light is incident upon (default value is n_inc = 1.0). # Fields in homogeneous layers are expressed in a Fourier series of diffraction # orders,where all orders within a radius of max_order_PWs in k-space are included. light_list = [objects.Light(wl, max_order_PWs = 1, theta = 0.0, phi = 0.0, \ n_inc=1.5) for wl in wavelengths] # Our structure must have a period, even if this is artificially imposed # on a homogeneous thin film. What's more, # it is critical that the period be consistent throughout a simulation! period = 300 # Define each layer of the structure. superstrate = objects.ThinFilm(period, height_nm = 'semi_inf', material = materials.Material(1.5 + 0.0j)) substrate = objects.ThinFilm(period, height_nm = 'semi_inf', material = materials.Material(3.0 + 0.0j)) def simulate_stack(light): ################ Evaluate each layer individually ############## sim_superstrate = superstrate.calc_modes(light) sim_substrate = substrate.calc_modes(light) ###################### Evaluate structure ###################### """ Now define full structure. Here order is critical and stack list MUST be ordered from bottom to top! """ stack = Stack((sim_substrate, sim_superstrate)) # Calculate scattering matrices of the stack (for all polarisations). stack.calc_scat(pol = 'TE') # Incident light has TE polarisation,
no_wl_1 = 4 wavelengths = np.linspace(wl_1, wl_2, no_wl_1) light_list = [objects.Light(wl, max_order_PWs = 1, theta = 0.0, phi = 0.0) \ for wl in wavelengths] # The period must be consistent throughout a simulation! period = 300 # Define each layer of the structure. superstrate = objects.ThinFilm(period, height_nm='semi_inf', material=materials.Air) # Define a thin film with (finite) thickness in nm and constant refractive index TF_1 = objects.ThinFilm(period, height_nm=100, material=materials.Material(1.0 + 0.05j)) # EMUstack calculation time is independent dispersion and thickness of layer! # This layer is made of Indium Phosphide, the tabulated refractive index of which # is stored in EMUstack/data/ # We artificially set the imaginary part of the layer to zero for all wavelengths. TF_2 = objects.ThinFilm(period, height_nm=5e6, material=materials.InP, loss=False) # By default loss = True TF_3 = objects.ThinFilm(period, height_nm=52, material=materials.Si_a) # Note that the semi-inf substrate must be lossess so that EMUstack can distinguish # propagating plane waves that carry energy from evanescent waves which do not. # This layer is therefore crystalline silicon with Im(n) == 0. substrate = objects.ThinFilm(period, height_nm='semi_inf',
n = 1 L = 0.4e9 strate = objects.ThinFilm(period, height_nm='semi_inf', material=materials.Air, loss=False) NW_rads = 0.0015e9 dummy_diameter = 1 NW_diameter = NW_rads * 2 NW_array = objects.NanoStruct('2D_array', period, NW_diameter, height_nm=wl_0 / (2 * n), inclusion_a=materials.Material(0.0 + 1e6j), background=materials.Material(n), loss=True, hyperbolic=True, make_mesh_now=True, force_mesh=True, lc_bkg=0.05, lc2=4.0) def simulate_stack(lyte): wl = lyte[0] kx = lyte[1] light = objects.Light(wl, max_order_PWs=2, k_parallel=[kx, 0.000000000001]) ################ Evaluate each layer individually ############## sim_NWs = NW_array.calc_modes(light)
world_1d=True, material=materials.Air) substrate = objects.ThinFilm(period, height_nm='semi_inf', world_1d=True, material=materials.Air) # Define 1D grating that is periodic in x. # The mesh for this is always made 'live' in objects.py the number of # FEM elements used is given by 1/lc_bkg. # See Fortran Backends section of tutorial for more details. grating = objects.NanoStruct('1D_array', period, int(round(0.75 * period)), height_nm=2900, background=materials.Material(1.46 + 0.0j), inclusion_a=materials.Material(5.0 + 0.0j), loss=True, lc_bkg=0.0051) def simulate_stack(light): ################ Evaluate each layer individually ############## sim_superstrate = superstrate.calc_modes(light) sim_grating = grating.calc_modes(light) sim_substrate = substrate.calc_modes(light) ###################### Evaluate structure ###################### """ Now define full structure. Here order is critical and stack list MUST be ordered from bottom to top! """
def setup_module(module): # Remove results of previous simulations plotting.clear_previous('.log') plotting.clear_previous('.pdf') plotting.clear_previous('.txt') ################ Light parameters ##################### wavelengths = np.linspace(800, 1600, 1) light_list = [ objects.Light(wl, max_order_PWs=6, theta=0.0, phi=0.0) for wl in wavelengths ] light = light_list[0] period = 760 superstrate = objects.ThinFilm(period, height_nm='semi_inf', world_1d=True, material=materials.Air, loss=False) substrate = objects.ThinFilm(period, height_nm='semi_inf', world_1d=True, material=materials.Air, loss=False) grating_1 = objects.NanoStruct('1D_array', period, diameter1=int(round(0.25 * period)), diameter2=int(round(0.25 * period)), height_nm=150, inclusion_a=materials.Material(1.46 + 0.0j), inclusion_b=materials.Material(1.46 + 0.0j), background=materials.Material(3.61 + 0.0j), loss=True, lc_bkg=0.005) grating_2 = objects.NanoStruct('1D_array', period, int(round(0.25 * period)), height_nm=900, background=materials.Material(3.61 + 0.0j), inclusion_a=materials.Material(1.46 + 0.0j), loss=True, lc_bkg=0.005) ################ Evaluate each layer individually ############## sim_superstrate = superstrate.calc_modes(light) sim_substrate = substrate.calc_modes(light) sim_grating_1 = grating_1.calc_modes(light) sim_grating_2 = grating_2.calc_modes(light) ################ Evaluate full solar cell structure ############## """ Now when defining full structure order is critical and stack list MUST be ordered from bottom to top! """ stack = Stack( (sim_substrate, sim_grating_1, sim_grating_2, sim_superstrate)) stack.calc_scat(pol='TE') module.stack_list = [stack] plotting.t_r_a_plots(stack_list, save_txt=True)
def test_altered_material(self): """Test that a shape has the default material""" s = shapes.Sphere(material=materials.Material(shininess=100)) self.assertEqual(s.material, materials.Material(shininess=100))
objects.Light(wl, max_order_PWs=1, theta=0.0, phi=0.0) for wl in wavelengths ] ################ Scattering matrices (for distinct layers) ############## """ Calculate scattering matrices for each distinct layer. Calculated in the order listed below, however this does not influence final structure which is defined later """ # period must be consistent throughout simulation!!! period = 1 superstrate = objects.ThinFilm(period=period, height_nm='semi_inf', material=materials.Material(3.5 + 0.0j), loss=False) homo_film1 = objects.ThinFilm(period=period, height_nm=50, material=materials.Material(3.6 + 0.27j), loss=True) homo_film2 = objects.ThinFilm(period=period, height_nm=200, material=materials.Si_c, loss=True) mirror = objects.ThinFilm(period=period, height_nm=100, material=materials.Ag,
wl = 1600 light_list = [objects.Light(wl, max_order_PWs = 2, theta = p, phi = 0.0) \ for p in azi_angles] ################ Grating parameters ##################### period = 760 superstrate = objects.ThinFilm(period, height_nm = 'semi_inf', material = materials.Air, loss = False) substrate = objects.ThinFilm(period, height_nm = 'semi_inf', material = materials.Air, loss = False) grating_1 = objects.NanoStruct('1D_array', period, small_d=period/2, diameter1=int(round(0.25*period)), diameter2=int(round(0.25*period)), height_nm = 150, inclusion_a = materials.Material(3.61 + 0.0j), inclusion_b = materials.Material(3.61 + 0.0j), background = materials.Material(1.46 + 0.0j), loss = True, make_mesh_now = True, force_mesh = False, lc_bkg = 0.1, lc2= 3.0) grating_2 = objects.NanoStruct('1D_array', period, int(round(0.75*period)), height_nm = 2900, background = materials.Material(1.46 + 0.0j), inclusion_a = materials.Material(3.61 + 0.0j), loss = True, make_mesh_now = True, force_mesh = False, lc_bkg = 0.1, lc2= 3.0) num_BMs = 60 def simulate_stack(light): ################ Evaluate each layer individually ############## sim_superstrate = superstrate.calc_modes(light)
superstrate = objects.ThinFilm(period, height_nm='semi_inf', material=materials.Air, loss=False, world_1d=True) substrate = objects.ThinFilm(period, height_nm='semi_inf', material=materials.Air, loss=False, world_1d=True) absorber = objects.ThinFilm(period, height_nm=10, material=materials.Material(1.0 + 0.05j), loss=True, world_1d=True) grating_1 = objects.NanoStruct('1D_array', period, int(round(0.75 * period)), height_nm=2900, background=materials.Material(1.46 + 0.0j), inclusion_a=materials.Material(3.61 + 0.0j), loss=True, lc_bkg=0.005) def simulate_stack(light):
def test_default_material(self): """Test that a shape has the default material""" s = shapes.Sphere() self.assertEqual(s.material, materials.Material())
def setUp(self): """Utility objects to make it faster to write tests""" self.glass_sphere = shapes.Sphere(material=materials.Material( refractive_index=1.5, transparency=1.0))