# fronts.ode

Transform the PDE into an ODE.

Given a positive function D and coordinate unit vector $$\mathbf{\hat{r}}$$, transforms the partial differential equation (PDE) in which $$\theta$$ is the unknown function of $$r$$ and $$t$$:

$\dfrac{\partial\theta}{\partial t} = \nabla\cdot\left[D(\theta)\dfrac{\partial\theta}{\partial r} \mathbf{\hat{r}}\right]$

into an ordinary differential equation (ODE) where $$\theta$$ is an unknown function of the Boltzmann variable $$o$$.

This function returns the fun and jac callables that may be used to solve the ODE with the solvers included with SciPy (scipy.integrate module). The second-order ODE is expressed as a system of first-order ODEs with independent variable $$o$$ where y in fun and jac correspond to the value of the function $$\theta$$ itself and y to its first derivative $$d\theta/do$$.

Parameters:
• D (callable) – Callable as D(theta, 1), which must return both $$D$$ and its first derivative evaluated at theta. If the returned jac will be used, it must also be callable as D(theta, 2) to obtain $$D$$, its first derivative, and its second derivative evaluated at theta. To allow vectorized usage of fun and jac, D must be able to accept a NumPy array as theta.

• radial ({False, 'cylindrical', 'polar', 'spherical'}, optional) –

Choice of coordinate unit vector $$\mathbf{\hat{r}}$$. Must be one of the following:

• False (default): $$\mathbf{\hat{r}}$$ is any coordinate unit vector in rectangular (Cartesian) coordinates, or an axial unit vector in a cylindrical coordinate system

• 'cylindrical' or 'polar': $$\mathbf{\hat{r}}$$ is the radial unit vector in a cylindrical or polar coordinate system

• 'spherical': $$\mathbf{\hat{r}}$$ is the radial unit vector in a spherical coordinate system

• catch_errors (bool, optional) –

Whether to catch exceptions that may be attributed to a domain error of D and convert them to NaN (or +/-Inf) values in the returns of fun and jac. If True, the following exceptions will be caught as domain errors:

• ValueError and ArithmeticError (the latter includes ZeroDivisionError) raised by a call to D

• ZeroDivisionError when attempting to divide by a zero value returned by D

• TypeError when assigning to the return array (usually because Python arithmetic inside D caused that function to return a complex value)

Returning NaN or infinite values signals the domain error to a caller that does not expect fun and jac to raise exceptions to indicate this condition (such as SciPy).

This option is useful in non-vectorized usage, and particularly where the invocation of D might use native Python mathematical functions and types. It is less relevant in vectorized usage and other cases that involve only NumPy types and functions, as those will not cause these exceptions by default.

If False (default), the exceptions will be allowed to propagate to the callers of fun and jac.

Returns:

• fun (callable) – Function that returns the right-hand side of the system. The calling signature is fun(o, y). In non-vectorized usage, o is a float and y is any sequence of two floats, and fun returns a NumPy array with shape (2,). For vectorized usage, o and y must be NumPy arrays with shapes (n,) and (2,n) respectively, and the return is a NumPy array of shape (2,n).

• jac (callable) – Function that returns the Jacobian matrix of the right-hand side of the system. The calling signature is jac(o, y). In non-vectorized usage, o is a scalar and y is an array-like with shape (2,n), and the return is a NumPy array with shape (2,2). In vectorized usage, o and y must be NumPy arrays with shapes (n,) and (2,n) respectively, and the return is a NumPy array of shape (2,2,n).

If radial is other than False, the PDE is undefined at $$r=0$$, and therefore the returned ODE is also undefined for $$o=0$$.