AbstractParticle

class plasmapy.particles.particle_class.AbstractParticle[source]

Bases: ABC

An abstract base class that defines the interface for particles.

Attributes Summary

charge

Provide the particle's electric charge.

json_dict

A dictionary representation of the particle object that is JSON friendly (i.e. convertible to a JSON object).

mass

Provide the particle's mass.

Methods Summary

json_dump(fp, **kwargs)

Write 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

Provide the particle’s electric charge.

json_dict

A dictionary representation of the particle object that is JSON friendly (i.e. convertible to a JSON object).

The dictionary should maintain the following format so that ParticleJSONDecoder knows how to decode the resulting JSON object.

{
    "plasmapy_particle": {
        # string representation of the particle class
        "type": "Particle",
        # string representation of the module contains the particle class
        "module": "plasmapy.particles.particle_class",
        # date stamp of when the object was created
        "date_created": "2020-07-20 17:46:13 UTC",
        # parameters used to initialized the particle class
        "__init__": {
            # tuple of positional arguments
            "args": (),
            # dictionary of keyword arguments
            "kwargs": {},
        },
    }
}

Only the "__init__" entry should be modified by the subclass.

mass

Provide the particle’s mass.

Methods Documentation

json_dump(fp, **kwargs: dict[str, Any]) None[source]

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

Parameters:
json_dumps(**kwargs: object) str[source]

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