Step-26 Materials with different heat diffusivity in one model

67 views
Skip to first unread message

JT Hu

unread,
Feb 8, 2016, 3:15:00 PM2/8/16
to Deal.II Googlegroup
Hi everyone,

I am trying to model a two materials heat transfer model starting from
step-26. I was able to make the single materials model - just multiply
the diffusivity term to laplacian and old solution terms:

system_rhs.add(-(1 - theta) * time_step * WATER_DIFFUSIVITY, tmp);
system_matrix.add(WATER_DIFFUSIVITY * theta * time_step, laplace_matrix);

But I am not sure how to do this when the diffusivity varies with
space. Any suggestions, especially which functions might be more
useful?

Best,
Jingtian

Wolfgang Bangerth

unread,
Feb 8, 2016, 3:40:29 PM2/8/16
to dea...@googlegroups.com
The coefficient needs to be part of the formulas with which you compute
the matrices. To this end, take a look how the functions in
MatrixCreator allow passing arguments that denote spatially variable
functions.

Best
W.

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@math.tamu.edu
www: http://www.math.tamu.edu/~bangerth/

JT Hu

unread,
Feb 8, 2016, 4:15:45 PM2/8/16
to Deal.II Googlegroup
Dear Wolfgang:

I looked at the MatrixCreator module and the functions
create_mass_matrix or create_laplacian_matrix can take an function
argument which is by default 0. (a = 0) Is that the function I can
change to be spatially variable?

Suggestions are highly appreciated!

Best,
Jingtian
> --
> The deal.II project is located at http://www.dealii.org/
> For mailing list/forum options, see
> https://groups.google.com/d/forum/dealii?hl=en
> --- You received this message because you are subscribed to the Google
> Groups "deal.II User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to dealii+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Wolfgang Bangerth

unread,
Feb 8, 2016, 4:21:30 PM2/8/16
to dea...@googlegroups.com
On 02/08/2016 03:15 PM, JT Hu wrote:
>
> I looked at the MatrixCreator module and the functions
> create_mass_matrix or create_laplacian_matrix can take an function
> argument which is by default 0. (a = 0) Is that the function I can
> change to be spatially variable?

Correct, that's the argument you need to use. It takes a *pointer* to a
Function<dim> object which by default is zero, but if you pass a nonzero
pointer, then that will be taken for the spatially variable coefficient.

JT Hu

unread,
Feb 8, 2016, 7:09:56 PM2/8/16
to Deal.II Googlegroup
Dear Wolfgang and other DealII group members:

Thanks for the suggestion - the code runs now. I basically created
another function (similar to RHS) that returns different diffusivity
at different point, created a dynamic function object and passed its
pointer to create_laplace_matrix function. Is that right? I assumed
that the same equation pretty much works and that
create_laplace_matrix will just multiply the diffusivity values to the
right matrix entries.

I still have some problems and questions:
1. Is there a special reason for passing the function by pointer
instead of reference? The RHS function is usually passed by reference.
Just for curiosity.
2. I got some strange result as attached. The distribution should be
simple since I have only a constant spherical heater in the center. It
might still be an issue of the time step I set, but I am not sure if
there is any other issue.

Any suggestions or comments are highly appreciated!

Best,
Jingtian
time step 1.png
time step 2.png
time step 6.png
time step 8.png
step-26.cc

Wolfgang Bangerth

unread,
Feb 8, 2016, 9:59:14 PM2/8/16
to dea...@googlegroups.com
On 02/08/2016 06:09 PM, JT Hu wrote:
> Thanks for the suggestion - the code runs now. I basically created
> another function (similar to RHS) that returns different diffusivity
> at different point, created a dynamic function object and passed its
> pointer to create_laplace_matrix function. Is that right? I assumed
> that the same equation pretty much works and that
> create_laplace_matrix will just multiply the diffusivity values to the
> right matrix entries.

Yes, that is the idea. The coefficient you pass in is part of the
integrand when computing the matrix entries.


> I still have some problems and questions:
> 1. Is there a special reason for passing the function by pointer
> instead of reference? The RHS function is usually passed by reference.
> Just for curiosity.

It's because there is no way to default a reference in case you don't
want to pass a coefficient. For pointers, the NULL pointer is always a
viable way to create a default value.


> 2. I got some strange result as attached. The distribution should be
> simple since I have only a constant spherical heater in the center. It
> might still be an issue of the time step I set, but I am not sure if
> there is any other issue.
>
> Any suggestions or comments are highly appreciated!

Yes, this doesn't look right. If you use a coefficient, do you adjust
the time step? Experiment first by choosing a constant coefficient, then
making things gradually more complicated.

jingt...@gmail.com

unread,
Feb 8, 2016, 10:02:14 PM2/8/16
to dea...@googlegroups.com, dea...@googlegroups.com
I change the time step to 40 ns and the results look much more reasonable. But is this just a problem of time step?

Best,
Jingtian


Jingtian


Wolfgang Bangerth

unread,
Feb 8, 2016, 10:03:10 PM2/8/16
to dea...@googlegroups.com
On 02/08/2016 09:02 PM, jingt...@gmail.com wrote:
> I change the time step to 40 ns and the results look much more
> reasonable. But is this just a problem of time step?
>

Who knows -- there are many things that can go wrong, and the only way
to find out is to run testcases for which you know the exact solution
and where you can demonstrate convergence.
Reply all
Reply to author
Forward
0 new messages