File:GaussianUpwind1D.gif
From Wikimedia Commons, the free media repository
Jump to navigation
Jump to search
GaussianUpwind1D.gif (800 × 600 pixels, file size: 208 KB, MIME type: image/gif, looped, 21 frames)
File information
Structured data
Captions
Summary[edit]
DescriptionGaussianUpwind1D.gif |
English: Upwind scheme for with boundary condition . |
Date | |
Source | Own work |
Author | Shiyu Ji |
Python/Matplotlib Code[edit]
# A numerical solution of 1D Gaussian advection equation by Upwind Scheme.
import matplotlib.pyplot as pl
import numpy as np
t0 = 0.0
dt = 0.1
t_final = 2
x0 = -2.0
dx = 0.1
x_max = 4.0
T = np.arange(t0, t_final+dt, dt)
X = np.arange(x0, x_max+dx, dx)
U = [0.0 for _ in X]
fig, ax = pl.subplots()
nframe = 0
for t in T:
if t == t0:
for i in range(len(X)):
U[i] = np.exp(-X[i]**2)
else:
U_prime = [0.0 for _ in X]
for i in range(len(X)):
if i == 0:
U_prime[i] = np.exp(-(x0-(1-np.cos(t)))**2)
elif i == len(X)-1:
U_prime[i] = np.exp(-(x_max-(1-np.cos(t)))**2)
else:
a = np.sin(t)
if a > 0:
U_prime[i] = U[i] - a*dt/dx*(U[i] - U[i-1])
else:
U_prime[i] = U[i] - a*dt/dx*(U[i+1] - U[i])
U = U_prime
ax.clear()
line, = ax.plot(X, U, 'b-', linewidth=3)
ax.set_xlabel('x')
ax.set_ylabel('u')
ax.set_xlim([x0, x_max])
fig.savefig('upwind1d/frame_'+"%03d" % nframe+'.png')
nframe += 1
# To generate GIF: convert frame_* GaussianUpwind1D.gif
Licensing[edit]
I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 05:26, 27 November 2016 | 800 × 600 (208 KB) | Shiyu Ji (talk | contribs) | for animated thumbnail | |
05:04, 27 November 2016 | 800 × 600 (6.05 MB) | Shiyu Ji (talk | contribs) | User created page with UploadWizard |
You cannot overwrite this file.
File usage on Commons
There are no pages that use this file.
File usage on other wikis
The following other wikis use this file:
- Usage on en.wikipedia.org
- Usage on mn.wikipedia.org
Hidden categories: