picongpu.pypicongpu.species.operation.densityprofile.plasmaramp.plasmaramp
This file is part of the PIConGPU. Copyright 2023 PIConGPU contributors Authors: Brian Edward Marre License: GPLv3+
Module Contents
Classes
abstract parent class for all plasma ramps |
- class picongpu.pypicongpu.species.operation.densityprofile.plasmaramp.plasmaramp.PlasmaRamp
Bases:
picongpu.pypicongpu.rendering.RenderedObject
abstract parent class for all plasma ramps
A plasma ramp describes ramp up of an edge of an initial density distribution
- check() None
check self, overwritten by child class
Perform checks if own parameters are valid. passes silently if everything is okay
- get_generic_profile_rendering_context() dict
retrieve a context valid for “any profile”
Problem: Plasma Ramps are polymorph, there are several distinct implementations, each of them has its respective schema.
In the template we need know which exact sub type of the general abstract type was used to generate the correct code.
This is difficult in JSON (particularly in a mustache-compatible way) since no type information is available in the schema.
Solution: We store which type was actually used in a wrapper in addition to actual data,
provided as usual by get_rendering_context() by the plasma ramp instance
If a generic plasma ramp is requested we us the wrapper schema for this class which contains the type meta information and the data content
E.g.:
{ "type": { "uniform": true, "gaussian": false, ... }, "data": DATA }
where DATA is the serialization as returned by get_rendering_context().
There are two context serialization methods for density profiles:
- get_rendering_context()
provided by RenderedObject parent class, serialization (“context building”) performed by _get_serialized()
_get_serialized() implemented in every plasma ramp
checks against schema of respective plasma ramp
- returned context is a representation of
exactly this plasma ramp
(left empty == not implemented in parent PlasmaRamp)
- get_generic_profile_rendering_context()
implemented in parent PlasmaRamp
returned representation is generic for any plasma ramp (i.e. contains which type is actually used)
passes information from get_rendering_context() through
returned representation is designed for easy use with templating engine mustache
- get_rendering_context() dict
get rendering context representation of this object
delegates work to _get_serialized and invokes checks performed by check_context_for_type(). :raise ValidationError: on schema violiation :raise RuntimeError: on schema not found :return: self as rendering context
- static check_context_for_type(type_to_check: type, context: dict) None
check if the given context is valid for the given type
Raises on error, passes silently if okay.
- Raises:
ValidationError – on schema violiation
RuntimeError – on schema not found