Added python module for native solution and parameter setting
[pde-python.git] / err.py
blobcfe49aae665b84d55694cecfcce2f178de9a336f
1 #!/usr/bin/python
2 #-*- coding: utf-8 -*-
4 from optparse import OptionParser
6 import numpy as np
8 import const as c
9 from grid import ExplicitSolver, norm
10 from waves import Exm
13 def err_main():
14 '''
15 Calculates error (norm) series
16 '''
18 # parser initialization
19 parser = OptionParser()
20 parser.add_option('--hy', dest='hy', default='1e-7')
21 parser.add_option('--hz', dest='hz', default='1e-7')
22 parser.add_option('--ht', dest='ht', default='1e-16')
23 (opts, args) = parser.parse_args()
25 # constants
26 time = np.double('1e-14')
27 ly = np.double('2e-5')
28 lz = np.double('2e-5')
30 ht = np.double(opts.ht)
31 hy = np.double(opts.hy)
32 hz = np.double(opts.hz)
34 solver = ExplicitSolver(int(ly / hy), int(lz / hz), time, ht, solver='inline')
35 uh = solver.solve()
37 u = uh.copy()
38 M = 550
39 for i in xrange(u.shape[0]):
40 for j in xrange(u.shape[1]):
41 u[i, j] = Exm(i * hy, j * hz, time, M)
43 print norm(u, uh)
46 if __name__ == '__main__':
47 err_main()