chemreac.integrate

This module provides functions for integrating the system of ODEs which the ReactionDiffusion represent. The main class representing a numerical integration of the system of ODEs is Integration.

If one does not want to hard code the choice of solver and solver parameters (e.g. tolerances), one may use run() which defers those choices to the user of the script through the use of environment variables.

class chemreac.integrate.Integration(solver, rd, C0, tout, sigm_damp=False, C0_is_log=False, tiny=None, **kwargs)[source]

Model kinetcs by integrating system of ODEs using user specified solver.

Parameters:

solver: string

“sundials” or “scipy” where scipy uses VODE as the solver.

rd: ReactionDiffusion instance

C0: array

initial concentrations (untransformed, i.e. linear)

tout: array

times for which to report solver results (untransformed)

sigm_damp: bool or tuple of (lim: float, n: int)

conditionally damp C0 with an algebraic sigmoid when rd.logy == True. s(x) = x/((x/lim)**n+1)**(1./n) if sigm==True then lim and n are the default of sigm()

C0_is_log: bool

If True: passed values in C0 are taken to be the natural logarithm of initial concentrations. If False and rd.logy == True: a very small number is added to C0 to avoid applying log to zero (see tiny).

tiny: float

added to C0 when rd.logy==True and C0_is_log==False. Note that if you explicitly want to avoid adding tiny you need to set it to zero (e.g. when manually setting any C0==0 to some epsilon).

(default: None => numpy.finfo(np.float64).tiny)

**kwargs:

mode: not supported by Sundials solver (current wrapper

code auto selects banded for N>1 and uses dense mode for N==1)

atol: float or sequence

absolute tolerance of solution

rtol: float

relative tolerance of solution

Attributes

Cout: array linear output concentrations
yout: array output from solver: log(concentrations) if rd.logy == True
info: dict Information from solver. Guaranteed to contain: - ‘texec’: execution time in seconds. - ‘atol’: float or array, absolute tolerance(s). - ‘rtol’: float, relative tolerance

Methods

_integrate() performs the integration, automatically called by __init__
chemreac.integrate.run(*args, **kwargs)[source]

run is provided for environment variable directed solver choice.

Set CHEMREAC_SOLVER to indicate what integrator to use (default: “scipy”).

Set CHEMREAC_SOLVER_KWARGS to a string which can be eval’d to a python dictionary. e.g. “{‘atol’: 1e-4, ‘rtol’=1e-7}”

chemreac.integrate.sigm(x, lim=150.0, n=8)[source]

Algebraic sigmoid to avoid overflow/underflow of ‘double exp(double)’