# transform=translate(0, 1, 0) * rotate(0, 90, 0), # material=UniformSurfaceEmitter(d65_white, 2)) # back_light = Sphere(0.1, # parent=enclosure, # transform=translate(0.80, -0.85, 0.80)*rotate(0, 0, 0), # material=UniformSurfaceEmitter(light_spectrum, 10.0)) # objects in enclosure box = Box(Point3D(-0.4, 0, -0.4), Point3D(0.3, 1.4, 0.3), parent=world, transform=translate(0.4, -1 + 1e-6, 0.4)*rotate(30, 0, 0), material=schott("N-BK7")) sphere = Sphere(0.4, parent=world, transform=translate(-0.4, -0.6 + 1e-6, -0.4)*rotate(0, 0, 0), material=schott("N-BK7")) filter_red = InterpolatedSF([100, 650, 660, 670, 680, 800], [0, 0, 1, 1, 0, 0]) filter_green = InterpolatedSF([100, 530, 540, 550, 560, 800], [0, 0, 1, 1, 0, 0]) filter_blue = InterpolatedSF([100, 480, 490, 500, 510, 800], [0, 0, 1, 1, 0, 0]) # create and setup the camera power_unfiltered = PowerPipeline2D(display_unsaturated_fraction=0.96, name="Unfiltered") power_unfiltered.display_update_time = 15 power_green = PowerPipeline2D(filter=filter_green, display_unsaturated_fraction=0.96, name="Green Filter") power_green.display_update_time = 15 power_red = PowerPipeline2D(filter=filter_red, display_unsaturated_fraction=0.96, name="Red Filter")
triangle_data = {'PowerDensity': power_density, 'PowerDensityError': error} export_vtk(mesh, basename + '.vtk', triangle_data=triangle_data) samples = 1000000 sphere_radius = 0.01 min_wl = 400 max_wl = 401 # set-up scenegraph world = World() emitter = Sphere(radius=sphere_radius, parent=world, transform=rotate_x(-90) * translate(-0.05409, -0.01264, 0.10064)) base_path = os.path.split(os.path.realpath(__file__))[0] mesh = import_obj(os.path.join(base_path, "../resources/stanford_bunny.obj"), material=AbsorbingSurface(), parent=world, flip_normals=True) power = PowerPipeline0D(accumulate=False) observer = MeshPixel(mesh, pipelines=[power], parent=world, min_wavelength=min_wl, max_wavelength=max_wl, spectral_bins=1,
transmission=InterpolatedSF([300, 490, 510, 590, 610, 800], array([0.0, 0.0, 1.0, 1.0, 0.0, 0.0]) * 0.7)) blue_glass = Dielectric( index=Sellmeier(1.03961212, 0.231792344, 1.01046945, 6.00069867e-3, 2.00179144e-2, 1.03560653e2), transmission=InterpolatedSF([300, 490, 510, 590, 610, 800], array([1.0, 1.0, 0.0, 0.0, 0.0, 0.0]) * 0.7)) world = World() cyl_x = Cylinder(1, 4.2, transform=rotate(90, 0, 0) * translate(0, 0, -2.1)) cyl_y = Cylinder(1, 4.2, transform=rotate(0, 90, 0) * translate(0, 0, -2.1)) cyl_z = Cylinder(1, 4.2, transform=rotate(0, 0, 0) * translate(0, 0, -2.1)) cube = Box(Point3D(-1.5, -1.5, -1.5), Point3D(1.5, 1.5, 1.5)) sphere = Sphere(2.0) Intersect(sphere, Subtract(cube, Union(Union(cyl_x, cyl_y), cyl_z)), world, translate(-2.1, 2.1, 2.5) * rotate(30, -20, 0), schott("N-LAK9")) Intersect(sphere, Subtract(cube, Union(Union(cyl_x, cyl_y), cyl_z)), world, translate(2.1, 2.1, 2.5) * rotate(-30, -20, 0), schott("SF6")) Intersect(sphere, Subtract(cube, Union(Union(cyl_x, cyl_y), cyl_z)), world, translate(2.1, -2.1, 2.5) * rotate(-30, 20, 0), schott("LF5G19")) Intersect(sphere, Subtract(cube, Union(Union(cyl_x, cyl_y), cyl_z)), world, translate(-2.1, -2.1, 2.5) * rotate(30, 20, 0), schott("N-BK7")) s1 = Sphere(1.0, transform=translate(0, 0, 1.0 - 0.01)) s2 = Sphere(0.5, transform=translate(0, 0, -0.5 + 0.01)) Intersect(s1, s2, world, translate(0, 0, -3.6) * rotate(50, 50, 0), schott("N-BK7"))
triangle_data = {'PowerDensity': power_density, 'PowerDensityError': error} export_vtk(mesh, basename + '.vtk', triangle_data=triangle_data) samples = 1000000 sphere_radius = 0.01 min_wl = 400 max_wl = 401 # set-up scenegraph world = World() emitter = Sphere(radius=sphere_radius, parent=world, transform=rotate_x(-90)*translate(-0.05409, -0.01264, 0.10064)) base_path = os.path.split(os.path.realpath(__file__))[0] mesh = import_obj(os.path.join(base_path, "../resources/stanford_bunny.obj"), material=AbsorbingSurface(), parent=world, flip_normals=True) power = PowerPipeline0D(accumulate=False) observer = MeshPixel(mesh, pipelines=[power], parent=world, min_wavelength=min_wl, max_wavelength=max_wl, spectral_bins=1, pixel_samples=samples, surface_offset=1E-6) print("Starting observations with volume emitter...") calculated_volume_emission = 16 / 3 * pi**2 * sphere_radius**3 * (max_wl - min_wl)
def add_isttok(self, pixel_samples=1000000): nickel_roughness = 0.23 min_wl = 50 max_wl = 51 # add vessel and cameras self.vessel = import_stl( "../isttok_3d/vessel5_stl.stl", scaling=1, mode='binary', parent=self.world, material=RoughNickel(nickel_roughness), #AbsorbingSurface(), transform=translate(0, 0, 0) * rotate(0, 0, 0)) self.camera_top = import_stl( "../isttok_3d/camera_top3_stl.stl", scaling=1, mode='binary', parent=self.world, material=AbsorbingSurface(), transform=translate( self.x_shift_top, self.y_shift_top + self.tube_height + self.lid_top, self.vessel_width / 2.0) * rotate(0, -90, 0)) # self.camera_outer = import_stl("../isttok_3d/camera_outer3_stl.stl", scaling=1, mode='binary', parent=self.world, # material=AbsorbingSurface(), # transform=translate(self.x_shift_outer - self.tube_height - self.lid_outer, # 0.0, # self.vessel_width / 2.0) * rotate(-90, 0, 0)) self.camera_outer = import_stl( "../isttok_3d/camera_outer4_newpin_stl.stl", scaling=1, mode='binary', parent=self.world, material=AbsorbingSurface(), transform=translate( self.x_shift_outer - self.tube_height - self.lid_outer, 0.0, self.vessel_width / 2.0) * rotate(-90, 0, 0)) pinhole_sphere_radius = 0.0005 # 0.0005 self.top_pinhole = Sphere(radius=pinhole_sphere_radius, parent=self.world, transform=translate(self.x_shift_top, self.y_shift_top, self.vessel_width / 2), material=Vacuum()) pinhole_sphere_radius = 0.00035 # 0.0005 self.out_pinhole = Sphere(radius=pinhole_sphere_radius, parent=self.world, transform=translate(self.x_shift_outer, 0.0, self.vessel_width / 2), material=Vacuum()) for i in range(16): self.top_power.append(PowerPipeline0D(accumulate=False)) self.out_power.append(PowerPipeline0D(accumulate=False)) top_px_x = self.top_px_first_x - i * 0.00095 top_px_y = self.top_px_first_y - i * 2 * (self.top_twist / 15) top_angle = degrees(asin(2 * self.top_twist / 0.01425)) out_px_y = self.out_px_first_y - i * 0.00095 out_px_x = self.out_px_first_x - i * 2 * (self.out_twist / 15) out_angle = -degrees(asin(2 * self.out_twist / 0.01425)) self.top_px.append( TargettedPixel( targets=[self.top_pinhole], targetted_path_prob=1.0, pipelines=[self.top_power[i]], x_width=0.00075, y_width=0.00405, min_wavelength=min_wl, max_wavelength=max_wl, spectral_bins=1, pixel_samples=pixel_samples, parent=self.world, quiet=True, ray_importance_sampling=True, ray_important_path_weight=0.05, ray_max_depth=50, transform=translate(top_px_x, top_px_y, self.top_px_z) * rotate(0, 0, top_angle) * rotate(0, -90, 0))) self.out_px.append( TargettedPixel( targets=[self.out_pinhole], targetted_path_prob=1.0, pipelines=[self.out_power[i]], x_width=0.00075, y_width=0.00405, min_wavelength=min_wl, max_wavelength=max_wl, spectral_bins=1, pixel_samples=pixel_samples, parent=self.world, quiet=True, ray_importance_sampling=True, ray_important_path_weight=0.05, ray_max_depth=50, transform=translate(out_px_x, out_px_y, self.out_px_z) * rotate(0, 0, out_angle) * rotate(-90, 0, 90)))
# 1. Create Primitives # -------------------- # Box defining the ground plane ground = Box(lower=Point3D(-50, -1.51, -50), upper=Point3D(50, -1.5, 50), material=Lambert()) # checker board wall that acts as emitter emitter = Box(lower=Point3D(-10, -10, 10), upper=Point3D(10, 10, 10.1), material=Checkerboard(4, d65_white, d65_white, 0.1, 2.0), transform=rotate(45, 0, 0)) # Sphere # Note that the sphere must be displaced slightly above the ground plane to prevent numerically issues that could # cause a light leak at the intersection between the sphere and the ground. sphere = Sphere(radius=1.5, transform=translate(0, 0.0001, 0), material=schott("N-BK7")) # 2. Add Observer # --------------- # Process the ray-traced spectra with the RGB pipeline. rgb = RGBPipeline2D() # camera camera = PinholeCamera((512, 512), pipelines=[rgb], transform=translate(0, 10, -10) * rotate(0, -45, 0)) # camera - pixel sampling settings camera.fov = 45 camera.pixel_samples = 250
# material=UniformSurfaceEmitter(d65_white, 2)) # alternate light #2 # back_light = Sphere(0.1, # parent=enclosure, # transform=translate(0.80, -0.85, 0.80)*rotate(0, 0, 0), # material=UniformSurfaceEmitter(light_spectrum, 10.0)) # objects in enclosure box = Box(Point3D(-0.4, 0, -0.4), Point3D(0.3, 1.4, 0.3), parent=world, transform=translate(0.4, -1 + 1e-6, 0.4)*rotate(30, 0, 0), material=schott("N-BK7")) sphere = Sphere(0.4, parent=world, transform=translate(-0.4, -0.6 + 1e-6, -0.4)*rotate(0, 0, 0), material=schott("N-BK7")) filter_red = InterpolatedSF([100, 650, 660, 670, 680, 800], [0, 0, 1, 1, 0, 0]) filter_green = InterpolatedSF([100, 530, 540, 550, 560, 800], [0, 0, 1, 1, 0, 0]) filter_blue = InterpolatedSF([100, 480, 490, 500, 510, 800], [0, 0, 1, 1, 0, 0]) # create and setup the camera power_unfiltered = PowerPipeline2D(display_unsaturated_fraction=0.96, name="Unfiltered") power_unfiltered.display_update_time = 15 power_green = PowerPipeline2D(filter=filter_green, display_unsaturated_fraction=0.96, name="Green Filter") power_green.display_update_time = 15 power_red = PowerPipeline2D(filter=filter_red, display_unsaturated_fraction=0.96, name="Red Filter")
transform=translate(0, 0, 0.015)), Cylinder(0.1998, 0.13, transform=translate(0, 0, 0.010)), transform=rotate(0, 90, 0)), parent=stand, material=Lambert(ConstantSF(1.0))) # construct main collimated light source prism_light = light_box(parent=world, transform=rotate(-35.5, 0, 0) * translate(0.10, 0, 0) * rotate(90, 0, 0)) # background light source top_light = Sphere(0.25, parent=world, transform=translate(-1, 2, 1), material=UniformSurfaceEmitter(d65_white, scale=5)) # Give the prism a high importance to ensure adequate sampling prism.material.importance = 9 rgb = RGBPipeline2D() rgb.display_sensitivity = 2.0 sampler = RGBAdaptiveSampler2D(rgb, min_samples=500) # create and setup the camera camera = PinholeCamera((1920, 1080), fov=45, parent=world, pipelines=[rgb],
from raysect.optical import World, translate, rotate from raysect.optical.observer import PinholeCamera from raysect.primitive import Sphere from raysect_vtk.primitives.to_mesh import sphere_to_mesh world = World() sphere = Sphere() sphere_mesh = sphere_to_mesh(sphere, subdivision_count=1) sphere_mesh.parent = world camera = PinholeCamera((256, 256), fov=40, parent=world, transform=translate(0, 0.16, -0.4) * rotate(0, -12, 0)) from raysect_vtk import visualise_scenegraph visualise_scenegraph(camera, focal_distance=3, zoom=0.5)
angle_increments = [-4, -3, -2, -1, 0, 1, 2, 3, 4] roughness = 0.25 colours = [ yellow, orange, red_orange, red, purple, blue, light_blue, cyan, green ] # coloured metal spheres angle = 6 radius = 0.12 distance = 3.2 for i in range(9): increment = angle_increments[i] Sphere(radius, world, transform=rotate(increment * angle, 0, 0) * translate(0, radius + 0.00001, distance), material=UniformSurfaceEmitter(colours[i])) # diffuse ground plane Box(Point3D(-100, -0.1, -100), Point3D(100, 0, 100), world, material=Lambert(ConstantSF(0.5))) rgb = RGBPipeline2D(name="sRGB") sampler = RGBAdaptiveSampler2D(rgb, ratio=10, fraction=0.2, min_samples=500, cutoff=0.05)
samples = 100000 sphere_radius = 0.5 cube_size = 2 min_wl = 400 max_wl = 401 # sanity check! if cube_size <= 2 * sphere_radius: raise ValueError("The cube dimensions must be larger that the sphere.") # set-up scenegraph world = World() emitter = Sphere(radius=sphere_radius, parent=world) base_path = os.path.split(os.path.realpath(__file__))[0] mesh = import_obj(os.path.join(base_path, "../resources/box_normals_inwards.obj"), scaling=2.0) power = PowerPipeline0D(accumulate=False) observer = MeshPixel(mesh, pipelines=[power], parent=world, min_wavelength=min_wl, max_wavelength=max_wl, spectral_bins=1, pixel_samples=samples) # Emitter is a sphere volume emitter located at the origin # Volume of the sphere is 4/3 * Pi * r^3, emission over 4 * pi # UnityVolumeEmitter emits 1W/str/m^3/ x nm, where x is the wavelength interval, integrated over length print("Starting observations with volume emitter...")
plt.ion() world = World() # Background checkerboard lightsource Box(Point3D(-10, -10, 4.0), Point3D(10, 10, 4.1), world, material=Checkerboard(1, d65_white, d65_white, 0.2, 0.8)) # Build a CSG primitive from a number of basic underlying primitives cyl_x = Cylinder(1, 4.2, transform=rotate(90, 0, 0)*translate(0, 0, -2.1)) cyl_y = Cylinder(1, 4.2, transform=rotate(0, 90, 0)*translate(0, 0, -2.1)) cyl_z = Cylinder(1, 4.2, transform=rotate(0, 0, 0)*translate(0, 0, -2.1)) cube = Box(Point3D(-1.5, -1.5, -1.5), Point3D(1.5, 1.5, 1.5)) sphere = Sphere(2.0) target = Intersect(sphere, cube, parent=world, transform=translate(0, 0, 0)*rotate(0, 0, 0), material=schott("N-BK7")) # create and setup the camera camera = PinholeCamera((256, 256), fov=45, parent=world, transform=translate(0, 0, -6) * rotate(0, 0, 0)) camera.spectral_rays = 9 camera.spectral_bins = 30 rgb = camera.pipelines[0] # for each frame rotate the CSG primitive and re-render num_frames = 25*20 full_rotation = 360 for frame in range(num_frames):
red_glass = Dielectric(index=ConstantSF(1.4), transmission=InterpolatedSF(wavelengths, red_attn)) green_glass = Dielectric(index=ConstantSF(1.4), transmission=InterpolatedSF(wavelengths, green_attn)) blue_glass = Dielectric(index=ConstantSF(1.4), transmission=InterpolatedSF(wavelengths, blue_attn)) yellow_glass = Dielectric(index=ConstantSF(1.4), transmission=InterpolatedSF(wavelengths, yellow_attn)) cyan_glass = Dielectric(index=ConstantSF(1.4), transmission=InterpolatedSF(wavelengths, cyan_attn)) purple_glass = Dielectric(index=ConstantSF(1.4), transmission=InterpolatedSF(wavelengths, purple_attn)) Sphere(1000, world, material=UniformSurfaceEmitter(d65_white, 1.0)) node = Node(parent=world, transform=rotate(0, 0, 90)) Box(Point3D(-0.5, 0, -2.5), Point3D(0.5, 0.25, 0.5), node, rotate(0, 0, 0) * translate(0, 1, -0.500001), red_glass) Box(Point3D(-0.5, 0, -2.5), Point3D(0.5, 0.25, 0.5), node, rotate(0, 0, 60) * translate(0, 1, -0.500001), yellow_glass) Box(Point3D(-0.5, 0, -2.5), Point3D(0.5, 0.25, 0.5), node, rotate(0, 0, 120) * translate(0, 1, -0.500001), green_glass) Box(Point3D(-0.5, 0, -2.5), Point3D(0.5, 0.25, 0.5), node, rotate(0, 0, 180) * translate(0, 1, -0.500001), cyan_glass) Box(Point3D(-0.5, 0, -2.5), Point3D(0.5, 0.25, 0.5), node, rotate(0, 0, 240) * translate(0, 1, -0.500001), blue_glass) Box(Point3D(-0.5, 0, -2.5), Point3D(0.5, 0.25, 0.5), node, rotate(0, 0, 300) * translate(0, 1, -0.500001), purple_glass)
from raysect.optical.observer import PinholeCamera, RGBPipeline2D from raysect.optical.material import UniformSurfaceEmitter from raysect.optical.library import * rough_max = 0.5 world = World() # glass spheres angle = 6 distance = 3 radius = 0.15 Sphere(radius, world, transform=rotate(-4 * angle, 0, 0) * translate(0, radius + 0.00001, distance), material=Aluminium()) Sphere(radius, world, transform=rotate(-3 * angle, 0, 0) * translate(0, radius + 0.00001, distance), material=RoughAluminium(0.125 * rough_max)) Sphere(radius, world, transform=rotate(-2 * angle, 0, 0) * translate(0, radius + 0.00001, distance), material=RoughAluminium(0.25 * rough_max)) Sphere(radius, world, transform=rotate(-1 * angle, 0, 0) *
fibre_radius = 0.005 fibre_half_angle = 20 # degrees min_wl = 400 max_wl = 401 # sanity checks! if fibre_distance <= sphere_radius: raise ValueError("The fibre must be outside the sphere.") cone_radius_on_axis = np.tan(np.deg2rad(fibre_half_angle)) * fibre_distance if cone_radius_on_axis <= sphere_radius + fibre_radius: raise ValueError("The fibre's acceptance angle must be large enough to see all of the sphere's radiance.") # set-up scenegraph world = World() emitter = Sphere(radius=sphere_radius, parent=world, material=UnityVolumeEmitter()) # The observer plane covers 1 side of a cube - to work out total power, multiply result by 6 fibre_power = PowerPipeline0D(accumulate=False) optical_fibre = FibreOptic([fibre_power], acceptance_angle=fibre_half_angle, radius=fibre_radius, min_wavelength=min_wl, max_wavelength=max_wl, spectral_bins=1, pixel_samples=samples, parent=world, transform=rotate(0, 0, 0)*translate(0, 0, -fibre_distance)) approximate_fraction_of_sphere = np.pi*fibre_radius**2 / (4 * np.pi * fibre_distance**2) # Emitter is a sphere volume emitter located at the origin # Volume of the sphere is 4/3 * Pi * r^3, emission over 4 * pi # UnityVolumeEmitter emits 1W/str/m^3/ x nm, where x is the wavelength interval, integrated over length
from cherab.tools.plasmas import GaussianVolume # tunables ion_density = 1e20 sigma = 0.25 # setup scenegraph world = World() # create atomic data source adas = OpenADAS(permit_extrapolation=True) # PLASMA ---------------------------------------------------------------------- plasma = Plasma(parent=world) plasma.atomic_data = adas plasma.geometry = Sphere(sigma * 5.0) plasma.geometry_transform = None plasma.integrator = NumericalIntegrator(step=sigma / 5.0) # define basic distributions d_density = GaussianVolume(0.5 * ion_density, sigma * 10000) n_density = d_density * 0.01 e_density = GaussianVolume(ion_density, sigma * 10000) temperature = 1 + GaussianVolume(79, sigma) bulk_velocity = ConstantVector3D(Vector3D(-1e6, 0, 0)) deuterium_mass = deuterium.atomic_weight * atomic_mass d_distribution = Maxwellian(d_density, temperature, bulk_velocity, deuterium_mass) nitrogen_mass = nitrogen.atomic_weight * atomic_mass n_distribution = Maxwellian(n_density, temperature, bulk_velocity,
from matplotlib.pyplot import * from numpy import array from raysect.primitive import Sphere, Box, Cylinder, Union, Intersect, Subtract from raysect.optical import World, translate, rotate, Point3D, d65_white, InterpolatedSF from raysect.optical.material.emitter import UniformSurfaceEmitter, Checkerboard from raysect.optical.material.dielectric import Dielectric, Sellmeier from raysect.optical.library import schott from raysect.optical.observer import PinholeCamera, RGBPipeline2D, SpectralPowerPipeline2D world = World() s1 = Sphere(1.0, transform=translate(0, 0, 0.25)) s2 = Sphere(1.0, transform=translate(0, 0, -0.25)) intersection = Intersect(s1, s2, transform=translate(0, 0, 0)) s3 = Sphere(1.0, transform=translate(0, 0.5, 0)) intersection = Union(intersection, s3, world, transform=translate(0.5, 0, 0)) camera = PinholeCamera((256, 256), parent=world, transform=translate(0, 0, -4) * rotate(0, 0, 0)) from raysect_vtk import visualise_scenegraph visualise_scenegraph(camera)
roughness = 0.25 colours = [ yellow, orange, red_orange, red, purple, blue, light_blue, cyan, green ] # coloured metal spheres angle = 6 radius = 0.12 distance = 3.2 for i in range(9): increment = angle_increments[i] Sphere(radius, world, transform=rotate(increment * angle, 0, 0) * translate(0, radius + 0.00001, distance), material=Lambert(colours[i])) # diffuse ground plane Box(Point3D(-100, -0.1, -100), Point3D(100, 0, 100), world, material=Lambert(ConstantSF(1 / 1000))) # four strip lights Cylinder(0.5, 1.0, world, transform=translate(0.5, 5, 8) * rotate(90, 0, 0), material=UniformSurfaceEmitter(d65_white, 1.0))
from matplotlib.pyplot import * from raysect.optical import World, translate, rotate, Point3D, d65_white, ConstantSF, Node from raysect.primitive import Sphere, Box, Cylinder, Subtract from raysect.primitive.lens.spherical import BiConvex from raysect.optical.library.metal import Gold, Silver, Copper, Titanium, Aluminium, Beryllium from raysect.optical.material import Lambert, UniformSurfaceEmitter, AbsorbingSurface, NullMaterial from raysect.optical.library import schott from raysect.optical.observer import RGBPipeline2D, BayerPipeline2D, TargettedCCDArray, CCDArray, RGBAdaptiveSampler2D from raysect.optical.colour import ciexyz_x, ciexyz_y, ciexyz_z world = World() Sphere(0.5, world, transform=translate(1.2, 0.5001, 0.6), material=Gold()) Sphere(0.5, world, transform=translate(0.6, 0.5001, -0.6), material=Silver()) Sphere(0.5, world, transform=translate(0, 0.5001, 0.6), material=Copper()) Sphere(0.5, world, transform=translate(-0.6, 0.5001, -0.6), material=Titanium()) Sphere(0.5, world, transform=translate(-1.2, 0.5001, 0.6), material=Aluminium()) Sphere(0.5, world, transform=translate(0, 0.5001, -1.8), material=Beryllium()) Box(Point3D(-100, -0.1, -100), Point3D(100, 0, 100), world, material=Lambert(ConstantSF(1.0))) Cylinder(3.0,
import numpy as np from mayavi import mlab from raysect.core import translate, Point3D from raysect.optical import World from raysect.primitive import Sphere, Mesh from raysect_mayavi.primitives import to_mesh from raysect_mayavi.primitives.triangle import triangle3d_intersects_triangle3d # OPERATION = 'UNION' # OPERATION = 'INTERSECTION' OPERATION = 'DIFFERENCE' world = World() s1 = Sphere(0.5, transform=translate(-0.25, 0, 0), name='s1') s2 = Sphere(0.5, transform=translate(0.25, 0, 0), name='s2') s1_vertices, s1_triangles = to_mesh(s1) n_s1_vertices = s1_vertices.shape[0] n_s1_triangles = s1_triangles.shape[0] s1_mesh = Mesh(vertices=s1_vertices, triangles=s1_triangles, smoothing=False) print() print('n_s1_triangles', n_s1_triangles) s2_vertices, s2_triangles = to_mesh(s2) n_s2_vertices = s2_vertices.shape[0] n_s2_triangles = s2_triangles.shape[0] s2_mesh = Mesh(vertices=s2_vertices, triangles=s2_triangles, smoothing=False) print('n_s2_triangles', n_s2_triangles)
scaling=0.01, smoothing=False, parent=world, transform=translate(0.0, 0.713001, 0.0) * rotate(-10, 0, 0), material=diamond_material) # floor Box(Point3D(-100, -0.1, -100), Point3D(100, 0, 100), world, material=RoughTitanium(0.1)) # front light Sphere(5, world, transform=translate(1, 8, -10), material=UniformVolumeEmitter(d65_white, 1.0)) # fill light Sphere(10, world, transform=translate(7, 20, 20), material=UniformSurfaceEmitter(d65_white, 0.15)) # camera rgb = RGBPipeline2D(display_update_time=15, display_unsaturated_fraction=0.995) sampler = RGBAdaptiveSampler2D(rgb, min_samples=1000, fraction=0.1, cutoff=0.01) camera = PinholeCamera((1024, 1024),
# metal spheres angle = 6 distance = 3.6 radius = 0.15 for i in range(9): temperature = temperature_scan[i] increment = angle_increments[i] material = Add(RoughIron(0.05), UniformSurfaceEmitter(BlackBody(temperature)), surface_only=True) Sphere(radius, world, transform=rotate(increment * angle, 0, 0) * translate(0, radius + 0.00001, distance), material=material) # glass spheres angle = 6 distance = 3 radius = 0.15 for i in range(9): temperature = temperature_scan[i] increment = angle_increments[i] # WARNING: This is an unphysical demo, the attenuation of the glass is not applied to the black body emission. # WARNING: The full volume emission is simply added to the light transmitted through the glass. # WARNING: In practice, only all emitting volumes or all absorbing volumes should be physically combined.
from raysect.optical import World, translate, rotate from raysect.optical.observer import PinholeCamera from raysect.primitive import Sphere world = World() sphere = Sphere(parent=world, transform=translate(2, 0, 0)) camera = PinholeCamera((256, 256), fov=40, parent=world, transform=translate(0, 0.16, -0.4) * rotate(0, -12, 0)) from raysect_vtk import visualise_scenegraph visualise_scenegraph(camera, focal_distance=3, zoom=0.5)
samples = 100000 sphere_radius = 0.5 cube_size = 2 min_wl = 400 max_wl = 401 # sanity check! if cube_size <= 2 * sphere_radius: raise ValueError("The cube dimensions must be larger that the sphere.") # set-up scenegraph world = World() emitter = Sphere(radius=sphere_radius, parent=world) # The observer plane covers 1 side of a cube - to work out total power, multiply result by 6 power = PowerPipeline0D(accumulate=False) observing_plane = Pixel([power], x_width=cube_size, y_width=cube_size, min_wavelength=min_wl, max_wavelength=max_wl, spectral_bins=1, pixel_samples=samples, parent=world, transform=rotate(0, 0, 0) * translate(0, 0, -cube_size / 2)) # Emitter is a sphere volume emitter located at the origin
min_wl = 400 max_wl = 401 # sanity check! if collection_sphere_radius <= emitting_sphere_radius: raise ValueError( "The collecting sphere radius must be larger that the emitting sphere." ) power = PowerPipeline0D(accumulate=False) # set-up scenegraph world = World() emitter = Sphere(radius=emitting_sphere_radius, parent=world, transform=translate(4, 0, 0)) observer = ObservingSphere([power], radius=collection_sphere_radius, min_wavelength=min_wl, max_wavelength=max_wl, spectral_bins=1, pixel_samples=samples, parent=world) # Emitter is a sphere volume emitter located at the origin # Volume of the sphere is 4/3 * Pi * r^3, emission over 4 * pi # UnityVolumeEmitter emits 1W/str/m^3/ x nm, where x is the wavelength interval, integrated over length print("Starting observations with volume emitter...") calculated_volume_emission = (4 * pi) * (