Find error in "NDsolve"

Posted 5 months ago
745 Views
|
4 Replies
|
3 Total Likes
|
 Hello, please I tried to solve this system by NDSolve, but I find errors and I do not know why! if someone can help me? Thank you t1 = 2; (Définit la fonction indicatrice) indicator[x_] := Piecewise[{{1, 0 < x < 1/2}}, 0]; E1 = D[g[x, t], {x, 2}] - D[g[x, t], {t, 2}] == indicator[x]*((Cos[\[Pi] t1] - Sin[\[Pi] t1]) Sin[\[Pi] x])/( 4 \[Pi])*DiracDelta[t - t1]; ic = {g[x, 0] == Sum[Sin[k *\[Pi]*x], {k, 1}], Derivative[0, 1][g][x, 0] == Sum[k *\[Pi] *Sin[k *\[Pi]* x], {k, 1}]}; (*Condition aux bord de Dirichlet*) bcc = {g[0, t] == 0, g[1, t] == 0}; (*résolution numérique de l'équation*) sol11 = NDSolve[{E1, ic, bcc}, g, {x, 0, 1}, {t, 0, 12}, MaxStepSize -> 0.1]; Best regards,
4 Replies
Sort By:
Posted 5 months ago
 On my (old) system (Mathematica 7) your code runs without any error message and gives back in sol11 an InterpolatingFunction object. You can plot it gF = g /. sol11[[1, 1]] Plot3D[gF[x, y], {x, 0, 1}, {y, 0, 10}] So, which errors do you find?
Posted 4 months ago
 Hey, sir, that's exactly what I need. gF = g /. sol11[[1, 1]] I'm always having this problem extracting the solution, can you tell me please where I can find out more about this kind of order?Best regards,
 Well, hmmm. Run your code and look at sol11 (without semicolon)Then you see that sol11 is a list of list. You can extract the content with sol11[[1,1]] in the Help - section of your Mathematica you might want to look up Part.The last command gives you a Rule (look that up as well) it says g -> something.Now when you writeg/.sol11[[1,1]]that rule is applied and g is substituted by the right hand side of the arrow ( look up ReplaceAll) gF = g/.sol11[[1,1]] assigns the InterpolatingFunction (the result of NDSolve) to the symbol gF, and then you can use gF in further operations.I hope this helps a bit.