3
$\begingroup$

I had a code that was working fine and I tried to add an extra few lines to find the solution of the same equation with different conditions. The original NDSolveValue solutions work fine but when it gets to evaluating solnG it just makes a "Ding" and stops evaluating the code. What is the cause of this sound and why will it not continue to evaluate the code?

Here is the code:

<< "NDSolve`FEM`"

ts = .000250; tsl = .000250; (* m *)
ρs = 3980;  ρsl = 958; (* kg/m3 *)
ks = .035;  ksl = .00067; (* kW/m/K *)
cs = .75; csl = 4.22; (* kJ/kg/K *)

ρ = If[0 <= z < ts, ρs, ρsl];
k = If[0 <= z < ts, ks, ksl];
c =  If[0 <= z < ts, cs, csl];

td = 0.075;
tg = 0.01;

eqn1 = k*D[T1[z], z] + 28; 
Tbl = 100;
Subscript[Γ1, D] = DirichletCondition[T1[z] == Tbl, z == ts + tsl];

BCr = NDSolveValue[{eqn1 == 0, Subscript[Γ1, D]}, T1, {z, 0, ts + tsl}];

Plot[BCr[z], {z, 0, ts + tsl}, GridLines -> {{ts}, {0}}]

Ti[z_] := \[Piecewise] {
    {BCr[z], 0 <= z < ts},
    {100, True}
   };
Plot[Ti[z], {z, 0, ts + tsl}, GridLines -> {{ts}, {0}}]

eqn2 = c ρ Derivative[1, 0][T][t, z] - k Derivative[0, 2][T][t, z]
Subscript[Γ, D] = DirichletCondition[T[t, z] == Tbl, z == ts + tsl];
Subscript[Γ, N] = NeumannValue[-28, z == 0];

solnD = 
  NDSolveValue[
    {eqn2 == Subscript[Γ, N], 
     Subscript[Γ, D], T[0, z] == Ti[z]}, 
    T, {t, 0, 1}, {z, 0, ts + tsl}, 
    Method -> 
      {"PDEDiscretization" -> 
        {"MethodOfLines", 
         "SpatialDiscretization" -> 
           {"FiniteElement", "MeshOptions" -> {"MaxCellMeasure" -> (ts + tsl)/1011}}}}]

Plot[solnD[t, ts], {t, 0, 1}, GridLines -> {{0}, {107}}, PlotRange -> Full]
Plot[solnD[td, z], {z, 0, ts + tsl}, GridLines -> {{ts}, {0}}]

eqn3 = ρ c D[Tg[t, z], t] - k D[Tg[t, z], z, z]; 
TiG[z_] := solnD[td, z];
Plot[TiG[z], {z, 0, ts}]
Tits = solnD[td, ts];
Subscript[Γd, N] = NeumannValue[-28, z == 0];

solnG = 
  NDSolveValue[
    {eqn3 == Subscript[Γd, N], 
     (Tg[t, z] /. z -> ts) == (-300*t + Tits), 
     Tg[0, z] == TiG[z]},
    Tg, {t, 0, .1}, {z, 0, ts}, 
    Method -> 
      {"PDEDiscretization" -> 
        {"MethodOfLines", 
         "SpatialDiscretization" -> 
           {"FiniteElement", "MeshOptions" -> {"MaxCellMeasure" -> (ts)/1011}}}}]

Animate[
  Plot[solnG[t, z], {z, 0, ts}, PlotRange -> {99, 111}], {t, 0, 1}]
$\endgroup$
6
  • $\begingroup$ Looks like a bug. Which lines did you change? $\endgroup$
    – user21
    Nov 29, 2015 at 23:40
  • 1
    $\begingroup$ Do you mean the kernel crashed? (The "ding.") $\endgroup$
    – Michael E2
    Nov 29, 2015 at 23:43
  • $\begingroup$ @MichaelE2, yes, I get a kernel crash. $\endgroup$
    – user21
    Nov 29, 2015 at 23:56
  • $\begingroup$ I did not change any of the original lines. I only added to the end of the code and initialized the variables 'td' and 'tg' at the top. It is strange because I had to comment out the animation line because I was getting errors from that animation and it was all working before. This would imply there is something wrong above the new code but other than the new code at the bottom and the initialization of the variables nothing changed. $\endgroup$
    – dowlguest
    Nov 30, 2015 at 0:37
  • 1
    $\begingroup$ I didn't change the name of 'solnD' to 'solnd' everywhere in the code but now that I have I am getting the same kernel crash and the animation does not work. Capitalization does not matter. The crash is from trying to solve for 'solnG'. I have determined that the crash seems to come from using the solution from 'solnD' as the initial condition for 'solnG'. When use a different initial condition the crash does not occur. $\endgroup$
    – dowlguest
    Nov 30, 2015 at 1:00

1 Answer 1

4
$\begingroup$

This is a bug. As a workaround try using:

TiG[z_?NumericQ] := solnD[td, z];
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.