Blog: Meeting 3/24: adaptive.py

File adaptive.py, 780 bytes (added by smurugan, 11 years ago)
Line 
1# This is a 1-D Adaptive Riemann Solver, written by Ruka Murugan
2import sys
3import problem
4import solvers
5import printdata
6import numpy as np
7
8def main():
9 if len(sys.argv) == 2: solver_type = sys.argv[1]
10 else:
11 print error
12 return 0
13 time = 0
14 grid, t_final, frames = problem.init_grid()
15 framecount = 0
16 while time <= t_final:
17 if printdata.check(time, framecount):
18 printdata.printframe(grid, framecount)
19 framecount += 1
20 if framecount > frames: break
21 else: print 'Time error'
22 t_frame = framecount * t_final /frames
23 grid, time = solvers.getUpdate(grid, time, t_frame, solver_type)
24
25
26
27if __name__ == "__main__":
28 error = "Error, usage is 'python adaptive.py [option]. -1 for Adaptive Iterative, -2 for Adaptive Non-Iterative, -3 for Exact Solver."
29 main()
30