Ejemplo n.º 1
0
def integrate_sensitivity(net, times, p=None, x0=None, rtol=None, varids=None):
    """

    :param net:
    :param times: list or tuple
    :param atol:
    :param rtol:
    :param varids: 
    """
    if isinstance(times, tuple):
        intermediate_output = True
    else:
        intermediate_output = False

    t0 = times[0]
    if t0 == 0:
        _times = times
    else:
        _times = [0] + list(times)

    if p is not None:
        net.p = p

    if x0 is None:
        x0 = net.x0

    if rtol is None:
        rtol = RTOL

    if not hasattr(net, 'res_function'):
        net.compile()

    out = Dynamics.integrate_sensitivity(net,
                                         _times,
                                         rtol=[rtol] * net.xdim,
                                         fill_traj=intermediate_output)

    if varids is not None:
        if set(varids) < set(net.varids):
            varids = itertools.product(varids, net.pids)
        out = out.copy_subset(varids)

    traj = out.values
    times = out.timepoints
    varids = out.key_column.keys()

    if t0 != 0:
        idx_t0 = list(times).index(t0)
        times = times[idx_t0:]
        traj = traj[idx_t0:]

    traj = Trajectory(traj, index=pd.Index(times, name='time'), columns=varids)

    return traj
Ejemplo n.º 2
0
def make_sens_traj(calcobject,params,times,senstrajfilename):
    """ Make the sensitivity trajectory for the calculation
    calcoject (same as in setup(...) above). 
    params: parameters as a KeyedList, sensitivity traj is 
    calculated at these parameters (should be same as in paramfile 
    in setup(...) above)
    times: the timepoints in the sensitivity trajectory (1-d array)
    senstrajfilename: the file to save the sensitivity trajectory to

    Note that if times is very finely spaced, the 
    sensitivity trajectory will need a lot of storage space """
    senstraj = Dynamics.integrate_sensitivity(calcobject, times, params, 1.0e-6)
    save(senstraj,senstrajfilename)
Ejemplo n.º 3
0
def make_sens_traj(calcobject, params, times, senstrajfilename):
    """ Make the sensitivity trajectory for the calculation
    calcoject (same as in setup(...) above). 
    params: parameters as a KeyedList, sensitivity traj is 
    calculated at these parameters (should be same as in paramfile 
    in setup(...) above)
    times: the timepoints in the sensitivity trajectory (1-d array)
    senstrajfilename: the file to save the sensitivity trajectory to

    Note that if times is very finely spaced, the 
    sensitivity trajectory will need a lot of storage space """
    senstraj = Dynamics.integrate_sensitivity(calcobject, times, params,
                                              1.0e-6)
    save(senstraj, senstrajfilename)