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) c6_distribution = Maxwellian(c6_density, temperature, bulk_velocity, elements.carbon.atomic_weight * atomic_mass) ne10_distribution = Maxwellian(ne10_density, temperature, bulk_velocity, elements.neon.atomic_weight * atomic_mass) e_distribution = Maxwellian(e_density, temperature, bulk_velocity, electron_mass) d_species = Species(elements.deuterium, 1, d_distribution) he2_species = Species(elements.helium, 2, he2_distribution) c6_species = Species(elements.carbon, 6, c6_distribution) ne10_species = Species(elements.neon, 10, ne10_distribution) # define species plasma.b_field = ConstantVector3D(Vector3D(1.0, 1.0, 1.0)) plasma.electron_distribution = e_distribution plasma.composition = [d_species, he2_species, c6_species, ne10_species] # BEAM ------------------------------------------------------------------------ beam = Beam(parent=world, transform=translate(1.0, 0.0, 0) * rotate(90, 0, 0)) beam.plasma = plasma beam.atomic_data = adas beam.energy = 60000 beam.power = 3e6 beam.element = elements.deuterium beam.sigma = 0.025 beam.divergence_x = 0.5 beam.divergence_y = 0.5 beam.length = 3.0 beam.attenuator = SingleRayAttenuator(clamp_to_zero=True) beam.models = [
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