Skip to content
This repository has been archived by the owner on Mar 8, 2021. It is now read-only.

Commit

Permalink
PEP8 ODE systems test
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Oct 9, 2013
1 parent 7948d54 commit ce5bc0b
Showing 1 changed file with 14 additions and 71 deletions.
85 changes: 14 additions & 71 deletions test/ode_systems.py
Expand Up @@ -18,11 +18,7 @@
from __future__ import division




import numpy
import numpy.linalg as la
from hedge.backends.jit import Discretization as JITDiscretization
from math import sqrt, log, sin, cos, exp


Expand All @@ -42,9 +38,6 @@ def __init__(self):
self.soln_1(self.t_start)])





class Basic(LinearODESystemsBase):
"""
ODE-system - basic
Expand Down Expand Up @@ -78,9 +71,6 @@ def soln_0(self, t):
)





class Full(LinearODESystemsBase):
"""
ODE-system - full
Expand Down Expand Up @@ -115,9 +105,6 @@ def soln_1(self, t):
return exp(t)*sin(t)





class Real(LinearODESystemsBase):
"""
ODE-system - real
Expand Down Expand Up @@ -149,8 +136,6 @@ def soln_1(self, t):
return 1/3*exp(-4*t)*(2*exp(5*t)-3)




class Comp(LinearODESystemsBase):
"""
ODE-system - complex
Expand Down Expand Up @@ -182,9 +167,6 @@ def soln_1(self, t):
return sin(t)*(cos(2*t)-1)-cos(t)*sin(2*t)





class CC(LinearODESystemsBase):
"""
ODE-system - complex-conjungated
Expand Down Expand Up @@ -214,9 +196,6 @@ def soln_1(self, t):
return exp(t)*cos(t)





class Tria(LinearODESystemsBase):
"""
ODE-system - tria
Expand Down Expand Up @@ -250,9 +229,6 @@ def soln_0(self, t):
)





class Inh(LinearODESystemsBase):
"""
ODE-system - inhom
Expand Down Expand Up @@ -281,13 +257,11 @@ def s2s_rhs(self, t, u, v):

def soln_0(self, t):
return exp(-2*t) * (6/25*sin(3*t)
+42/25*cos(3*t))+8/25*exp(2*t)
+ 42/25*cos(3*t))+8/25*exp(2*t)

def soln_1(self, t):
return exp(-2*t) * (-42/25*sin(3*t)
+6/25*cos(3*t))-6/25*exp(2*t)


+ 6 / 25*cos(3*t))-6/25*exp(2*t)


class Inh2(LinearODESystemsBase):
Expand Down Expand Up @@ -326,9 +300,6 @@ def soln_1(self, t):
return -9/40*exp(-4*t)+3/5*exp(t)-0.5*t-3/8





class ExtForceStiff(LinearODESystemsBase):
"""
∂w/∂t = A w + f(t)
Expand Down Expand Up @@ -364,13 +335,11 @@ def soln_0(self, t):
- 1000 * (exp(-t) + exp(-0.001*t))

def soln_1(self, t):
return 1000 * (self.c1 * exp(self.lambda_1*t) * (self.lambda_1 + 1)\
+ self.c2 * exp(self.lambda_2*t) * (self.lambda_2 + 1)\
return 1000 * (self.c1 * exp(self.lambda_1*t) * (self.lambda_1 + 1)
+ self.c2 * exp(self.lambda_2*t) * (self.lambda_2 + 1)
- 999 * exp(-0.001*t))




class StiffUncoupled(LinearODESystemsBase):
"""
∂w/∂t = A w
Expand Down Expand Up @@ -401,9 +370,6 @@ def soln_1(self, t):
return exp(self.lambda_2*t)





class NonStiffUncoupled(LinearODESystemsBase):
"""
∂w/∂t = A w
Expand Down Expand Up @@ -434,17 +400,14 @@ def soln_1(self, t):
return exp(self.lambda_2*t)





class WeakCoupled(LinearODESystemsBase):
"""
A = [[-1,0.001]
[0.001,-0.001]]
"""
def __init__(self):
self.lambda_1 = -(sqrt(998005)+1001)/2000 #-1.000001001
self.lambda_2 = (sqrt(998005)-1001)/2000 #-0.000998999
self.lambda_1 = -(sqrt(998005)+1001)/2000 # -1.000001001
self.lambda_2 = (sqrt(998005)-1001)/2000 # -0.000998999
LinearODESystemsBase.__init__(self)
self.t_end = 2

Expand All @@ -470,16 +433,14 @@ def soln_1(self, t):
)




class WeakCoupledInit(LinearODESystemsBase):
"""
A = [[-1,0.001]
[0.001,-0.001]]
"""
def __init__(self):
self.lambda_1 = -(sqrt(998005)+1001)/2000 #-1.000001001
self.lambda_2 = (sqrt(998005)-1001)/2000 #-0.000998999
self.lambda_1 = -(sqrt(998005)+1001)/2000 # -1.000001001
self.lambda_2 = (sqrt(998005)-1001)/2000 # -0.000998999
self.a11 = -1
self.a12 = 0.001
self.t_start = 0
Expand Down Expand Up @@ -515,9 +476,6 @@ def soln_1(self, t):
)





class StrongCoupled(LinearODESystemsBase):
"""
A = [[-1,-1]
Expand Down Expand Up @@ -551,9 +509,6 @@ def soln_1(self, t):
)





class ExtForceNonStiff(LinearODESystemsBase):
"""
∂w/∂t = A w + f(t)
Expand Down Expand Up @@ -589,14 +544,10 @@ def soln_0(self, t):

def soln_1(self, t):
return self.c1 * (self.lambda_1 + 10) * exp(self.lambda_1*t)\
+ self.c2 *(self.lambda_2 + 10) * exp(self.lambda_2*t)\
+ self.c2 * (self.lambda_2 + 10) * exp(self.lambda_2*t)\
- 9 * exp(-t)






class StiffCoupled2(LinearODESystemsBase):
"""
A = [[-1,0.999]
Expand Down Expand Up @@ -624,10 +575,7 @@ def soln_0(self, t):
return exp(self.lambda_1*t) + exp(self.lambda_2*t)

def soln_1(self, t):
return exp(self.lambda_2*t)



return exp(self.lambda_2*t)


class StiffComp(LinearODESystemsBase):
Expand Down Expand Up @@ -657,10 +605,7 @@ def soln_0(self, t):
return 2*cos(10*t)

def soln_1(self, t):
return -20*sin(10*t)



return -20*sin(10*t)


class StiffComp2(LinearODESystemsBase):
Expand Down Expand Up @@ -699,15 +644,13 @@ def soln_0(self, t):
def soln_1(self, t):
return -1/self.a12 * (
(exp(self.alpha*t)*self.omega*sin(t*self.omega)
+ (self.a11-self.alpha)*exp(self.alpha*t)*cos(t*self.omega))*self.c2
+ (self.a11-self.alpha)*exp(self.alpha*t)*cos(t*self.omega))
* self.c2
+ ((self.a11-self.alpha)*exp(self.alpha*t)*sin(t*self.omega)
- exp(self.alpha*t)*self.omega*cos(t*self.omega))*self.c1
)





class StiffOscil(LinearODESystemsBase):
"""
A = [[10*sin(t),0]
Expand Down Expand Up @@ -735,4 +678,4 @@ def soln_0(self, t):
return 1/10*sin(t*10)

def soln_1(self, t):
return sin(t)
return sin(t)

0 comments on commit ce5bc0b

Please sign in to comment.