Skip to content

plasmacoll.markers

Marker storage that :meth:~plasmacoll.mcc.MonteCarloCollisions.collide_species works on.

Any object with positions, velocities and weights arrays and remove/add methods (the :class:MarkerSet protocol) can be collided, so a particle-in-cell code can pass its own particle containers through a thin adapter. :class:ParticleArrays is a simple implementation that keeps the markers in three arrays and compacts them on removal.

Classes

NameDescription
MarkerSetThe markers of one species, as the collision operator needs them.
ParticleArraysMarkers of one species held in three arrays.

MarkerSetclass#

class MarkerSet(Protocol)

Bases: Protocol

The markers of one species, as the collision operator needs them.

positions has shape (N, ndim) (any ndim, read only by density profiles and copied to products), velocities shape (N, 3) in m/s, weights shape (N,): the number of physical particles per marker. Collisions update rows of velocities in place.

positionsproperty#

positions: Array

Return the marker positions, shape (N, ndim).

velocitiesproperty#

velocities: Array

Return the marker velocities, shape (N, 3), updated in place.

weightsproperty#

weights: Array

Return the marker weights, shape (N,).

addmethod#

def add(positions: Array, velocities: Array, weights: Array) -> None

Append new markers.

removemethod#

def remove(mask: Array) -> None

Remove the markers flagged in the boolean mask of length N.

ParticleArraysclassdataclass#

class ParticleArrays(positions: Array, velocities: Array, weights: Array)

Markers of one species held in three arrays.

Attributes

NameTypeDescription
positionsArrayPositions, shape (N, ndim).
velocitiesArrayVelocities in m/s, shape (N, 3).
weightsArrayPhysical particles per marker, shape (N,).

positionsattributeinstance attribute#

positions: Array

velocitiesattributeinstance attribute#

velocities: Array

weightsattributeinstance attribute#

weights: Array

total_weightproperty#

total_weight: float

Return the number of physical particles the markers represent.

addmethod#

def add(positions: Array, velocities: Array, weights: Array) -> None

Append new markers.

emptymethodclassmethod#

def empty(ndim: int = 1) -> ParticleArrays

Return a set without markers, with ndim position components.

maxwellianmethodclassmethod#

def maxwellian(num: int, mass: float, temperature: float, weight: float = 1.0, drift: tuple[float, float, float] = (0.0, 0.0, 0.0), ndim: int = 1, rng: Any = None, seed: int | None = None) -> ParticleArrays

Sample num markers from a drifting Maxwellian, all at the origin.

Parameters

NameTypeDefaultDescription
numintrequiredThe number of markers.
massfloatrequiredParticle mass in kg.
temperaturefloatrequiredTemperature in K; see :func:plasmacoll.constants.ev_to_kelvin.
weightfloat1.0Physical particles per marker.
drifttuple[float, float, float](0.0, 0.0, 0.0)Mean velocity in m/s.
ndimint1Number of position components.
rngAnyNoneA NumPy or CuPy Generator; one seeded with seed if None.
seedint | NoneNoneSeed of the generator made when rng is None.

mean_energy_evmethod#

def mean_energy_ev(mass: float) -> float

Return the weighted mean kinetic energy in eV (0 without markers).

removemethod#

def remove(mask: Array) -> None

Remove the markers flagged in the boolean mask.

temperaturemethod#

def temperature(mass: float) -> float

Return the kinetic temperature in K about the mean velocity (0 if empty).