PlasmaPy Plasma
Attention
This feature is under development. Breaking changes may occur in the future.
Overview
One of the core classes in PlasmaPy is
Plasma
. In order to make it easy to work with
different plasma data in PlasmaPy, the
Plasma
object provides a number of methods for
commonly existing plasmas in nature.
All Plasma objects are created using the Plasma factory
Plasma
.
A number of plasma data structures are supported by subclassing this base object. See Plasma Subclasses to see a list of all of them.
Creating Plasma Objects
Plasma objects are constructed using the special factory class
Plasma
:
>>> x = plasmapy.plasma.Plasma(T_e=T_e,
... n_e=n_e,
... Z=Z,
... particle=particle)
The result of a call to Plasma
will be
either a GenericPlasma
object, or a
subclass of
GenericPlasma
which deals with a specific
type of data, e.g. PlasmaBlob
or
Plasma3D
(see Plasma Subclasses
to see a list of all of them).
- class plasmapy.plasma.plasma_factory.PlasmaFactory(
- default_widget_type=None,
- additional_validation_functions=None,
- registry=None,
Plasma factory class. Used to create a variety of Plasma objects. Valid plasma structures are specified by registering them with the factory.
Attention
This feature is under development. Breaking changes may occur in the future.
Using Plasma Objects
Once a Plasma object has been created using
Plasma
it will be a instance or a
subclass of the GenericPlasma
class. The
documentation of
GenericPlasma
lists the attributes and
methods that are available on all Plasma objects.
Plasma Classes
Defined in plasmapy.plasma.sources
are a set of
GenericPlasma
subclasses which convert the
keyword arguments data to the standard
GenericPlasma
interface. These subclasses also
provide a method, which describes to the
Plasma
factory
which the data match its plasma data structure.
Classes
Registration class for |
|
|
Representation of the analytical Lundquist solution for force-free magnetic flux ropes [Lundquist, 1950]. |
|
A Generic Plasma class. |
|
Define a Harris Sheet Equilibrium. |
Plasma Subclasses
The Plasma3D
class is a basic
structure to contain spatial information about a plasma. To initialize
a Plasma3D system, first create an instance of the
Plasma3D
class and then set
the density
,
momentum
,
pressure
and
magnetic_field
.
Note
This feature is currently under development.
The PlasmaBlob
class is a
basic structure to contain just plasma parameter information about a
plasma with no associated spatial or temporal scales. To initialize a
PlasmaBlob
system, call
it with arguments: electron temperature (T_e
) and electron density
(n_e
). You may also optionally define the ionization (Z
), and
relevant plasma particle (particle
).
Note
This feature is currently under development.
Classes
|
Core class for describing and calculating plasma parameters with spatial dimensions. |
|
Class for describing and calculating plasma parameters without spatial/temporal description. |
Writing a new Plasma subclass
Any subclass of GenericPlasma
which
defines a method named is_datasource_for
will automatically be
registered with the
Plasma
factory. The
is_datasource_for
method describes the form of the data for which
the GenericPlasma
subclass is valid. For
example, it might check the number and types of keyword arguments. This
makes it straightforward to define your own
GenericPlasma
subclass for a new data
structure or a custom data source like simulated data. These classes
only have to be imported for this to work, as demonstrated by the
following example.
import astropy.units as u
import plasmapy.plasma
class FuturePlasma(plasmapy.plasma.GenericPlasma):
def __init__(self, **kwargs):
super().__init__(**kwargs)
# Specify a classmethod that determines if the input data matches
# this new subclass
@classmethod
def is_datasource_for(cls, **kwargs):
"""
Determines if any of keyword arguments have a dimensionless value.
"""
for _, value in kwargs.items():
try:
if value.unit == u.dimensionless_unscaled:
return True
except AttributeError:
pass
return False
This class will now be available through the
Plasma
factory as long
as this class has been defined, i.e. imported into the current session.
If you do not want to create a method named is_datasource_for
you
can manually register your class and matching method using the following
method.
import plasmapy.plasma
plasmapy.plasma.Plasma.register(FuturePlasma, FuturePlasma.some_matching_method)
API
Sub-Packages & Modules
Classes for representing cylindrical equilibria. |
|
Functionality for representing one-dimensional equilibria. |
|
Exceptions and warnings for functionality defined in |
|
Defines the AbstractGrid class and child classes. |
|
Module for defining the base framework of the plasma classes. |
|
Module for defining the framework around the plasma factory. |
|
Classes
Registration class for |
|
|
Representation of the analytical Lundquist solution for force-free magnetic flux ropes [Lundquist, 1950]. |
|
A Generic Plasma class. |
|
Define a Harris Sheet Equilibrium. |
Variables & Attributes
Plasma factory class. |