def test_no_element_setter(self): species = Species(elements.carbon, 3, self.get_maxwellian()) with self.assertRaises( AttributeError, msg= 'It must not be possible to change the element of a species!'): species.element = elements.fluorine
def test_no_ionisation_setter(self): species = Species(elements.carbon, 3, self.get_maxwellian()) with self.assertRaises( AttributeError, msg= 'It must not be possible to change the ionisation of a species!' ): species.ionisation = 5
def test_no_distribution_setter(self): species = Species(elements.carbon, 3, self.get_maxwellian()) with self.assertRaises( AttributeError, msg= 'It must not be possible to change the distribution of a species!' ): species.distribution = Maxwellian( lambda x, y, z: 2e20, lambda x, y, z: 3e3, lambda x, y, z: Vector3D(1.6e5, 0, 0), 4.1 * atomic_mass)
def test_negative_ionisation(self): distribution = self.get_maxwellian() with self.assertRaises( ValueError, msg='The ionisation of a species must not be negative!'): Species(elements.carbon, -2, distribution)
def test_too_big_ionisation(self): distribution = self.get_maxwellian() with self.assertRaises( ValueError, msg= 'The ionisation of a species must not be superior than the atomic number of the element!' ): Species(elements.carbon, 7, distribution)
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) 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
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, nitrogen_mass) e_distribution = Maxwellian(e_density, temperature, bulk_velocity, electron_mass) d0_species = Species(deuterium, 0, d_distribution) d1_species = Species(deuterium, 1, d_distribution) n1_species = Species(nitrogen, 1, n_distribution) # define species plasma.b_field = ConstantVector3D(Vector3D(1.0, 1.0, 1.0)) plasma.electron_distribution = e_distribution plasma.composition = [d0_species, d1_species, n1_species] # setup the Balmer lines hydrogen_I_410 = Line(deuterium, 0, (6, 2)) # n = 6->2: 410.12nm hydrogen_I_396 = Line(deuterium, 0, (7, 2)) # n = 7->2: 396.95nm # setup the Nitrgon II line with multiplet splitting instructions nitrogen_II_404 = Line(nitrogen, 1, ("2s2 2p1 4f1 3G13.0", "2s2 2p1 3d1 3F10.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
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 h0_density = NeutralFunction(peak_density, 0.1, pedestal_top=pedestal_top) h0_temperature = Constant3D(neutral_temperature) h0_distribution = Maxwellian(h0_density, h0_temperature, velocity_profile, hydrogen.atomic_weight * atomic_mass) species.append(Species(hydrogen, 0, h0_distribution)) # define hydrogen ion species distribution h1_density = IonFunction(peak_density, 0, pedestal_top=pedestal_top) h1_temperature = IonFunction(peak_temperature, 0, pedestal_top=pedestal_top) h1_distribution = Maxwellian(h1_density, h1_temperature, velocity_profile, hydrogen.atomic_weight * atomic_mass) species.append(Species(hydrogen, 1, h1_distribution)) # add impurities if impurities: for impurity, ionisation, concentration in impurities: imp_density = IonFunction(peak_density * concentration, 0, pedestal_top=pedestal_top) imp_temperature = IonFunction(peak_temperature,
density_c6_data = sal.get( DATA_PATH.format(PULSE_PLASMA, user, 'PRFL', 'C6', sequence)).data[mask] density_c6_psi = Interpolate1DCubic(psi_coord, density_c6_data) density_c6 = AxisymmetricMapper( Blend2D(Constant2D(0.0), IsoMapper2D(psin_2d, density_c6_psi), inside_lcfs)) density_d = lambda x, y, z: electron_density(x, y, z) - 6 * density_c6(x, y, z) d_distribution = Maxwellian(density_d, ion_temperature, flow_velocity, deuterium.atomic_weight * atomic_mass) c6_distribution = Maxwellian(density_c6, ion_temperature, flow_velocity, carbon.atomic_weight * atomic_mass) e_distribution = Maxwellian(electron_density, ion_temperature, flow_velocity, electron_mass) d_species = Species(deuterium, 1, d_distribution) c6_species = Species(carbon, 6, c6_distribution) plasma.electron_distribution = e_distribution plasma.composition = [d_species, c6_species] # ########################### NBI CONFIGURATION ############################# # print('Loading JET PINI configuration...') attenuation_instructions = (SingleRayAttenuator, {'clamp_to_zero': True}) beam_emission_instructions = [(BeamCXLine, {'line': Line(carbon, 5, (8, 7))})] pini_8_1 = load_pini_from_ppf(PULSE, '8.1', plasma, adas, attenuation_instructions,
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) e_density = GaussianVolume(ion_density, sigma * 10000) temperature = 1 + GaussianVolume(79, sigma) bulk_velocity = ConstantVector3D(Vector3D(-1e5, 0, 0)) d_mass = elements.deuterium.atomic_weight * atomic_mass d_distribution = Maxwellian(d_density, temperature, bulk_velocity, d_mass) e_distribution = Maxwellian(e_density, temperature, bulk_velocity, electron_mass) d0_species = Species(elements.deuterium, 0, d_distribution) d1_species = Species(elements.deuterium, 1, d_distribution) # define species plasma.b_field = ConstantVector3D(Vector3D(1.0, 1.0, 1.0)) plasma.electron_distribution = e_distribution plasma.composition = [d0_species, d1_species] # Setup elements.deuterium lines d_alpha = Line(elements.deuterium, 0, (3, 2)) d_beta = Line(elements.deuterium, 0, (4, 2)) d_gamma = Line(elements.deuterium, 0, (5, 2)) d_delta = Line(elements.deuterium, 0, (6, 2)) d_epsilon = Line(elements.deuterium, 0, (7, 2)) plasma.models = [
plt.title('c6 density') plt.figure() plt.imshow(d) plt.colorbar() plt.title('deuterium density in poloidal plane') #define distributions d_distribution = Maxwellian(density_d, ion_temperature, flow_velocity, deuterium.atomic_weight * atomic_mass) c6_distribution = Maxwellian(density_c6, ion_temperature, flow_velocity, carbon.atomic_weight * atomic_mass) e_distribution = Maxwellian(electron_density, ion_temperature, flow_velocity, electron_mass) 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 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) d1_distribution = Maxwellian(d1_density, d1_temperature, zero_velocity, deuterium.atomic_weight * atomic_mass) d1_species = Species(deuterium, 1, d1_distribution) # define the electron distribution e_density = IonFunction(peak_density, 0, magnetic_axis) e_temperature = IonFunction(peak_temperature, 0, magnetic_axis) e_distribution = Maxwellian(e_density, e_temperature, zero_velocity, electron_mass) # define species plasma.b_field = ConstantVector3D(Vector3D(1.0, 1.0, 1.0))