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
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,
width = 1.0 length = 1.0 height = 3.0 peak_density = 5e19 pedestal_top = 1 neutral_temperature = 0.5 peak_temperature = 2500 impurities = [(carbon, 6, 0.005)] world = World() adas = OpenADAS(permit_extrapolation=True, missing_rates_return_null=True) plasma = Plasma(parent=world) plasma.atomic_data = adas plasma.geometry = Box(Point3D(0, -width / 2, -height / 2), Point3D(length, width / 2, height / 2)) species = [] # make a non-zero velocity profile for the plasma vy_profile = IonFunction(1E5, 0, pedestal_top=pedestal_top) def vectorfunction3d(x, y, z): vy = vy_profile(x, y, z) return Vector3D(0, vy, 0) velocity_profile = PythonVectorFunction3D(vectorfunction3d) # define neutral species distribution
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)
# 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)
# 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