Blog: Meeting 3/24: problem.py

File problem.py, 658 bytes (added by smurugan, 11 years ago)
Line 
1import math
2import numpy as np
3
4xmin = 0 #Left Boundary
5xmax = 1 #Right Boundary
6dx = .01 #stepsize
7t_final = .25 #Final time in Computational Units
8gamma = 1.4
9CFL = .05
10npts = int((xmax - xmin)/dx)
11frames = 1 #number of data prints
12Q_TOL = 2 #tolerance level for AIRS
13
14
15def init_grid():
16 U = np.zeros((npts, 3))
17 #From here on is user defined initial conditions
18 #U[i, :] is defined as [density, velocity, pressure]
19 UL0 = np.array([1.0,0.75,1.0])
20 UR0 = np.array([.125, 0.0, .1])
21 x0 = .5
22 for i in range(npts):
23 for j in range(3):
24 if (i*dx) < x0:
25 U[i,j] = UL0[j]
26 else:
27 U[i,j] = UR0[j]
28 return U, t_final, frames