pencil.math.derivatives

Differential operators in different coordinate systems.

Submodules

Attributes

xder

yder

zder

xder2

yder2

zder2

xder3

yder3

zder3

xder5

yder5

zder5

xder6

yder6

zder6

Functions

div(f[, dx, dy, dz, x, y, coordinate_system, grid])

div(f, dx=None, dy=None, dz=None, x=None, y=None, coordinate_system="cartesian", grid=None)

curl(f[, dx, dy, dz, x, y, run2D, coordinate_system, grid])

curl(f, dx=None, dy=None, dz=None, x=None, y=None, run2D=False, coordinate_system="cartesian", grid=None)

grad(f[, dx, dy, dz, x, y, coordinate_system, grid])

grad(f, dx=None, dy=None, dz=None, x=None, y=None, coordinate_system="cartesian", grid=None)

curl2(f[, dx, dy, dz, x, y, coordinate_system, grid])

curl2(f, dx=None, dy=None, dz=None, x=None, y=None, coordinate_system="cartesian", grid=None)

del2(f[, dx, dy, dz, x, y, coordinate_system, grid])

del2(f, dx=None, dy=None, dz=None, x=None, y=None, coordinate_system="cartesian", grid=None)

curl3(f, dx, dy, dz[, x, y, coordinate_system])

curl3(f, dx, dy, dz, x=None, y=None, coordinate_system="cartesian")

del6(f[, dx, dy, dz, grid])

del6(f, dx=None, dy=None, dz=None, grid=None)

gij(f, dx, dy, dz[, nder])

Calculate del6 (defined here as d^6/dx^6 + d^6/dy^6 + d^6/dz^6, rather

traceless_strain(f, dx, dy, dz[, x, y, z, ...])

simple_centered(x, y)

Calculate dy by center differencing using array slices

Package Contents

pencil.math.derivatives.xder
pencil.math.derivatives.yder
pencil.math.derivatives.zder
pencil.math.derivatives.xder2
pencil.math.derivatives.yder2
pencil.math.derivatives.zder2
pencil.math.derivatives.xder3
pencil.math.derivatives.yder3
pencil.math.derivatives.zder3
pencil.math.derivatives.xder5
pencil.math.derivatives.yder5
pencil.math.derivatives.zder5
pencil.math.derivatives.xder6
pencil.math.derivatives.yder6
pencil.math.derivatives.zder6
pencil.math.derivatives.div(f, dx=None, dy=None, dz=None, x=None, y=None, coordinate_system='cartesian', grid=None)

div(f, dx=None, dy=None, dz=None, x=None, y=None, coordinate_system=”cartesian”, grid=None)

Take divergence of pencil code vector array f in various coordinate systems.

Parameters:
  • f (ndarray) – Pencil code vector array f.

  • grid (pencil.read.grids.Grid) – Pencil grid object. See pc.read.grid().

  • coordinate_system (string) – Coordinate system under which to take the divergence. Takes ‘cartesian’, ‘cylindrical’ and ‘spherical’.

  • compatibility) (Deprecated parameters (only for backwards)

  • --------------------------------------------------------

  • dx (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None

  • dy (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None

  • dz (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None

  • x (ndarrays) – Radial (x) and polar (y) coordinates, 1d arrays. These will not have any effect if grid!=None

  • y (ndarrays) – Radial (x) and polar (y) coordinates, 1d arrays. These will not have any effect if grid!=None

pencil.math.derivatives.curl(f, dx=None, dy=None, dz=None, x=None, y=None, run2D=False, coordinate_system='cartesian', grid=None)

curl(f, dx=None, dy=None, dz=None, x=None, y=None, run2D=False, coordinate_system=”cartesian”, grid=None)

Take the curl of a pencil code vector array f in various coordinate systems.

Parameters:
  • f (ndarray) – Pencil code scalar array f.

  • grid (pencil.read.grids.Grid) – Pencil grid object. See pc.read.grid().

  • run2D (bool) – Deals with pure 2-D snapshots. !Only for Cartesian grids at the moment! Requires grid!=None.

  • coordinate_system (string) – Coordinate system under which to take the divergence. Takes ‘cartesian’, ‘cylindrical’ and ‘spherical’. !Does not work for 2d runs yet!

  • compatibility) (Deprecated parameters (only for backwards)

  • --------------------------------------------------------

  • dx (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None

  • dy (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None

  • dz (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None

  • x (ndarrays) – Radial (x) and polar (y) coordinates, 1d arrays. These will not have any effect if grid!=None

  • y (ndarrays) – Radial (x) and polar (y) coordinates, 1d arrays. These will not have any effect if grid!=None

pencil.math.derivatives.grad(f, dx=None, dy=None, dz=None, x=None, y=None, coordinate_system='cartesian', grid=None)

grad(f, dx=None, dy=None, dz=None, x=None, y=None, coordinate_system=”cartesian”, grid=None)

Take the gradient of a pencil code scalar array f in various coordinate systems.

Parameters:
  • f (ndarray) – Pencil code scalar array f.

  • grid (pencil.read.grids.Grid) – Pencil grid object. See pc.read.grid().

  • coordinate_system (string) – Coordinate system under which to take the divergence. Takes ‘cartesian’, ‘cylindrical’ and ‘spherical’.

  • compatibility) (Deprecated parameters (only for backwards)

  • --------------------------------------------------------

  • dx (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None

  • dy (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None

  • dz (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None

  • x (ndarrays) – Radial (x) and polar (y) coordinates, 1d arrays. These will not have any effect if grid!=None

  • y (ndarrays) – Radial (x) and polar (y) coordinates, 1d arrays. These will not have any effect if grid!=None

pencil.math.derivatives.curl2(f, dx=None, dy=None, dz=None, x=None, y=None, coordinate_system='cartesian', grid=None)

curl2(f, dx=None, dy=None, dz=None, x=None, y=None, coordinate_system=”cartesian”, grid=None)

Take the double curl of a pencil code vector array f.

Parameters:
  • f (ndarray) – Pencil code vector array f.

  • grid (pencil.read.grids.Grid) – Pencil grid object. See pc.read.grid().

  • coordinate_system (string) – Coordinate system under which to take the divergence. Takes ‘cartesian’, ‘cylindrical’ and ‘spherical’.

  • compatibility) (Deprecated parameters (only for backwards)

  • --------------------------------------------------------

  • dx (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None

  • dy (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None

  • dz (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None

  • x (ndarrays) – Radial (x) and polar (y) coordinates, 1d arrays. These will not have any effect if grid!=None

  • y (ndarrays) – Radial (x) and polar (y) coordinates, 1d arrays. These will not have any effect if grid!=None

pencil.math.derivatives.del2(f, dx=None, dy=None, dz=None, x=None, y=None, coordinate_system='cartesian', grid=None)

del2(f, dx=None, dy=None, dz=None, x=None, y=None, coordinate_system=”cartesian”, grid=None)

Calculate del2, the Laplacian of a scalar field f.

Parameters:
  • f (ndarray) – Pencil code vector array f.

  • grid (pencil.read.grids.Grid) – Pencil grid object. See pc.read.grid().

  • coordinate_system (string) – Coordinate system under which to take the divergence. Takes ‘cartesian’, ‘cylindrical’ and ‘spherical’.

  • compatibility) (Deprecated parameters (only for backwards)

  • --------------------------------------------------------

  • dx (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None

  • dy (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None

  • dz (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None

  • x (ndarrays) – Radial (x) and polar (y) coordinates, 1d arrays. These will not have any effect if grid!=None

  • y (ndarrays) – Radial (x) and polar (y) coordinates, 1d arrays. These will not have any effect if grid!=None

pencil.math.derivatives.curl3(f, dx, dy, dz, x=None, y=None, coordinate_system='cartesian')

curl3(f, dx, dy, dz, x=None, y=None, coordinate_system=”cartesian”)

Take the triple curl of a pencil code vector array f. Supports only equidistant grids.

Parameters:
  • f (ndarray) – Pencil code vector array f.

  • dx (floats) – Grid spacing in the three dimensions.

  • dy (floats) – Grid spacing in the three dimensions.

  • dz (floats) – Grid spacing in the three dimensions.

  • x (ndarrays) – Radial (x) and polar (y) coordinates, 1d arrays.

  • y (ndarrays) – Radial (x) and polar (y) coordinates, 1d arrays.

  • coordinate_system (string) – Coordinate system under which to take the divergence. Takes ‘cartesian’ and ‘cylindrical’.

pencil.math.derivatives.del6(f, dx=None, dy=None, dz=None, grid=None)

del6(f, dx=None, dy=None, dz=None, grid=None)

Calculate del6 (defined here as d^6/dx^6 + d^6/dy^6 + d^6/dz^6, rather than del2^3) of a scalar f for hyperdiffusion.

Parameters:
  • f (ndarray) – Pencil code scalar array f.

  • grid (pencil.read.grids.Grid) – Pencil grid object. See pc.read.grid().

  • compatibility) (Deprecated parameters (only for backwards)

  • --------------------------------------------------------

  • dx (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None

  • dy (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None

  • dz (floats) – Grid spacing in the three dimensions. These will not have any effect if grid!=None

pencil.math.derivatives.gij(f, dx, dy, dz, nder=6)

Calculate del6 (defined here as d^6/dx^6 + d^6/dy^6 + d^6/dz^6, rather than del2^3) of a scalar f for hyperdiffusion.

pencil.math.derivatives.traceless_strain(f, dx, dy, dz, x=None, y=None, z=None, coordinate_system='cartesian')
pencil.math.derivatives.simple_centered(x, y)

Calculate dy by center differencing using array slices