Heat conduction problem with direction dependent parameters

More
3 years 9 months ago - 3 years 9 months ago #3560 by user85
Hello guys,

I want to simulate a heat conduction problem with a direction dependent heat conductivity. Therefore, I use the H1 finite element space.

The heat conductivity coefficients are stored in separate CoefficientFunctions:

coeff_ax = CoefficientFunction((1/1000,0,0))
coeff_ay = CoefficientFunction((0,1/100000,0))
coeff_az = CoefficientFunction((0,0,1/10000))

Now I want to assemble the BilinearForm:

a = BilinearForm((coeff_ax*(grad(u)[0]) + coeff_ay*(grad(u)[1])+ coeff_az*(grad(u)[2])) * grad(v) * dx)

Is this the best way or is there a more efficient way, e.g., where I only need scalar-valued CoefficientFunctions?

Thank you for your help!

Best,
Max
Last edit: 3 years 9 months ago by user85.
More
3 years 9 months ago - 3 years 9 months ago #3561 by joachim
the code get's more compact if you use a matrix-CF for the conductivity:
Code:
coef_a = CoefficientFunction( ( 1/1000, 0, 0, 0, 1, 0, 0, 0, 10), dims=(3,3) ) BilinearForm( (coef_a * grad(u) ) * grad(v) )

you can print the expression tree:
Code:
print( coef_a * grad(u) * grad(v) )
a rule of thumb is trying to keep the expression tree as compact as possible.

Joachim
Last edit: 3 years 9 months ago by joachim.
The following user(s) said Thank You: user85
More
3 years 9 months ago - 3 years 9 months ago #3595 by user85
Hello Joachim,

thank you once again for your help. Now I have created a simple python script to simulate such an inhomogeneous heat conductivity problem over time (see example_forum.py).


File Attachment:

File Name: solutions.zip
File Size:1,570 KB


The example is about a brick element which is heated by a constant heat flow into the element.

However, I wonder about the solution which seems to be unphysical. If I choose the values
Code:
scal_x = 1 scal_y = 0.01 #1 scal_z = 0.1 #1

to account for direction dependent heat conductivity, I get temperatures (at intermediate points in time) which are below the initial temperature. This cannot be correct since the heat flow into the brick is always positive.

Do you have an answer to this issue?

Thank you very much!

Best,
Max
Last edit: 3 years 9 months ago by user85.
More
3 years 9 months ago #3596 by joachim
Hi Max,

I found two problems:

line 36: gfu_old = gfu

you make gfu_old the same Python object as gfu. Just two names.

I guess you want:
Code:
gfu_old = GridFunction(h1) gfu_old.vec.data = gfu.vec


The more serious issue is the missing comparison principle of finite elements, even of of lowest order methods. Thus, also positive sources may lead to negativ temperature. This failure is much more serious for very anisotropic conductivities.

But it works for lowest order mixed or hybrid mixed methods (I think for anisotropic as well) !
Have a look into sections

docu.ngsolve.org/latest/i-tutorials/unit-2.5-mixed/mixed.html
docu.ngsolve.org/latest/i-tutorials/unit-2.7-hybrid/hybrid.html

Joachim
The following user(s) said Thank You: user85
Time to create page: 0.141 seconds