This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Understanding Method of Manufactured solutions w.r.t. heat equation

0 votes

Hello,

I am trying to understand the MMS and also solving the heat equation for the first time.

So, I have a working code built on the equation below. I understand the superficial structure of MMS, and how the individual components of the python code below come together, but I am not able to make sense of the entire process with heat eq. comprehensively. So we chose a solution, then project it on the mesh as initial condition at t=0, then the heat source derived from the solution is used in bilinear form, and the selected solution is also used a BC (updated with time).

  1. It would be very kind if someone could explain this concept in brief to make sense out of it. I have a basic idea which makes sense of the fact that we use this approach to verify the code, but still if anyone could put in a few words of conceptual simplicity, it would be awesome.

  2. In context to the heat equation, how is the physics working here? I mean, we have an initial condition of heat distribution on the mesh given by u0, and we are controlling the heat value on Boundary using the solution by updating it with time, then we are also heating the mesh from source 'f'. So the heat distribution in mesh changes from u0 at t= 0 to u1 at t = T under the influence of given source. Is that correct?

gh

This is the code and below that is the output I get:

mesh = UnitSquareMesh (8, 8)
V = FunctionSpace (mesh, "Lagrange", 1)

dt = Constant (0.3) ; t = float (dt) ; T = 1.8
t0 = 0
I = Expression ("exp(-4*DOLFIN_PI*DOLFIN_PI*t)*cos(2* DOLFIN_PI *x[0])*cos(2* DOLFIN_PI *x[1])", t=t0 )

u0 = interpolate (I, V)
u1 = Function (V)

u = TrialFunction (V)
v = TestFunction (V)
f = Expression ("4*DOLFIN_PI*DOLFIN_PI *exp( -4* DOLFIN_PI * DOLFIN_PI *t) *cos(2* DOLFIN_PI *x[0]) *cos(2* DOLFIN_PI *x[1])",t=t0 )
a = u*v*dx + dt* inner (grad(u), grad(v))*dx
L = u0*v*dx + dt*f*v*dx
bc = DirichletBC (V, I ,"on_boundary")

while (t <= T):
   I.t = t
   f.t = t
   solve (a == L , u1 , bc)
   u0.assign (u1)    # Update
   t += float (dt)
plot (u1 , title = "Approximated final solution", interactive =True)

fg

asked Oct 5, 2015 by Chaitanya_Raj_Goyal FEniCS User (4,150 points)
edited Oct 5, 2015 by Chaitanya_Raj_Goyal

1 Answer

+1 vote

MMS is typically used to verify the code by checking wether certain error estimates
are valid. For the heat equation you should see that the error decrease in
terms of dt and h of certain powers. These tests are quite often pretty strict
in the sense that many bugs will show up as violations of the estimates.

There is no physics in MMS. Typically, MMS solution are simplified analytical
expressions that are hard to imaging in real word examples. However,
if your program has been verified with MMS, then you typically only
need to change the BC and IC to get to a real example. The edits will be
very local and can be verified on their own.

answered Oct 5, 2015 by Kent-Andre Mardal FEniCS Expert (14,380 points)
...