The python boutcore module¶
Installing¶
Installing boutcore can be tricky. Ideally it should be just
./configure --enable-shared
make -j 4 python
but getting all the
dependencies can be difficult.
make python
creates the python3 module.
If problems arise, it might be worth checking a copy of the bout module out, to reduce the risk of causing issues with the old bout installation. This is especially true if you are trying to run boutcore not on compute nodes of a super computer but rather on post-processing/login/… nodes.
To use boutcore on the login node, a self compiled version of mpi may be
required, as the provided one may be only for the compute nodes.
Further, numpy header files are required, therefore numpy needs to be
compiled as well.
Further, the header files need to be exposed to the boutcore cython
compilation, e.g. by adding them to _boutcore_build/boutcore.pyx.in
.
It seems both NUMPY/numpy/core/include
and
NUMPY/build/src.linux-x86_64-2.7/numpy/core/include/numpy
need to be
added, where NUMPY
is the path of the numpy directory.
For running boutcore on the post processing nodes, fftw3 needs to be
compiled as well, if certain fftw routines are used. Note, fftw needs
to be configured with --enable-shared
.
After installing mpi e.g. in ~/local/mpich
, bout needs to be
configured with something like:
./configure --enable-shared MPICC=~/local/mpich/bin/mpicc MPICXX=~/local/mpich/bin/mpicxx --with-fftw=~/local/fftw/
--enable-shared
is required, so that pvode etc. is compiles as position
independent code.
If you are running fedora - you can install pre-build binaries:
sudo dnf copr enable davidsch/bout
sudo dnf install python3-bout++-mpich
module load mpi/mpich-$(arch)
Purpose¶
The boutcore module exposes (part) of the BOUT++ C++ library to python. It allows to calculate e.g. BOUT++ derivatives in python.
State¶
Field3D and Field2D are working. If other fields are needed, please open an issue.
Fields can be accessed directly using the [] operators, and give a list of slice objects.
The get all data, f3d.getAll()
is equivalent to f3d[:,:,]
and returns a numpy array.
This array can be addressed with
e.g. []
operators, and then the field can be set again with
f3d.setAll(numpyarray)
.
It is also possible to set a part of an Field3D with the []
operators.
Addition, multiplication etc. are all available.
The derivatives should all be working, if find a missing one, please open an issue.
Vectors are not exposed yet.
Functions¶
-
class
boutcore.
Coordinates
¶ Contains information about geometry, such as metric tensors
-
boutcore.
D2DX2
¶ 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:
-
boutcore.
D2DY2
¶ 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:
-
boutcore.
D2DZ2
¶ 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:
-
boutcore.
DDX
¶ 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:
-
boutcore.
DDY
¶ 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:
-
boutcore.
DDZ
¶ 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:
-
boutcore.
Div_par
¶ 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.
- region (string) – The region for which to calculate the derivative
Returns: The computed Div_par derivative
Return type:
-
boutcore.
FDDX
¶ Compute the derivative FDDX
Parameters: - field (Field3D) – The Field3D object of which to calculate the derivative
- velocity (Field3D) – The Field3D object of which the field is advected
- 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:
-
boutcore.
FDDY
¶ Compute the derivative FDDY
Parameters: - field (Field3D) – The Field3D object of which to calculate the derivative
- velocity (Field3D) – The Field3D object of which the field is advected
- 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:
-
boutcore.
FDDZ
¶ Compute the derivative FDDZ
Parameters: - field (Field3D) – The Field3D object of which to calculate the derivative
- velocity (Field3D) – The Field3D object of which the field is advected
- 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:
-
class
boutcore.
Field2D
¶ The Field2D class
-
applyBoundary
¶ 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
¶ 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
(outputs, name, tind, mesh, ignoreDataType)¶ 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
(name, tind, mesh, ignoreDataType, **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
(mesh)¶ Create a Field2D.
Parameters: mesh (Mesh, optional) – The mesh of the Field2D. If None, use global mesh
-
get
¶ Get all data of the Field2D
Returns: A 2D numpy array with the data of the Field2D Return type: array
-
getAll
¶ Get all data of the Field2D
Returns: A 2D numpy array with the data of the Field2D Return type: array
-
getLocation
¶ Get the location of the Field2D
Returns: Representation of the field’s location. Return type: string
-
isAllocated
¶ Check if the Field2D has its own datablock allocated
Returns: whether the Field is allocated Return type: bool
-
set
¶ 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
¶ 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
¶ 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
boutcore.
Field3D
¶ The Field3D class
-
applyBoundary
¶ 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
¶ 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
(outputs, name, tind, mesh, ignoreDataType)¶ 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
(name, tind, mesh, ignoreDataType, **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
(mesh)¶ Create a Field3D.
Parameters: mesh (Mesh, optional) – The mesh of the Field3D. If None, use global mesh
-
get
¶ Get all data of the Field3D
Returns: A 3D numpy array with the data of the Field3D Return type: array
-
getAll
¶ Get all data of the Field3D
Returns: A 3D numpy array with the data of the Field3D Return type: array
-
getLocation
¶ Get the location of the Field3D
Returns: Representation of the field’s location. Return type: string
-
isAllocated
¶ Check if the Field3D has its own datablock allocated
Returns: whether the Field is allocated Return type: bool
-
set
¶ 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
¶ 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
¶ 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.
-
-
boutcore.
Grad_par
¶ 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.
- region (string) – The region for which to calculate the derivative
Returns: The computed Grad_par derivative
Return type:
-
boutcore.
Grad_perp
¶ 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.
- region (string) – The region for which to calculate the derivative
Returns: The computed Grad_perp derivative
Return type:
-
boutcore.
Grad_perp_dot_Grad_perp
¶ - 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: float
-
boutcore.
Laplace
¶ Compute the full Laplacian abla^2(a)
- a : Field3D
- The Field3D object of which to calculate the derivative
- Field3D
- The computed Laplacian
-
class
boutcore.
Laplacian
¶ 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
¶ Set the ‘A’ coefficient of the Laplacian solver
Parameters: A (Field3D) – Field to set as coefficient
-
setCoefC
¶ Set the ‘C’ coefficient of the Laplacian solver
Parameters: C (Field3D) – Field to set as coefficient
-
setCoefC1
¶ Set the ‘C1’ coefficient of the Laplacian solver
Parameters: C1 (Field3D) – Field to set as coefficient
-
setCoefC2
¶ Set the ‘C2’ coefficient of the Laplacian solver
Parameters: C2 (Field3D) – Field to set as coefficient
-
setCoefD
¶ Set the ‘D’ coefficient of the Laplacian solver
Parameters: D (Field3D) – Field to set as coefficient
-
setCoefEx
¶ Set the ‘Ex’ coefficient of the Laplacian solver
Parameters: Ex (Field3D) – Field to set as coefficient
-
setCoefEz
¶ Set the ‘Ez’ coefficient of the Laplacian solver
Parameters: Ez (Field3D) – Field to set as coefficient
-
setCoefs
¶ Set the coefficients for the Laplacian solver. The coefficients A, C, C1, C2, D, Ex and Ez can be passed as keyword arguments
-
-
class
boutcore.
Mesh
¶ Mesh class
Contains information about geometry. It contains also the coordinates and is responsible for taking deriavtives.
-
communicate
¶ Communicate (MPI) the boundaries of the Field3Ds with neighbours
Parameters: args (Field3D) – Abitrary number of fields
-
coordinates
¶ Get the Coordinates object of this mesh
-
normalise
¶ 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
boutcore.
Options
¶ The Options class
-
classmethod
fromFile
(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
¶ 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
- name (string) – the name of the value to get. Can be relative,
e.g.
-
set
¶ 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.
- name (string) – the name of the value to be set. Can be relative,
e.g.
-
classmethod
-
class
boutcore.
PhysicsModel
¶ The PhysicsModel base class for python
-
init
¶ This can be overwritten to do model specific initialization
-
solve
¶ Call the solver. This makes sure that self.init(restart) and self.rhs(time) are called from the solver.
-
solve_for
¶ 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
boutcore.
PhysicsModelBase
¶ The PhysicsModelBase in python - better use the PhysicsModel class
-
setInit
¶ set the init function to be called
Parameters: init (function) – Must not be a method, and must accept an bool (restart) as argument
-
setRhs
¶ set the rhs function to be called
Parameters: rhs (function) – Must not be a method, and must accept an double (time) as argument
-
-
class
boutcore.
PythonModelCallback
¶ Needed for callbacks from C++ to python
-
boutcore.
VDDX
¶ Compute the derivative VDDX
Parameters: - field (Field3D) – The Field3D object of which to calculate the derivative
- velocity (Field3D) – The Field3D object of which the field is advected
- 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:
-
boutcore.
VDDY
¶ Compute the derivative VDDY
Parameters: - field (Field3D) – The Field3D object of which to calculate the derivative
- velocity (Field3D) – The Field3D object of which the field is advected
- 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:
-
boutcore.
VDDZ
¶ Compute the derivative VDDZ
Parameters: - field (Field3D) – The Field3D object of which to calculate the derivative
- velocity (Field3D) – The Field3D object of which the field is advected
- 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:
-
class
boutcore.
Vector2D
¶ Vector2D class
A vector of Field2D
-
x
¶ The Field2D in x direction
-
y
¶ The Field2D in y direction
-
z
¶ The Field2D in z direction
-
-
class
boutcore.
Vector3D
¶ Vector3D class
A vector of Field3D
-
x
¶ The Field3D in x direction
-
y
¶ The Field3D in y direction
-
z
¶ The Field3D in z direction
-
-
boutcore.
Vpar_Grad_par
¶ Compute the derivative Vpar_Grad_par
Parameters: - field (Field3D) – The Field3D object of which to calculate the derivative
- velocity (Field3D) – The Field3D object of which the field is advected
- 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 Vpar_Grad_par derivative
Return type:
-
boutcore.
abs
¶ Calculate abs of a
Parameters: a (Field3D Field2D) – The field for which to calculate abs Returns: abs of a Return type: Field3D Field2D
-
boutcore.
bracket
¶ 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:
-
boutcore.
checkInit
¶ Assert that boutcore has been initialized
-
boutcore.
cos
¶ Calculate cos of a
Parameters: a (Field3D Field2D) – The field for which to calculate cos Returns: cos of a Return type: Field3D Field2D
-
boutcore.
create3D
¶ 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
-
boutcore.
exp
¶ Calculate exp of a
Parameters: a (Field3D Field2D) – The field for which to calculate exp Returns: exp of a Return type: Field3D Field2D
-
boutcore.
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.
-
boutcore.
init
¶ 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.
-
boutcore.
interp_to
¶ 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:
-
boutcore.
log
¶ Calculate log of a
Parameters: a (Field3D Field2D) – The field for which to calculate log Returns: log of a Return type: Field3D Field2D
-
boutcore.
max
¶ Get the maximum
Parameters: a (Field3D) – The field Returns: the maximum value of a Return type: float
-
boutcore.
min
¶ Get the minimum
Parameters: a (Field3D) – The field Returns: the minimum value of a Return type: float
-
boutcore.
pow
¶ 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:
-
boutcore.
setOption
¶ 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.
- name (string) – the name of the value to be set. Can be relative,
e.g.
-
boutcore.
sin
¶ Calculate sin of a
Parameters: a (Field3D Field2D) – The field for which to calculate sin Returns: sin of a Return type: Field3D Field2D
-
boutcore.
sqrt
¶ Calculate sqrt of a
Parameters: a (Field3D Field2D) – The field for which to calculate sqrt Returns: sqrt of a Return type: Field3D Field2D
Examples¶
Some trivial post processing:
import boutcore
import numpy as np
args="-d data -f BOUT.settings -o BOUT.post".split(" ")
boutcore.init(args)
dens=boutcore.Field3D.fromCollect("n",path="data")
temp=boutcore.Field3D.fromCollect("T",path="data")
pres=dens*temp
dpdz=boutcore.DDZ(pres,outloc="CELL_ZLOW")
A simple MMS test:
import boutcore
import numpy as np
boutcore.init("-d data -f BOUT.settings -o BOUT.post")
for nz in [64,128,256]:
boutcore.setOption("meshz:nz","%d"%nz)
mesh=boutcore.Mesh(OptionSection="meshz")
f=boutcore.create3D("sin(z)",mesh)
sim=boutcore.DDZ(f)
ana=boutcore.create3D("cos(z)",mesh)
err=sim-ana
err=boutcore.max(boutcore.abs(err))
errors.append(err)
A real example - unstagger data:
import boutcore
boutcore.init("-d data -f BOUT.settings -o BOUT.post")
# uses location from dump - is already staggered
upar=boutcore.Field3D.fromCollect("Upar")
upar=boutcore.interp_to(upar,"CELL_CENTRE")
# convert to numpy array
upar=upar.getAll()
A real example - check derivative contributions:
#!/usr/bin/env python
from boutcore import *
import numpy as np
from netCDF4 import Dataset
import sys
if len(sys.argv)> 1:
path=sys.argv[1]
else:
path="data"
times=collect("t_array",path=path)
boutcore.init("-d data -f BOUT.settings -o BOUT.post")
with Dataset(path+'/vort.nc', 'w', format='NETCDF4') as outdmp:
phiSolver=Laplacian()
phi=Field3D.fromCollect("n",path=path,tind=0,info=False)
zeros=phi.getAll()*0
phi.setAll(zeros)
outdmp.createDimension('x',zeros.shape[0])
outdmp.createDimension('y',zeros.shape[1])
outdmp.createDimension('z',zeros.shape[2])
outdmp.createDimension('t',None)
t_array_=outdmp.createVariable('t_array','f4',('t'))
t_array_[:]=times
ExB = outdmp.createVariable('ExB' ,'f4',('t','x','y','z'))
par_adv = outdmp.createVariable('par_adv','f4',('t','x','y','z'))
def setXGuards(phi,phi_arr):
for z in range(tmp.shape[2]):
phi[0,:,z]=phi_arr
phi[1,:,z]=phi_arr
phi[-2,:,z]=phi_arr
phi[-1,:,z]=phi_arr
with open(path+"/equilibrium/phi_eq.dat","rb") as inf:
phi_arr=np.fromfile(inf,dtype=np.double)
bm="BRACKET_ARAKAWA_OLD"
for tind in range(len(times)):
vort = Field3D.fromCollect("vort" ,path=path,tind=tind,info=False)
U = Field3D.fromCollect("U" ,path=path,tind=tind,info=False)
setXGuards(phi,phi_arr)
phi=phiSolver.solve(vort,phi)
ExB[tind,:,:,:]=(-bracket(phi, vort, bm, "CELL_CENTRE")).getAll()
par_adv[tind,:,:,:]=(- Vpar_Grad_par(U, vort)).getAll()
Functions - undocumented¶
Functions - special and inherited¶
-
class
boutcore.
Coordinates
Contains information about geometry, such as metric tensors
-
__delattr__
¶ Implement delattr(self, name).
-
__dir__
()¶ Default dir() implementation.
-
__eq__
¶ Return self==value.
-
__format__
()¶ Default object formatter.
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__init__
¶ Initialize self. See help(type(self)) for accurate signature.
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce_ex__
()¶ Helper for pickle.
-
__repr__
¶ Return repr(self).
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
()¶ Size of object in memory, in bytes.
-
__str__
¶ Return str(self).
-
__subclasshook__
()¶ Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
-
-
boutcore.
D2DX2
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:
-
boutcore.
D2DY2
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:
-
boutcore.
D2DZ2
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:
-
boutcore.
DDX
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:
-
boutcore.
DDY
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:
-
boutcore.
DDZ
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:
-
boutcore.
Div_par
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.
- region (string) – The region for which to calculate the derivative
Returns: The computed Div_par derivative
Return type:
-
boutcore.
FDDX
Compute the derivative FDDX
Parameters: - field (Field3D) – The Field3D object of which to calculate the derivative
- velocity (Field3D) – The Field3D object of which the field is advected
- 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:
-
boutcore.
FDDY
Compute the derivative FDDY
Parameters: - field (Field3D) – The Field3D object of which to calculate the derivative
- velocity (Field3D) – The Field3D object of which the field is advected
- 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:
-
boutcore.
FDDZ
Compute the derivative FDDZ
Parameters: - field (Field3D) – The Field3D object of which to calculate the derivative
- velocity (Field3D) – The Field3D object of which the field is advected
- 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:
-
class
boutcore.
Field2D
The Field2D class
-
__add__
¶ Return self+value.
-
__delattr__
¶ Implement delattr(self, name).
-
__delitem__
¶ Delete self[key].
-
__dir__
()¶ Default dir() implementation.
-
__eq__
¶ Return self==value.
-
__format__
()¶ Default object formatter.
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__getitem__
¶ Get data from the Field2D Supports full 2D slicing support. Partially slicing is currently not supported.
Parameters: slices (tuple_like of slice) – List of slice objects, which shall be returned. Must contain 2 slice objects Returns: Numpy array of the requested data Return type: array
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__iadd__
¶ Return self+=value.
-
__imul__
¶ Return self*=value.
-
__init__
¶ Initialize self. See help(type(self)) for accurate signature.
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__isub__
¶ Return self-=value.
-
__itruediv__
¶ Return self/=value.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__mul__
¶ Return self*value.
-
__ne__
¶ Return self!=value.
-
__neg__
¶ returns: negative of the Field :rtype: Field2D
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce_ex__
()¶ Helper for pickle.
-
__repr__
¶ Return repr(self).
-
__setattr__
¶ Implement setattr(self, name, value).
-
__setitem__
¶ Parameters: * slices (tuple_like, slice) – slice objects of the data to be set. Must contain 2 slice objects * data (array_like) – Values to be set. Must be 2D and match the size of the slicing object.
-
__sizeof__
()¶ Size of object in memory, in bytes.
-
__str__
¶ Return str(self).
-
__sub__
¶ Return self-value.
-
__subclasshook__
()¶ Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
-
__truediv__
¶ Return self/value.
-
applyBoundary
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
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
(outputs, name, tind, mesh, ignoreDataType) 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
(name, tind, mesh, ignoreDataType, **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
(mesh) Create a Field2D.
Parameters: mesh (Mesh, optional) – The mesh of the Field2D. If None, use global mesh
-
get
Get all data of the Field2D
Returns: A 2D numpy array with the data of the Field2D Return type: array
-
getAll
Get all data of the Field2D
Returns: A 2D numpy array with the data of the Field2D Return type: array
-
getLocation
Get the location of the Field2D
Returns: Representation of the field’s location. Return type: string
-
isAllocated
Check if the Field2D has its own datablock allocated
Returns: whether the Field is allocated Return type: bool
-
set
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
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
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
boutcore.
Field3D
The Field3D class
-
__add__
¶ Return self+value.
-
__delattr__
¶ Implement delattr(self, name).
-
__delitem__
¶ Delete self[key].
-
__dir__
()¶ Default dir() implementation.
-
__eq__
¶ Return self==value.
-
__format__
()¶ Default object formatter.
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__getitem__
¶ Get data from the Field3D Supports full 3D slicing support. Partially slicing is currently not supported.
Parameters: slices (tuple_like of slice) – List of slice objects, which shall be returned. Must contain 3 slice objects Returns: Numpy array of the requested data Return type: array
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__iadd__
¶ Return self+=value.
-
__imul__
¶ Return self*=value.
-
__init__
¶ Initialize self. See help(type(self)) for accurate signature.
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__isub__
¶ Return self-=value.
-
__itruediv__
¶ Return self/=value.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__mul__
¶ Return self*value.
-
__ne__
¶ Return self!=value.
-
__neg__
¶ returns: negative of the Field :rtype: Field3D
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce_ex__
()¶ Helper for pickle.
-
__repr__
¶ Return repr(self).
-
__setattr__
¶ Implement setattr(self, name, value).
-
__setitem__
¶ Parameters: * slices (tuple_like, slice) – slice objects of the data to be set. Must contain 3 slice objects * data (array_like) – Values to be set. Must be 3D and match the size of the slicing object.
-
__sizeof__
()¶ Size of object in memory, in bytes.
-
__str__
¶ Return str(self).
-
__sub__
¶ Return self-value.
-
__subclasshook__
()¶ Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
-
__truediv__
¶ Return self/value.
-
applyBoundary
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
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
(outputs, name, tind, mesh, ignoreDataType) 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
(name, tind, mesh, ignoreDataType, **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
(mesh) Create a Field3D.
Parameters: mesh (Mesh, optional) – The mesh of the Field3D. If None, use global mesh
-
get
Get all data of the Field3D
Returns: A 3D numpy array with the data of the Field3D Return type: array
-
getAll
Get all data of the Field3D
Returns: A 3D numpy array with the data of the Field3D Return type: array
-
getLocation
Get the location of the Field3D
Returns: Representation of the field’s location. Return type: string
-
isAllocated
Check if the Field3D has its own datablock allocated
Returns: whether the Field is allocated Return type: bool
-
set
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
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
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.
-
-
boutcore.
Grad_par
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.
- region (string) – The region for which to calculate the derivative
Returns: The computed Grad_par derivative
Return type:
-
boutcore.
Grad_perp
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.
- region (string) – The region for which to calculate the derivative
Returns: The computed Grad_perp derivative
Return type:
-
boutcore.
Grad_perp_dot_Grad_perp
- 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: float
-
boutcore.
Laplace
Compute the full Laplacian abla^2(a)
- a : Field3D
- The Field3D object of which to calculate the derivative
- Field3D
- The computed Laplacian
-
class
boutcore.
Laplacian
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
-
__delattr__
¶ Implement delattr(self, name).
-
__dir__
()¶ Default dir() implementation.
-
__eq__
¶ Return self==value.
-
__format__
()¶ Default object formatter.
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__init__
¶ Initialiase a Laplacian solver
Parameters: section (Options, optional) – The section from the Option tree to take the options from
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce_ex__
()¶ Helper for pickle.
-
__repr__
¶ Return repr(self).
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
()¶ Size of object in memory, in bytes.
-
__str__
¶ Return str(self).
-
__subclasshook__
()¶ Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
-
setCoefA
Set the ‘A’ coefficient of the Laplacian solver
Parameters: A (Field3D) – Field to set as coefficient
-
setCoefC
Set the ‘C’ coefficient of the Laplacian solver
Parameters: C (Field3D) – Field to set as coefficient
-
setCoefC1
Set the ‘C1’ coefficient of the Laplacian solver
Parameters: C1 (Field3D) – Field to set as coefficient
-
setCoefC2
Set the ‘C2’ coefficient of the Laplacian solver
Parameters: C2 (Field3D) – Field to set as coefficient
-
setCoefD
Set the ‘D’ coefficient of the Laplacian solver
Parameters: D (Field3D) – Field to set as coefficient
-
setCoefEx
Set the ‘Ex’ coefficient of the Laplacian solver
Parameters: Ex (Field3D) – Field to set as coefficient
-
setCoefEz
Set the ‘Ez’ coefficient of the Laplacian solver
Parameters: Ez (Field3D) – Field to set as coefficient
-
setCoefs
Set the coefficients for the Laplacian solver. The coefficients A, C, C1, C2, D, Ex and Ez can be passed as keyword arguments
-
solve
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:
-
-
class
boutcore.
Mesh
Mesh class
Contains information about geometry. It contains also the coordinates and is responsible for taking deriavtives.
-
__delattr__
¶ Implement delattr(self, name).
-
__dir__
()¶ Default dir() implementation.
-
__eq__
¶ Return self==value.
-
__format__
()¶ Default object formatter.
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__init__
¶ Create a Mesh
- create : bool, optional
- Create the underling C++ object. Disabled probably only useful for internal usage. Use at own risk.
- section : string, optional
- The section of the options which to read. If not given, default to the root section.
- options : Options, optional
- The Option which to use. Can be specified together with section, in which case the subsection from the current Options object is used. If nether section nor options is given, the default section (mesh) from the global Options object is used.
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce_ex__
()¶ Helper for pickle.
-
__repr__
¶ Return repr(self).
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
()¶ Size of object in memory, in bytes.
-
__str__
¶ Return str(self).
-
__subclasshook__
()¶ Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
-
communicate
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
() Get the global Mesh object
Returns: The global instance Return type: Mesh
-
normalise
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
boutcore.
Options
The Options class
-
__delattr__
¶ Implement delattr(self, name).
-
__dir__
()¶ Default dir() implementation.
-
__eq__
¶ Return self==value.
-
__format__
()¶ Default object formatter.
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__init__
¶ 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
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce_ex__
()¶ Helper for pickle.
-
__repr__
¶ Return repr(self).
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
()¶ Size of object in memory, in bytes.
-
__str__
¶ Return str(self).
-
__subclasshook__
()¶ Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
-
classmethod
fromFile
(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
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
- name (string) – the name of the value to get. Can be relative,
e.g.
-
set
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.
- name (string) – the name of the value to be set. Can be relative,
e.g.
-
-
class
boutcore.
PhysicsModel
The PhysicsModel base class for python
-
__delattr__
¶ Implement delattr(self, name).
-
__dir__
()¶ Default dir() implementation.
-
__eq__
¶ Return self==value.
-
__format__
()¶ Default object formatter.
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce_ex__
()¶ Helper for pickle.
-
__repr__
¶ Return repr(self).
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
()¶ Size of object in memory, in bytes.
-
__str__
¶ Return str(self).
-
__subclasshook__
()¶ Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
-
__weakref__
¶ list of weak references to the object (if defined)
-
init
This can be overwritten to do model specific initialization
-
setInit
¶ set the init function to be called
Parameters: init (function) – Must not be a method, and must accept an bool (restart) as argument
-
setRhs
¶ set the rhs function to be called
Parameters: rhs (function) – Must not be a method, and must accept an double (time) as argument
-
solve
Call the solver. This makes sure that self.init(restart) and self.rhs(time) are called from the solver.
-
solve_for
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
boutcore.
PhysicsModelBase
The PhysicsModelBase in python - better use the PhysicsModel class
-
__delattr__
¶ Implement delattr(self, name).
-
__dir__
()¶ Default dir() implementation.
-
__eq__
¶ Return self==value.
-
__format__
()¶ Default object formatter.
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__init__
¶ Initialize self. See help(type(self)) for accurate signature.
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce_ex__
()¶ Helper for pickle.
-
__repr__
¶ Return repr(self).
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
()¶ Size of object in memory, in bytes.
-
__str__
¶ Return str(self).
-
__subclasshook__
()¶ Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
-
setInit
set the init function to be called
Parameters: init (function) – Must not be a method, and must accept an bool (restart) as argument
-
setRhs
set the rhs function to be called
Parameters: rhs (function) – Must not be a method, and must accept an double (time) as argument
-
-
class
boutcore.
PythonModelCallback
Needed for callbacks from C++ to python
-
__delattr__
¶ Implement delattr(self, name).
-
__dir__
()¶ Default dir() implementation.
-
__eq__
¶ Return self==value.
-
__format__
()¶ Default object formatter.
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__init__
¶ Initialize self. See help(type(self)) for accurate signature.
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce_ex__
()¶ Helper for pickle.
-
__repr__
¶ Return repr(self).
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
()¶ Size of object in memory, in bytes.
-
__str__
¶ Return str(self).
-
__subclasshook__
()¶ Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
-
-
boutcore.
VDDX
Compute the derivative VDDX
Parameters: - field (Field3D) – The Field3D object of which to calculate the derivative
- velocity (Field3D) – The Field3D object of which the field is advected
- 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:
-
boutcore.
VDDY
Compute the derivative VDDY
Parameters: - field (Field3D) – The Field3D object of which to calculate the derivative
- velocity (Field3D) – The Field3D object of which the field is advected
- 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:
-
boutcore.
VDDZ
Compute the derivative VDDZ
Parameters: - field (Field3D) – The Field3D object of which to calculate the derivative
- velocity (Field3D) – The Field3D object of which the field is advected
- 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:
-
class
boutcore.
Vector2D
Vector2D class
A vector of Field2D
-
__delattr__
¶ Implement delattr(self, name).
-
__dir__
()¶ Default dir() implementation.
-
__eq__
¶ Return self==value.
-
__format__
()¶ Default object formatter.
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__init__
¶ Initialize self. See help(type(self)) for accurate signature.
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__mul__
¶ Return self*value.
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce_ex__
()¶ Helper for pickle.
-
__repr__
¶ Return repr(self).
-
__rmul__
¶ Return value*self.
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
()¶ Size of object in memory, in bytes.
-
__str__
¶ Return str(self).
-
__subclasshook__
()¶ Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
-
x
The Field2D in x direction
-
y
The Field2D in y direction
-
z
The Field2D in z direction
-
-
class
boutcore.
Vector3D
Vector3D class
A vector of Field3D
-
__delattr__
¶ Implement delattr(self, name).
-
__dir__
()¶ Default dir() implementation.
-
__eq__
¶ Return self==value.
-
__format__
()¶ Default object formatter.
-
__ge__
¶ Return self>=value.
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
¶ Return self>value.
-
__hash__
¶ Return hash(self).
-
__init__
¶ Initialize self. See help(type(self)) for accurate signature.
-
__init_subclass__
()¶ This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
-
__le__
¶ Return self<=value.
-
__lt__
¶ Return self<value.
-
__mul__
¶ Return self*value.
-
__ne__
¶ Return self!=value.
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__reduce_ex__
()¶ Helper for pickle.
-
__repr__
¶ Return repr(self).
-
__rmul__
¶ Return value*self.
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
()¶ Size of object in memory, in bytes.
-
__str__
¶ Return str(self).
-
__subclasshook__
()¶ Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).
-
x
The Field3D in x direction
-
y
The Field3D in y direction
-
z
The Field3D in z direction
-
-
boutcore.
Vpar_Grad_par
Compute the derivative Vpar_Grad_par
Parameters: - field (Field3D) – The Field3D object of which to calculate the derivative
- velocity (Field3D) – The Field3D object of which the field is advected
- 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 Vpar_Grad_par derivative
Return type:
-
boutcore.
abs
Calculate abs of a
Parameters: a (Field3D Field2D) – The field for which to calculate abs Returns: abs of a Return type: Field3D Field2D
-
boutcore.
bracket
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:
-
boutcore.
checkInit
Assert that boutcore has been initialized
-
boutcore.
cos
Calculate cos of a
Parameters: a (Field3D Field2D) – The field for which to calculate cos Returns: cos of a Return type: Field3D Field2D
-
boutcore.
create3D
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
-
boutcore.
exp
Calculate exp of a
Parameters: a (Field3D Field2D) – The field for which to calculate exp Returns: exp of a Return type: Field3D Field2D
-
boutcore.
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.
-
boutcore.
init
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.
-
boutcore.
interp_to
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:
-
boutcore.
log
Calculate log of a
Parameters: a (Field3D Field2D) – The field for which to calculate log Returns: log of a Return type: Field3D Field2D
-
boutcore.
max
Get the maximum
Parameters: a (Field3D) – The field Returns: the maximum value of a Return type: float
-
boutcore.
min
Get the minimum
Parameters: a (Field3D) – The field Returns: the minimum value of a Return type: float
-
boutcore.
pow
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:
-
boutcore.
setOption
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.
- name (string) – the name of the value to be set. Can be relative,
e.g.
-
boutcore.
sin
Calculate sin of a
Parameters: a (Field3D Field2D) – The field for which to calculate sin Returns: sin of a Return type: Field3D Field2D
-
boutcore.
sqrt
Calculate sqrt of a
Parameters: a (Field3D Field2D) – The field for which to calculate sqrt Returns: sqrt of a Return type: Field3D Field2D