Documentation for the Package extended_stencil¶
Module extended_stencil.dispersion¶
-
class
extended_stencil.dispersion.Dispersion(runinit2=True)¶ This class is used to define objects which understand the dispersion relation of a stencil. As it is an abstract base class, only its subclasses are really useful.
Note
It implements a mechanism to lazily initialize parts of the object, in order to keep the object pickleable.
The initializer should only create pickleable state.
Parameters: runinit2 (bool) – Run second initializer Dispersion.init2()immediately. Default is False.-
Y= 1.0¶
-
Z= 1.0¶
-
coefficients¶ This read-only property returns the full list of coefficients defining the numerical dispersion relation
-
dim= 0¶
-
dt_multiplier= 1.0¶
-
dt_ok(parameters)¶ This function represents the optimization constraint that the time step must fulfil the CFL condition
Parameters: parameters (numpy.ndarray) – Array containing the parameters.
-
dx= 1.0¶
-
init2()¶ Second initializer which must be used to create unpickleable state on lazy initialization.
-
norm(parameters)¶ This method returns the norm of the dispersion relation with the given parameters.
Parameters: parameters (numpy.ndarray) – Array containing the parameters.
-
omega(parameters)¶ This function returns the function \(\omega(\vec{k})\)
Parameters: parameters (numpy.ndarray) – Array containing the parameters.
-
omega_output(fname, parameters)¶ This method writes the dispersion relation to the file fname.
Parameters: - fname (string) – Filename
- parameters (numpy.ndarray) – Array containing the parameters.
-
parameters¶ This read/write-property manages the parameters to the numerical dispersion relation. Setting the property requires an array of the correct length.
Parameters: parameters (numpy.ndarray) – Array containing the parameters.
-
sqrtarg¶ This read-only property represents the term under the square-root on the right hand side of \(s_\omega=\sqrt{\sum_i s_i^2 A_i}\).
-
sqrtres¶ This read-only property represents the right hand side of \(s_\omega=\sqrt{\sum_i s_i^2 A_i}\).
-
stencil= None¶
-
stencil_ok(parameters)¶ This function represents the optimization constraint that \(s_\omega=\sqrt{\sum_i s_i^2 A_i}\leq 1\).
Parameters: parameters (numpy.ndarray) – Array containing the parameters.
-
w= 1.0¶
-
Module extended_stencil.optimize¶
-
class
extended_stencil.optimize.Optimize(args)¶ Class that contains the main optimization logic.
Parameters: args (namespace) – Namespace object containing all the arguments. -
omega_output(fname, x)¶ Write resulting dispersion relation through
extended_stencil.dispersion.Dispersion.omega_output().
-
optimize()¶ Execute the optimization.
This will loop through the grid of starting values and return the best optimization result.
-
Module extended_stencil.stencil¶
-
class
extended_stencil.stencil.Stencil¶ Parent class representing all Stencils
-
Coefficients= None¶
-
Parameters= None¶
-
coefficients(args)¶ Method that converts the given parameters into the stencil coefficients.
Parameters: args (iterable) – iterable of parameters
-
dof¶ Read-only property giving the number of the degrees of freedom.
-
classmethod
get_stencil(args)¶ This method will do two things:
- Interpret the given args in order to determine the set of flags that the user wants
- Find and instantiate a
Stencilsubclass that has the requested flags
Parameters: args (namespace) – Namespace object containing all the arguments. Returns: Object of a subclass of StencilReturn type: Stencil
-
classmethod
register_subclasses(sub=None)¶ This method will walk the tree of subclasses of
Stenciland fillStencil.stencils. This method runs recursively.Parameters: sub ( Stencil) – Start from thus subclass
-
stencils= {}¶
-
-
class
extended_stencil.stencil.StencilCylinder3D¶ Three dimensional stencil that is the same on two out of three axes.
-
Flags= frozenset({<StencilFlags.DIM3: 1>, <StencilFlags.CYLINDERSYM: 4>})¶
-
-
class
extended_stencil.stencil.StencilCylinderDivFree3D¶ Three dimensional stencil that is the same on two out of three axes and preserves \(\operatorname{div}\vec{B}=0\).
-
Flags= frozenset({<StencilFlags.DIM3: 1>, <StencilFlags.DIVFREE: 2>, <StencilFlags.CYLINDERSYM: 4>})¶
-
-
class
extended_stencil.stencil.StencilDivFree2D¶ Two dimensional stencil that preserves \(\operatorname{div}\vec{B}=0\).
-
Flags= frozenset({<StencilFlags.DIVFREE: 2>, <StencilFlags.DIM2: 0>})¶
-
-
class
extended_stencil.stencil.StencilDivFree3D¶ Three dimensional stencil that preserves \(\operatorname{div}\vec{B}=0\).
-
Flags= frozenset({<StencilFlags.DIM3: 1>, <StencilFlags.DIVFREE: 2>})¶
-
-
class
extended_stencil.stencil.StencilFlags¶ An enumeration representing various flags a Stencil can carry.
-
CYLINDERSYM= 4¶
-
DIM2= 0¶
-
DIM3= 1¶
-
DIVFREE= 2¶
-
ISOTROPIC= 3¶
-
SYMMETRICBETA= 5¶
-
-
class
extended_stencil.stencil.StencilFree2D¶ Most general two-dimensional stencil
-
Coefficients= namedarray(['dt', 'alphax', 'alphay', 'betaxy', 'betayx', 'deltax', 'deltay'])¶
-
Flags= frozenset({<StencilFlags.DIM2: 0>})¶
-
-
class
extended_stencil.stencil.StencilFree3D¶ Most general three-dimensional stencil
-
Coefficients= namedarray(['dt', 'alphax', 'alphay', 'alphaz', 'betaxy', 'betaxz', 'betayx', 'betayz', 'betazx', 'betazy', 'deltax', 'deltay', 'deltaz'])¶
-
Flags= frozenset({<StencilFlags.DIM3: 1>})¶
-
-
class
extended_stencil.stencil.StencilIsotropic2D¶ A two dimensional stencil that is the same on all axis.
-
Flags= frozenset({<StencilFlags.SYMMETRICBETA: 5>, <StencilFlags.ISOTROPIC: 3>, <StencilFlags.DIM2: 0>})¶
-
-
class
extended_stencil.stencil.StencilIsotropic3D¶ Three dimensional stencil with symmetric \(\beta_{ij}\) that is the same on all axes.
-
Flags= frozenset({<StencilFlags.SYMMETRICBETA: 5>, <StencilFlags.DIM3: 1>, <StencilFlags.ISOTROPIC: 3>})¶
-
-
class
extended_stencil.stencil.StencilIsotropicDivFree2D¶ A two dimensional stencil that is the same on each axis and preserves \(\operatorname{div}\vec{B}=0\).
-
Flags= frozenset({<StencilFlags.SYMMETRICBETA: 5>, <StencilFlags.ISOTROPIC: 3>, <StencilFlags.DIVFREE: 2>, <StencilFlags.DIM2: 0>})¶
-
-
class
extended_stencil.stencil.StencilIsotropicDivFree3D¶ Three dimensional stencil with symmetric \(\beta_{ij}\) that is the same on all axes and preserves \(\operatorname{div}\vec{B}=0\).
-
Flags= frozenset({<StencilFlags.SYMMETRICBETA: 5>, <StencilFlags.DIM3: 1>, <StencilFlags.DIVFREE: 2>, <StencilFlags.ISOTROPIC: 3>})¶
-
-
class
extended_stencil.stencil.StencilSymmetric2D¶ Two dimensional stencil with symmetric \(\beta_{ij}\).
-
Flags= frozenset({<StencilFlags.SYMMETRICBETA: 5>, <StencilFlags.DIM2: 0>})¶
-
-
class
extended_stencil.stencil.StencilSymmetric3D¶ Three dimensional stencil with symmetric \(\beta_{ij}\).
-
Flags= frozenset({<StencilFlags.SYMMETRICBETA: 5>, <StencilFlags.DIM3: 1>})¶
-
-
extended_stencil.stencil.get_stencil(args)¶ Module level function that will call
Stencil.get_stencil().
-
class
extended_stencil.stencil.namedarray(field_names)¶ Class representing a set of field names such that any list or array of numbers can be casted into a
numpy.recarrayParameters: field_names (list) – List of field names -
__call__(args)¶ Convert a list or an array into a
numpy.recarrayParameters: args (iterable) – List or Array to be converted
-
convert(other)¶ Convert a
numpy.recarrayto anumpy.recarraywith additional fields, filling the additional fields with 0.Parameters: other ( numpy.recarray) – Thenumpy.recarrayto be converted.
-
Module extended_stencil.weight¶
-
extended_stencil.weight.weight_xaxis()¶ Factory function that returns a function set_weight_xaxis which acts on an object of
extended_stencil.dispersion.Dispersionand applies a weight function that only cares about the \(k_x\)-axis
-
extended_stencil.weight.weight_xaxis_soft(width=0.1)¶ Factory function that returns a function set_weight_xaxis_soft which acts on an object of
extended_stencil.dispersion.Dispersionand applies a weight function that only cares about a region close to the \(k_x\)-axis