Exemplo n.º 1
0
    def integrate(self, t, y, tf, opts):
        atol = self.options["atol"]
        tol = self.options["rtol"]
        absrel = atol / tol

        m = self.problem.m
        n = self.problem.n

        a = N.empty((m, m))
        w = N.empty((m, m))
        slu = N.empty((2 * m, ))
        ips = N.empty((m, ), 'int32')
        ind = N.empty((2 * m, ), 'int32')
        eq = N.empty((m, ), 'bool')
        wght = N.ones((m + n, ))

        #Store the opts
        self._opts = opts

        t, lflag = dasp3dp.dasp3(self.problem.rhs1, self.problem.rhs2,
                                 self._solout, t, tf, self.wsy, self.wsz, n, m,
                                 tol, absrel, wght, self.problem.eps, a, w,
                                 slu, ips, eq, ind)

        #Checking return
        if lflag == 0:
            flag = ID_PY_COMPLETE
        else:
            raise Exception("DASP3 failed with flag %d" % lflag)

        #Retrieving statistics
        self.statistics["nsteps"] += dasp3dp.COUNTS.NSTEP
        self.statistics["nyder"] += dasp3dp.COUNTS.NYDER
        self.statistics["nzder"] += dasp3dp.COUNTS.NZDER
        self.statistics["nerrfails"] += dasp3dp.COUNTS.NREJ
        self.statistics["nlus"] += 0

        return flag, self._tlist, self._ylist
Exemplo n.º 2
0
#...ERROR TOLERANCE PARAMETERS
tol = 1.e-3
absrel = ones((4, ))
wght = ones((4, ))

#...SINGULAR PERTURBATION PARAMETER
eps = array([.33333333e-3])

#...SIMULATION OF BELOUSOV-ZHABOTINSKII REACTION

a = empty((m, m))
w = empty((m, m))
slu = empty((2 * m, ))
ips = empty((m, ), 'int32')
ind = empty((2 * m, ), 'int32')
eq = empty((m, ), 'bool')
print tol
t, lflag = dasp.dasp3(dydt, dzdt, outpda, t, tend, wsy, wsz, n, m, tol, absrel,
                      wght, eps, a, w, slu, ips, eq, ind)
print 't, lflag', t, lflag
stats = """ 
Statistics
==========
NSTEPS {nsteps}  NYDERIV {nyderiv}  NZDERIV {nzderiv}
Rejected steps {nrej}
"""
print stats.format(nsteps=dasp.COUNTS.NSTEP,
                   nyderiv=dasp.COUNTS.NYDER,
                   nzderiv=dasp.COUNTS.NZDER,
                   nrej=dasp.COUNTS.NREJ)