def test_integralKernelMinus(self):
        n = 10
        m = 10
        listn = np.zeros(n, dtype=object)
        vals = np.zeros((n, m), dtype=object)
        for i in range(n):
            Plus0 = np.array(CFS_Action.integralKernelMinus(i + 1)).reshape(
                2, 2)
            print(Plus0)
            #Plus1 = np.array(CFS_Action.integralKernelMinus(i +1), dtype = object).reshape(2,2)
            listn[i] = si.lambdify(r[0], [
                sy.simplify(-2 * si.cos(r[0] / 2) * CFS_Action.prefactor(i) *
                            JacPol(si.Rational(1, 2), si.Rational(3, 2), i) +
                            Plus0[0, 0] + Plus0[1, 1])
            ],
                                   real=False)
            #print( sy.simplify(JacPol(1/2,3/2, i)),'=?=', sy.jacobi(i, 1/2,3/2, r[0]))
            #listn[i] =si.lambdify(r[0], [sy.simplify(JacPol(1/2,3/2, i)) - sy.jacobi(i, 1/2,3/2, r[0])])

        for i in range(n):
            for j in range(m):
                vals[i, j] = listn[i](j)

        print(vals)
        np.testing.assert_almost_equal(vals, np.zeros((n, m)), 10)
    def test_integralKernelPlus(self):
        '''
        The idea in this test is to use the fact, that i know that if i 
        add the diagonal terms, the imaginary parts cancel each other out and
        the real terms add up. That's the idea for this and the following 3 tests. 
        Also this test is the most updated version. Here i do not use lambdify, 
        because of simplify, the terms really cancel to zero. Befor that i didn't 
        use simplify, so i had to use lambdify. I'm keeping the other tests the 
        way they are, so that i just can check how i did this. There were some 
        problems, i had to figure out and in future i maybe need to look it up.:) 
        '''
        n = 10
        m = 10
        listn = np.zeros(n, dtype=object)
        vals = np.zeros((n, m), dtype=object)
        for i in range(n):
            Plus0 = np.array(CFS_Action.integralKernelPlus(
                i + 1))  #, dtype = object).reshape(2,2)
            print(Plus0)
            listn[i] = sy.simplify(
                -2 * si.cos(r[0] / 2) * CFS_Action.prefactor(i) *
                JacPol(si.Rational(1, 2), si.Rational(3, 2), i) + Plus0[0, 0] +
                Plus0[1, 1])
        for i in range(n):
            vals[i] = listn[i]

        print(vals)
        np.testing.assert_array_equal(listn, np.zeros(n), 10)
Пример #3
0
    def integralKernelMinus(self, n):
        n = n - 1
        lala1 = sy.jacobi(n, si.Rational(1, 2), si.Rational(3, 2), r[0])
        lala2 = sy.jacobi(n, si.Rational(3, 2), si.Rational(1, 2), r[0])

        return self.prefactor(n) * (si.cos(r[0] / 2) * lala1 * ident +
                                    I * si.sin(r[0] / 2) * lala2 * sigma3)
    def test_Lagrangian(self):
        """
        This Test only works for N  = 1, Rho=1.
        """
        n = 10

        LagVals = np.zeros(n)
        for i in range(n):
            KK = si.Rational(i, 1)
            CFS_Action.K_Liste[0] = KK
            Lag = CFS_Action.lagrangian_without_bound_constr()
            delta = 1 - KK**2 + (1 + KK**2) * sy.cos(r[0])
            Res = si.pi**(-8) * 8 * (1 + KK**2) * si.cos(r[0] / 2)**2 * delta
            LagVals[i] = sy.simplify(Res - Lag)
        np.testing.assert_array_equal(LagVals, np.zeros(n))
Пример #5
0
Taking everything together, our code is:

.. literalinclude:: ../examples/noisy_lorenz.py
	:dedent: 1
	:lines: 75-100
"""

if __name__ == "__main__":
    from jitcsde import y, jitcsde
    import numpy
    import symengine

    ρ = 28
    σ = 10
    β = symengine.Rational(8, 3)
    p = 0.1

    f = [σ * (y(1) - y(0)), y(0) * (ρ - y(2)) - y(1), y(0) * y(1) - β * y(2)]

    g = [p * y(i) for i in range(3)]

    SDE = jitcsde(f, g)

    initial_state = numpy.random.random(3)
    SDE.set_initial_value(initial_state, 0.0)

    data = []
    for time in numpy.arange(0.0, 100.0, 0.01):
        data.append(SDE.integrate(time))
    numpy.savetxt("timeseries.dat", data)
Пример #6
0
 def lagrangian_without_bound_constr(self):
     sub1 = self.closedChain()
     return np.trace(np.dot(
         sub1, sub1)) - si.Rational(1, 4) * np.trace(sub1) * np.trace(sub1)