Dear All, As I’m learning Mathematica, I encountered troubles I can’t seem to solve on my own. Here’s My code :
Clear["Global`*"];
HeatEq = \!\(
\*SubscriptBox[\(\[PartialD]\), \(t\)]\(T[x, y, t]\)\) == Laplacian[
T[x, y, t],{x, y}];
L = 2; l = 1/2; tmax = 15;
\[CapitalOmega] = Rectangle[{0, 0}, {L, l}];
boundaries = {T[x, y, 0] == 5, T[0, y, t] == 0, T[L, y, t] == 0,
T[x, 0, t] == 0, T[x, l, t] == 0};
boundaries2 = {DirichletCondition[T[x, y, t] == 0, True],
T[x, y, 0] == 5};
sol = NDSolveValue[Join[{HeatEq}, boundaries2],
T, {x, y} \[Element] \[CapitalOmega], {t, 0, tmax}];
Animate[DensityPlot[
sol[x, y, t], {x, y} \[Element] \[CapitalOmega]], {t, 0, tmax}]
As you wander through my code, here is what it is supposed to do :
- Clear all variables previously used, and define the Heat equation in 2 dimensions of space
- Define the rectangle I’m going to cool down.
- Define the boundaries (0°C on the edges, 5°C elsewhere)
- Solve the equation, and get the temperature.
- Plot an animation over time of the cooling
If facing two major issues here. The first one concerns the boundaries conditions. When I use the DirichletCondition, it seems to work “on its own”, and yet produces strange results (Where the boundaries are not respected in the simulation). Moreover, As you can see I defined an original boundary condition, and exposing all of them, edge per edge. Yet this one doesn’t work, and I really don’t understand why. It produces the message : “Boundary condition T[x,1/2,t]==0 is not specified on a single edge of the boundary of the computational domain”.
In a second time, I just can’t seem to find how you fix a color scale for the integrity of a sequence of density plot. I want to have each color affected to a single value of temperature, for every density plot in a list. And after hours of testing of changes for ColourFunction, I got nothing viable.
I’ve been searching on the web for hours, and I can’t find any solution. Would you kindly help me? I’m looking forward to your answers!
Kind Regards.
