Problem imposing Dirichlet boundary conditions for unsteady Heat Equation

More
4 years 7 months ago #2580 by Luma
Hello NGSolve users!

I am pretty new to the software and my question might be caused by my inexperience, but even after doing the tutorials and watching the videos, i struggle to impose inhomogeneous Dirichlet boundary conditions on the example of unsteady heat equation (similar to 3.1):

I want to set a certain temperature at the bottom boundary of the unit square and i do so by setting gfu.Set(mytemperature, BND)
and embedding it into the load vector
rhs = f.vec.CreateVector()
rhs.data = f.vec - a.mat * gfu.vec ,
like shown in section 1.3 of the tutorials.

Using this new right hand side in the implicit Euler scheme given in 3.1
res.data = dt * rhs - dt * a.mat * gfu.vec
gfu.vec.data += invmstar * res
causes the solution to explode in the vicinity of the Dirichlet boundary.

(Another small issue: I am currently not able to use 'dx' for the definition of the bilinear and linear forms. Despite using version 6.2.1810 on python 3.7, the error states that dx is not defined. So i just used SymbolicBFI() instead)

Again, sorry if this is a obvious mistake, but im really stuck here.
I attached a python script containing the code that doesn't behave like i expect it to.

Thanks in advance for your supportnd kind regards!
Lukas
Attachments:
More
4 years 7 months ago - 4 years 7 months ago #2581 by hvwahl
Hi Lukas,

the main issue is the fact that you are dealing with a time-dependent problem, such that the different steps (building the right-hand side, setting the boundary condition and homogenising the boundary condition) needs to be done in every time step and in the correct order:

First, the right hand side needs the solution from the last time-step, so the first thing is to compute the new right-hand side for that particular time-step:
Code:
res.data = m.mat * gfu.vec + dt * f.vec
Then you can modify the solution, i.e. set the in-homogeneous Dirichlet condition for the homogenisation:
Code:
gfu.Set(283.15, BND)
with this you can then homogenise the boundary condition with respect to the system you solve in that time-step (the system is mstar, rather than a) and solve the requires system
Code:
res.data += -mstar * gfu.vec gfu.vec.data += invmstar * res


I hope this helps.

Best wishes,
Henry
Last edit: 4 years 7 months ago by hvwahl.
The following user(s) said Thank You: Luma
More
4 years 7 months ago #2582 by christopher
Hi,
and your problem with dx is that your version (1810) is quite old. dx was introduced about a year ago. Current version is 2004.
Time to create page: 0.102 seconds