DimensionlessParticle

class plasmapy.particles.DimensionlessParticle(*, mass: numbers.Real = None, charge: numbers.Real = None)

Bases: plasmapy.particles.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, optional) – The mass of the dimensionless particle.
  • charge (real number, keyword-only, optional) – The electric charge of the dimensionless particle.

Notes

If the charge or mass is not specified, then the corresponding value will be set to numpy.nan.

Examples

>>> from plasmapy.particles import DimensionlessParticle
>>> dimensionless_particle = DimensionlessParticle(mass=1.0, charge=-1.0)
>>> dimensionless_particle.mass
1.0
>>> dimensionless_particle.charge
-1.0

Attributes Summary

charge Return the dimensionless charge of the particle.
json_dict A json friendly dictionary representation of the particle.
mass Return the dimensionless mass of the particle.

Methods Summary

json_dump(fp, **kwargs) Writes the particle’s json_dict to the fp file object using json.dump.
json_dumps(**kwargs) Serialize the particle’s json_dict into a JSON formatted str using json.dumps.

Attributes Documentation

charge

Return the dimensionless charge of the particle.

json_dict

A json friendly dictionary representation of the particle. (see AbstractParticle.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}}}}
>>> 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}}}}
mass

Return the dimensionless mass of the particle.

Methods Documentation

json_dump(fp, **kwargs)

Writes the particle’s json_dict to the fp file object using json.dump.

Parameters:
json_dumps(**kwargs) → str

Serialize the particle’s json_dict into a JSON formatted str using json.dumps.

Parameters:**kwargs – Any keyword accepted by json.dumps.
Returns:JSON formatted str.
Return type:str