Message Boards Message Boards

GROUPS:

Use piecewise parameters in NDSolve

Posted 3 months ago
677 Views
|
3 Replies
|
0 Total Likes
|

Hello, I am getting the following error message in Mathematica 12 when attempting to numerical solve a system of PDEs with a piecewise-defined parameter:

LinearSolve::nosol: Linear equation encountered that has no solution.

Does anyone know what is causing this error? I'm including the code below, and I also attached it.

Thank you,

Abed

ClearAll["Global`*"];

eqn = {
   kAC[Subscript[R, outer][x, t], Subscript[R, inner]] D[P[x, t], 
      x] == - QL[x, t],
   D[QL[x, t], x] == 
    1 - D[Subscript[A, outer][x, t], t] HeavisideTheta[
       Subscript[A, outer][x, t] - Subscript[A, inner]]
   };

kAC[rO_, rI_] := Piecewise[{
    {(Pi/(8 \[Mu])) (rO^4 - rI^4 - ((rO^2 - rI^2)^2/Log[rO/rI])), 
     rO - rI > 0}
    },
   0
   ];
radiiToArea = {Subscript[R, outer][x, t] -> Sqrt[
    Subscript[A, outer][x, t]]/Sqrt[\[Pi]], 
   Subscript[R, inner] -> Sqrt[Subscript[A, inner]]/Sqrt[\[Pi]]};
eqn = eqn /. radiiToArea;

cond = {
   P[l, t] == 0,
   QL[0, t] == 0,
   QL[x, 0] == 0,
   P[x, 0] == 0
   };

pToARelationship = {P[x, t] == 
    2 Pi Sqrt[4 Subscript[A, outer][x, t]/Pi]};

aOuterSol = 
  Solve[pToARelationship, Subscript[A, outer][x, t]] // FullSimplify //
    Flatten;

aOuterSol = Join[aOuterSol, D[aOuterSol, t]];

eqn = eqn /. aOuterSol;

fullSystem = Join[eqn, cond];

parameterVals = {\[Mu] -> 1, Subscript[A, inner] -> 1, l -> 10};

nSol = NDSolve[
   fullSystem /. parameterVals, {P[x, t], QL[x, t]}, {x, 0, 10}, {t, 
    0, 1000}, Method -> {"PDEDiscretization" -> {"MethodOfLines",
       "SpatialDiscretization" -> {"FiniteElement"}}}] // Flatten
Attachments:
3 Replies
Posted 3 months ago

I was able to figure out the issue with some help from Mathworks. A zero coefficient was preventing the ability to calculate the derivative. I am now encountering a new issue, but I will make a separate post.

Mathworks may not be giving you a correct solution. You had better check that as well.

You should post a substitution of the solution in the original equation showing it solves.

There are differences of interpretation to keep in mind. In Mathematica, if u[x,0]== x+t^2 and you take the t derivative you'll get 0, not something like 2(0). If you doing symbolic solving and need the derivative for t, you must use u[x,t] and then substitute 0 for t.

Posted 2 months ago

Hi John, Thanks. I meant to say Wolfram, not Mathworks. Sorry about that.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract