added graphs
[pde-python.git] / const.py
blob40d14765c5368fa54f0aa20af2f2f6db8f90886f
1 #-*- coding: utf-8 -*-
3 from numpy import sqrt, double, power
5 C = double('3e8')
6 LY = double('2e-5')
7 LZ = double('2e-5')
8 LAMBDA = double('2e-6')
10 HY = double(1e-7)
11 HZ = double(1e-7)
13 def get_characteristic(x):
14 if not isinstance(x, double):
15 raise TypeError('argument must be numpy.float64')
16 else:
17 s = "%g" % x
18 l = s.split('e')
19 return int(l[1])
21 def timestep(val):
22 # val = step / (C * sqrt(2))
23 c = get_characteristic(val)
24 return power(10, double(c))
26 HT = timestep(HY)
28 def test_exp_stable(hy=HY, hz=HZ, ht=HZ, c=C):
29 gy = (c**2 * ht**2) / (hy**2)
30 gz = (c**2 * ht**2) / (hz**2)
31 return (gy + gz < 1)
33 def test_imp_stable(hy=HY, ht=HT, c=C):
34 gy = (c**2 * ht**2) / (hy**2)
35 return (gy <= 1)