lens = boundaries.ParametricMultiTriangleBoundary( zero_points, vg, [ boundaries.ThicknessConstraint(0.0, "min"), boundaries.ThicknessConstraint(0.2, "min"), ], [True, False], auto_update_mesh=True, material_list=[{ "mat_in": 1, "mat_out": 0 }] * 2, vertex_update_map=vertex_update_map) target = boundaries.ManualTriangleBoundary( mesh=pv.Plane(center=(target_distance, 0, 0), direction=(1, 0, 0), i_size=100, j_size=100, i_resolution=1, j_resolution=1).triangulate()) target.frozen = True # build the optical system system = engine.OpticalSystem3D() system.optical = lens.surfaces system.targets = [target] system.sources = [random_source] system.materials = [{"n": materials.vacuum}, {"n": materials.acrylic}] system.update() # draw the boundary plot = pv.Plotter()
# Set up the source angular_size = PI / 8 print(f"Angular Size: {np.degrees(angular_size)}") #sphere = dist.StaticUniformSphere(angular_size, 100000) #sphere = dist.RandomUniformSphere(angular_size, 100000) #sphere = dist.StaticLambertianSphere(angular_size, 100000) sphere = dist.RandomLambertianSphere(angular_size, 100000) source = sources.PointSource(3, (0, 0, 0), (1, 0, 0), sphere, [drawing.YELLOW]) source.frozen = True print(f"Minimum phi generated: {np.degrees(tf.reduce_min(sphere.ranks[:,0]))}") print(f"Maximum phi generated: {np.degrees(tf.reduce_max(sphere.ranks[:,0]))}") # Set up the target angular_step_size = 5 plane_mesh = pv.Plane((1, 0, 0), (1, 0, 0), i_size=.1, j_size=.1).triangulate() target = boundaries.ManualTriangleBoundary(mesh=plane_mesh) # set up the system system = engine.OpticalSystem3D() system.sources = [source] system.targets = [target] eng = engine.OpticalEngine(3, [], optical_system=system) def rotate_target(): target.mesh.rotate_y(angular_step_size) if True: # plot the histogram
# build the plotter plot = pv.Plotter() plot.add_axes() plot.camera_position = [(0, 0, 5), (0, 0, 0), (0, 1, 0)] points, faces = mt.circular_mesh( mesh_params["radius"], mesh_params["target_edge_size"], starting_radius=mesh_params["starting_radius"], theta_start=mesh_params["angle_start"], theta_end=mesh_params["angle_end"]) mesh = pv.PolyData(points, faces) vg = boundaries.FromVectorVG((1, 0, 0)) boundary = boundaries.ManualTriangleBoundary(mesh=mesh) drawer = drawing.TriangleDrawer(plot, draw_norm_arrows=True, norm_arrow_visibility=True, norm_arrow_length=.2) drawer.surface = boundary def update(mesh, mesh_params): mesh.points, mesh.faces = mt.circular_mesh( mesh_params["radius"], mesh_params["target_edge_size"], starting_radius=mesh_params["starting_radius"], theta_start=mesh_params["angle_start"], theta_end=mesh_params["angle_end"])
import tfrt.boundaries as boundaries import tfrt.engine as engine import tfrt.operation as operation import tfrt.materials as materials PI = tf.constant(pi, dtype=tf.float64) # set up the imaging problem source_distance = 10 target_distance = 10 # build the optical system target = boundaries.ManualTriangleBoundary( mesh=pv.Plane(center=(target_distance, 0, 0), direction=(1, 0, 0), i_size=100, j_size=100, i_resolution=1, j_resolution=1).triangulate()) target.frozen = True system = engine.OpticalSystem3D() system.targets = [target] system.materials = [{"n": materials.vacuum}, {"n": materials.acrylic}] # build the optical surfaces first_surface = boundaries.ManualTriangleBoundary( file_name="./stl/hexalens_full_first.stl", material_dict={ "mat_in": 1, "mat_out": 0
PI = tf.constant(pi, dtype=tf.float64) # build the source rays #base_points = distributions.StaticUniformSquare(1, 5) angles = distributions.StaticUniformSphere(PI / 8.0, 25) source = sources.PointSource(3, (-1, 0, 0), (1, 0, 0), angles, drawing.RAINBOW_6, dense=True) source.frozen = True # build the boundary surface1 = boundaries.ManualTriangleBoundary( file_name="./stl/short_pyramid.stl", material_dict={ "mat_in": 1, "mat_out": 0 }) surface2 = boundaries.ManualTriangleBoundary(mesh=pv.Sphere(radius=.5, center=(1, 0, 0)), material_dict={ "mat_in": 1, "mat_out": 0 }) surface3 = boundaries.ManualTriangleBoundary( mesh=pv.Plane(center=(3, 0, 0), direction=(1, 0, 0), i_size=7, j_size=7, i_resolution=1, j_resolution=1).triangulate())
def get_test_square(angle): plane = pv.Plane((5, np.sin(angle), np.cos(angle)), (0, np.sin(angle), np.cos(angle)), .1, .1, 1, 1).triangulate() return boundaries.ManualTriangleBoundary(mesh=plane)