Пример #1
0
    def load_cad(self, load_full=False):
        from raysect.primitive.mesh import Mesh
        from raysect.optical.material.absorber import AbsorbingSurface
        from raysect.optical import World
        import os
        world = World()

        if load_full:
            MESH_PARTS = MASTU_FULL_MESH + VACUUM_VESSEL + \
                         UPPER_DIVERTOR_NOSE + UPPER_DIVERTOR_ARMOUR + UPPER_DIVERTOR + \
                         LOWER_DIVERTOR_NOSE + LOWER_DIVERTOR_ARMOUR + LOWER_DIVERTOR + \
                         LOWER_ELM_COILS + LOWER_GAS_BAFFLE + \
                         UPPER_ELM_COILS + UPPER_GAS_BAFFLE + \
                         ELM_COILS + PF_COILS + \
                         T5_LOWER + T4_LOWER + T3_LOWER + T2_LOWER + T1_LOWER + \
                         T5_UPPER + T4_UPPER + T3_UPPER + T2_UPPER + T1_UPPER + \
                         C6_TILES + C5_TILES + C4_TILES + C3_TILES + C2_TILES + C1_TILE + \
                         B1_UPPER + B2_UPPER + B3_UPPER + B4_UPPER + \
                         B1_LOWER + B2_LOWER + B3_LOWER + B4_LOWER +  \
                         BEAM_DUMPS + SXD_BOLOMETERS
        else:
            MESH_PARTS = CENTRE_COLUMN + LOWER_DIVERTOR_ARMOUR

        #MESH_PARTS=VACUUM_VESSEL
        for cad_file in MESH_PARTS:
            directory, filename = os.path.split(cad_file[0])
            name, ext = filename.split('.')
            print("importing {} ...".format(filename))
            Mesh.from_file(cad_file[0],
                           parent=world,
                           material=AbsorbingSurface(),
                           name=name)
        return world
Пример #2
0
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
lens = BiConvex(0.0254,
                0.0052,
                0.0506,
                0.0506,
                parent=world,
                material=lens_glass)
lens.meta['viz-color'] = (66 / 255, 188 / 255, 244 / 255)
lens.meta['viz-opacity'] = 0.5

# lens.meta['viz']['color'] = (66/255, 188/255, 244/255)
# lens.meta['viz']['opacity'] = 0.5

# Create a target plane behind the lens.
target = Box(lower=Point3D(-0.05, -0.05, -0),
             upper=Point3D(0.05, 0.05, 0),
             material=AbsorbingSurface(),
             transform=translate(0, 0, 0.1),
             parent=world)
target.meta['viz-color'] = (224 / 255, 100 / 255, 17 / 255)

# for each sample direction trace a logging ray and plot the ray trajectory
plt.ion()
fig = plt.figure()
# ax = fig.gca(projection='3d')

# for u in np.linspace(-0.006, 0.006, 5):
for v in np.linspace(-0.012, 0.012, 11):

    start = Point3D(v, 0, -0.05)
    log_ray = LoggingRay(start, Vector3D(0, 0, 1))
    log_ray.trace(world)
Пример #4
0
from raysect.primitive import Cylinder, import_stl

# Define constants
PI = pi
AMU = 1.66053892e-27
ELEMENTARY_CHARGE = elementary_charge
SPEED_OF_LIGHT = speed_of_light

world = World()


MESH_PARTS = ['/projects/cadmesh/mast/mastu-light/mug_centrecolumn_endplates.stl',
             '/projects/cadmesh/mast/mastu-light/mug_divertor_nose_plates.stl']

for path in MESH_PARTS:
   import_stl(path, parent=world, material=AbsorbingSurface())  # Mesh with perfect absorber

# Load plasma from SOLPS model
mds_server = 'solps-mdsplus.aug.ipp.mpg.de:8001'
ref_number = 69636
sim = SOLPSSimulation.load_from_mdsplus(mds_server, ref_number)
plasma = sim.plasma
mesh = sim.mesh
vessel = mesh.vessel


class ExcitationLine(VolumeEmitterInhomogeneous):

    def __init__(self, line, electron_distribution, atom_species, step=0.005, block=0, filename=None):

        super().__init__(step=step)
Пример #5
0
from raysect.optical import World
from raysect.optical.material.absorber import AbsorbingSurface

from cherab.mastu.machine import import_mastu_mesh
from cherab.mastu.bolometry import load_default_bolometer_config


world = World()
sxd_outer = load_default_bolometer_config('SXDL - Outer', parent=world)
sxd_upper = load_default_bolometer_config('SXDL - Upper', parent=world)
core_poloidal = load_default_bolometer_config('CORE - Poloidal', parent=world)
# Don't plot tangential array on a poloidal cross section
detectors = list(sxd_outer) + list(sxd_upper) + list(core_poloidal)

import_mastu_mesh(world, override_material=AbsorbingSurface())

client = pyuda.Client()
passive_structures = client.geometry('/passive/efit', 50000)


fig, ax = plt.subplots()
for detector in detectors:
    print('Tracing detector {}'.format(detector.name))
    start, end, _ = detector.trace_sightline()
    start_r = np.hypot(start.x, start.y)
    end_r = np.hypot(end.x, end.y)
    ax.plot([start_r, end_r], [start.z, end.z], 'r')

passive_structures.plot(ax_2d=ax, color='k')
ax.axis('equal')
Пример #6
0
from cherab.core.model.lineshape import StarkBroadenedLine
from cherab.mastu.machine import *


plt.ion()
world = World()
z_vec = Vector3D(0, 0, 1)

MESH_PARTS = CENTRE_COLUMN + LOWER_DIVERTOR_ARMOUR


for cad_file in MESH_PARTS:
    directory, filename = os.path.split(cad_file)
    name, ext = filename.split('.')
    print("importing {} ...".format(filename))
    Mesh.from_file(cad_file, parent=world, material=AbsorbingSurface(), name=name)


# Load plasma from SOLPS model
mds_server = 'solps-mdsplus.aug.ipp.mpg.de:8001'
ref_number = 69636
sim = load_solps_from_mdsplus(mds_server, ref_number)
plasma = sim.create_plasma(parent=world)
plasma.atomic_data = OpenADAS(permit_extrapolation=True)
mesh = sim.mesh
vessel = mesh.vessel


# Setup deuterium lines
d_alpha = Line(deuterium, 0, (3, 2))
d_beta = Line(deuterium, 0, (4, 2))
Пример #7
0
    'vessel_s08-09.rsm', 'vessel_s10-11.rsm', 'vessel_s12-13.rsm',
    'vessel_s14-15.rsm', 'vessel_s16-01.rsm', 'divertor_s02-03.rsm',
    'divertor_s04-05.rsm', 'divertor_s06-07.rsm', 'divertor_s08-09.rsm',
    'divertor_s10-11.rsm', 'divertor_s12-13.rsm', 'divertor_s14-15.rsm',
    'divertor_s16-01.rsm', 'inner_heat_shield_s01.rsm',
    'inner_heat_shield_s02.rsm', 'inner_heat_shield_s03.rsm',
    'inner_heat_shield_s04.rsm', 'inner_heat_shield_s05.rsm',
    'inner_heat_shield_s06.rsm', 'inner_heat_shield_s07.rsm',
    'inner_heat_shield_s08.rsm', 'inner_heat_shield_s09.rsm',
    'inner_heat_shield_s10.rsm', 'inner_heat_shield_s11.rsm',
    'inner_heat_shield_s12.rsm', 'inner_heat_shield_s13.rsm',
    'inner_heat_shield_s14.rsm', 'inner_heat_shield_s15.rsm',
    'inner_heat_shield_s16.rsm'
]

machine_material = AbsorbingSurface()  # Mesh with perfect absorber

for path in MESH_PARTS:
    path = MESH_PATH + path
    print("importing {}  ...".format(os.path.split(path)[1]))
    directory, filename = os.path.split(path)
    name, ext = filename.split('.')
    Mesh.from_file(path, parent=world, material=machine_material, name=name)

# Load simulation from MDSplus
mds_server = 'solps-mdsplus.aug.ipp.mpg.de:8001'
ref_number = 40195
sim = SOLPSSimulation.load_from_mdsplus(mds_server, ref_number)

# Load simulation from raw output files
# SIM_PATH = '/home/mcarr/mst1/aug_2016/solps_testcase/'

world = World()

# Create a glass BiConvex lens we want to study
lens_glass = schott("N-BK7")
lens_glass.transmission_only = True
lens = BiConvex(0.0254, 0.0052, 0.0506, 0.0506, parent=world, material=lens_glass)
lens.meta['viz-color'] = (66/255, 188/255, 244/255)
lens.meta['viz-opacity'] = 0.5

# lens.meta['viz']['color'] = (66/255, 188/255, 244/255)
# lens.meta['viz']['opacity'] = 0.5

# Create a target plane behind the lens.
target = Box(lower=Point3D(-0.05, -0.05, -0), upper=Point3D(0.05, 0.05, 0), material=AbsorbingSurface(),
             transform=translate(0, 0, 0.1), parent=world)
target.meta['viz-color'] = (224/255, 100/255, 17/255)


# for each sample direction trace a logging ray and plot the ray trajectory
plt.ion()
fig = plt.figure()
# ax = fig.gca(projection='3d')

# for u in np.linspace(-0.006, 0.006, 5):
for v in np.linspace(-0.012, 0.012, 11):

    start = Point3D(v, 0, -0.05)
    log_ray = LoggingRay(start, Vector3D(0, 0, 1))
    log_ray.trace(world)