Esempio n. 1
0
def test_stratHeun_ND_additive():
    tspan = np.arange(0.0, 2000.0, 0.002)
    y0 = np.zeros(3)
    def f(y, t):
        return np.array([ -1.0*y[0],
                          y[2],
                          -1.0*y[1] - 0.4*y[2] ])
    def G(y, t):
        return np.diag([0.2, 0.0, 0.5])
    y = sdeint.stratHeun(f, G, y0, tspan)
    w = np.fft.rfft(y[:, 2])
Esempio n. 2
0
def test_stratHeun_ND_additive():
    tspan = np.arange(0.0, 2000.0, 0.002)
    y0 = np.zeros(3)

    def f(y, t):
        return np.array([-1.0 * y[0], y[2], -1.0 * y[1] - 0.4 * y[2]])

    def G(y, t):
        return np.diag([0.2, 0.0, 0.5])

    y = sdeint.stratHeun(f, G, y0, tspan)
    w = np.fft.rfft(y[:, 2])
Esempio n. 3
0
 def test_stratHeun_R74(self, exact_solution_R74):
     (dW, I, J, f, f_strat, G, G_separate, y0, tspan,
      y) = exact_solution_R74
     yHeun = sdeint.stratHeun(f_strat, G, y0, tspan, dW=dW)
     _assert_close(yHeun, y, 1e-2, 1e-2)
     return yHeun
Esempio n. 4
0
 def test_stratHeun_KPS445(self, exact_solution_KPS445):
     (dW, I, J, f, f_strat, G, y0, tspan, y) = exact_solution_KPS445
     yHeun = sdeint.stratHeun(f_strat, G, y0, tspan, dW=dW)[:, 0]
     _assert_close(yHeun, y, 1e-2, 1e-2)
     return yHeun
Esempio n. 5
0
 def test_stratHeun_R74(self, exact_solution_R74):
     (dW, I, J, f, f_strat, G, G_separate, y0, tspan,y) = exact_solution_R74
     yHeun = sdeint.stratHeun(f_strat, G, y0, tspan, dW=dW)
     _assert_close(yHeun, y, 1e-2, 1e-2)
     return yHeun
Esempio n. 6
0
 def test_stratHeun_KPS445(self, exact_solution_KPS445):
     (dW, I, J, f, f_strat, G, y0, tspan, y) = exact_solution_KPS445
     yHeun = sdeint.stratHeun(f_strat, G, y0, tspan, dW=dW)[:,0]
     _assert_close(yHeun, y, 1e-2, 1e-2)
     return yHeun
    return w


def g(x, t):
    """ This simulates the right part of equation (5.1).
    """
    z = x * sigma[alpha[time_to_index[t]]]
    return z


def f(x, t):
    """ Simulates left part of equation (5.1).
    """
    return x * (b[alpha[time_to_index[t]]] -
                x * a[alpha[time_to_index[t]]])


result = sdeint.stratHeun(f, g, x0, tspan)


import matplotlib.pylab as plt
plt.style.use('ggplot')

fig = plt.figure()
ax = plt.subplot()
ax.clear()
ax.plot(tspan, result)
ax.legend()
fig.tight_layout()