8 from optparse
import OptionParser
13 from grid
import ImplicitSolver
, ExplicitSolver
18 parser
= OptionParser()
19 parser
.add_option("-t", "--time", dest
="time", help="Time", metavar
="TIME", default
="1e-14")
20 parser
.add_option("-y", dest
="ny", help="Y capacity", metavar
="I", default
="20")
21 parser
.add_option("-z", dest
="nz", help="Z capacity", metavar
="J", default
="20")
22 parser
.add_option("-s", "--ht", dest
="ht", help="time step", metavar
="STEP", default
="")
23 (options
, args
) = parser
.parse_args()
25 time
= np
.float64(options
.time
)
26 ny
= np
.int(options
.ny
)
27 nz
= np
.int(options
.nz
)
29 if (len(options
.ht
) != 0):
30 ht
= np
.float64(options
.ht
)
32 solver_s
= Solver(ny
, nz
, time
, ht
, solver
='python', debug
=True)
33 solver_w
= Solver(ny
, nz
, time
, ht
, solver
='blitz', debug
=True)
34 solver_i
= Solver(ny
, nz
, time
, ht
, solver
='inline', debug
=True)
44 print 'standard:', t2
- t1
45 print 'blitz:', t3
- t2
46 print 'inline:', t4
- t3
50 parser
= OptionParser()
51 parser
.add_option("-t", "--time", dest
="time", help="Time", metavar
="TIME", default
="1e-14")
52 parser
.add_option("-y", dest
="ny", help="Y capacity", metavar
="I", default
="20")
53 parser
.add_option("-z", dest
="nz", help="Z capacity", metavar
="J", default
="20")
54 parser
.add_option("-s", "--ht", dest
="ht", help="time step", metavar
="STEP", default
="")
55 (options
, args
) = parser
.parse_args()
57 time
= np
.float64(options
.time
)
58 ny
= np
.int(options
.ny
)
59 nz
= np
.int(options
.nz
)
61 if (len(options
.ht
) != 0):
62 ht
= np
.float64(options
.ht
)
64 # solver = Solver(ny, nz, time, ht, solver='inline', debug=True)
67 solver
= ImplicitSolver(ny
, nz
, time
, ht
, debug
=True)
70 #solvere = Solver(ny, nz, time, ht, scheme='explicit')
73 d
= np
.arange(0, solver
.J
+ 1)
74 z
= [solver
.hz
* j
for j
in d
]
75 Ea
= [Exm(const
.LY
/2, z_
, time
, 1000) for z_
in z
]
76 En
= u
[u
.shape
[0] / 2, :]
78 a_line
, = plt
.plot(z
, Ea
, lw
=1, color
="red")
79 n_line
, = plt
.plot(z
, En
, lw
=1, color
="green")
80 plt
.legend((a_line
, n_line
), (u
"Analitycal", u
"Implicit scheme"))
82 plt
.xlim((min(z
), max(z
)))
85 if __name__
== '__main__':