1

I have a function that I want to max out at a certain value, say 1 for simplicity. There is a pump that will heat in a certain area, but once its reaches the cap, it no longer heats past this (as if it it were in thermal equilibrium). As it is just diffusion that occurs, no other point would therefore be able to go above this cap, but when I try to introduce it, either I can't specify a range of points for this cap to apply to, or I have tried to code it incorrectly.

I have based my code from Solve a one dimensional heat transfer problem with NDSolve which adds the time component of heating, but allows it to increase indefinitely. My code adds a Gaussian element rather than the referenced time based element, but I know this bit works. There are two ways I see to solve this, either turn off the "heating" at that point when the capped is reached or force a boundary condition where no point can go above this cap, therefore avoiding the heating issue. However, when trying to do this either way, my code doesn't seem to like it, any advice? My code is shown below, should you want to see what it currently looks like (without any cap in place). Any advice would be appreciated.

ModelGaussian = A*Exp[-((r - r01)^2/w^2)];(*Gaussian model*)

opts = (Method -> {"PDEDiscretization" -> {"MethodOfLines", "SpatialDiscretization" -> {"FiniteElement", "MeshOptions" -> {"MaxCellMeasure" -> 0.001}, "IntegrationOrder" -> 5}}});

rat = 1;(Scaling Ratio) maxTime = 4; SizeOfPump = 20;(How large an size the pump effects) SizeOfModel = 3;(How many times larger the model is compared to pump)

MidInGauss = 0;(Where Gauss peak starts-0 is middle) wInGauss = 20;(Width of Gaussian Peak ([Sigma]/Sqrt[2])) AmpInGauss = 1;(Peak for Gauss)

(If within the pump span,add the Gaussian pump,else don't add anything)

g[x_, t_] = If[Abs[x] <= SizeOfPump, ModelGaussian /. {r -> x, r01 -> MidInGauss, w -> wInGauss, A -> AmpInGauss}, 0];

s = NDSolve[{ratD[T[t, x], t] - D[D[T[t, x], x], x] == g[x, t], T[0, x] == 0}, T, {t, 0, maxTime}, {x, 0, SizeOfModelSizeOfPump}, opts];

imgs = Plot[ Evaluate[ If[x > 0, T[#, x] /. s, T[#, -x] /. s]], {x, -SizeOfModel* SizeOfPump, SizeOfModel*SizeOfPump}, PlotRange -> All] & /@ Subdivide[0, maxTime, 100]; ListAnimate@imgs

user21
  • 39,710
  • 8
  • 110
  • 167
Xyive
  • 115
  • 6
  • Is this like a thermostat that turns off a heater once temperature at a specific point, or average over a region, reaches a certain value? If so, you might use When[...] to reset heating to zero when that event occurs. – tad Jul 15 '21 at 23:24
  • 1
    As @tad suggested, you may want to look at the thermostat model in the WhenEvent documentation. – Tim Laska Jul 16 '21 at 02:13
  • @tad Its not that the heater "turns off" as such, but that it can't heat past this capping value. Imagine a heater that heats to 40 deg C, once a point in the room is 40 deg C it wouldn't get any hotter, as the heater can't heat past this point, but other parts of the room can still be heated (if not at 40 deg C). – Xyive Jul 19 '21 at 09:28
  • Using the WhenEvent, I would make the changes: g[x_, t_] = If[Abs[x] <= SizeOfQD, OnOffMode[x]*ModelGaussian /. {r -> x, r01 -> MidInGauss, w -> wInGauss, A -> AmplInGauss }, 0]; and

    ` s = NDSolve[ {rat*D[T[t, x], t] - D[D[T[t, x], x], x] == g[x, t],

    T[0, x] == 0, WhenEvent[T[t, x] >= 1 , OnOffMode[x] -> 0], WhenEvent[T[t, x] < 1 , OnOffMode[x] -> 1]}, T, {t, 0, maxTime}, {x, 0, SizeOfModel*SizeOfQD}, opts]`

    However, it gives the warning OnOffMode won't directly set the state due to the LHS not being a list of state variables. Any advice?

    – Xyive Jul 19 '21 at 09:29
  • This is like pumping heat in the way salt solves as a substance in water. Can be done with a very high temperature difference, so that heat current does not depend on the receiver temperature. If the heating device works at a constant temperature, its a boundary condition. At reaching the thermostat temperature level, the boundary condition switches from T(b)=const to T'[b]=0. The functionality can be implemented by a mixed boundary condition Theta[Tmax-T[b]] + T'[ b] Theta[ T[b]-Tmax] ==0 . Constant production term applies for electrical heaters. – Roland F May 01 '23 at 18:10

1 Answers1

0

Best way to solve, rather than using When is by modifying the equation used by using multiplying the pump source g[x, t] by:

(1(*Max Temp*)- T[t, x])

where 1 is the max temperature (which can be set to whatever you want).

Xyive
  • 115
  • 6
  • 4
    This would correspond to a source whose output goes smoothly to zero as $T$ approaches the target temperature. If the source turns off suddenly at some target temperature, a better choice would be to multiply by UnitStep[targettemp - T[x,t]]. – Michael Seifert Aug 09 '21 at 14:14