def place_source(self): # self.source = Cylinder(radius=self.vessel_in_rad-0.002, height=self.vessel_width, # material=self.PlasmaEmit(shape=self.plasma_shape, count=self.plasma_count, center=self.plasma_center, # width=self.plasma_width, power_gain=self.plasma_power_gain, flatlen=self.plasma_flat), # parent=self.world, transform=translate(0, 0, 0) * rotate(0, 0, 0), name='PlasmaSource') self.source = Cylinder(radius=self.vessel_in_rad - 0.0015, height=self.vessel_width, parent=self.world, transform=translate(0, 0, 0) * rotate(0, 0, 0), name='PlasmaSource') self.lid_back = Cylinder( radius=self.vessel_in_rad + 0.002, height=0.001, material=AbsorbingSurface(), parent=self.world, transform=translate(0, 0, self.vessel_width + 0.0005) * rotate(0, 0, 0)) self.lid_front = Cylinder(radius=self.vessel_in_rad + 0.002, height=0.001, material=AbsorbingSurface(), parent=self.world, transform=translate(0, 0, -0.0015) * rotate(0, 0, 0))
def place_source(self, radius, angle, legs): self.lamp_radius = radius self.lamp_angle = angle pos_x = -self.lamp_radius * cos(radians(self.lamp_angle)) pos_y = self.lamp_radius * sin(radians(self.lamp_angle)) self.source = Cylinder( radius=0.00205, height=0.15, parent=self.world, transform=translate( pos_x, pos_y, -0.0454), # scale=(1/0.007)*(699/(26*5))*1e8* (1/(1.175*1e6))) material=UniformVolumeEmitter(ConstantSF(1.0), scale=1.0), #65.372925*1e3), name="light cylinder") if legs: leg_radius = 0.07705 first_leg_angle = angle + 22.5 if radius != 0.0: for i in range(8): leg_angle = first_leg_angle + i * 45 leg_n = Cylinder(radius=0.00455, height=0.15, parent=self.world, material=AbsorbingSurface(), transform=translate( -leg_radius * cos(radians(leg_angle)), leg_radius * sin(radians(leg_angle)), -0.0454))
def get_proj_matrix(self, pixel_side=60, out_file="proj_matrix1"): geo_matrix = np.empty((32, 0)) for pixel in range(pixel_side * pixel_side): print('Progress: ' + str(round(100 * pixel / (pixel_side * pixel_side), 1)) + " %") self.world = World() self.add_isttok() self.pixel_source = Cylinder(radius=self.vessel_in_rad - 0.0015, height=self.vessel_width, parent=self.world, transform=translate(0, 0, 0) * rotate(0, 0, 0), name='PlasmaSource') one_pixel = PixelMaterial(pixel_side=pixel_side, pixel_id=pixel, print=False) self.pixel_source.material = one_pixel self.simulate_rays() column = np.hstack((self.top_data, self.out_data)).reshape((32, 1)) geo_matrix = np.hstack((geo_matrix, column)) np.save(out_file, geo_matrix)
def __init__(self, radius_outer, height, n_radius, n_height, radius_inner=0, n_polar=0, period=360., step=None, voxel_map=None, mask=None, parent=None, transform=None): grid_shape = (n_radius, n_polar, n_height) if n_polar else (n_radius, n_height) if n_polar: if not 0 < period <= 360.: raise ValueError('period must be > 0 and <= 360') dr = (radius_outer - radius_inner) / n_radius dz = height / n_height dphi = period / n_polar if n_polar else 0 grid_steps = (dr, dphi, dz) if n_polar else (dr, dz) eps_r = 1.e-5 * dr eps_z = 1.e-5 * dz step = step or 0.1 * min(dr, dz) material = CylindricalRayTransferEmitter(grid_shape, grid_steps, mask=mask, voxel_map=voxel_map, integrator=CylindricalRayTransferIntegrator(step), rmin=radius_inner, period=period) primitive = Subtract(Cylinder(radius_outer - eps_r, height - eps_z), Cylinder(radius_inner + eps_r, height - eps_z), material=material, parent=parent, transform=transform) super().__init__(primitive)
def place_single_pixel(self, pixel_id, pixel_side=60): pixel_material = PixelMaterial(pixel_side=pixel_side, pixel_id=pixel_id) self.pixel_source = Cylinder(radius=self.vessel_in_rad - 0.0015, height=self.vessel_width, parent=self.world, transform=translate(0, 0, 0) * rotate(0, 0, 0), name='PlasmaSource', material=pixel_material)
def place_lamp(self, radius, angle): self.lamp_radius = radius self.lamp_angle = angle pos_x = -self.lamp_radius * cos(radians(self.lamp_angle)) pos_y = self.lamp_radius * sin(radians(self.lamp_angle)) self.lamp_source = Cylinder(radius=0.00205, height=0.15, parent=self.world, transform=translate(pos_x, pos_y, -0.0454), material=UniformVolumeEmitter( ConstantSF(1.0), scale=1.0), name="light cylinder") self.plot_lamp_tomogram(radius=radius, angle=angle)
def test_evaluate_function_2d(self): """ Unlike test_integration_2d() in TestRayTransferCylinder here we test how CylindricalRayTransferEmitter works with NumericalIntegrator in axysimmetric case. Testing against ToroidalVoxelGrid. """ world = World() material = CylindricalRayTransferEmitter( (2, 2), (1., 1.), rmin=2., integrator=NumericalIntegrator(0.0001)) primitive = Subtract(Cylinder(3.999999, 1.999999), Cylinder(2.0, 1.999999), material=material, parent=world) ray = Ray(origin=Point3D(4., 1., 2.), direction=Vector3D(-4., -1., -2.) / np.sqrt(21.), min_wavelength=500., max_wavelength=501., bins=4) spectrum = ray.trace(world) world = World() vertices = [] for rv in [2., 3.]: for zv in [0., 1.]: vertices.append([ Point2D(rv, zv + 1.), Point2D(rv + 1., zv + 1.), Point2D(rv + 1., zv), Point2D(rv, zv) ]) tvg = ToroidalVoxelGrid(vertices, parent=world, primitive_type='csg', active='all') tvg.set_active('all') spectrum_test = ray.trace(world) self.assertTrue( np.allclose(spectrum_test.samples, spectrum.samples, atol=0.001))
def test_evaluate_function_3d(self): """ Unlike test_integration_3d() in TestRayTransferCylinder here we test how CylindricalRayTransferEmitter works with NumericalIntegrator in 3D case. """ world = World() material = CylindricalRayTransferEmitter( (2, 3, 2), (1., 30., 1.), period=90., integrator=NumericalIntegrator(0.0001)) primitive = Subtract(Cylinder(1.999999, 1.999999), Cylinder(0.000001, 1.999999), material=material, parent=world) ray = Ray(origin=Point3D(np.sqrt(2.), np.sqrt(2.), 2.), direction=Vector3D(-1., -1., -np.sqrt(2.)) / 2., min_wavelength=500., max_wavelength=501., bins=12) spectrum = ray.trace(world) spectrum_test = np.zeros(12) spectrum_test[2] = spectrum_test[9] = np.sqrt(2.) self.assertTrue( np.allclose(spectrum_test, spectrum.samples, atol=0.001))
def load_vessel_world(mesh_parts, shift_p5=False): """Load the world containing the vessel mesh parts. <mesh_parts> is a list of filenames containing mesh files in either RSM or OBJ format, which are to be loaded into the world. If shift_p5 is True, the mesh files representing the P5 coils will have a downward shift applied to them to account for the UEP sag. This is described in CD/MU/04783. Returns world, the root of the scenegraph. """ world = World() for path, _ in mesh_parts: print("importing {} ...".format(os.path.split(path)[1])) filename = os.path.split(path)[-1] name, ext = filename.split('.') if 'P5_' in path and shift_p5: p5_zshift = -0.00485 # From CD/MU/04783 transform = translate(0, 0, p5_zshift) else: transform = None if ext.lower() == 'rsm': Mesh.from_file(path, parent=world, material=AbsorbingSurface(), transform=transform, name=name) elif ext.lower() == 'obj': import_obj(path, parent=world, material=AbsorbingSurface(), name=name) else: raise ValueError("Only RSM and OBJ meshes are supported.") # Add a solid cylinder at R=0 to prevent rays finding their way through the # gaps in the centre column armour. This is only necessary for the MAST # meshes, but it does no harm to add it to MAST-U meshes too height = 6 radius = 0.1 Cylinder(radius=radius, height=height, parent=world, transform=translate(0, 0, -height / 2), material=AbsorbingSurface(), name='Blocking Cylinder') return world
def place_plasma(self, shape='gaussian', emissiv_gain=1.0, mean=None, cov=None): fourier_plasma = PlasmaProf(shape=shape, emissiv_gain=emissiv_gain, mean=mean, cov=cov) # print(type(fourier_plasma)) self.plasma_source = Cylinder(radius=self.vessel_in_rad - 0.0015, height=self.vessel_width, parent=self.world, transform=translate(0, 0, 0) * rotate(0, 0, 0), name='PlasmaSource', material=fourier_plasma)
floor = Box(Point3D(-1000, -0.1, -1000), Point3D(1000, 0, 1000), parent=world, material=Lambert()) # construct prism from utility method prism = equilateral_prism(0.06, 0.15, parent=world, material=schott("SF11"), transform=translate(0, 0.0 + 1e-6, -0.01)) # Curved target screen for collecting rainbow light stand = Intersect( Box(Point3D(-10, -10, -10), Point3D(10, 10, 0)), Subtract(Cylinder(0.21, 0.15), Cylinder(0.20, 0.16, transform=translate(0, 0, -0.005)), transform=rotate(0, 90, 0)), transform=translate(0.0, 1e-6, 0.0), parent=world, material=schott("N-BK7") # RoughIron(0.25) ) surface = Intersect(Box(Point3D(-10, -10, -10), Point3D(10, 10, -0.015)), Subtract(Cylinder(0.1999, 0.12, transform=translate(0, 0, 0.015)), Cylinder(0.1998, 0.13, transform=translate(0, 0, 0.010)), transform=rotate(0, 90, 0)),
input('pause...') world = World() Intersect(b1, b2, parent=world) visualise_scenegraph(world) input('pause...') world = World() Subtract(b1, b2, parent=world) visualise_scenegraph(world) input('pause...') ######################################################################################################################## # Cylinders c1 = Cylinder(0.5, 2) c2 = Cylinder(0.5, 2, transform=translate(0.15, 0, 0.4)) world = World() Union(c1, c2, parent=world) visualise_scenegraph(world) input('pause...') world = World() Intersect(c1, c2, parent=world) visualise_scenegraph(world) input('pause...') world = World() Subtract(c1, c2, parent=world) visualise_scenegraph(world)
""" import os import numpy as np from matplotlib import pyplot as plt from raysect.primitive import Cylinder, Subtract from raysect.optical import World, translate, rotate from raysect.optical.observer import PinholeCamera, FullFrameSampler2D from cherab.tools.raytransfer import RayTransferPipeline2D, RayTransferCylinder from cherab.tools.raytransfer import RoughNickel world = World() # creating the scene, two cylinders act like a wall here cylinder_inner = Cylinder(radius=100., height=200.) cylinder_outer = Cylinder(radius=300., height=200.) wall = Subtract(cylinder_outer, cylinder_inner, material=RoughNickel(0.1), parent=world, transform=translate(0, 0, -100.)) # creating ray transfer cylinder with 260 (m) outer radius, 140 (m) inner radius, # 160 (m) height and 60 deg peroid for cylindrical periodic emission profile defined # on a 12 x 16 x 16 (R, Phi, Z) gird rtc = RayTransferCylinder(260., 160., 12, 16, radius_inner=140., n_polar=16, period=60.) rtc.parent = world rtc.transform = translate(0, 0, -80.) # setting the integration step rtc.step = 0.2 # creating ray transfer pipeline
back_curvature, parent=world) biconcave_lens = BiConcave(diameter, center_thickness, front_curvature, back_curvature, parent=world, transform=translate(0, 0, 1)) planoconvex_lens = PlanoConvex(diameter, center_thickness, front_curvature, parent=world, transform=translate(0, 0, 2)) planoconcave_lens = PlanoConcave(diameter, center_thickness, front_curvature, parent=world, transform=translate(0, 0, 3)) meniscus_lens = Meniscus(diameter, center_thickness, front_curvature, back_curvature, parent=world, transform=translate(0, 0, 4)) cylinder_primitive = Cylinder(radius=0.5 * diameter, height=center_thickness, parent=world, transform=translate(0, 0, 5)) visualise_scenegraph(world) mlab.show()
# sample our plasma functions at the mesh vertices d0_vertex_densities = np.array( [neutral_distribution(r, peak_density) for r, z in vertex_coords]) d1_vertex_densities = np.array( [ion_distribution(r, peak_density, 0) for r, z in vertex_coords]) d1_vertex_temperatures = np.array( [ion_distribution(r, peak_temperature, 0) for r, z in vertex_coords]) ################### # plasma creation # world = World() # setup scenegraph plasma = Plasma(parent=world) plasma.atomic_data = OpenADAS(permit_extrapolation=True) plasma.geometry = Cylinder(1.5, 4, transform=translate(0, 0, -2)) plasma.geometry_transform = translate(0, 0, -2) # No net velocity for any species zero_velocity = ConstantVector3D(Vector3D(0, 0, 0)) # define neutral species distribution # create a 2D interpolator from the mesh coords and data samples d0_density_interp = Interpolator2DMesh(vertex_coords, d0_vertex_densities, triangles, limit=False) # map the 2D interpolator into a 3D function using the axisymmetry operator d0_density = AxisymmetricMapper(d0_density_interp) d0_temperature = Constant3D(0.5) # constant 0.5eV temperature for all neutrals
UniformVolumeEmitter(BlackBody(temperature), scale=10.0), volume_only=True) Sphere(radius, world, transform=rotate(increment * angle, 0, 0) * translate(0, radius + 0.00001, distance), material=material) # diffuse ground plane Box(Point3D(-100, -0.1, -100), Point3D(100, 0, 100), world, material=Lambert()) # four strip lights Cylinder(0.5, 1.0, world, transform=translate(0.5, 5, 8) * rotate(90, 0, 0), material=UniformSurfaceEmitter(d65_white, 0.5)) Cylinder(0.5, 1.0, world, transform=translate(0.5, 5, 6) * rotate(90, 0, 0), material=UniformSurfaceEmitter(d65_white, 0.5)) Cylinder(0.5, 1.0, world, transform=translate(0.5, 5, 4) * rotate(90, 0, 0), material=UniformSurfaceEmitter(d65_white, 0.5)) Cylinder(0.5, 1.0, world,
return central_radiatior + ring_radiator else: return 0 # add radiation source to world shift = translate(0, 0, -1) rad_function_3d = AxisymmetricMapper(rad_function) radiation_emitter = VolumeTransform(RadiationFunction(rad_function_3d), shift.inverse()) world = World() geom = Cylinder(CYLINDER_RADIUS, CYLINDER_HEIGHT, transform=shift, parent=world, material=radiation_emitter) ############################################ # make a toroidal wall wrapping the plasma # # number of poloidal wall elements n_poloidal = 250 d_angle = (2 * np.pi) / n_poloidal wall_polygon = np.zeros((n_poloidal, 2)) for i in range(n_poloidal): pr = PLASMA_AXIS.x + WALL_RADIUS * np.sin(d_angle * i) pz = PLASMA_AXIS.y + WALL_RADIUS * np.cos(d_angle * i) wall_polygon[i, :] = pr, pz
d1_species = Species(elements.deuterium, 1, d_distribution) c6_species = Species(carbon, 6, c6_distribution) #define plasma parameters - electron distribution, impurity composition and B field from EFIT plasma.electron_distribution = e_distribution plasma.composition = [d1_species, c6_species] plasma.b_field = VectorAxisymmetricMapper(equil_time_slice.b_field) sigma = 0.25 integration_step = 0.02 #define the plasma geometry plasma.integrator.step = integration_step plasma.integrator.min_samples = 1000 plasma.atomic_data = adas plasma.geometry = Cylinder(sigma * 2, sigma * 10.0) plasma.geometry_transform = translate(0, -sigma * 5.0, 0) * rotate(0, 90, 0) # # # ########################### NBI CONFIGURATION ############################# # #Geometry south_pos = Point3D(0.188819939, -6.88824321, 0.0) #Position of PINI grid center duct_pos = Point3D(0.539, -1.926, 0.00) #position of beam duct south_pos.vector_to(duct_pos) #beam vector beam_axis = south_pos.vector_to(duct_pos).normalise() up = Vector3D(0, 0, 1) beam_rotation = rotate_basis(beam_axis, up) beam_position = translate(south_pos.x, south_pos.y, south_pos.z)
mm(3.127), mm(86.759), mm(20.4942), parent=l2, transform=translate(0, 0, mm(-7.949)), material=schott("N-LAK9")) image_plane = Node(parent=l3, transform=translate(0, 0, mm( -41.5))) # tweaked position gives a sharper image (original: 41.10346 mm) # disable importance sampling of the lenses (enabled by default for dielectrics and emitters) l1.material.importance = 0.0 l2.material.importance = 0.0 l3.material.importance = 0.0 # cylinder body holding the lenses and CCD body = Subtract(Cylinder(mm(26), mm(80.0), transform=translate(0, 0, mm(-63))), Cylinder(mm(25), mm(79.1), transform=translate(0, 0, mm(-62))), parent=camera, transform=translate(0, 0, 0), material=AbsorbingSurface()) # L1 lens mount l1_mount = Subtract(Cylinder(mm(25.5), mm(5.0), transform=translate(0, 0, mm(0))), Cylinder(mm(21 / 2 + 0.01), mm(5.1), transform=translate(0, 0, mm(-0.05))), parent=l1, transform=translate(0, 0, mm(0)), material=AbsorbingSurface())
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() c1 = Cylinder(1.0, height=3, transform=translate(0, 0, 0), parent=world) camera = PinholeCamera((256, 256), parent=world, transform=translate(0, 0, -4) * rotate(0, 0, 0)) from raysect_vtk import visualise_scenegraph visualise_scenegraph(camera)
""" import os import numpy as np from matplotlib import pyplot as plt from raysect.primitive import Cylinder, Subtract from raysect.optical import World, translate, rotate from raysect.optical.observer import PinholeCamera, FullFrameSampler2D from cherab.tools.raytransfer import RayTransferPipeline2D, RayTransferCylinder from cherab.tools.raytransfer import RoughNickel world = World() # creating the scene cylinder_inner = Cylinder(radius=80., height=140.) cylinder_outer = Cylinder(radius=220., height=140.) wall = Subtract(cylinder_outer, cylinder_inner, material=RoughNickel(0.1), parent=world, transform=translate(0, 0, -70.)) # creating ray transfer cylinder with 200 (m) outer radius, 100 (m) inner radius, 140 (m) height # for axisymmetric cylindrical emission profile defined on a 100 x 100 (R, Z) gird rtc = RayTransferCylinder(200., 100., 100, 100, radius_inner=100.) # n_polar=0 by default (axisymmetric case) rtc.parent = world rtc.transform = translate(0, 0, -50.) # unlike the demo with a mask, here we not only cut out a circle but also # create 50 ring-shaped light sources using the voxel map rad_circle = 50. xsqr = np.linspace(-49.5, 49.5, 100) ** 2
def mask_corners(element): """ Support detectors with rounded corners, by producing a mask to cover the corners. The mask is produced by placing thin rectangles of side element.curvature_radius at each corner, and then cylinders of radius element.curvature_radius centred on the inner vertex of those rectangles. Then each corner of the mask is the part of the rectangle not covered by the cylinder. The curvature radius should be given in units of metres. """ # Make the mask very (but not infinitely) thin, so that raysect # can actually detect that it's there. We'll work in the local # coordinate system of the element, with dx=width, dy=height, # dz=depth. dz = 1e-6 rc = element.curvature_radius # Shorthand try: dx = element.x_width dy = element.y_width except AttributeError: dx = element.dx dy = element.dy # Create a box and a cylinder of the appropriate size. # Then position copies of these at each corner. box_template = Box(Point3D(0, 0, 0), Point3D(rc, rc, dz)) cylinder_template = Cylinder(rc, dz) top_left_box = box_template.instance( transform=translate(-dx / 2, dy / 2 - rc, 0), ) top_left_cylinder = cylinder_template.instance( transform=translate(-dx / 2 + rc, dy / 2 - rc, 0), ) top_left_mask = Subtract(top_left_box, Intersect(top_left_box, top_left_cylinder)) top_right_box = box_template.instance( transform=translate(dx / 2 - rc, dy / 2 - rc, 0), ) top_right_cylinder = cylinder_template.instance( transform=translate(dx / 2 - rc, dy / 2 - rc, 0), ) top_right_mask = Subtract(top_right_box, Intersect(top_right_box, top_right_cylinder)) bottom_right_box = box_template.instance( transform=translate(dx / 2 - rc, -dy / 2, 0), ) bottom_right_cylinder = cylinder_template.instance( transform=translate(dx / 2 - rc, -dy / 2 + rc, 0), ) bottom_right_mask = Subtract(bottom_right_box, Intersect(bottom_right_box, bottom_right_cylinder)) bottom_left_box = box_template.instance( transform=translate(-dx / 2, -dy / 2, 0), ) bottom_left_cylinder = cylinder_template.instance( transform=translate(-dx / 2 + rc, -dy / 2 + rc, 0), ) bottom_left_mask = Subtract(bottom_left_box, Intersect(bottom_left_box, bottom_left_cylinder)) # The foil mask is the sum of all 4 of these corner shapes mask = functools.reduce(Union, (top_left_mask, top_right_mask, bottom_right_mask, bottom_left_mask)) mask.material = AbsorbingSurface() mask.transform = translate(0, 0, dz) mask.name = element.name + ' - rounded edges mask' mask.parent = element
# Setup deuterium line d_alpha = Line(deuterium, 0, (3, 2), wavelength=656.19) # Load the deuterium atom species and electron distribution for use in rate calculations. d_atom_species = plasma.get_species(deuterium, 0) electrons = plasma.electron_distribution # Load the Excitation and Recombination lines and add them as emitters to the world. d_alpha_excit = ExcitationLine(d_alpha, plasma.electron_distribution, d_atom_species) outer_radius = plasma.misc_properties['maxr'] + 0.001 plasma_height = plasma.misc_properties['maxz'] - plasma.misc_properties['minz'] lower_z = plasma.misc_properties['minz'] main_plasma_cylinder = Cylinder(outer_radius, plasma_height, parent=world, material=d_alpha_excit, transform=translate(0, 0, lower_z)) # Load a MAST-U midplane camera camera_config = load_calcam_calibration('./demo/mast/camera_configs/mug_bulletb_midplane.nc') # Setup camera for interactive use... pixels_shape, pixel_origins, pixel_directions = camera_config camera = VectorCamera(pixel_origins, pixel_directions, pixels=pixels_shape, parent=world) camera.spectral_samples = 15 camera.pixel_samples = 1 camera.display_progress = True camera.display_update_time = 20 ion() camera.observe()
# tunables peak_density = 1e19 peak_temperature = 2500 magnetic_axis = (2.5, 0) # setup scenegraph world = World() ################### # plasma creation # plasma = Plasma(parent=world) plasma.atomic_data = OpenADAS(permit_extrapolation=True) plasma.geometry = Cylinder(3.5, 2.2, transform=translate(0, 0, -1.1)) plasma.geometry_transform = translate(0, 0, -1.1) # No net velocity for any species zero_velocity = ConstantVector3D(Vector3D(0, 0, 0)) # define neutral species distribution d0_density = NeutralFunction(peak_density, 0.1, magnetic_axis) d0_temperature = Constant3D(0.5) # constant 0.5eV temperature for all neutrals d0_distribution = Maxwellian(d0_density, d0_temperature, zero_velocity, deuterium.atomic_weight * atomic_mass) d0_species = Species(deuterium, 0, d0_distribution) # define deuterium ion species distribution d1_density = IonFunction(peak_density, 0, magnetic_axis) d1_temperature = IonFunction(peak_temperature, 0, magnetic_axis)
def create_plasma(self, parent=None, transform=None, name=None): """ Make a CHERAB plasma object from this SOLEGE2D simulation. :param Node parent: The plasma's parent node in the scenegraph, e.g. a World object. :param AffineMatrix3D transform: Affine matrix describing the location and orientation of the plasma in the world. :param str name: User friendly name for this plasma (default = "SOLEDGE2D Plasma"). :rtype: Plasma """ mesh = self.mesh name = name or "SOLEDGE2D Plasma" plasma = Plasma(parent=parent, transform=transform, name=name) radius = mesh.mesh_extent['maxr'] height = mesh.mesh_extent['maxz'] - mesh.mesh_extent['minz'] plasma.geometry = Cylinder(radius, height) plasma.geometry_transform = translate(0, 0, mesh.mesh_extent['minz']) tri_index_lookup = self.mesh.triangle_index_lookup tri_to_grid = self.mesh.triangle_to_grid_map if isinstance(self._b_field_vectors, np.ndarray): plasma.b_field = SOLEDGE2DVectorFunction3D( tri_index_lookup, tri_to_grid, self._b_field_vectors_cartesian) else: print( 'Warning! No magnetic field data available for this simulation.' ) # Create electron species triangle_data = _map_data_onto_triangles(self._electron_temperature) electron_te_interp = Discrete2DMesh(mesh.vertex_coords, mesh.triangles, triangle_data, limit=False) electron_temp = AxisymmetricMapper(electron_te_interp) triangle_data = _map_data_onto_triangles(self._electron_density) electron_ne_interp = Discrete2DMesh.instance(electron_te_interp, triangle_data) electron_dens = AxisymmetricMapper(electron_ne_interp) electron_velocity = lambda x, y, z: Vector3D(0, 0, 0) plasma.electron_distribution = Maxwellian(electron_dens, electron_temp, electron_velocity, electron_mass) if not isinstance(self.velocities_cartesian, np.ndarray): print( 'Warning! No velocity field data available for this simulation.' ) b2_neutral_i = 0 # counter for B2 neutrals for k, sp in enumerate(self.species_list): # Identify the species based on its symbol symbol, charge = re.match(_SPECIES_REGEX, sp).groups() charge = int(charge) species_type = _species_symbol_map[symbol] # If neutral and B" atomic density available, use B2 density, otherwise use fluid species density. if isinstance(self.b2_neutral_densities, np.ndarray) and charge == 0: species_dens_data = self.b2_neutral_densities[:, :, b2_neutral_i] b2_neutral_i += 1 else: species_dens_data = self.species_density[:, :, k] triangle_data = _map_data_onto_triangles(species_dens_data) dens = AxisymmetricMapper( Discrete2DMesh.instance(electron_te_interp, triangle_data)) # dens = SOLPSFunction3D(tri_index_lookup, tri_to_grid, species_dens_data) # Create the velocity vector lookup function if isinstance(self.velocities_cartesian, np.ndarray): velocity = SOLEDGE2DVectorFunction3D( tri_index_lookup, tri_to_grid, self.velocities_cartesian[:, :, k, :]) else: velocity = lambda x, y, z: Vector3D(0, 0, 0) distribution = Maxwellian(dens, electron_temp, velocity, species_type.atomic_weight * atomic_mass) plasma.composition.add(Species(species_type, charge, distribution)) return plasma
# construct diffuse floor surface floor = Box(Point3D(-1000, -0.1, -1000), Point3D(1000, 0, 1000), parent=world, material=Lambert()) # construct prism from utility method prism = equilateral_prism(0.06, 0.15, parent=world, material=schott("SF11"), transform=translate(0, 0.0 + 1e-6, 0)) # Curved target screen for collecting rainbow light screen = Intersect( Box(Point3D(-10, -10, -10), Point3D(10, 10, 0)), Subtract(Cylinder(0.22, 0.15), Cylinder(0.20, 0.16, transform=translate(0, 0, -0.005)), transform=rotate(0, 90, 0)), parent=world, material=Lambert() ) # 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.5, parent=world, transform=translate(0, 2, -1), material=UniformSurfaceEmitter(d65_white, scale=2))
import numpy as np import matplotlib.pyplot as plt from raysect.core import Point3D, Vector3D, rotate_basis, translate, Ray as CoreRay from raysect.core.math.sampler import DiskSampler3D, RectangleSampler3D, TargettedHemisphereSampler from raysect.optical import World from raysect.primitive import Box, Cylinder, Subtract from raysect.optical.material import AbsorbingSurface, NullMaterial R_2_PI = 1 / (2 * np.pi) world = World() # Setup pinhole target_plane = Box(Point3D(-10, -10, -0.000001), Point3D(10, 10, 0.000001)) hole = Cylinder(0.001, 0.001, transform=translate(0, 0, -0.0005)) pinhole = Subtract(target_plane, hole, parent=world, material=AbsorbingSurface()) target = Cylinder(0.0012, 0.001, transform=translate(0, 0, -0.0011), parent=world, material=NullMaterial()) def analytic_etendue(area_det, area_slit, distance, alpha, gamma): return area_det * area_slit * np.cos(alpha / 360 * (2 * np.pi)) * np.cos(
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, 8.0, world, transform=translate(4, 8, 0) * rotate(90, 0, 0), material=UniformSurfaceEmitter(d65_white, 1.0)) camera = Node(parent=world, transform=translate(0, 4, -3.5) * rotate(0, -48, 180)) # b = BiConvex(0.0508, 0.0036, 1.0295, 1.0295, parent=camera, transform=translate(0, 0, 0.1), material=schott("N-BK7")) # b = BiConvex(0.0508, 0.0062, 0.205, 0.205, parent=camera, transform=translate(0, 0, 0.05), material=schott("N-BK7")) lens = BiConvex(0.0508, 0.0144, 0.0593, 0.0593, parent=camera, transform=translate(0, 0, 0.0536), material=schott("N-BK7"))
green_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([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))
from raysect.optical import World, translate, rotate from raysect.optical.observer import PinholeCamera from raysect.primitive import Cylinder world = World() cylinder = Cylinder(parent=world, transform=translate(1.5, 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)