The Burgers' equation sums up the equations solved in the last two posts: the nonlinear convection and the diffusion; still being not very complicated, some analytical solutions exist and the numerical solution can be validated easily.
The set of equations to be solved is the following:
∂u∂t+u∂u∂x+v∂u∂y=ν(∂2u∂x2+∂2u∂y2)
∂v∂t+u∂v∂x+v∂v∂y=ν(∂2v∂x2+∂2v∂y2)
They all look familiar and to solve them we will be using the steps we already know.
The algebraic approximation is the following:
un+1i,j−uni,jΔt+uni,juni,j−uni−1,jΔx+vni,juni,j−uni,j−1Δy=
ν(uni+1,j−2uni,j+uni−1,jΔx2+uni,j+1−2uni,j+uni,j−1Δy2)
vn+1i,j−vni,jΔt+uni,jvni,j−vni−1,jΔx+vni,jvni,j−vni,j−1Δy=
ν(vni+1,j−2vni,j+vni−1,jΔx2+vni,j+1−2vni,j+vni,j−1Δy2)
And the scheme to be implemented in Python:
un+1i,j=uni,j−ΔtΔxuni,j(uni,j−uni−1,j)−ΔtΔyvni,j(uni,j−uni,j−1)+
νΔtΔx2(uni+1,j−2uni,j+uni−1,j)+νΔtΔy2(uni,j+1−2uni,j+uni,j+1)
vn+1i,j=vni,j−ΔtΔxuni,j(vni,j−vni−1,j)−ΔtΔyvni,j(vni,j−vni,j−1)+
νΔtΔx2(vni+1,j−2vni,j+vni−1,j)+νΔtΔy2(vni,j+1−2vni,j+vni,j+1)
The code written to solve this is made by reusing pieces from the mentioned codes.
|
Python code for Burgers Equation [lines 1-44] |
|
Python code for Burgers Equation [lines 45-87] |
This time another time of plot is used, the wireframe.
The initial conditions:
The solution after 120 and 1200 steps:
The discussion from previous steps apply: the wave profile is affected both by convection and diffusion; convection makes the wave to be carried with the flow and deforms it, creating a crest; the diffusion makes the momentum to spread in the domain and reduces the magnitude of the wave.
The code and plots are available on
my GitHub account; several changes from the posted code may apply.
If there are any question feel free to leave a comment below.
0 comments:
Post a Comment