boutpp package#

Module contents#

class boutpp.Coordinates#

Contains information about geometry, such as metric tensors

Bxy#

libboutpp.Field2D

Type:

Bxy

G1#

libboutpp.Field2D

Type:

G1

G1_11#

libboutpp.Field2D

Type:

G1_11

G1_12#

libboutpp.Field2D

Type:

G1_12

G1_13#

libboutpp.Field2D

Type:

G1_13

G1_22#

libboutpp.Field2D

Type:

G1_22

G1_23#

libboutpp.Field2D

Type:

G1_23

G1_33#

libboutpp.Field2D

Type:

G1_33

G2#

libboutpp.Field2D

Type:

G2

G2_11#

libboutpp.Field2D

Type:

G2_11

G2_12#

libboutpp.Field2D

Type:

G2_12

G2_13#

libboutpp.Field2D

Type:

G2_13

G2_22#

libboutpp.Field2D

Type:

G2_22

G2_23#

libboutpp.Field2D

Type:

G2_23

G2_33#

libboutpp.Field2D

Type:

G2_33

G3#

libboutpp.Field2D

Type:

G3

G3_11#

libboutpp.Field2D

Type:

G3_11

G3_12#

libboutpp.Field2D

Type:

G3_12

G3_13#

libboutpp.Field2D

Type:

G3_13

G3_22#

libboutpp.Field2D

Type:

G3_22

G3_23#

libboutpp.Field2D

Type:

G3_23

G3_33#

libboutpp.Field2D

Type:

G3_33

IntShiftTorsion#

libboutpp.Field2D

Type:

IntShiftTorsion

J#

libboutpp.Field2D

Type:

J

ShiftTorsion#

libboutpp.Field2D

Type:

ShiftTorsion

dx#

libboutpp.Field2D

Type:

dx

dy#

libboutpp.Field2D

Type:

dy

dz#

libboutpp.Field2D

Type:

dz

g11#

libboutpp.Field2D

Type:

g11

g12#

libboutpp.Field2D

Type:

g12

g13#

libboutpp.Field2D

Type:

g13

g22#

libboutpp.Field2D

Type:

g22

g23#

libboutpp.Field2D

Type:

g23

g33#

libboutpp.Field2D

Type:

g33

g_11#

libboutpp.Field2D

Type:

g_11

g_12#

libboutpp.Field2D

Type:

g_12

g_13#

libboutpp.Field2D

Type:

g_13

g_22#

libboutpp.Field2D

Type:

g_22

g_23#

libboutpp.Field2D

Type:

g_23

g_33#

libboutpp.Field2D

Type:

g_33

boutpp.D2DX2(Field3D field, outloc=u'CELL_DEFAULT', method=u'DIFF_DEFAULT', region=u'RGN_NOBNDRY')#

Compute the derivative D2DX2

Parameters:
  • field (Field3D) – The Field3D object of which to calculate the derivative

  • outloc (string) – The location where the derivative is expected. Defaults to the same as field.

  • method (string) – The method to calculate the derivative.

  • region (string) – The region for which to calculate the derivative

Returns:

The computed D2DX2 derivative

Return type:

Field3D

boutpp.D2DXDY(Field3D field, outloc=u'CELL_DEFAULT', method=u'DIFF_DEFAULT', region=u'RGN_NOBNDRY')#

Compute the derivative D2DXDY

Parameters:
  • field (Field3D) – The Field3D object of which to calculate the derivative

  • outloc (string) – The location where the derivative is expected. Defaults to the same as field.

  • method (string) – The method to calculate the derivative.

  • region (string) – The region for which to calculate the derivative

Returns:

The computed D2DXDY derivative

Return type:

Field3D

boutpp.D2DXDZ(Field3D field, outloc=u'CELL_DEFAULT', method=u'DIFF_DEFAULT', region=u'RGN_NOBNDRY')#

Compute the derivative D2DXDZ

Parameters:
  • field (Field3D) – The Field3D object of which to calculate the derivative

  • outloc (string) – The location where the derivative is expected. Defaults to the same as field.

  • method (string) – The method to calculate the derivative.

  • region (string) – The region for which to calculate the derivative

Returns:

The computed D2DXDZ derivative

Return type:

Field3D

boutpp.D2DY2(Field3D field, outloc=u'CELL_DEFAULT', method=u'DIFF_DEFAULT', region=u'RGN_NOBNDRY')#

Compute the derivative D2DY2

Parameters:
  • field (Field3D) – The Field3D object of which to calculate the derivative

  • outloc (string) – The location where the derivative is expected. Defaults to the same as field.

  • method (string) – The method to calculate the derivative.

  • region (string) – The region for which to calculate the derivative

Returns:

The computed D2DY2 derivative

Return type:

Field3D

boutpp.D2DYDZ(Field3D field, outloc=u'CELL_DEFAULT', method=u'DIFF_DEFAULT', region=u'RGN_NOBNDRY')#

Compute the derivative D2DYDZ

Parameters:
  • field (Field3D) – The Field3D object of which to calculate the derivative

  • outloc (string) – The location where the derivative is expected. Defaults to the same as field.

  • method (string) – The method to calculate the derivative.

  • region (string) – The region for which to calculate the derivative

Returns:

The computed D2DYDZ derivative

Return type:

Field3D

boutpp.D2DZ2(Field3D field, outloc=u'CELL_DEFAULT', method=u'DIFF_DEFAULT', region=u'RGN_NOBNDRY')#

Compute the derivative D2DZ2

Parameters:
  • field (Field3D) – The Field3D object of which to calculate the derivative

  • outloc (string) – The location where the derivative is expected. Defaults to the same as field.

  • method (string) – The method to calculate the derivative.

  • region (string) – The region for which to calculate the derivative

Returns:

The computed D2DZ2 derivative

Return type:

Field3D

boutpp.DDX(Field3D field, outloc=u'CELL_DEFAULT', method=u'DIFF_DEFAULT', region=u'RGN_NOBNDRY')#

Compute the derivative DDX

Parameters:
  • field (Field3D) – The Field3D object of which to calculate the derivative

  • outloc (string) – The location where the derivative is expected. Defaults to the same as field.

  • method (string) – The method to calculate the derivative.

  • region (string) – The region for which to calculate the derivative

Returns:

The computed DDX derivative

Return type:

Field3D

boutpp.DDY(Field3D field, outloc=u'CELL_DEFAULT', method=u'DIFF_DEFAULT', region=u'RGN_NOBNDRY')#

Compute the derivative DDY

Parameters:
  • field (Field3D) – The Field3D object of which to calculate the derivative

  • outloc (string) – The location where the derivative is expected. Defaults to the same as field.

  • method (string) – The method to calculate the derivative.

  • region (string) – The region for which to calculate the derivative

Returns:

The computed DDY derivative

Return type:

Field3D

boutpp.DDZ(Field3D field, outloc=u'CELL_DEFAULT', method=u'DIFF_DEFAULT', region=u'RGN_NOBNDRY')#

Compute the derivative DDZ

Parameters:
  • field (Field3D) – The Field3D object of which to calculate the derivative

  • outloc (string) – The location where the derivative is expected. Defaults to the same as field.

  • method (string) – The method to calculate the derivative.

  • region (string) – The region for which to calculate the derivative

Returns:

The computed DDZ derivative

Return type:

Field3D

boutpp.Delp2(Field3D a)#
boutpp.Div_par(Field3D field, outloc=u'CELL_DEFAULT', method=u'DIFF_DEFAULT')#

Compute the derivative Div_par

Parameters:
  • field (Field3D) – The Field3D object of which to calculate the derivative

  • outloc (string) – The location where the derivative is expected. Defaults to the same as field.

  • method (string) – The method to calculate the derivative.

Returns:

The computed Div_par derivative

Return type:

Field3D

boutpp.FDDX(Field3D velocity, Field3D field, outloc=u'CELL_DEFAULT', method=u'DIFF_DEFAULT', region=u'RGN_NOBNDRY')#

Compute the flux derivative FDDX

Parameters:
  • velocity (Field3D) – The Field3D object of which the field is advected

  • field (Field3D) – The Field3D object of which to calculate the derivative

  • outloc (string) – The location where the derivative is expected. Defaults to the same as field.

  • method (string) – The method to calculate the derivative.

  • region (string) – The region for which to calculate the derivative

Returns:

The computed FDDX derivative

Return type:

Field3D

boutpp.FDDY(Field3D velocity, Field3D field, outloc=u'CELL_DEFAULT', method=u'DIFF_DEFAULT', region=u'RGN_NOBNDRY')#

Compute the flux derivative FDDY

Parameters:
  • velocity (Field3D) – The Field3D object of which the field is advected

  • field (Field3D) – The Field3D object of which to calculate the derivative

  • outloc (string) – The location where the derivative is expected. Defaults to the same as field.

  • method (string) – The method to calculate the derivative.

  • region (string) – The region for which to calculate the derivative

Returns:

The computed FDDY derivative

Return type:

Field3D

boutpp.FDDZ(Field3D velocity, Field3D field, outloc=u'CELL_DEFAULT', method=u'DIFF_DEFAULT', region=u'RGN_NOBNDRY')#

Compute the flux derivative FDDZ

Parameters:
  • velocity (Field3D) – The Field3D object of which the field is advected

  • field (Field3D) – The Field3D object of which to calculate the derivative

  • outloc (string) – The location where the derivative is expected. Defaults to the same as field.

  • method (string) – The method to calculate the derivative.

  • region (string) – The region for which to calculate the derivative

Returns:

The computed FDDZ derivative

Return type:

Field3D

class boutpp.Field2D#

The Field2D class

applyBoundary(self, boundary=None, time=None)#

Set the boundaries of a Field2D. Only one of both arguments can be provided. If no value is provided, the default boundary is applied.

Parameters:
  • boundary (string, optional) – The boundary to be set. Has to be a valid boundary type, e.g. “neumann”.

  • time (float, optional) – The time to be used by the boundary, if time dependent boundary conditions are used.

ddt(self, val=None)#

Get or set the time derivative

Parameters:

val (Field2D, optional) – If set, set the time derivative to val

Returns:

The time derivative

Return type:

Field2D

classmethod fromBoutOutputs(cls, outputs, name, tind=-1, mesh=None, ignoreDataType=False)#

Create a Field2D from reading in a datafile via collect.

Parameters:
  • outputs (BoutOutputs) – object to read from

  • tind (int, optional) – time slice to read

  • mesh (Mesh, optional) – if not defined, use global mesh

  • ignoreDataType (bool, optional) – Do not fail if data is not float64

  • **kwargs – remaining arguments are passed to collect

classmethod fromCollect(cls, name, tind=-1, mesh=None, ignoreDataType=False, **kwargs)#

Create a Field2D from reading in a datafile via collect.

Parameters:
  • tind (int, optional) – time slice to read

  • mesh (Mesh, optional) – if not defined, use global mesh

  • ignoreDataType (bool, optional) – Do not fail if data is not float64

  • **kwargs – remaining arguments are passed to collect

classmethod fromMesh(cls, mesh=None)#

Create a Field2D.

Parameters:

mesh (Mesh, optional) – The mesh of the Field2D. If None, use global mesh

get(self)#

Get all data of the Field2D

Returns:

A 2D numpy array with the data of the Field2D

Return type:

array

getAll(self)#

Get all data of the Field2D

Returns:

A 2D numpy array with the data of the Field2D

Return type:

array

getLocation(self)#

Get the location of the Field2D

Returns:

Representation of the field’s location.

Return type:

string

getMesh(self)#

Get the mesh associated with the field

Returns:

The mesh of the field

Return type:

bc.Mesh

isAllocated(self)#

Check if the Field2D has its own datablock allocated

Returns:

whether the Field is allocated

Return type:

bool

set(self, data, ignoreDataType=False)#

Set all data of the Field2D

Parameters:
  • data (array_like) – The data to be set

  • ignoreDataType (bool, optional) – Ignore if data is off different type to BoutReal

setAll(self, data, ignoreDataType=False)#

Set all data of the Field2D

Parameters:
  • data (array_like) – The data to be set

  • ignoreDataType (bool, optional) – Ignore if data is off different type to BoutRealxx

setLocation(self, location)#

Set the location of the Field2D This does not do any modification of the data.

Parameters:

location (string) – The location to be set, e.g. “YLOW” or “CELL_YLOW” are supported.

class boutpp.Field3D#

The Field3D class

applyBoundary(self, boundary=None, time=None)#

Set the boundaries of a Field3D. Only one of both arguments can be provided. If no value is provided, the default boundary is applied.

Parameters:
  • boundary (string, optional) – The boundary to be set. Has to be a valid boundary type, e.g. “neumann”.

  • time (float, optional) – The time to be used by the boundary, if time dependent boundary conditions are used.

applyParallelBoundary(self, boundary=None, time=None)#

Set the boundaries of a Field3D. Only one of both arguments can be provided. If no value is provided, the default boundary is applied.

Parameters:
  • boundary (string, optional) – The boundary to be set. Has to be a valid boundary type, e.g. “neumann”.

  • time (float, optional) – The time to be used by the boundary, if time dependent boundary conditions are used.

ddt(self, val=None)#

Get or set the time derivative

Parameters:

val (Field3D, optional) – If set, set the time derivative to val

Returns:

The time derivative

Return type:

Field3D

classmethod fromBoutOutputs(cls, outputs, name, tind=-1, mesh=None, ignoreDataType=False)#

Create a Field3D from reading in a datafile via collect.

Parameters:
  • outputs (BoutOutputs) – object to read from

  • tind (int, optional) – time slice to read

  • mesh (Mesh, optional) – if not defined, use global mesh

  • ignoreDataType (bool, optional) – Do not fail if data is not float64

  • **kwargs – remaining arguments are passed to collect

classmethod fromCollect(cls, name, tind=-1, mesh=None, ignoreDataType=False, **kwargs)#

Create a Field3D from reading in a datafile via collect.

Parameters:
  • tind (int, optional) – time slice to read

  • mesh (Mesh, optional) – if not defined, use global mesh

  • ignoreDataType (bool, optional) – Do not fail if data is not float64

  • **kwargs – remaining arguments are passed to collect

classmethod fromMesh(cls, mesh=None)#

Create a Field3D.

Parameters:

mesh (Mesh, optional) – The mesh of the Field3D. If None, use global mesh

get(self)#

Get all data of the Field3D

Returns:

A 3D numpy array with the data of the Field3D

Return type:

array

getAll(self)#

Get all data of the Field3D

Returns:

A 3D numpy array with the data of the Field3D

Return type:

array

getLocation(self)#

Get the location of the Field3D

Returns:

Representation of the field’s location.

Return type:

string

getMesh(self)#

Get the mesh associated with the field

Returns:

The mesh of the field

Return type:

bc.Mesh

isAllocated(self)#

Check if the Field3D has its own datablock allocated

Returns:

whether the Field is allocated

Return type:

bool

set(self, data, ignoreDataType=False)#

Set all data of the Field3D

Parameters:
  • data (array_like) – The data to be set

  • ignoreDataType (bool, optional) – Ignore if data is off different type to BoutReal

setAll(self, data, ignoreDataType=False)#

Set all data of the Field3D

Parameters:
  • data (array_like) – The data to be set

  • ignoreDataType (bool, optional) – Ignore if data is off different type to BoutRealxx

setLocation(self, location)#

Set the location of the Field3D This does not do any modification of the data.

Parameters:

location (string) – The location to be set, e.g. “YLOW” or “CELL_YLOW” are supported.

class boutpp.FieldFactory#
boutpp.Grad(Field3D field, outloc=u'CELL_DEFAULT', method=u'DIFF_DEFAULT')#

Compute the derivative Grad

Parameters:
  • field (Field3D) – The Field3D object of which to calculate the derivative

  • outloc (string) – The location where the derivative is expected. Defaults to the same as field.

  • method (string) – The method to calculate the derivative.

Returns:

The computed Grad derivative

Return type:

Vector3D

boutpp.Grad_par(Field3D field, outloc=u'CELL_DEFAULT', method=u'DIFF_DEFAULT')#

Compute the derivative Grad_par

Parameters:
  • field (Field3D) – The Field3D object of which to calculate the derivative

  • outloc (string) – The location where the derivative is expected. Defaults to the same as field.

  • method (string) – The method to calculate the derivative.

Returns:

The computed Grad_par derivative

Return type:

Field3D

boutpp.Grad_perp(Field3D field, outloc=u'CELL_DEFAULT', method=u'DIFF_DEFAULT')#

Compute the derivative Grad_perp

Parameters:
  • field (Field3D) – The Field3D object of which to calculate the derivative

  • outloc (string) – The location where the derivative is expected. Defaults to the same as field.

  • method (string) – The method to calculate the derivative.

Returns:

The computed Grad_perp derivative

Return type:

Vector3D

boutpp.Grad_perp_dot_Grad_perp(Field3D a, Field3D b)#
Parameters:
  • a (Field3D) – The left field of the multiplication

  • b (Field3D) – The right field of the multiplication

Returns:

the scalar product of the perpendicular gradient contributions

Return type:

Field3D

boutpp.Laplace(Field3D a)#

Compute the full Laplacian nabla^2(a)

Parameters:

a (Field3D) – The Field3D object of which to calculate the derivative

Returns:

The computed Laplacian

Return type:

Field3D

class boutpp.Laplacian(section=None)#

Laplacian inversion solver

Compute the Laplacian inversion of objects.

Equation solved is: dnabla^2_perp x + (1/c1)nabla_perp c2cdotnabla_perp x + exnabla_x x + eznabla_z x + a x = b

setCoefA(self, Field3D A)#

Set the “A” coefficient of the Laplacian solver

Parameters:

A (Field3D) – Field to set as coefficient

setCoefC(self, Field3D C)#

Set the “C” coefficient of the Laplacian solver

Parameters:

C (Field3D) – Field to set as coefficient

setCoefC1(self, Field3D C1)#

Set the “C1” coefficient of the Laplacian solver

Parameters:

C1 (Field3D) – Field to set as coefficient

setCoefC2(self, Field3D C2)#

Set the “C2” coefficient of the Laplacian solver

Parameters:

C2 (Field3D) – Field to set as coefficient

setCoefD(self, Field3D D)#

Set the “D” coefficient of the Laplacian solver

Parameters:

D (Field3D) – Field to set as coefficient

setCoefEx(self, Field3D Ex)#

Set the “Ex” coefficient of the Laplacian solver

Parameters:

Ex (Field3D) – Field to set as coefficient

setCoefEz(self, Field3D Ez)#

Set the “Ez” coefficient of the Laplacian solver

Parameters:

Ez (Field3D) – Field to set as coefficient

setCoefs(self, **kwargs)#

Set the coefficients for the Laplacian solver. The coefficients A, C, C1, C2, D, Ex and Ez can be passed as keyword arguments

solve(self, Field3D x, Field3D guess)#

Calculate the Laplacian inversion

Parameters:
  • x (Field3D) – Field to be inverted

  • guess (Field3D) – initial guess for the inversion

Returns:

the inversion of x, where guess is a guess to start with

Return type:

Field3D

class boutpp.Mesh(create=True, section=None, options=None)#

Mesh class

Contains information about geometry. It contains also the coordinates and is responsible for taking deriavtives.

communicate(self, *args)#

Communicate (MPI) the boundaries of the Field3Ds with neighbours

Parameters:

args (Field3D) – Abitrary number of fields

coordinates#

Get the Coordinates object of this mesh

classmethod getGlobal(cls)#

Get the global Mesh object

Returns:

The global instance

Return type:

Mesh

normalise(self, double norm)#

Normalise the mesh.

Usefull if the Options are in SI units, but the simulation is written in Bohm units. Calling it multiple times will not change the mesh, if the normalisation is always the same.

It calls mesh->dx/=norm etc. followed by a call to geometry().

Parameters:

norm (float) – The length with which to rescale

class boutpp.Options(**kwargs)#

The Options class

assign(self, value, source='')#
assignRepeat(self, value, time_dimension='t', save_repeat=True, source='')#
force(self, value, source='')#
classmethod fromFile(cls, file)#

Create a new Options object by reading a file

Parameters:

file (string) – The path of the file to read

Returns:

The Options object

Return type:

Options

get(self, name, default)#

Get an option

Parameters:
  • name (string) – the name of the value to get. Can be relative, e.g. “mesh:ddx:first”.

  • default (bool or string or float) – Depending on the type of the default, different things will be returned. Supported types are bool, string or float

Returns:

See default for the type. The option that was read if available, otherwise default

Return type:

bool or string or float

static root(name='')#

Get a section from the global options tree

Parameters:

name (string, optional) – The name of the section. Can contain “:” to specify subsections. Defaults to the root section “”.

Returns:

The Options object

Return type:

Options

set(self, name, value, source='PyInterface', force=False)#

Set an option

Parameters:
  • name (string) – the name of the value to be set. Can be relative, e.g. “mesh:ddx:first”.

  • value (string) – the value to be set

  • source (string, optional) – The source of the change. Useful for keeping track of where what was set.

  • force (bool, optional) – If a value is overwritten, an exception is thrown. setting this to True avoids the exception.

setConditionallyUsed(self)#

Set the attribute “conditionally used” to be true for p options and all its children/sections, causing Options::getUnused() to assume those options have been used. This is useful to ignore options when checking for typos etc.

class boutpp.PhysicsModel#

The PhysicsModel base class for python

To implement your own PhysicsModel derive from this class and provide a rhs function which takes the self and the simulation time as input, and the init function which takes self and whether the simulation has been restarted as an argument.

A complete simulation could look something like this:

import boutpp as bc

bc.init(“mesh:n=48”) class MyModel(bc.PhysicsModel):

def init(self,restart):

self.dens = bc.create3D(“sin(x)”) self.solve_for(n=self.dens)

def rhs(self,time):

self.dens.ddt(bc.DDX(self.dens))

model = MyModel() model.solve()

init(self, restart)#

This can be overwritten to do model specific initialization

solve(self)#

Call the solver. This makes sure that self.init(restart) and self.rhs(time) are called from the solver.

solve_for(self, *args, **kwargs)#

Add Field3D’s to be solved for. Need to pass as name=field - where name is the name that is used e.g. for the dump file and field is a Field3D

Parameters:

kwargs (dictionary of Field2D or Field3D) – Keys must be strings, and value of dict must be the Field3D which should be evolved.

class boutpp.PhysicsModelBase#

The PhysicsModelBase in python - better use the PhysicsModel class

setInit(self, init)#

set the init function to be called

Parameters:

init (function) – Must not be a method, and must accept an bool (restart) as argument

setRhs(self, rhs)#

set the rhs function to be called

Parameters:

rhs (function) – Must not be a method, and must accept an double (time) as argument

solve(self)#
solve_for(self, **kwargs)#
class boutpp.PythonModelCallback#

Needed for callbacks from C++ to python

execute(self, parameter) void#
boutpp.VDDX(Field3D velocity, Field3D field, outloc=u'CELL_DEFAULT', method=u'DIFF_DEFAULT', region=u'RGN_NOBNDRY')#

Compute the flux derivative VDDX

Parameters:
  • velocity (Field3D) – The Field3D object of which the field is advected

  • field (Field3D) – The Field3D object of which to calculate the derivative

  • outloc (string) – The location where the derivative is expected. Defaults to the same as field.

  • method (string) – The method to calculate the derivative.

  • region (string) – The region for which to calculate the derivative

Returns:

The computed VDDX derivative

Return type:

Field3D

boutpp.VDDY(Field3D velocity, Field3D field, outloc=u'CELL_DEFAULT', method=u'DIFF_DEFAULT', region=u'RGN_NOBNDRY')#

Compute the flux derivative VDDY

Parameters:
  • velocity (Field3D) – The Field3D object of which the field is advected

  • field (Field3D) – The Field3D object of which to calculate the derivative

  • outloc (string) – The location where the derivative is expected. Defaults to the same as field.

  • method (string) – The method to calculate the derivative.

  • region (string) – The region for which to calculate the derivative

Returns:

The computed VDDY derivative

Return type:

Field3D

boutpp.VDDZ(Field3D velocity, Field3D field, outloc=u'CELL_DEFAULT', method=u'DIFF_DEFAULT', region=u'RGN_NOBNDRY')#

Compute the flux derivative VDDZ

Parameters:
  • velocity (Field3D) – The Field3D object of which the field is advected

  • field (Field3D) – The Field3D object of which to calculate the derivative

  • outloc (string) – The location where the derivative is expected. Defaults to the same as field.

  • method (string) – The method to calculate the derivative.

  • region (string) – The region for which to calculate the derivative

Returns:

The computed VDDZ derivative

Return type:

Field3D

class boutpp.Vector2D#

Vector2D class

A vector of Field2D

get(self)#

Get all data of the Vector2D

Returns:

A 3D numpy array with the data of the Vector2D

Return type:

np.ndarray

x#

The Field2D in x direction

y#

The Field2D in y direction

z#

The Field2D in z direction

class boutpp.Vector3D#

Vector3D class

A vector of Field3D

get(self)#

Get all data of the Vector3D

Returns:

A 4D numpy array with the data of the Vector3D

Return type:

np.ndarray

x#

The Field3D in x direction

y#

The Field3D in y direction

z#

The Field3D in z direction

boutpp.Vpar_Grad_par(Field3D velocity, Field3D field, outloc=u'CELL_DEFAULT', method=u'DIFF_DEFAULT')#

Compute the flux derivative Vpar_Grad_par

Parameters:
  • velocity (Field3D) – The Field3D object of which the field is advected

  • field (Field3D) – The Field3D object of which to calculate the derivative

  • outloc (string) – The location where the derivative is expected. Defaults to the same as field.

  • method (string) – The method to calculate the derivative.

Returns:

The computed Vpar_Grad_par derivative

Return type:

Field3D

boutpp.abs(a)#

Calculate abs of a

Parameters:

a (Field3D or Field2D) – The field for which to calculate abs

Returns:

abs of a

Return type:

Field3D or Field2D

boutpp.bracket(Field3D a, Field3D b, method=u'BRACKET_STD', outloc=u'CELL_DEFAULT')#

Calculate the poison bracket for Field3D a and Field3D b.

Parameters:
  • a (Field3D) – The left field in the bracket

  • b (Field3D) – The right field in the bracket

  • method (string) – The method to be used

  • outloc (string) – The location of the calculated derivative

Returns:

The bracket

Return type:

Field3D

boutpp.checkInit()#

Assert that boutpp has been initialized

boutpp.cos(a)#

Calculate cos of a

Parameters:

a (Field3D or Field2D) – The field for which to calculate cos

Returns:

cos of a

Return type:

Field3D or Field2D

boutpp.create3D(string, Mesh msh=None, outloc=u'CELL_DEFAULT', time=0)#

Returns a Field3D from the fieldfactory :Parameters: * string (string) – Expression to create. This can contain references to the options

  • msh (Mesh) – the Mesh to use, defaults to the global mesh.

  • outloc (string) – the cell location of the returned field

  • time (float) – is the time

Returns:

the Field from the expression

Return type:

Field3D

boutpp.cross(Vector3D a, Vector3D b)#

Compute the cross product of two vectors

Parameters:

a, b (Vector3D) – The two Vector3D objects of which to calculate the cross product

Returns:

The cross product

Return type:

Vector3D

boutpp.exp(a)#

Calculate exp of a

Parameters:

a (Field3D or Field2D) – The field for which to calculate exp

Returns:

exp of a

Return type:

Field3D or Field2D

boutpp.finalise()#

Finalize BOUT++ and also MPI. After this most objects and functions are not valid anymore.

Note that this deallocates the C++ objects, thus the python objects might not work any more.

boutpp.init(args=[])#

Initialization function for the library.

Parameters:

args (list of string or string, optional) – It accepts ether a list of strings, or a string that is split at the spaces. This is passed on to MPI and other libraries that BOUT++ initializes.

boutpp.interp_to(Field3D f3d, location)#

Interpolate a Field3D to a given location

Parameters:
  • f3d (Field3D) – The field to interpolate

  • location (string) – The location to which to interploate

Returns:

the interpolated field

Return type:

Field3D

boutpp.log(a)#

Calculate log of a

Parameters:

a (Field3D or Field2D) – The field for which to calculate log

Returns:

log of a

Return type:

Field3D or Field2D

boutpp.max(Field3D a)#

Get the maximum

Parameters:

a (Field3D) – The field

Returns:

the maximum value of a

Return type:

float

boutpp.min(Field3D a)#

Get the minimum

Parameters:

a (Field3D) – The field

Returns:

the minimum value of a

Return type:

float

boutpp.pow(Field3D a, exponent)#

Returns a**e where a is a Field3D and e is a number

Parameters:
  • a (Field3D) – The field for which to calculate the power

  • exponent (float) – The exponent

Returns:

The a**exponent

Return type:

Field3D

boutpp.print(*args, sep=' ', end='\n')#
boutpp.setOption(name, value, source='PyInterface', force=False)#

Set an option in the global Options tree. Prefer Options.set to avoid unexpected results if several Option roots are avalaible.

Parameters:
  • name (string) – the name of the value to be set. Can be relative, e.g. “mesh:ddx:first”.

  • value (string) – the value to be set

  • source (string) – The source of the change. Useful for keeping track of where what was set.

  • force (bool) – If a value is overwritten, an exception is thrown. setting this to True avoids the exception.

boutpp.sin(a)#

Calculate sin of a

Parameters:

a (Field3D or Field2D) – The field for which to calculate sin

Returns:

sin of a

Return type:

Field3D or Field2D

boutpp.size_t#

alias of uint64

boutpp.sqrt(a)#

Calculate sqrt of a

Parameters:

a (Field3D or Field2D) – The field for which to calculate sqrt

Returns:

sqrt of a

Return type:

Field3D or Field2D

boutpp.writeDefaultOutputFile(Options options: Options)#