pynucastro.eos.difference_utils module

pynucastro.eos.difference_utils module#

Some high-order finite-difference approximations for the EOS.

pynucastro.eos.difference_utils.adaptive_diff(func, x0, h, *, component=None, max_levels=10)[source]#

Perform an adaptive centered-difference estimate to the first derivative using Richardson-extrapolation / Ridders’ method.

Parameters:
  • func (Callable) – the function to difference, assumed to be of the form func(x)

  • x0 (float) – the point at which to approximate the derivative

  • delta (float) – the step-size to use

  • component (str) – if func returns an object, use this component for the derivative.

  • max_levels (int) – the number of levels / iterations in the tableau used in extrapolating the deriviative to higher order

Returns:

  • deriv (float) – an estimate of the derivative at x0

  • err (float) – the estimated error in the difference approximation

pynucastro.eos.difference_utils.eighth_order_diff(func, x0, delta, *, component=None)[source]#

Compute an 8th order accurate centered difference approximation of a function, and allow us to specify the component of the object that is returned (if applicable)

Parameters:
  • func (Callable) – the function to difference, assumed to be of the form func(x)

  • x0 (float) – the point at which to approximate the derivative

  • delta (float) – the step-size to use

  • component (str) – if func returns an object, use this component for the derivative.

Return type:

float

pynucastro.eos.difference_utils.fourth_order_diff(func, x0, delta, *, component=None)[source]#

Compute a 4th order accurate centered difference approximation of a function, and allow us to specify the component of the object that is returned (if applicable)

Parameters:
  • func (Callable) – the function to difference, assumed to be of the form func(x)

  • x0 (float) – the point at which to approximate the derivative

  • delta (float) – the step-size to use

  • component (str) – if func returns an object, use this component for the derivative.

Return type:

float

pynucastro.eos.difference_utils.sixth_order_diff(func, x0, delta, *, component=None)[source]#

Compute a 6th order accurate centered difference approximation of a function, and allow us to specify the component of the object that is returned (if applicable)

Parameters:
  • func (Callable) – the function to difference, assumed to be of the form func(x)

  • x0 (float) – the point at which to approximate the derivative

  • delta (float) – the step-size to use

  • component (str) – if func returns an object, use this component for the derivative.

Return type:

float