CoolDwarf.utils.math package

Submodules

CoolDwarf.utils.math.calc module

calc.py – Calculus related functions for CoolDwarf

This module contains functions related to calculus that are used in CoolDwarf.

Functions include: - partial_derivative_x: Function to calculate the partial derivative along the x-axis - compute_partial_derivatives: Function to compute the partial derivatives of a scalar field

Dependencies

  • numpy

Example usage

>>> import numpy as np
>>> from CoolDwarf.utils.math.calc import partial_derivative_x, compute_partial_derivatives
>>> var = np.random.rand(10, 10, 10)
>>> dx = 1.0
>>> partial_x = partial_derivative_x(var, dx)
>>> x = np.linspace(0, 1, 10)
>>> y = np.linspace(0, 1, 10)
>>> z = np.linspace(0, 1, 10)
>>> dfdx, dfdy, dfdz = compute_partial_derivatives(var, x, y, z)
CoolDwarf.utils.math.calc.compute_partial_derivatives(scalar_field: ndarray, x: ndarray, y: ndarray, z: ndarray) Tuple[ndarray, ndarray, ndarray]

Function to compute the partial derivatives of a scalar field

Parameters:
scalar_fieldnp.ndarray

3D array representing the scalar field

xnp.ndarray

Array of x-axis values

ynp.ndarray

Array of y-axis values

znp.ndarray

Array of z-axis values

Returns:
dfdxnp.ndarray

Array containing the partial derivative along the x-axis

dfdynp.ndarray

Array containing the partial derivative along the y-axis

dfdznp.ndarray

Array containing the partial derivative along the z-axis

CoolDwarf.utils.math.calc.partial_derivative_x(var: ndarray, dx: float) ndarray

Function to calculate the partial derivative along the x-axis

Parameters:
varnp.ndarray

Array of values to calculate the partial derivative of

dxfloat

Spacing between the x-axis points

Returns:
partial_xnp.ndarray

Array containing the partial derivative along the x-axis

CoolDwarf.utils.math.kernel module

CoolDwarf.utils.math.kernel.make_3d_kernels()

Module contents