コード例 #1
0
ファイル: test_jitcode.py プロジェクト: neurophysik/jitcode
	def test_save_and_load_with_jac(self):
		self.ODE = jitcode_lyap(**vanilla,n_lyap=n,wants_jacobian=True)
		filename = self.ODE.save_compiled(overwrite=True)
		self.ODE = jitcode_lyap((),n=n,n_lyap=n,module_location=filename)
		self.ODE.set_integrator("vode")
		self.assertTrue(_is_C(self.ODE.f))
		self.assertTrue(_is_C(self.ODE.jac))
コード例 #2
0
 def test_save_and_load_with_jac(self):
     self.ODE = jitcode_lyap(**vanilla, n_lyap=n, wants_jacobian=True)
     filename = self.ODE.save_compiled(overwrite=True)
     self.ODE = jitcode_lyap((), n=n, n_lyap=n, module_location=filename)
     self.ODE.set_integrator("vode")
     self.assertTrue(_is_C(self.ODE.f))
     self.assertTrue(_is_C(self.ODE.jac))
コード例 #3
0
ファイル: test_jitcode.py プロジェクト: geier/jitcode
	def test_identity_of_lyaps(self):
		n = len(f)
		x = np.random.random((n+1)*n)
		ODE1 = jitcode_lyap(f, n_lyap=n)
		ODE2 = jitcode_lyap(f_alt, get_f_alt_helpers(), n_lyap=n)
		ODE1.set_integrator("dopri5")
		ODE2.set_integrator("dopri5")
		assert_allclose(ODE1.f(0.0,x), ODE2.f(0.0,x))
コード例 #4
0
ファイル: test_jitcode.py プロジェクト: kiaderouiche/jitcode
	def test_identity_of_lyaps(self):
		n = len(f)
		x = np.random.random((n+1)*n)
		ODE1 = jitcode_lyap(f, n_lyap=n)
		ODE2 = jitcode_lyap(f_alt, get_f_alt_helpers(), n_lyap=n)
		ODE1.set_integrator("dopri5")
		ODE2.set_integrator("dopri5")
		assert_allclose(ODE1.f(0.0,x), ODE2.f(0.0,x))
コード例 #5
0
 def test_regular(self):
     self.ODE = jitcode_lyap(**vanilla, n_lyap=n)
     self.ODE.set_integrator("dopri5")
コード例 #6
0
ファイル: double_fhn_lyapunov.py プロジェクト: geier/jitcode
    import numpy as np

    a = -0.025794
    b1 = 0.0065
    b2 = 0.0135
    c = 0.02
    k = 0.128

    t, y = provide_basic_symbols()

    f = [
        y(0) * (a - y(0)) * (y(0) - 1.0) - y(1) + k * (y(2) - y(0)),
        b1 * y(0) - c * y(1),
        y(2) * (a - y(2)) * (y(2) - 1.0) - y(3) + k * (y(0) - y(2)),
        b2 * y(2) - c * y(3)
    ]

    initial_state = np.array([1., 2., 3., 4.])

    n = len(f)
    ODE = jitcode_lyap(f, n_lyap=n)
    ODE.set_integrator("vode")
    ODE.set_initial_value(initial_state, 0.0)

    data = np.vstack(ODE.integrate(T) for T in range(10, 100000, 10))

    for i in range(n):
        lyap = np.average(data[1000:, n + i])
        stderr = sem(data[1000:, n + i])
        print("%i. Lyapunov exponent: % .4f ± %.4f" % (i + 1, lyap, stderr))
コード例 #7
0
ファイル: test_generation.py プロジェクト: dw-liedji/jitcode
 def evaluate(scenario):
     ODE = jitcode_lyap(**scenario, n_lyap=n)
     ODE.compile_C()
     return ODE.f(0.0, x)
コード例 #8
0
ファイル: test_jitcode.py プロジェクト: geier/jitcode
	def test_lyapunov_with_helpers_and_jac(self):
		self.ODE = jitcode_lyap(f_alt, get_f_alt_helpers(), n_lyap=self.n)
		self.ODE.set_integrator("vode")
コード例 #9
0
ファイル: test_jitcode.py プロジェクト: geier/jitcode
	def test_lyapunov_with_helpers(self):
		self.ODE = jitcode_lyap(f_alt, get_f_alt_helpers(), n_lyap=self.n)
		self.ODE.set_integrator("dopri5")
コード例 #10
0
ファイル: test_jitcode.py プロジェクト: geier/jitcode
	def test_lyapunov_with_jac(self):
		self.ODE = jitcode_lyap(f, n_lyap=self.n)
		self.ODE.set_integrator("vode")
コード例 #11
0
	b1 =  0.0065
	b2 =  0.0135
	c  =  0.02
	k  =  0.128
	
	f = [
		y(0) * ( a-y(0) ) * ( y(0)-1.0 ) - y(1) + k * (y(2) - y(0)),
		b1*y(0) - c*y(1),
		y(2) * ( a-y(2) ) * ( y(2)-1.0 ) - y(3) + k * (y(0) - y(2)),
		b2*y(2) - c*y(3)
		]
	
	initial_state = np.array([1.,2.,3.,4.])
	
	n = len(f)
	ODE = jitcode_lyap(f, n_lyap=n)
	ODE.set_integrator("vode")
	ODE.set_initial_value(initial_state,0.0)
	
	times = range(10,100000,10)
	lyaps = []
	for time in times:
		lyaps.append(ODE.integrate(time)[1])
	
	# converting to NumPy array for easier handling
	lyaps = np.vstack(lyaps)
	
	for i in range(n):
		lyap = np.average(lyaps[1000:,i])
		stderr = sem(lyaps[1000:,i]) # Note that this only an estimate
		print("%i. Lyapunov exponent: % .4f ± %.4f" % (i+1,lyap,stderr))
コード例 #12
0
ファイル: test_jitcode.py プロジェクト: neurophysik/jitcode
	def test_regular(self):
		self.ODE = jitcode_lyap(**vanilla,n_lyap=n)
		self.ODE.set_integrator("dopri5")
コード例 #13
0
ファイル: test_jitcode.py プロジェクト: kiaderouiche/jitcode
	def test_lyapunov_with_helpers_and_jac(self):
		self.ODE = jitcode_lyap(f_alt, get_f_alt_helpers(), n_lyap=self.n)
		self.ODE.set_integrator("vode")
コード例 #14
0
ファイル: test_jitcode.py プロジェクト: kiaderouiche/jitcode
	def test_lyapunov_with_helpers(self):
		self.ODE = jitcode_lyap(f_alt, get_f_alt_helpers(), n_lyap=self.n)
		self.ODE.set_integrator("dopri5")
コード例 #15
0
ファイル: test_jitcode.py プロジェクト: kiaderouiche/jitcode
	def test_lyapunov_with_jac(self):
		self.ODE = jitcode_lyap(f, n_lyap=self.n)
		self.ODE.set_integrator("vode")
コード例 #16
0
ファイル: test_jitcode.py プロジェクト: kiaderouiche/jitcode
	def test_lyapunov(self):
		self.ODE = jitcode_lyap(f, n_lyap=self.n)
		self.ODE.set_integrator("dopri5")
コード例 #17
0
 def test_jac(self):
     self.ODE = jitcode_lyap(**vanilla, n_lyap=n)
     self.ODE.set_integrator("lsoda")
コード例 #18
0
ファイル: test_jitcode.py プロジェクト: geier/jitcode
	def test_lyapunov(self):
		self.ODE = jitcode_lyap(f, n_lyap=self.n)
		self.ODE.set_integrator("dopri5")
コード例 #19
0
		def evaluate(scenario):
			ODE = jitcode_lyap(**scenario,n_lyap=n)
			ODE.compile_C()
			return ODE.f(0.0,x)
コード例 #20
0
ファイル: test_jitcode.py プロジェクト: neurophysik/jitcode
	def test_jac(self):
		self.ODE = jitcode_lyap(**vanilla,n_lyap=n)
		self.ODE.set_integrator("lsoda")