rxnfit.rate_const_ft_eval module

Rate constant evaluator for time-dependent k(t).

“ft” in the module name stands for f(t), i.e. rate constants as functions of time. Builds a callable (t, params) -> dict of rate constant values for use in ODE integration and fitting when rate constants depend on time t and/or other parameters.

rxnfit.rate_const_ft_eval.build_evaluator(rate_consts_dict, symbolic_rate_const_keys, fixed_rate_consts=None)

Build a callable (t, params) -> dict of rate constant values.

Given rate_consts_dict (keys -> float, Symbol, or SymPy Expr possibly containing t and/or other symbols), returns a function that, for a given t and a list of parameter values (in symbolic_rate_const_keys order), returns a dict mapping every rate constant key to a numeric value. Used when rate constants are time-dependent or when building SolverConfig for re-integration after fitting.

Parameters:
  • rate_consts_dict (dict) – Rate constant key -> float, sympy.Symbol, or SymPy Expr (e.g. a*exp(t), k1/4). May contain symbol t.

  • symbolic_rate_const_keys (list) – Order of free parameter names (e.g. [‘k1’, ‘a’, ‘b’]). Must not include ‘t’.

  • fixed_rate_consts (dict, optional) – Key -> float for constants already resolved. If None, only numeric entries in rate_consts_dict are treated as fixed.

Returns:

evaluator(t, params) where t is float and params is a

sequence of floats in symbolic_rate_const_keys order. Returns dict mapping each key in rate_consts_dict to float.

Return type:

callable

rxnfit.rate_const_ft_eval.has_time_dependent_rates(rate_consts_dict)

Return True if any rate constant expression contains the symbol t.

Parameters:

rate_consts_dict (dict) – Rate constant key -> float, Symbol, or Expr.

Returns:

True if any value has ‘t’ in its free_symbols.

Return type:

bool