@@ -195,7 +195,7 @@ def evolve(self, C, tmax):
195
195
self .t = 0.0
196
196
197
197
g = self .grid
198
-
198
+
199
199
# main evolution loop
200
200
while (self .t < tmax ):
201
201
@@ -222,80 +222,80 @@ def evolve(self, C, tmax):
222
222
self .t += dt
223
223
224
224
225
- if __name__ == "__main__" :
225
+ if __name__ == "__main__" :
226
226
#-----------------------------------------------------------------------------
227
227
# sine
228
-
228
+
229
229
xmin = 0.0
230
230
xmax = 1.0
231
231
nx = 256
232
232
ng = 2
233
233
g = Grid1d (nx , ng , bc = "periodic" )
234
-
234
+
235
235
# maximum evolution time based on period for unit velocity
236
236
tmax = (xmax - xmin )/ 1.0
237
-
237
+
238
238
C = 0.8
239
-
239
+
240
240
plt .clf ()
241
-
241
+
242
242
s = Simulation (g )
243
-
243
+
244
244
for i in range (0 , 10 ):
245
245
tend = (i + 1 )* 0.02 * tmax
246
246
s .init_cond ("sine" )
247
-
247
+
248
248
uinit = s .grid .u .copy ()
249
-
249
+
250
250
s .evolve (C , tend )
251
-
251
+
252
252
c = 1.0 - (0.1 + i * 0.1 )
253
253
g = s .grid
254
254
plt .plot (g .x [g .ilo :g .ihi + 1 ], g .u [g .ilo :g .ihi + 1 ], color = str (c ))
255
-
256
-
255
+
256
+
257
257
g = s .grid
258
258
plt .plot (g .x [g .ilo :g .ihi + 1 ], uinit [g .ilo :g .ihi + 1 ], ls = ":" , color = "0.9" , zorder = - 1 )
259
-
259
+
260
260
plt .xlabel ("$x$" )
261
261
plt .ylabel ("$u$" )
262
262
plt .savefig ("fv-burger-sine.pdf" )
263
-
264
-
263
+
264
+
265
265
#-----------------------------------------------------------------------------
266
266
# rarefaction
267
-
267
+
268
268
xmin = 0.0
269
269
xmax = 1.0
270
270
nx = 256
271
271
ng = 2
272
272
g = Grid1d (nx , ng , bc = "outflow" )
273
-
273
+
274
274
# maximum evolution time based on period for unit velocity
275
275
tmax = (xmax - xmin )/ 1.0
276
-
276
+
277
277
C = 0.8
278
-
278
+
279
279
plt .clf ()
280
-
280
+
281
281
s = Simulation (g )
282
-
282
+
283
283
for i in range (0 , 10 ):
284
284
tend = (i + 1 )* 0.02 * tmax
285
-
285
+
286
286
s .init_cond ("rarefaction" )
287
-
287
+
288
288
uinit = s .grid .u .copy ()
289
-
289
+
290
290
s .evolve (C , tend )
291
-
291
+
292
292
c = 1.0 - (0.1 + i * 0.1 )
293
293
plt .plot (g .x [g .ilo :g .ihi + 1 ], g .u [g .ilo :g .ihi + 1 ], color = str (c ))
294
-
295
-
294
+
295
+
296
296
plt .plot (g .x [g .ilo :g .ihi + 1 ], uinit [g .ilo :g .ihi + 1 ], ls = ":" , color = "0.9" , zorder = - 1 )
297
-
297
+
298
298
plt .xlabel ("$x$" )
299
299
plt .ylabel ("$u$" )
300
-
300
+
301
301
plt .savefig ("fv-burger-rarefaction.pdf" )
0 commit comments