Merzbild.jl internal API reference

The public API functions are exported by the module

Particle indexing

Merzbild.map_cont_indexFunction
map_cont_index(particle_indexer, i)

Maps a continuous index in the range [0, n_local-1] to an index in the particle array given a ParticleIndexer instance describing how particle indices are split across 2 groups.

Positional arguments

  • particle_indexer: the ParticleIndexer instance
  • i: the index to map
map_cont_index(pia, cell, species, i)

Maps a continuous index in the range [0, n_local-1] to an index in the particle array for particles of a specific species in a specific cell.

Positional arguments

  • pia: the ParticleIndexerArray instance
  • cell: the index of the cell in which the particles are located
  • species: the index of the particles' species
  • i: the index to map
Merzbild.update_particle_indexer_new_lower_countFunction
update_particle_indexer_new_lower_count(pia, cell, species, new_lower_count)

Update a ParticleIndexerArray instance when the particle count of a given species in a given cell is reduced.

Positional arguments

  • pia: the ParticleIndexerArray instance
  • cell: the index of the cell in which the particles are located
  • species: the index of the particles' species
  • new_lower_count: the new number of particles of the given species in the given cell
Merzbild.update_particle_indexer_new_particleFunction
update_particle_indexer_new_particle(pia, cell, species)

Update a ParticleIndexerArray instance when a particle of a given species in a given cell is created. This places the particle index in the 2-nd group of particle indices in the ParticleIndexer instance.

Positional arguments

  • pia: the ParticleIndexerArray instance
  • cell: the index of the cell in which the particle is created
  • species: the index of the species of which the particle is created
Base.getindexFunction
Base.getindex(pv::ParticleVector, i)

Returns the underlying particle in a ParticleVector instance with index i.

Is usually called as ParticleVector[i].

Positional arguments

  • pv: ParticleVector instance
  • i: the index of the particle to be selected
Base.setindex!Function
Base.setindex!(pv::ParticleVector, p::Particle, i::Integer)

Set the underlying particle in a ParticleVector instance with index i to a new particle.

Is usually called as ParticleVector[i] = p.

Positional arguments

  • pv: ParticleVector instance
  • p: the Particle instance to write
  • i: the index of the particle to be written to
Base.lengthFunction
Base.length(pv::ParticleVector)

Returns the length of a ParticleVector instance.

Is usually called as length(ParticleVector).

Positional arguments

  • pv: ParticleVector instance
Base.resize!Function
Base.resize!(pv::ParticleVector, n::Integer)

Resize a ParticleVector instance.

Is usually called as resize!(ParticleVector, n).

Positional arguments

  • pv: ParticleVector instance
  • n: the new length of the ParticleVector instance (i.e. the length of all the vector fields of the instance)
Merzbild.update_particle_buffer_new_particleMethod
update_particle_buffer_new_particle(pv::ParticleVector, position)

Update the buffer in a ParticleVector instance when a new particle is created. This writes the index of the new particle (the last index stored in the active part of the buffer) to the index vector at position position, and reduces the length of the active part of the buffer by 1.

Positional arguments

  • pv: ParticleVector instance
  • position: the position in the index vector to which to write the index of the new particle
Merzbild.update_particle_buffer_new_particleMethod
update_particle_buffer_new_particle(pv::ParticleVector, pia, species)

Update the buffer in a ParticleVector instance when a new particle is created at the end of the particle array, and reduces the length of the active part of the buffer by 1. This assumes that the pia structure has already an updated particle count (that accounts for the newly created particle), as the index of the new particle taken from the buffer is written to pv.index.[pia.n_total[species]].

Positional arguments

  • pv: ParticleVector instance
  • pia: the ParticleIndexerArray instance
  • species: the index of the species of which a new particle is created
Merzbild.update_particle_buffer_new_particleMethod
update_particle_buffer_new_particle(pv::Vector{Particle}, pia, species)

Dummy function in case Vector{Particle} is used and not a ParticleVector, just to make the simplest 0-D examples work.

Merzbild.update_particle_buffer_new_particleMethod
update_particle_buffer_new_particle(pv::Vector{Particle}, position)

Dummy function in case Vector{Particle} is used and not a ParticleVector, just to make the simplest 0-D examples work.

Merzbild.delete_particle!Function
delete_particle!(pv::ParticleVector, pia, cell, species, i)

Delete particle with index i of species species in cell cell and update the particle indexers and buffers accordingly. This changes the ordering of the non-deleted particles in the cell.

Positional arguments

  • pv: ParticleVector instance
  • pia: the ParticleIndexerArray instance
  • cell: the index of the cell in which the particle is deleted
  • species: the index of the species of which the particle is deleted
  • i: the index of the particle to delete
Merzbild.delete_particle_end!Function
delete_particle_end!(pv::ParticleVector, pia, cell, species)

Delete the last particle of species species in cell cell: if particles are present in the 2nd group of the indices stored in the ParticleIndexer instance, it will delete the last particle in that group; otherwise it will delete the last particle in the 1st group of particles pointed to by the ParticleIndexer instance. If no particles are present in the cell, the function does nothing.

Positional arguments

  • pv: ParticleVector instance
  • pia: the ParticleIndexerArray instance
  • cell: the index of the cell in which the particle is deleted
  • species: the index of the species of which the particle is deleted
Merzbild.delete_particle_end_group1!Function
delete_particle_end_group1!(pv::ParticleVector, pia, cell, species)

Delete particle with index pia.indexer[cell, species].end1of speciesspeciesin cellcell` and update the particle indexers and buffers accordingly (i.e. delete the last particle in the 1st group of particles of a given species in a given cell). This also sets the weight of the deleted particle to 0. If no particles are present in the 1st group of particles, the function does nothing.

Positional arguments

  • pv: ParticleVector instance
  • pia: the ParticleIndexerArray instance
  • cell: the index of the cell in which the particle is deleted
  • species: the index of the species of which the particle is deleted
Merzbild.delete_particle_end_group2!Function
delete_particle_end_group2!(pv::ParticleVector, pia, cell, species)

Delete particle with index pia.indexer[cell, species].end2of speciesspeciesin cellcell` and update the particle indexers and buffers accordingly (i.e. delete the last particle in the 2nd group of the particles of a given species in a given cell). This also sets the weight of the deleted particle to 0. If no particles are present in the 2nd group of particles, the function does nothing.

Positional arguments

  • pv: ParticleVector instance
  • pia: the ParticleIndexerArray instance
  • cell: the index of the cell in which the particle is deleted
  • species: the index of the species of which the particle is deleted

Loading species and interaction data

Merzbild.compute_mu_refFunction
compute_mu_ref(m_r, vhs_o, vhs_Tref, vhs_d)

Compute reference viscosity for the VHS model.

Positional arguments

  • m_r: collision-reduced mass
  • vhs_o: exponent for the VHS potential
  • vhs_Tref: reference temperature for the VHS potential
  • vhs_d: diameter for the VHS potential

Returns

  • reference viscosity

Sampling

Merzbild.UnitDVGridType
UnitDVGrid

Stores information about a uniform discrete 3-dimensional velocity grid with extent $[-1.0,1.0]\times[-1.0,1.0]\times[-1.0,1.0]$.

Fields

  • nx: number of cells in x direction
  • ny: number of cells in y direction
  • nz: number of cells in z direction
  • dx: grid spacing in x direction
  • dy: grid spacing in y direction
  • dz: grid spacing in z direction
  • vx_grid: Vector of grid nodes in x direction
  • vy_grid: Vector of grid nodes in y direction
  • vz_grid: Vector of grid nodes in z direction
Merzbild.DVGridType
DVGrid

Stores information about a uniform discrete 3-dimensional velocity grid with extent $[-v_{x,max},v_{x,max}]\times[-v_{y,max},v_{y,max}]\times[-v_{z,max},v_{z,max}]$.

Fields

  • base_grid: the underlying unit (non-scaled) UnitDVGrid uniform grid
  • vx_max: extent of the grid in the x direction
  • vy_max: extent of the grid in the y direction
  • vz_max: extent of the grid in the z direction
  • dy: grid spacing in x direction
  • dy: grid spacing in y direction
  • dz: grid spacing in z direction
  • vx_grid: Vector of grid nodes in x direction
  • vy_grid: Vector of grid nodes in y direction
  • vz_grid: Vector of grid nodes in z direction
Merzbild.VDFType
VDF

Stores the values of a function evaluated on 3-dimensional velocity grid.

Fields

  • nx: the number of grid elements in the x direction
  • ny: the number of grid elements in the y direction
  • nz: the number of grid elements in the z direction
  • w: the 3-dimensional array of values
Merzbild.sample_bkw!Function
sample_bkw!(rng, particles, nparticles, offset, m, T, v0)

Sample particle velocities from the BKW distribution with temperature T for a species with mass m at t=0 and add a velocity offset. Note: This does not update the particle weights, positions, or any indexing structures.

Positional arguments

  • rng: the random number generator
  • particles: the Vector-like structure holding the particles
  • nparticles: the number of particles to sample
  • offset: offset the starting position for writing the sampled particles to the particles array
  • m: species' mass
  • T: temperature
  • v0: the 3-dimensional velocity to add to the sampled velocities
sample_bkw!(rng, particles, nparticles, m, T, v0)

Sample particles' velocities from the BKW distribution with temperature T for a species with mass m at t=0 and add a velocity offset. This does not update the particle weights, positions, or any indexing structures. The sampled particles are written to the start of the particles array.

Positional arguments

  • rng: the random number generator
  • particles: the Vector-like structure holding the particles
  • nparticles: the number of particles to sample
  • m: species' mass
  • T: temperature
  • v0: the 3-dimensional velocity to add to the sampled velocities
Merzbild.evaluate_distribution_on_grid!Function
evaluate_distribution_on_grid!(vdf, distribution_function, grid, w_total, cutoff_v; normalize=true)

Evaluate a distribution on a discrete velocity grid, considering only points inside a sphere of a given radius (the value of the VDF at points outside of the sphere will be 0.0). The values can be re-normalized so that the distribution has the prescribed computational weight/density.

Positional arguments

  • vdf: The VDF instance where the evaluated values will be stored
  • distribution_function: the distribution function to be evaluated which takes the x, y, and z velocities as parameters
  • grid: the DVGrid on which the distribution function is evaluated
  • w_total: the total weight used in the re-normalization
  • cutoff_v: the radius of the sphere used to cut off high velocities: on grid points outside the sphere the VDF will be 0

Keyword arguments

  • normalize: if true, the resulting values of the VDF will be renormalized so that their sum is equal to w_total
Merzbild.sample_maxwellian_single!Function
sample_maxwellian_single!(rng, v, m, T, v0)

Sample a single particle from a Maxwellian distribution with temperature T for a species with mass m and add a velocity offset.

Positional arguments

  • rng: The random number generator
  • v: the 3-dimensional vector to store the sampled velocity
  • m: the molecular mass of the species
  • T: the temperature
  • v_offset: the offset velocity vector to be added to the sampled velocity
Merzbild.sample_maxwellian!Function
sample_maxwellian!(rng, particles, nparticles, offset, m, T, v0)

Sample nparticles particles from a Maxwellian with temperature T for a species with mass m and add a velocity offset. Note: This does not update the particle weights, positions, or any indexing structures.

Positional arguments

  • rng: the random number generator
  • particles: the Vector-like structure holding the particles
  • nparticles: the number of particles to sample
  • offset: offset the starting position for writing the sampled particles to the particles array
  • m: species' mass
  • T: temperature
  • v0: the 3-dimensional velocity to add to the sampled velocities
sample_maxwellian!(rng, particles, nparticles, m, T, v0)

Sample nparticles particles from a Maxwellian with temperature T for a species with mass m and add a velocity offset. Note: This does not update the particle weights, positions, or any indexing structures. The sampled particles are written to the start of the particles array.

Positional arguments

  • rng: the random number generator
  • particles: the Vector-like structure holding the particles
  • nparticles: the number of particles to sample
  • m: species' mass
  • T: temperature
  • v0: the 3-dimensional velocity to add to the sampled velocities

Collision computations

Merzbild.compute_n_coll_single_speciesFunction
compute_n_coll_single_species(rng, collision_factors, np, Δt, V)

Compute the non-integer number of collisions between particles of same species.

Positional arguments

  • rng: the random number generator
  • collision_factors: the CollisionFactors holding the estimate of $(\sigma g w)_{max}$ for the species in question in the cell
  • np: number of particles in the cell
  • Δt: timestep
  • V: cell volume

Returns

The non-integer number of collisions.

Merzbild.compute_n_coll_two_speciesFunction
compute_n_coll_two_species(rng, collision_factors, np1, np2, Δt, V)

Compute number of collisions between particles of different species

Positional arguments

  • rng: the random number generator
  • collision_factors: the CollisionFactors holding the estimate of $(\sigma g w)_{max}$ for the species in question in the cell
  • np1: number of particles of the first species in the cell
  • np2: number of particles of the second species in the cell
  • Δt: timestep
  • V: cell volume

Returns

The non-integer number of collisions.

Merzbild.compute_vhs_factorFunction
compute_vhs_factor(vhs_Tref, vhs_d, vhs_o, m_r)

Compute interaction-specific factor $\pi D_{VHS}^2 (2 T_{ref,VHS}/m_r)^{(\omega_{VHS} - 0.5)} \frac{1}{\Gamma(2.5 - \omega_{VHS})}$.

Positional arguments

  • vhs_Tref: reference temperature for the VHS potential
  • vhs_d: diameter for the VHS potential
  • vhs_o: exponent for the VHS potential
  • m_r: collision-reduced mass

Returns

  • computed VHS cross-section factor
Merzbild.compute_com!Function
compute_com!(collision_data::CollisionData, interaction::Interaction, p1, p2)

Compute center of mass velocity of two particles.

Positional arguments

  • collision_data: the CollisionData instance where the computed velocity will be stored
  • interaction: the Interaction instance for the species of the colliding particles
  • p1: the first particle
  • p2: the second particle
Merzbild.compute_g!Function
compute_g!(collision_data::CollisionData, p1, p2)

Compute relative velocity (vector and its magnitude) of two particles.

Positional arguments

  • collision_data: the CollisionData instance where the computed velocity will be stored
  • p1: the first particle
  • p2: the second particle
Merzbild.compute_g_new_ionization!Function
compute_g_new_ionization!(collision_data, interaction, E_i, energy_splitting)

Compute post-ionization magnitudes of the relative velocities of the impacting and newly created electrons.

Positional arguments

  • collision_data: the CollisionData instance where the computed velocity will be stored
  • interaction: the Interaction instance for the electron-neutral interaction which produced the ion
  • E_i: ionization energy of the neutral species in electron-volt
  • energy_splitting: how the energy is divided among the electrons: if ElectronEnergySplitEqual, the energy is split equally, if ElectronEnergySplitZeroE, one electron takes all of the energy
Merzbild.scatter_vhs!Function
scatter_vhs!(rng, collision_data, interaction, p1, p2)

Scatter two particles using VHS (isotropic) scattering.

Positional arguments

  • rng: the random number generator
  • collision_data: the CollisionData instance to which stores the center-of-mass velocity, the magnitude of the pre-collisional relative velocity of the particles and to which the new post-collisional velocity will be written
  • interaction: the Interaction instance for the colliding particles
  • p1: the first colliding particle
  • p2: the second colliding particle
Merzbild.scatter_electron_vhs!Function
scatter_vhs!(rng, collision_data, interaction, p1, p2)

Scatter an electron off of a neutral particle using VHS (isotropic) scattering and re-scale its relative velocity to g_new.

Positional arguments

  • rng: the random number generator
  • collision_data: the CollisionData instance to which stores the center-of-mass velocity and the magnitude of the pre-collisional relative velocity of the electron and the neutral
  • particles_electron: the electron particle to scatter off of the neutral particle
  • g_new: the magnitude of the post-collisional relative velocity
Merzbild.scatter_ionization_electrons!Function
scatter_ionization_electrons!(rng, collision_data, particles_electron, i1, i2)

Scatter two electrons off of a neutral using VHS (isotropic) scattering.

Positional arguments

  • rng: the random number generator
  • collision_data: the CollisionData instance to which stores the center-of-mass velocity the magnitude of the pre-collisional relative velocity of the electron and the neutral, and the post-collisional magnitudes of the velocities of the electrons
  • particles_electron: the vector of electron particles to scatter off of the neutral particle
  • i1: the index of the first electron particle to scatter off of the neutral
  • i2: the index of the second electron particle to scatter off of the neutral
Merzbild.sigma_vhsFunction
sigma_vhs(interaction, g)

Computes the VHS cross-section.

Positional arguments

  • interaction: the Interaction instance
  • g: the relative velocity of the collision

Returns

The value of the computed cross-section.

Merzbild.compute_tabulated_cs_constant_continuationFunction
compute_tabulated_cs_constant_continuation(tabulated_cs_data, E_coll)

Compute an energy-dependent cross-section from tabulated data using linear interpolation. If the energy is smaller than the minimum energy used for the tabulation, return first element of the table; if energy is larger than the maximum energy used for the tabulation, return last element of the table.

Positional arguments

  • tabulated_cs_data: a TabulatedCSData instance with the tabulated energies and cross-section values
  • E_coll: the collision energy for which to compute the cross-section

Returns

The value of the cross-section.

Merzbild.compute_tabulated_cs_zero_continuationFunction
compute_tabulated_cs_zero_continuation(tabulated_cs_data, E_coll)

Compute an energy-dependent cross-section from tabulated data using linear interpolation. If the energy is outside of the range of energies used for the tabulation, returns 0.0.

Positional arguments

  • tabulated_cs_data: a TabulatedCSData instance with the tabulated energies and cross-section values
  • E_coll: the collision energy for which to compute the cross-section

Returns

The value of the cross-section.

Merzbild.compute_cross_sections_only!Function
compute_cross_sections_only!(computed_cs, interaction, g, electron_neutral_interactions, neutral_species_index)

Compute electron-impact ionization and excitation cross-sections, and electron-neutral elastic scattering crosss-sections, and return collision energy in eV. Here neutral_species_index is the index of the neutral species being considered in the overall array of the Species instances that includes all species in the simulation and was used to construct the ElectronNeutralInteractions instance.

Positional arguments

  • computed_cs: the vector of ComputedCrossSection instances in which the computed values will be stored
  • interaction: the Interaction instance describing the electron-neutral interaction being considered
  • g: the magnitude of the relative collision velocity
  • electron_neutral_interactions: the ElectronNeutralInteractions instance storing the tabulated cross-section data
  • neutral_species_index: the index of the neutral species being considered

Returns

The electron-neutral collision energy in eV.

Merzbild.compute_cross_sections!Function
compute_cross_sections!(computed_cs, interaction, g, electron_neutral_interactions, neutral_species_index)

Compute electron-impact ionization and excitation cross-sections, electron-neutral elastic scattering cross-sections, total collision cross-section, probabilities of the different processes, and return collision energy in eV. Here neutral_species_index is the index of the neutral species being considered in the overall array of the Species instances that includes all species in the simulation and was used to construct the ElectronNeutralInteractions instance.

Positional arguments

  • computed_cs: the vector of ComputedCrossSection instances in which the computed values will be stored
  • interaction: the Interaction instance describing the electron-neutral interaction being considered
  • g: the magnitude of the relative collision velocity
  • electron_neutral_interactions: the ElectronNeutralInteractions instance storing the tabulated cross-section data
  • neutral_species_index: the index of the neutral species being considered

Returns

The electron-neutral collision energy in eV.

Merzbild.get_cs_totalFunction
get_cs_total(electron_neutral_interactions, computed_cs, neutral_species_index)

Get the value of a computed total collision cross-section for electron-neutral interactions. Here neutral_species_index is the index of the neutral species being considered in the overall array of the Species instances that includes all species in the simulation and was used to construct the ElectronNeutralInteractions instance.

Positional arguments

  • electron_neutral_interactions: the ElectronNeutralInteractions instance storing the tabulated cross-section data
  • computed_cs: the vector of ComputedCrossSection instances holding the computed cross-section values
  • neutral_species_index: the index of the neutral species being considered

Returns

The value of the total collision cross-section.

Merzbild.get_cs_elasticFunction
get_cs_elastic(electron_neutral_interactions, computed_cs, neutral_species_index)

Get the value of a computed electron-neutral elastic scattering cross-section. Here neutral_species_index is the index of the neutral species being considered in the overall array of the Species instances that includes all species in the simulation and was used to construct the ElectronNeutralInteractions instance.

Positional arguments

  • electron_neutral_interactions: the ElectronNeutralInteractions instance storing the tabulated cross-section data
  • computed_cs: the vector of ComputedCrossSection instances holding the computed cross-section values
  • neutral_species_index: the index of the neutral species being considered

Returns

The value of the elastic scattering cross-section.

Merzbild.get_cs_ionizationFunction
get_cs_ionization(electron_neutral_interactions, computed_cs, neutral_species_index)

Get the value of a computed electron-impact ionization cross-section. Here neutral_species_index is the index of the neutral species being considered in the overall array of the Species instances that includes all species in the simulation and was used to construct the ElectronNeutralInteractions instance.

Positional arguments

  • electron_neutral_interactions: the ElectronNeutralInteractions instance storing the tabulated cross-section data
  • computed_cs: the vector of ComputedCrossSection instances holding the computed cross-section values
  • neutral_species_index: the index of the neutral species being considered

Returns

The value of the electron-impact ionization scattering cross-section.

Merzbild.get_ionization_thresholdFunction
get_ionization_threshold(electron_neutral_interactions, neutral_species_index)

Get the ionization threshold energy. Here neutral_species_index is the index of the neutral species being considered in the overall array of the Species instances that includes all species in the simulation and was used to construct the ElectronNeutralInteractions instance.

Positional arguments

  • electron_neutral_interactions the ElectronNeutralInteractions instance storing the tabulated cross-section data
  • neutral_species_index: the index of the neutral species being considered

Returns

The ionization threshold energy of a specific neutral species.

Merzbild.get_electron_energy_splitFunction
get_electron_energy_split(electron_neutral_interactions, neutral_species_index)

Get the way electron energy is split during ionization for a specific electron-neutral interaction. Here neutral_species_index is the index of the neutral species being considered in the overall array of the Species instances that includes all species in the simulation and was used to construct the ElectronNeutralInteractions instance.

Positional arguments

  • electron_neutral_interactions the ElectronNeutralInteractions instance storing the tabulated cross-section data
  • neutral_species_index: the index of the neutral species being considered

Returns

The ElectronEnergySplit value for the specific electron-neutral interaction.

Electron-neutral interactions

Merzbild.TabulatedCSDataType
TabulatedCSData

Structure for storing tabulated cross-section data as a function of relative collision energy

Fields

  • n_vals: number of values stored
  • E: array of relative collision energies
  • sigma: array of cross-section values at these energies
  • ΔE: how much energy is lost (gained) in the collision in case it is inelastic
Merzbild.ElasticScatteringType
ElasticScattering

Structure to hold data on an elastic scattering cross-section.

Fields

  • data: a TabulatedCSData instance holding the cross-section values
  • scattering: the ScatteringLaw model for the scattering of the particles
Merzbild.ExcitationSinkType
Ionization

Structure to hold data on electron-impact electronic excitation cross-sections for a specific species.

Fields

  • n_reactions: number of electron-impact electronic excitation reactions
  • data: an array of TabulatedCSData instances (of length n_reactions) holding the cross-section values for each reaction
  • scattering: the ScatteringLaw model for the scattering of the particles
Merzbild.IonizationType
Ionization

Structure to hold data on an electron-impact ionization cross-section.

Fields

  • data: a TabulatedCSData instance holding the cross-section values
  • scattering: the ScatteringLaw model for the scattering of the electrons
  • split: the ElectronEnergySplit model for energy splitting across the primary and secondary electrons
Merzbild.find_species_in_dbFunction

Find a chemical species in an LXCat-format XML; returns the first instance of the species found and the id of the "Groups" element in which the species was found. The following conditions need to be satisfied for a tuple (i,j) for it to be returned: tag(xml_data[i]) == "Groups" and attributes(xml_data[i][j])["id"] == species_name.

Positional arguments

  • xml_data: the LXCat-format XML data to be searched
  • species_name: the name of the species to search for

Returns

Tuple (i,j) denoting the index of the group and group element in which the species is located

Merzbild.load_elastic_dataFunction
load_elastic_data(xml_data)

Load electron-neutral elastic scattering data from the part of an LXCat-format XML file for a specific species. The following should hold for the data to be loaded: tag(xml_data[i]) == "Processes", attributes(xml_data[i][j])["type"] == "Ionization". This will load the first set of data found for the ionization process.

Positional arguments

  • xml_data: the LXCat-format XML data to be searched

Returns

TabulatedCSData structure containing the electron-neutral elastic scattering cross-section data.

Throws

DataMissingException if data not found or not all required data present.

Merzbild.load_ionization_dataFunction
load_ionization_data(xml_data)

Load electron-impact ionization data from the part of an LXCat-format XML file for a specific species. The following should hold for the data to be loaded: tag(xml_data[i]) == "Processes", attributes(xml_data[i][j])["type"] == "Ionization". This will load the first set of data found for the ionization process.

Positional arguments

  • xml_data: the LXCat-format XML data to be searched

Returns

TabulatedCSData structure containing the electron-impact ionization cross-section data.

Throws

DataMissingException if data not found or not all required data present.

Merging

Merzbild.GridCellType
GridCell

Struct for keeping track of merging-related quantities in a velocity grid cell.

Fields

  • np: number of particles in cell
  • w: total computational weight of particles in cell
  • v_mean: mean velocity of particles in cell
  • v_std_sq: variance of velocity of particles in cell
  • x_mean: mean position of particles in cell
  • x_std_sq: variance of position of particles in cell
  • particle_index1: index of first particle in the cell (first as in the first particle that is found to belong to the cell)
  • particle_index1: index of second particle in the cell (second as in the second particle that is found to belong to the cell)
  • w1: the post-merge weight to assign to the first particle in the cell
  • w2: the post-merge weight to assign to the second particle in the cell
  • v1: the post-merge velocity to assign to the first particle in the cell
  • v2: the post-merge velocity to assign to the second particle in the cell
  • x1: the post-merge position to assign to the first particle in the cell
  • x2: the post-merge position to assign to the second particle in the cell
Merzbild.compute_velocity_extent!Function
compute_velocity_extent!(merging_grid, cell, species, species_data, phys_props)

Compute extent of velocity grid based on temperature in the cell.

Positional arguments:

  • merging_grid: the grid merging (GridN2Merge) instance for which to compute the extent
  • cell: the index of the cell in which the temperature was computed
  • species: the index of the species for which the temperature was computed
  • species_data: the array of Species data
  • phys_props: the PhysProps instance containing the computed temperature
Merzbild.compute_grid_indexFunction
compute_grid_index(merging_grid, v)

Compute index of cell on the merging grid in which a velocity is located (the last 8 indices correspond to the velocity octants outside the grid).

Positional arguments:

  • merging_grid: the grid merging (GridN2Merge) instance defining the velocity space grid
  • v: the velocity vector

Returns:

Index of cell on the merging grid.

Merzbild.clear_merging_grid!Function
clear_merging_grid!(merging_grid)

Resets all data for a merging grid instance.

Positional arguments:

  • merging_grid: the grid merging (GridN2Merge) instance defining the velocity space grid
Merzbild.compute_grid!Function
compute_grid!(merging_grid::GridN2Merge, particles, pia, cell, species)

Compute all the required cell properties for a grid-based merge.

Positional arguments:

  • merging_grid: the grid merging (GridN2Merge) instance defining the velocity space grid
  • particles: the ParticleVector instance of the particles to be merged
  • pia: the ParticleIndexerArray instance
  • cell: the cell index
  • species: the species index
Merzbild.compute_new_particles!Function
compute_new_particles!(rng, merging_grid::GridN2Merge, particles, pia, cell, species)

Compute new particles based on the grid cell properties without checking particle locations. So particles may end up outside of the domain.

Positional arguments:

  • rng: the random number generator instance
  • merging_grid: the grid merging (GridN2Merge) instance defining the velocity space grid
  • particles: the ParticleVector instance of the particles to be merged
  • pia: the ParticleIndexerArray instance
  • cell: the cell index
  • species: the species index
compute_new_particles!(rng, octree::OctreeN2Merge, particles, pia, cell, species)

Compute post-merge particles particles based on octree bin properties without checking particle locations. So particles may end up outside of the domain.

Positional arguments:

  • rng: the random number generator instance
  • octree: the OctreeN2Merge instance
  • particles: the ParticleVector instance of the particles to be merged
  • pia: the ParticleIndexerArray instance
  • cell: the cell index
  • species: the species index
Merzbild.vx_signFunction
vx_sign(octant)

Return sign of velocity vx of an octant in velocity space.

Positional arguments

  • octant: index of the octant in velocity space

Returns

Sign of the x-velocity corresponding to the octant.

Merzbild.vy_signFunction
vy_sign(octant)

Return sign of velocity vy of an octant in velocity space.

Positional arguments

  • octant: index of the octant in velocity space

Returns

Sign of the y-velocity corresponding to the octant.

Merzbild.vz_signFunction
vz_sign(octant)

Return sign of velocity vz of an octant in velocity space.

Positional arguments

  • octant: index of the octant in velocity space

Returns

Sign of the z-velocity corresponding to the octant

Merzbild.check_speed_boundFunction
check_speed_bound(speed_val, minval, maxval)

Compare speed_val to the bounds and return either the value if its within bounds or the appropriate closest bound.

Positional arguments

  • speed_val: value to check
  • minval: lower bound
  • maxval: upper bound

Returns

Either original value or value of closest bound.

check_speed_bound(speed_val, minval, maxval, multiplier)

Compare speed_val time a multiplier to the bounds and return either the value times the multiplier if its within bounds or the appropriate closest bound times the multiplier.

Positional arguments

  • speed_val: value to check
  • minval: lower bound
  • maxval: upper bound
  • multiplier: the multiplier

Returns

Either original value times the multiplier or value of closest bound times the multiplier.

Merzbild.base_multi_index_momentsFunction
base_multi_index_moments()

Base multi indices corresponding to conservation of mass, momentum, and energy components.

Positional arguments

None

Returns

A vector of multi-indices (3-tuples) which corresponding to mass, momentum, and directional energy.

Merzbild.compute_w_total_v0!Function
compute_w_total_v0!(nnls_merging, particles, pia, cell, species)

Compute total computational weight of particles and mean velocity, as well as velocity bounds of the set of particles in each velocity direction.

Positional arguments

  • nnls_merging: the NNLSMerge instance where the computed values will be stored
  • particles: the ParticleVector instance containing the particles that are being merged
  • pia: the ParticleIndexerArray instance
  • cell: the index of the grid cell in which particles are being merged
  • species: the index of the species being merged
Merzbild.ccmFunction
ccm(v, v0, mim)

Compute unweighted central moment.

Positional arguments

  • v: the 3-dimensional velocity vector
  • v0: the 3-dimensional mean velocity vector
  • mim: the 3-dimensional multi-index

Returns

Computed unweighted central moment.

ccm(vx, vy, vz, vx0, vy0, vz0, mim)

Compute unweighted central moment.

Positional arguments

  • vx: the x component of the velocity
  • vy: the y component of the velocity
  • vz: the z component of the velocity
  • vx0: the x component of the mean velocity
  • vy0: the y component of the mean velocity
  • vz0: the z component of the mean velocity
  • mim: the 3-dimensional multi-index

Returns

Computed unweighted central moment.

Merzbild.compute_lhs_and_rhs!Function
compute_lhs_and_rhs!(nnls_merging, lhs_matrix, particles, pia, cell, species)

Compute LHS matrix and RHS vector for NNLS merging. Returns the pre-merge number of particles.

Positional arguments

  • nnls_merging: the NNLSMerge instance where the RHS vector will be stored
  • lhs_matrix: the matrix of size n_total_conserved x n_particles, where n_total_conserved is the number of conserved moments and n_particles is the pre-merge number of particles
  • particles: the ParticleVector instance containing the particles that are being merged
  • pia: the ParticleIndexerArray instance
  • cell: the index of the grid cell in which particles are being merged
  • species: the index of the species being merged

Returns

The pre-merge number of particles.

Merzbild.compute_lhs_and_rhs_rate_preserving!Function
compute_lhs_and_rhs_rate_preserving!(nnls_merging, lhs_matrix, particles, pia, cell, species)

Compute LHS matrix and RHS vector for the rate-preserving NNLS merging (for electrons). Approximate elastic scattering and electron-impact ionization rates are conserved.

Positional arguments

  • nnls_merging: the NNLSMerge instance where the RHS vector will be stored
  • lhs_matrix: the matrix of size n_total_conserved x n_particles, where n_total_conserved is the number of conserved moments and n_particles is the pre-merge number of particles
  • interaction: the Interaction instance describing the electron-neutral interaction being considered
  • electron_neutral_interactions: the ElectronNeutralInteractions instance storing the tabulated cross-section data used to compute the rates
  • computed_cs: the vector of ComputedCrossSection instances in which the computed values will be stored
  • particles: the ParticleVector instance containing the particles that are being merged
  • pia: the ParticleIndexerArray instance
  • cell: the index of the grid cell in which particles are being merged
  • species: the index of the species being merged
  • neutral_species_index: the index of the neutral species which is the collision partner in the electron-neutral collisions for which approximate rates are being preserved.
Merzbild.compute_lhs_particles_additional!Function
compute_lhs_particles_additional!(rng, col_index, nnls_merging, lhs_matrix,
                                       particles, pia, cell, species,
                                       n_rand_pairs)

Compute additional LHS columns for additional particles. One particle is added at the local zero velocity ( i.e. mean velocity of the whole system of particles), 8 particles are added (1 per velocity space octant) using the standard deviation of the velocities of the whole particle system in each direction to determine their velocities (+ bounded via use of the check_speed_bound function). A second set of 8 particles is added using a similar scheme, but the velocities are multiplied by 0.5. Finally, n_rand_pairs particle pairs are chosen and their mean velocities are used to compute these additional particles.

Positional arguments

  • rng: the random number generator instance
  • col_index: the index of the first column where to start writing the additionally computed values
  • nnls_merging: the NNLSMerge instance where the RHS vector will be stored
  • lhs_matrix: the matrix of size n_total_conserved x n_particles, where n_total_conserved is the number of conserved moments and n_particles is the pre-merge number of particles
  • particles: the ParticleVector instance containing the particles that are being merged
  • pia: the ParticleIndexerArray instance
  • cell: the index of the grid cell in which particles are being merged
  • species: the index of the species being merged
  • n_rand_pairs: the number of random particle pairs to choose
Merzbild.compute_lhs_particles_additional_rate_preserving!Function
compute_lhs_particles_additional_rate_preserving!(rng, col_index, nnls_merging, lhs_matrix,
                                       interaction, electron_neutral_interactions, computed_cs, 
                                       particles, pia, cell, species, neutral_species_index,
                                       n_rand_pairs)

Compute additional LHS columns for additional particles for the rate-preserving NNLS merging (for electrons). One particle is added at the local zero velocity (i.e. mean velocity of the whole system of particles), 8 particles are added (1 per velocity space octant) using the standard deviation of the velocities of the whole particle system in each direction to determine their velocities (+ bounded via use of the check_speed_bound function). A second set of 8 particles is added using a similar scheme, but the velocities are multiplied by 0.5. Finally, n_rand_pairs particle pairs are chosen and their mean velocities are used to compute these additional particles.

Positional arguments

  • rng: the random number generator instance
  • col_index: the index of the first column where to start writing the additionally computed values
  • nnls_merging: the NNLSMerge instance where the RHS vector will be stored
  • lhs_matrix: the matrix of size n_total_conserved x n_particles, where n_total_conserved is the number of conserved moments and n_particles is the pre-merge number of particles
  • interaction: the Interaction instance describing the electron-neutral interaction being considered
  • electron_neutral_interactions: the ElectronNeutralInteractions instance storing the tabulated cross-section data used to compute the rates
  • computed_cs: the vector of ComputedCrossSection instances in which the computed values will be stored
  • particles: the ParticleVector instance containing the particles that are being merged
  • pia: the ParticleIndexerArray instance
  • cell: the index of the grid cell in which particles are being merged
  • species: the index of the species being merged
  • neutral_species_index: the index of the neutral species which is the collision partner in the electron-neutral collisions for which approximate rates are being preserved.
  • n_rand_pairs: the number of random particle pairs to choose
Merzbild.scale_lhs_rhs!Function
scale_lhs_rhs!(nnls_merging, lhs_matrix)

Scale the LHS and RHS of the NNLS system using the reference velocity $v_{ref}$. Each moment is scaled by $(1/v_{ref})^{n_{tot}}$, where $n_{tot}$ is the total order of the moment (i.e. for a moment with multi-index (i,j,k) the total order is i+j+k).

Positional arguments

  • nnls_merging: the NNLSMerge instance
  • lhs_matrix: the matrix of the LHS
Merzbild.scale_lhs_rhs_rate_preserving!Function
scale_lhs_rhs_rate_preserving!(nnls_merging, lhs_matrix, ref_cs_elastic, ref_cs_ion)

Scale the LHS and RHS of the NNLS system for the rate-preserving electron merging using the reference velocity $v_{ref}$ and reference elastic scattering and ionization cross-sections. Each moment is scaled by $(1/v_{ref})^{n_{tot}}$, where $n_{tot}$ is the total order of the moment (i.e. for a moment with multi-index (i,j,k) the total order is i+j+k). The entries in the LHS and RHS corresponding to the rates are scaled by $1/(v_{ref} * \sigma_{p})$, where $\sigma_{p}$ is the cross-section of process $p$.

Positional arguments

  • nnls_merging: the NNLSMerge instance
  • lhs_matrix: the matrix of the LHS
  • ref_cs_elastic: the reference elastic scattering cross-section
  • ref_cs_ion: the reference ionization cross-section
Merzbild.compute_post_merge_particles_nnls!Function
compute_post_merge_particles_nnls!(lhs_ncols, lhs_matrix,
                                        nnls_merging, particles, pia, cell, species)

Compute post-merge particles based on the solution of the NNLS problem. This will replace the particles with the post-merge ones and delete any extraneous particles.

Positional arguments

  • lhs_ncols: the number of columns in the LHS matrix
  • lhs_matrix: the LHS matrix of the NNLS system
  • nnls_merging: the NNLSMerge instance
  • particles: the ParticleVector instance containing the particles that are being merged
  • pia: the ParticleIndexerArray instance
  • cell: the index of the grid cell in which particles are being merged
  • species: the index of the species being merged
Merzbild.OctreeCellType
OctreeCell

Struct holding computed bin properties needed for refinement of an octree bin.

Fields

  • np: number of particles in cell
  • w: total computational weight of particles in cell
  • v_min: vector of the per-component lower bounds of the velocities in the cell
  • v_max: vector of the per-component upper bounds of the velocities in the cell
  • depth: level of refinement the cell is at
  • can_be_refined: whether the cell can be refined further
Merzbild.OctreeFullCellType
OctreeFullCell

Struct holding computed bin properties required to merge the particles in a bin.

Fields

  • v_mean: mean velocity of particles in cell
  • v_std_sq: variance of velocity of particles in cell
  • x_mean: mean position of particles in cell
  • x_std_sq: variance of position of particles in cell
  • particle_index1: index of first particle in the cell (first as in the first particle that is found to belong to the cell)
  • particle_index1: index of second particle in the cell (second as in the second particle that is found to belong to the cell)
  • w1: the post-merge weight to assign to the first particle in the cell
  • w2: the post-merge weight to assign to the second particle in the cell
  • v1: the post-merge velocity to assign to the first particle in the cell
  • v2: the post-merge velocity to assign to the second particle in the cell
  • x1: the post-merge position to assign to the first particle in the cell
  • x2: the post-merge position to assign to the second particle in the cell
Merzbild.fill_binsFunction
fill_bins(Nbins)

Fill the octree bins structs with zero data, used as a utility function for initialization.

Positional arguments:

  • Nbins: number of OctreeCell bins to create

Returns: An array of Nbins OctreeCell instances filled with zeros.

Merzbild.fill_full_binsFunction
fill_full_bins(Nbins)

Fill the octree bins full structs with zero data, used as a utility function for initialization.

Positional arguments:

  • Nbins: number of OctreeFullCell bins to create

Returns: An array of Nbins OctreeFullCell instances filled with zeros.

Merzbild.clear_octree!Function
clear_octree!(octree)

Reset octree before doing a new merge.

Positional arguments:

  • octree: the OctreeN2Merge instance
Merzbild.resize_octree_buffers!Function
resize_octree_buffers!(octree, n_particles)

Check and resize octree buffers if needed to accommodate a larger number of particles. The size of the buffers is set to n_particles + DELTA_PARTICLES if the their sizes are smaller than n_particles.

Positional arguments:

  • octree: the OctreeN2Merge instance
  • n_particles: the current number of particles being merged
Merzbild.compute_octantFunction
compute_octant(particle_v, v_middle)

Compute octant of particle velocity relative to a v_middle` The order of the octants is:

1. - - -
2. + - -
3. - + -
4. + + -
5. - - +
6. + - +
7. - + +
8. + + +

Positional arguments:

  • particle_v: the velocity of the particle
  • v_middle: the velocity relative to which the octant is computed

Returns:

The octant number

Merzbild.bin_bounds_inherit!Function
bin_bounds_inherit!(octree, bin_id, v_min_parent, v_max_parent, v_middle, octant)

Compute new bin bounds of one of the 8 octant sub-bins inheriting bounds of parent bin. The order of the octants is

1. - - -
2. + - -
3. - + -
4. + + -
5. - - +
6. + - +
7. - + +
8. + + +

Positional arguments:

  • octree: the OctreeN2Merge instance
  • bin_id: the index of the bin for which the velocity bounds are being recomputed
  • v_min_parent: the velocity vector of the lower bound of the velocities of the parent bin
  • v_max_parent: the velocity vector of the upper bound of the velocities of the parent bin
  • v_middle: the velocity across which the split is being performed
  • octant: the octant of the parent bin to which this bin corresponds
Merzbild.bin_bounds_recompute!Function
bin_bounds_recompute!(octree, bin_id, bs, be, particles)

Recompute bin bounds based on particle velocities by setting them to the smallest and largest velocities of the particles in each velocity direction.

Positional arguments:

  • octree: the OctreeN2Merge instance
  • bin_id: the index of the bin for which the velocity bounds are being recomputed
  • bs: index of the first particle in bin
  • be: index of the last particle in bin
  • particles: the ParticleVector instance of the particles to be merged
Merzbild.compute_v_mean!Function
compute_v_mean!(octree, bs, be, particles)

Compute mean velocity of particles in a bin.

Positional arguments:

  • octree: the OctreeN2Merge instance
  • bs: index of the first particle in bin
  • be: index of the last particle in bin
  • particles: the ParticleVector instance of the particles to be merged
Merzbild.compute_v_median!Function
compute_v_median!(octree, bs, be, particles)

Compute median velocity of particles in a bin. NOTE: allocates memory and is probably not fully correct!

Positional arguments:

  • octree: the OctreeN2Merge instance
  • bs: index of the first particle in bin
  • be: index of the last particle in bin
  • particles: the ParticleVector instance of the particles to be merged
Merzbild.get_new_bin_idFunction
get_new_bin_id(i, bin_id, Nbins)

Get index of a newly created bin once a bin with index bin_id is split into 8 sub-bins. The bin_id index is re-used for the 1-st sub-bin, and the other 7 sub-bins are tacked onto the end of the list of bins (so they have indices Nbins + 1, Nbins + 2, ..., where Nbins was the total number of octree bins before the split).

Positional arguments

  • i: index of sub-octant (ranging from 1 to 8) of the split bin for which to return a new bin index
  • bin_id: index of bin being split
  • Nbins: total number of octree bins before the split

Returns

Index of a newly created bin corresponding to a bin created from sub-octant i of bin bin_id.

Merzbild.split_bin!Function
split_bin!(octree, bin_id, particles)

Sort particles into sub-bins of a bin with index bin_id (by splitting it into octants), keeping track of which sub-bins particles end up in. Also sets the velocity bounds of the new bins.

Positional arguments:

  • octree: the OctreeN2Merge instance
  • bin_id: octree bin index
  • particles: the ParticleVector instance of the particles to be merged
Merzbild.compute_bin_props!Function
compute_bin_props!(octree, bin_id, particles)

Compute properties in a bin required for merging: total computational weight, mean velocity and position, standard deviation of particle velocities and positions.

Positional arguments:

  • octree: the OctreeN2Merge instance
  • bin_id: octree bin index
  • particles: the ParticleVector instance of the particles to be merged
Merzbild.get_bin_post_merge_npFunction
get_bin_post_merge_np(octree, bin_id)

Get number of post-merge particles in a bin: 2 if the number of particles in the bin is >= 2, otherwise the number of particles in the bin (0 or 1) is returned.

Positional arguments:

  • octree: the OctreeN2Merge instance
  • bin_id: octree bin index

Returns

The number of post-merge particles in a single octree bin (0, 1, or 2).

Merzbild.init_octree!Function
init_octree!(octree, particles, pia, cell, species)

Initialize the top bin in an octree by copying particle indices and setting bin bounds.

Positional arguments

  • octree: the OctreeN2Merge instance
  • particles: the ParticleVector instance containing the particles to be merged
  • pia: the ParticleIndexerArray instance
  • cell: the index of the grid cell in which particles are being merged
  • species: the index of the species being merged
Merzbild.merge_octree_N2_based!Function
merge_octree_N2_based!(rng, octree, particles, pia, cell, species, target_np)

Perform N:2 merging without checking whether particle positions end up outside of the simulation domain.

Positional arguments

  • rng: the random number generator instance
  • octree: the OctreeN2Merge instance
  • particles: the ParticleVector instance containing the particles to be merged
  • pia: the ParticleIndexerArray instance
  • cell: the index of the grid cell in which particles are being merged
  • species: the index of the species being merged
  • target_np: the target post-merge number of particles; the post-merge number of particles will not exceed this value but may be not exactly equal to it

Grids

Merzbild.Cell1DType
Cell1D

Cell element of a 1-D grid

Fields

  • xlo: coordinate of the left end of the element
  • xhi: coordinate of the right end of the element
  • V: cell volume
Merzbild.get_cellFunction
get_cell(grid1duniform::Grid1DUniform, x_pos)

Find in which cell of 1-D uniform grid the coordinate is located

Positional arguments

  • grid1duniform: the 1-D uniform grid
  • x_pos: the 3-D coordinate vector for the which the cell index is to be determined (only the first component is used)

Particle movement

Merzbild.convect_single_particle!Function
convect_single_particle!(rng, grid::Grid1DUniform, boundaries::MaxwellWalls1D, particle, species, Δt)

Convect a singe particle on a 1-D uniform grid.

Positional arguments

  • rng: the random number generator
  • grid: the grid on which the convection is performed
  • boundaries: the MaxwellWalls1D struct describing the boundaries (it is assumed that the wall with index 1 is the left wall and the wall with index 2 is the right wall)
  • particles: the particle to be convected
  • species: the index of the species being convected
  • Δt: the convection timestep

Particle-surface interactions

Merzbild.specular_reflection_x!Function
specular_reflection_x!(particle)

Perform specular reflection of a particle in the x direction.

Positional arguments

  • particle: the Particle instance for which the velocity is reflected
Merzbild.diffuse_reflection_x!Function
specular_reflection_x!(particle)

Perform diffuse reflection of a particle, assuming the wall is orthogonal to the x axis.

Positional arguments

  • rng: the random number generator
  • particle: the Particle instance for which the velocity is reflected
  • wall_reflection_v_sq: the squared thermal velocity of the species reflected at the wall temperature
  • wall_normal_sign: sign of the wall normal
  • wall_v: wall velocity vector
Merzbild.reflect_particle_x!Function
reflect_particle_x!(rng, particle, wall_reflection_v_sq, wall_normal_sign, wall_v, wall_accommodation)

Reflect particle from a Maxwell wall orthogonal to the x axis.

Positional arguments

  • rng: the random number generator
  • particle: the Particle instance for which the velocity is reflected
  • wall_reflection_v_sq: the squared thermal velocity of the species reflected at the wall temperature
  • wall_normal_sign: sign of the wall normal
  • wall_v: wall velocity vector
  • wall_accommodation: wall accommodation coefficient

Constants

Merzbild.eV_J_invConstant

1.0/eV[J], 1/J (or equivalent to how much 1 J is equal to expressed in eV)

Misc

Merzbild.compute_thermal_velocityFunction
compute_thermal_velocity(m, T)

Compute the thermal velocity $\sqrt(2kT/m)$.

Positional arguments

  • m: the molecular mass of the species
  • T: the temperature

Returns

The thermal velocity

Merzbild.binary_searchFunction
binary_search(x, val)

Binary search for value val in a sorted array x. Finds the position mid such that x[mid] < val < x[mid+1].

Positional arguments

  • x: the sorted array to be searched
  • val: the value to search for

Returns

  • -1 if val < x[1]
  • 0 if val > x[end]
  • Otherwise, returns the index mid satisfying x[mid] < val < x[mid+1]
Merzbild.linear_interpolationFunction
linear_interpolation(x, y, val, pos, lower_limit, upper_limit)

Perform linear interpolation of a tabulated function y(x), given a parameter value val, a sorted array of values of x and corresponding values of y, as well as the index of the closest values of x to val. In case val is outside of the limits of x, return placeholder values. That is, given that x[pos] < val < x[pos+1], we want to interpolate y(val) given that y[x[pos]] = y[pos], y[x[pos+1]] = y[pos+1].

Positional arguments

  • x: the vector of values of the parameter of the function to be interpolated
  • y: the vector of the corresponding function values
  • val: the value of the parameter at which the function is to be interpolated
  • pos: the index of the element in x such that x[pos] < val < x[pos+1], or -1 if val < x[1], 0 if val > x[end]
  • lower_limit: the value to return if val < x[1]
  • upper_limit: the value to return if val > x[end]

Returns

  • The linearly interpolated value of y(val) if x[1] <= val <= x[end]
  • lower_limit, if val < x[1]
  • upper_limit, if val > x[end]
Merzbild.compute_mixed_momentFunction
compute_mixed_moment(particles, pia, cell, species, powers; sum_scaler=1.0, res_scaler=1.0)

Compute mixed velocity moment of particles in a cell: $\sum_i w_i v_{x,i}^{p_x} v_{y,i}^{p_y} v_{z,i}^{p_z}$

Positional arguments

  • particles: the Vector of ParticleVectors containing all the particles in a simulation
  • pia: the ParticleIndexerArray instance
  • cell: the cell in which the moment is being computed
  • species: the species for which the mixed moment is being computed
  • powers: a Vector of the powers to which the x-, y-, and z-components of the velocity are to be raised

Keyword arguments

  • sum_scaler: during the summation over the particles, scale each summand by this factor potentially reduce round-off issues
  • res_scaler: scaling factor by which to multiply the result at the end

NNLS

Merzbild.solve!Function

Algorithm NNLS: NONNEGATIVE LEAST SQUARES

The original version of this code was developed by Charles L. Lawson and Richard J. Hanson at Jet Propulsion Laboratory 1973 JUN 15, and published in the book "SOLVING LEAST SQUARES PROBLEMS", Prentice-HalL, 1974. Revised FEB 1995 to accompany reprinting of the book by SIAM.

GIVEN AN M BY N MATRIX, A, AND AN M-VECTOR, B, COMPUTE AN N-VECTOR, X, THAT SOLVES THE LEAST SQUARES PROBLEM A * X = B SUBJECT TO X .GE. 0

Merzbild.construct_householder!Function

CONSTRUCTION AND/OR APPLICATION OF A SINGLE HOUSEHOLDER TRANSFORMATION.. Q = I + U*(U**T)/B

The original version of this code was developed by Charles L. Lawson and Richard J. Hanson at Jet Propulsion Laboratory 1973 JUN 12, and published in the book "SOLVING LEAST SQUARES PROBLEMS", Prentice-HalL, 1974. Revised FEB 1995 to accompany reprinting of the book by SIAM.

Merzbild.fastviewFunction

UnsafeVectorView only works for isbitstype types. For other types, we're already allocating lots of memory elsewhere, so creating a new View is fine.

This function looks type-unstable, but the isbitstype(T) test can be evaluated by the compiler, so the result is actually type-stable.

Fallback for non-contiguous arrays, for which UnsafeVectorView does not make sense.

Merzbild.solve_triangular_system!Function

The original version of this code was developed by Charles L. Lawson and Richard J. Hanson at Jet Propulsion Laboratory 1973 JUN 15, and published in the book "SOLVING LEAST SQUARES PROBLEMS", Prentice-HalL, 1974. Revised FEB 1995 to accompany reprinting of the book by SIAM.

Merzbild.UnsafeVectorViewType

Views in Julia still allocate some memory (since they need to keep a reference to the original array). This type allocates no memory and does no bounds checking. Use it with caution.

Merzbild.orthogonal_rotmatFunction

COMPUTE ORTHOGONAL ROTATION MATRIX.. The original version of this code was developed by Charles L. Lawson and Richard J. Hanson at Jet Propulsion Laboratory 1973 JUN 12, and published in the book "SOLVING LEAST SQUARES PROBLEMS", Prentice-HalL, 1974. Revised FEB 1995 to accompany reprinting of the book by SIAM.

COMPUTE.. MATRIX (C, S) SO THAT (C, S)(A) = (SQRT(A2+B2)) (-S,C) (-S,C)(B) ( 0 ) COMPUTE SIG = SQRT(A2+B2) SIG IS COMPUTED LAST TO ALLOW FOR THE POSSIBILITY THAT SIG MAY BE IN THE SAME LOCATION AS A OR B .

Merzbild.apply_householder!Function

CONSTRUCTION AND/OR APPLICATION OF A SINGLE HOUSEHOLDER TRANSFORMATION.. Q = I + U*(U**T)/B

The original version of this code was developed by Charles L. Lawson and Richard J. Hanson at Jet Propulsion Laboratory 1973 JUN 12, and published in the book "SOLVING LEAST SQUARES PROBLEMS", Prentice-HalL, 1974. Revised FEB 1995 to accompany reprinting of the book by SIAM.