DimensionlessParticle
- class plasmapy.particles.particle_class.DimensionlessParticle( )[source]
Bases:
AbstractParticle
A class to represent dimensionless custom particles.
This class may be used, for example, to represent a particle in a dimensionless particle-in-cell simulation.
- Parameters:
mass (positive real number, keyword-only, default:
nan
) – The mass of the dimensionless particle.charge (real number, keyword-only, default:
nan
) – The electric charge of the dimensionless particle.symbol (str, keyword-only, optional) – The symbol to be assigned to the dimensionless particle.
See also
Notes
DimensionlessParticle
instances are not considered particle-like because dimensionless particles cannot uniquely identify a physical particle without normalization information.Examples
>>> from plasmapy.particles import DimensionlessParticle >>> particle = DimensionlessParticle(mass=1.0, charge=-1.0, symbol="ξ") >>> particle.mass 1.0 >>> particle.charge -1.0 >>> particle.symbol 'ξ'
Attributes Summary
The dimensionless charge of the
DimensionlessParticle
.A
json
friendly dictionary representation of theDimensionlessParticle
.The dimensionless mass of the
DimensionlessParticle
.The symbol assigned to the
DimensionlessParticle
.Methods Summary
json_dump
(fp, **kwargs)Write the particle's
json_dict
to thefp
file object usingjson.dump
.json_dumps
(**kwargs)Serialize the particle's
json_dict
into a JSON formattedstr
usingjson.dumps
.Attributes Documentation
- charge
The dimensionless charge of the
DimensionlessParticle
.
- json_dict
A
json
friendly dictionary representation of theDimensionlessParticle
.See
json_dict
for more details.Examples
>>> from plasmapy.particles import DimensionlessParticle >>> dimensionless_particle = DimensionlessParticle(mass=1.0, charge=-1.0) >>> dimensionless_particle.json_dict {'plasmapy_particle': {'type': 'DimensionlessParticle', 'module': 'plasmapy.particles.particle_class', 'date_created': '...', '__init__': {'args': (), 'kwargs': {'mass': 1.0, 'charge': -1.0, 'symbol': 'DimensionlessParticle(mass=1.0, charge=-1.0)'}}}} >>> dimensionless_particle = DimensionlessParticle(mass=1.0) >>> dimensionless_particle.json_dict {'plasmapy_particle': {'type': 'DimensionlessParticle', 'module': 'plasmapy.particles.particle_class', 'date_created': '...', '__init__': {'args': (), 'kwargs': {'mass': 1.0, 'charge': nan, 'symbol': 'DimensionlessParticle(mass=1.0, charge=nan)'}}}}
- mass
The dimensionless mass of the
DimensionlessParticle
.
- symbol
The symbol assigned to the
DimensionlessParticle
.If no symbol was defined, then return the value given by
repr
.
Methods Documentation
- json_dump(fp, **kwargs: dict[str, Any]) None
Write the particle’s
json_dict
to thefp
file object usingjson.dump
.- Parameters:
fp (file object) – Destination file object to write the JSON serialized
json_dict
.**kwargs – Any keyword accepted by
json.dump
.
- json_dumps(**kwargs: object) str
Serialize the particle’s
json_dict
into a JSON formattedstr
usingjson.dumps
.- Parameters:
**kwargs – Any keyword accepted by
json.dumps
.- Returns:
JSON formatted
str
.- Return type: