@@ -195,7 +195,7 @@ def evolve(self, C, tmax):
195195 self .t = 0.0
196196
197197 g = self .grid
198-
198+
199199 # main evolution loop
200200 while (self .t < tmax ):
201201
@@ -222,80 +222,80 @@ def evolve(self, C, tmax):
222222 self .t += dt
223223
224224
225- if __name__ == "__main__" :
225+ if __name__ == "__main__" :
226226 #-----------------------------------------------------------------------------
227227 # sine
228-
228+
229229 xmin = 0.0
230230 xmax = 1.0
231231 nx = 256
232232 ng = 2
233233 g = Grid1d (nx , ng , bc = "periodic" )
234-
234+
235235 # maximum evolution time based on period for unit velocity
236236 tmax = (xmax - xmin )/ 1.0
237-
237+
238238 C = 0.8
239-
239+
240240 plt .clf ()
241-
241+
242242 s = Simulation (g )
243-
243+
244244 for i in range (0 , 10 ):
245245 tend = (i + 1 )* 0.02 * tmax
246246 s .init_cond ("sine" )
247-
247+
248248 uinit = s .grid .u .copy ()
249-
249+
250250 s .evolve (C , tend )
251-
251+
252252 c = 1.0 - (0.1 + i * 0.1 )
253253 g = s .grid
254254 plt .plot (g .x [g .ilo :g .ihi + 1 ], g .u [g .ilo :g .ihi + 1 ], color = str (c ))
255-
256-
255+
256+
257257 g = s .grid
258258 plt .plot (g .x [g .ilo :g .ihi + 1 ], uinit [g .ilo :g .ihi + 1 ], ls = ":" , color = "0.9" , zorder = - 1 )
259-
259+
260260 plt .xlabel ("$x$" )
261261 plt .ylabel ("$u$" )
262262 plt .savefig ("fv-burger-sine.pdf" )
263-
264-
263+
264+
265265 #-----------------------------------------------------------------------------
266266 # rarefaction
267-
267+
268268 xmin = 0.0
269269 xmax = 1.0
270270 nx = 256
271271 ng = 2
272272 g = Grid1d (nx , ng , bc = "outflow" )
273-
273+
274274 # maximum evolution time based on period for unit velocity
275275 tmax = (xmax - xmin )/ 1.0
276-
276+
277277 C = 0.8
278-
278+
279279 plt .clf ()
280-
280+
281281 s = Simulation (g )
282-
282+
283283 for i in range (0 , 10 ):
284284 tend = (i + 1 )* 0.02 * tmax
285-
285+
286286 s .init_cond ("rarefaction" )
287-
287+
288288 uinit = s .grid .u .copy ()
289-
289+
290290 s .evolve (C , tend )
291-
291+
292292 c = 1.0 - (0.1 + i * 0.1 )
293293 plt .plot (g .x [g .ilo :g .ihi + 1 ], g .u [g .ilo :g .ihi + 1 ], color = str (c ))
294-
295-
294+
295+
296296 plt .plot (g .x [g .ilo :g .ihi + 1 ], uinit [g .ilo :g .ihi + 1 ], ls = ":" , color = "0.9" , zorder = - 1 )
297-
297+
298298 plt .xlabel ("$x$" )
299299 plt .ylabel ("$u$" )
300-
300+
301301 plt .savefig ("fv-burger-rarefaction.pdf" )
0 commit comments