# Heat conduction problem with direction dependent parameters

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:

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

Best,
Max

the code getâ€™s more compact if you use a matrix-CF for the conductivity:

``````coef_a = CoefficientFunction( ( 1/1000, 0, 0,   0, 1, 0,  0, 0, 10), dims=(3,3) )

you can print the expression tree:

``print(  coef_a * grad(u) * grad(v)  )``

a rule of thumb is trying to keep the expression tree as compact as possible.

Joachim

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).

https://ngsolve.org/media/kunena/attachments/1494/solutions.zip

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

```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

Attachment: example_forum.py

Attachment: solutions.zip

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:

``````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

Joachim