Package SloppyCell :: Package ReactionNetworks :: Module Dynamics
[hide private]

Module Dynamics

source code


Methods for evaluating the dynamics of Network.

Classes [hide private]
  IntegrationException
  FixedPointException
Functions [hide private]
 
daeint(res, t, y0, yp0, rtol, atol, nrt=0, rt=None, jac=None, tstop=None, intermediate_output=False, ineq_constr=False, calculate_ic=False, var_types=None, redir_output=True, max_steps=500, rpar=None, hmax=None)
Integrate a system of ordinary differential algebraic equations with or without events.
source code
 
integrate_tidbit(net, res_func, Dfun, root_func, IC, yp0, curTimes, rtol, atol, fill_traj, return_derivs, redirect_msgs, calculate_ic, var_types) source code
 
generate_tolerances(net, rtol, atol=None) source code
 
integrate(net, times, rtol=None, atol=None, params=None, fill_traj=True, return_events=False, return_derivs=False, redirect_msgs=True, calculate_ic=False, include_extra_event_info=False, use_constraints=True)
Integrate a Network, returning a Trajectory.
source code
 
fired_events(net, time, y, yp, crossing_dirs, events_occurred, pendingEvents, chained_off_of=None, use_constraints=False) source code
 
integrate_sens_subset(net, times, rtol=None, fill_traj=False, opt_vars=None, return_derivs=False, redirect_msgs=True)
Integrate the sensitivity equations for a list of optimizable variables.
source code
 
integrate_sens_single(net, traj, rtol, opt_var, return_derivs, redirect_msgs)
Integrate the sensitivity equations for a single optimization variable.
source code
 
_parse_sens_result(result, net, opt_vars, yout, youtdt=None)
Utility function for parsing the return from integrate_sens_subset
source code
 
integrate_sensitivity(net, times, params=None, rtol=None, fill_traj=False, return_derivs=False, redirect_msgs=True) source code
 
dyn_var_fixed_point(net, dv0=None, with_logs=True, xtol=1e-6, time=0, stability=False, fsolve_factor=100, maxfev=10000)
Return the dynamic variables values at the closest fixed point of the net.
source code
 
find_ypic_sens(y, yp, time, var_types, rtol, atol_for_sens, constants, net, opt_var, redirect_msgs=False) source code
 
find_ics(y, yp, time, var_types, rtol, atol, constants, net, redirect_msgs=False) source code
 
_reduce_times(yout, tout, times) source code
Variables [hide private]
  logger = logging.getLogger('ReactionNetworks.Dynamics')
  _double_epsilon_ = scipy.finfo(scipy.float_).eps
  _double_tiny_ = scipy.finfo(scipy.float_).tiny
  MAX_STEPS = 1e5
  global_rtol = 1e-6
  global_atol = None
  global_hmax = None
  return_derivs = False
  reduce_space = 0
  failed_args = []
  failed_kwargs = {}

Imports: copy, sets, sys, scipy, logging, daskr, Trajectory_mod, Utility, event_info, HAVE_PYPAR, my_rank, my_host, num_procs, pypar


Function Details [hide private]

daeint(res, t, y0, yp0, rtol, atol, nrt=0, rt=None, jac=None, tstop=None, intermediate_output=False, ineq_constr=False, calculate_ic=False, var_types=None, redir_output=True, max_steps=500, rpar=None, hmax=None)

source code 
Integrate a system of ordinary differential algebraic equations with or
without events.

Description:

  Solve a system of ordinary differential algebraic equations using the
  FORTRAN library DDASKR.
  
  Uses the backward differentiation formulas of orders one through five
  to solve a system of the form G(T,Y,Y') = 0 where Y can be a vector.

  Values for Y and Y' at the initial time must be given as input.  These
  values should be consistent, that is, if t0, y0, yp0 are the given
  initial values, they should satisfy G(t0,y0,yp0) = 0.  However, if
  consistent values are not known, in many cases you can have DDASKR
  solve for them if the appropriate option in the info array is set.

  Normally, DDASKR solves the system from some intial t0 to a specified
  tout.  This wrapper takes a list of times t as input, and then solves
  the system for the range of times.  In the interval mode of operation,
  only the solution values at time points in t will be returned.
  Intermediate results can also be obtained easily by specifying info(3).

  While integrating the given DAE system, DDASKR also searches for roots
  of the given constraint functions Ri(T,Y,Y') given by RT. If DDASKR
  detects a sign change in any Ri(T,Y,Y'), it will return the intermediate
  value of T and Y for which Ri(T,Y,Y') = 0.

  Caution: If some Ri has a root at or very near the initial time, DDASKR
  may fail to find it, or may find extraneous roots there, because it does
  not yet have a sufficient history of the solution.
  
Inputs:

  res  -- res(t, y, ...) computes the residual function for the
          differential/algebraic system to be solved.
  t    -- a sequence of time points for which to solve for y.  The intial 
          value of the dependent variable(s) y should correspond to the
          first time in this sequence.
  y0   -- this array must contain the initial values of the NEQ solution
          components at the initial time point (note NEQ is defined as the
          length of this array).
  yp0  -- this array must contain the initial values of the NEQ first
          derivatives of the solution components at the initial time point.
  jac  -- this is the name of a routine that you may supply that relates to
          the Jacobian matrix of the nonlinear system that the code must
          solve at each time step.
  rtol -- array of relative error tolerances (must be non-negative).
  atol -- array of absolute error tolerances (must be non-negative).
  rt   -- this is the name of the subroutine for defining the vector
          Ri(T, Y, Y') of constraint functions.
  nrt  -- the number of constraint functions Ri(T, Y, Y').
  jac  -- the name of a routine that you may supply (optionally) that
          relactes to the Jacobian matrix of the nonlinear system that the
          code must solve at each time step. If no Jacobian is passed then
          the system will automatically use a numerical Jacobian.
  args -- parameter for passing extra information to the wrapper.
  tstop -- sometimes it is not possible to integrate past some point tstop
          because the equation changes there or it is not defined past
          tstop.  if tstop is set the integrator will not integrate past
          tstop.  NOTE:  If you select a tstop, the integrator may skip
          some points in your list of time points, t.  This is because it
          may pass tstop before hitting all the points in the list of times
          for an integration that is progressing quickly.
  intermediate_output -- True to have all output returned.
  ineq_constr -- True to have inequality constraint checking on.
          If True, the code will check for non-negativity in Y during the
          integration (not during initial condition calculations).
  calculate_ic -- True to have the DDASKR automatically calculate
         consistent initial conditions.  Given Y_d, the code will
         calculate Y_a and Y'_d (note: you must also pass var_types
         to indicate which variables are algebraic and which are
         differential).  We do not use the functionality of daskr
         that allows calculation of Y given Y'.
  var_types -- this list tells whether each variable in the system is
          differential or algebraic. Vor a variable Yi, var_types[i] = +1 if
          Yi is differential, and var_types[i] = -1 if it is algebraic.
  redir_output -- False to have print statements from DASKR printed to the
          standard output.  If redir_output is True, the output will be
          redirected.
  max_steps -- set this if you want the integrator to be able to take more
          than 500 steps between time points when you're not in
          "intermediate output" mode.  If intermediate_output = True then
          every time step is considered an output point so there are never
          multiple steps between time points.  If intermediate_output =
          False (default) then the integrator will stop after taking 500
          steps unless max_steps is set > 500.  The default value for
          max_steps is 500.
  rpar -- If not None, this sequence is passed to the function being
          evaluated and can be used to pass additional arguments.
  hmax -- If not None, this sets an upper limit to the step sizes that 
          ddaskr will take during the integration. Setting this can help
          integration for difficult systems, but it can also slow things
          down.
     
Outputs:  (yout, tout, ypout, t_root, y_root, i_root)

  yout -- the numerically calculated list of solution points corresponding
          to the times in tout.
  tout -- the list of time points corresponding to yout.
  ypout -- the numerically calculated list of solution points corresponding
  to the times in tout.
  t_root -- the time of a terminating event.
  y_root -- the system state at time t_root.
  i_root -- tells which event(s) fired and how they fired.
            If i_root(i) = 0, then event i did not fire. If nonzero,
            i_root(i) shows the direction of the sign change in Ri.
            i_root(i) = 1  means Ri changed from negative to positive.
            i_root(i) = -1 means Ri changed from positive to negative.
  

integrate(net, times, rtol=None, atol=None, params=None, fill_traj=True, return_events=False, return_derivs=False, redirect_msgs=True, calculate_ic=False, include_extra_event_info=False, use_constraints=True)

source code 

Integrate a Network, returning a Trajectory.

net            The Network to integrate.
times          A sequence of times to include in the integration output.
params         Parameters for the integration. If params=None, the current
               parameters of net are used.
rtol           Relative error tolerance for this integration.  
               If rtol = None then relative tolerance is set by 
               Dynamics.global_rtol.
atol           Absolute error tolerance for this integration.
fill_traj      If True, the integrator will add the times it samples to
               the returned trajectory. This is slower, but the resulting
               trajectory will be more densely sampled where the dynamics
               change quickly.
return_events  If True, the output is (traj, te, ye, ie). te is a sequence
               of times at which events fired. ye is a sequence of the
               dynamic variable values where the events fired. ie is the
               index of the fired events.
return_derivs  If True, the returned trajectory records the time derivatives
               of all quantities.
redirect_msgs  If False, the errors and other output generated by the
               integrator will be returned to the display.
calculate_ic   If True, the integrator will calculate consistent initial
               conditions.
include_extra_event_info    If True, the returned trajectory will have more
                detailed event information, inclusing pre- and post- execution
                state, and assigned variable informtaion.
use_constraints    If True, and if the network has constraints, will raise
                   an exception if a constraint's math function becomes True
                   at any time.

dyn_var_fixed_point(net, dv0=None, with_logs=True, xtol=1e-6, time=0, stability=False, fsolve_factor=100, maxfev=10000)

source code 

Return the dynamic variables values at the closest fixed point of the net.

dv0  Initial guess for the fixed point. If not given, the current state
     of the net is used.
with_logs   If True, the calculation is done in terms of logs of variables,
            so that they cannot be negative.
xtol Tolerance to aim for.
time Time to plug into equations.
stability   If True, return the stability for the fixed point. -1 indicates
            stable node, +1 indicates unstable node, 0 indicates saddle
fsolve_factor   'factor' argument for fsolve. For more information, see 
                help(scipy.optimize.fsolve). Should be in range 0.1 to 100.
maxfev      'maxfev' argument for fsolve. For more information, see 
                help(scipy.optimize.fsolve). Should be an integer > 1.