Exemple #1
0
from cherab.core.math import Constant3D, ConstantVector3D
from cherab.core.atomic import elements, Line
from cherab.openadas import OpenADAS
from cherab.core.model import SingleRayAttenuator, BeamCXLine
from cherab.tools.plasmas import GaussianVolume

integration_step = 0.02

# setup scenegraph
world = World()

# create atomic data source
adas = OpenADAS(permit_extrapolation=True)

# PLASMA ----------------------------------------------------------------------
plasma = Plasma(parent=world)

# define basic distributions
ion_density = 9e19
sigma = 0.25

d_density = GaussianVolume(0.94 * ion_density, sigma)
he2_density = GaussianVolume(0.04 * ion_density, sigma)
c6_density = GaussianVolume(0.01 * ion_density, sigma)
ne10_density = GaussianVolume(0.01 * ion_density, sigma)
e_density = GaussianVolume((0.94 + 0.04*2 + 0.01*6 + 0.01*10) * ion_density, sigma)
temperature = 1000 + GaussianVolume(4000, sigma)
bulk_velocity = ConstantVector3D(Vector3D(200e3, 0, 0))

d_distribution = Maxwellian(d_density, temperature, bulk_velocity, elements.deuterium.atomic_weight * atomic_mass)
he2_distribution = Maxwellian(he2_density, temperature, bulk_velocity, elements.helium.atomic_weight * atomic_mass)
Exemple #2
0
    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