1D Burgers equation#
We consider the 1d Burgers equation
\(u_0(x) := u(x,t)\) denotes the initial condition. We choose homogeneous neumann boundary conditions in this example, i.e. $\(\partial_n u = 0, \partial \Omega\)\( with \)\Omega = (0,1)$
Time scheme#
We shall use a \(\theta\)-scheme in this case and consider the following problem
hence
from now on, we shall denote by \(f^n\) the right hand side of the previous equation
Weak formulation#
Let \(v \in \mathcal{V}\) be a function test, we have by integrating by parts the highest order term:
The previous weak formulation is still nonlinear with respect to \(u^{n+1}\). We shall then follow the same strategy as for the previous chapter on nonlinear Poisson problem.
The strategy is to define the left hand side as a LinearForm with respect to \(v\), then linearize it around \(u^{n+1}\). We therefor can use either Picard or Newton method to treat the nonlinearity.
We consider the following linear form
Our problem is then
where
SymPDE code#
domain = Line()
V = ScalarFunctionSpace('V', domain)
u = element_of(V, name='u')
v = element_of(V, name='v')
w = element_of(V, name='w')
un = element_of(V, name='un') # time iteration
uk = element_of(V, name='uk') # nonlinear solver iteration
x = domain.coordinates
nu = Constant('nu')
theta = Constant('theta')
dt = Constant('dt')
Defining the Linear form \(G\)#
# Linear form g: V --> R
expr = v * u + dt*theta*v*w*dx(u) + dt*theta*nu*dx(v)*dx(u)
g = LinearForm(v, integral(domain, expr))
Defining the Linear form \(l\)#
# Linear form l: V --> R
expr = v * un - dt*theta*v*un*dx(un) - dt*theta*nu*dx(v)*dx(un)
l = LinearForm(v, integral(domain, expr))
Picard Method#
Picard iteration#
# Variational problem
picard = find(u, forall=v, lhs=g(v, u=u,w=uk), rhs=l(v))
Newton Method#
Let’s define
Newton method writes
Newton iteration#
F = LinearForm(v, g(v,w=u)-l(v))
du = element_of(V, name='du')
Fprime = linearize(F, u, trials=du)
# Variational problem
newton = find(du, forall=v, lhs=Fprime(du, v,u=uk), rhs=-F(v,u=uk))