0
$\begingroup$

I solve a NonLinear PDE and get a solution (which for other reasons I put into a vector): SolVec1[1][[2]][x,t], where x and t are the indipendent variables.

Now, I would like to get a distribution of the maximum of the solution vs time.

I tried two different things, but the most intuitive and quick doesn't work.

1) A For loop to fill the function of the maxima >>> works but takes very long.

For[it = 0, it <= T, it++,

   MAX1[it] = First[Maximize[SolVec1[[1]][[2]][x, it], 0 <= x <= L , x]];

 ]

2) Defining a function MAX1[t] of time, and then plot it >>> doesn't work.

MAX1[t_] := First[Maximize[SolVec1[[1]][[2]][x, t], 
0 <= x <= L , x]];

 Plot[Evaluate[MAX1[t]], {t, 0, T}, PlotRange -> All, 
 AxesLabel -> {"t", "Max[\[Theta]]"}, Frame -> True, 
 PlotLabel -> "Max[\[Theta]](t), A=0"]

NMaximize::nnum: The function value -InterpolatingFunction[{{0.,10.},{0.,15.}},{3,10,1,
{25,228},{6,4},0,0,0,0},<<1>>,{Developer`PackedArrayForm,{<<1>>},{<<1>>}},
{Automatic,Automatic}][<<1>>] is not a number at {x} = {6.52468}. >>

Edit: SolVec1[1][[2]] is the solution coming out from a call of NDSolve.

u[\[Lambda]_, \[Omega]_, v_, \[Alpha]a_, aa_, A_] = -(1/(1 + \[Lambda]^2*(aa + A E ^-\[Phi][x, t])*Sin[2*\[Theta][x, t]]^2))*((aa + A E ^-\[Phi][x, t])*\[Lambda]*\[Omega]*\!\(\*SuperscriptBox["\[Theta]", TagBox[RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}],Derivative],MultilineFunction->None]\)[x, t]^2*Sin[2*\[Theta][x, t]]*      Sin[\[Theta][x, t]]^2 - 
 2*(aa + A E ^-\[Phi][x, t])*v*\[Phi][x, t]^2*\!\(\*SuperscriptBox["\[Theta]", TagBox[RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}],Derivative],MultilineFunction->None]\)[x, t]*      Sin[\[Theta][x, t]] + (aa + 
    A E ^-\[Phi][x, t])*\[Alpha]a*\[Phi][x, t]^2*
  Sin[2*\[Theta][x, t]] + \!\(\*SuperscriptBox["\[Phi]", TagBox[RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}],Derivative],MultilineFunction->None]\)[x, t]*      Cos[\[Theta][x, 
    t]]*(\[Omega] - \[Lambda]*\[Omega]*Cos[2*\[Theta][x, t]]));


eqn1[\[Lambda]_, w_, v_, \[Alpha]a_, a_, A_] := \!\(\*SubscriptBox[\(\[PartialD]\), \(t\)]\ \(\[Theta][x, t]\)\) - (\!\(\*SuperscriptBox["\[Theta]", TagBox[RowBox[{"(", RowBox[{"2", ",", "0"}], ")"}],Derivative],MultilineFunction->None]\)[x,        t] (1 - w Cos[\[Theta][x, t]]^2) (a + A E^\[Phi][x, t]) +      1/2*(a + A E^\[Phi][x, t]) w \!\(\*SuperscriptBox["\[Theta]", TagBox[RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}],Derivative],MultilineFunction->None]\)[x, t]^2 Sin[2 \[Theta][x, t]] - \[Phi][x,        t] (a + A E^-\[Phi][x, t]) v \!\(\*SuperscriptBox["\[Theta]", TagBox[RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}],Derivative],MultilineFunction->None]\)[x, t] Sin[\[Theta][x, t]] -      u[\[Lambda], w, v, \[Alpha]a, a,        A] (1 - \[Lambda] Cos[2 \[Theta][x, t]]) + (a +         A E^\[Phi][x, t]) w \!\(\*SuperscriptBox["\[Phi]", TagBox[RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}],Derivative],MultilineFunction->None]\)[x, t] Cos[\[Theta][x, t]]);


eqn2[\[Lambda]_, w_, v_, \[Alpha]a_, a_, A_] := \!\(\*SubscriptBox[\(\[PartialD]\), (t\)]\ \(\[Phi][x, t]\)\) - \!\(\*SubscriptBox[\(\[PartialD]\), \(x\)]\ \((v \((a +\*StyleBox["A",FontSize->10]\*StyleBox[" ",FontSize->10]\*SuperscriptBox[StyleBox["E",FontSize->10], RowBox[{"-", RowBox[{"\[Phi]", "[", RowBox[{"x", ",", "t"}], "]"}]}]])\) SuperscriptBox[\(\[Phi][x, t]\), \(2\)] Sin[\[Theta][x,          t]] + \((DD \((1 - \[Xi]\ \*SuperscriptBox[\(Sin[\[Theta][x, t]]\), \(2\)])\) - w\ \*SuperscriptBox[\(Cos[\[Theta][x, t]]\), \(2\)])\)\ *\((a + \*StyleBox["A",FontSize->10]\*StyleBox[" ",FontSize->10]\*SuperscriptBox[StyleBox["E",FontSize->10], RowBox[{"\[Phi]", "[", RowBox[{"x", ",", "t"}], "]"}]])\)*\ \*SuperscriptBox["\[Phi]", TagBox[RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}],Derivative],MultilineFunction->None][x, t] + \[Lambda]\ u[\[Lambda], w,         v, \[Alpha]a, a, A]\ Sin[\[Theta][x, t]]\ Sin[        2\ \[Theta][x, t]])\)\); 



sol1 = {\[Theta], \[Phi]} /. First[NDSolve[{
  eqn1[\[Lambda], w, \[Beta], \[Alpha]j, 1, 0] == 0,
  eqn2[\[Lambda], w, \[Beta], \[Alpha]j, 1, 0] == 0,
  \[Theta][0, t] == 0,
  \[Theta][L, t] == 0,
  \[Theta][x, 0] == First[InitialMode[x, 1, 0.5]],

\!\(\*SuperscriptBox["\[Phi]", TagBox[RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}],Derivative],MultilineFunction->None]\)[0, t] == 0,

\!\(\*SuperscriptBox["\[Phi]", TagBox[RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}],Derivative],MultilineFunction->None]\)[L, t] == 0,
  \[Phi][x, 0] == Last[InitialMode[x, 1, 0.5]]}, 
{\[Theta], \[Phi]}, {x, 0, 
  L}, {t, 0, T}, AccuracyGoal -> 4, PrecisionGoal -> 5]] ;

SolVec1[[i]] = {sol1[[1]], sol1[[2]]};

Plotting at the point ($x\simeq6.525$), nothing special happens:

 In[124]:= Plot[SolVec1[[1]][[2]][6.5246780797402835`, t], {t, 0, T}, PlotRange ->All]

enter image description here

$\endgroup$
  • 1
    $\begingroup$ What is the output of MAX1[t] for some t? If you want help, can you give a simplified version of SolVec? $\endgroup$ – bill s Feb 16 '14 at 20:28
  • $\begingroup$ @bills Edit done $\endgroup$ – usumdelphini Feb 17 '14 at 10:28
  • $\begingroup$ To clarify what @bills requested, it is unlikely that someone here can help you if they cannot reproduce the error; therefore, you should provide a definition for SolVec1. $\endgroup$ – bobthechemist Feb 17 '14 at 10:39
  • $\begingroup$ Voila the code! $\endgroup$ – usumdelphini Feb 17 '14 at 12:34

Your Answer

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

Browse other questions tagged or ask your own question.