1
$\begingroup$

I have been trying to plot the solution of a set of differential equations solved used NDSolve. Now, in one of the cases, I have the find a parametric plot of the square of the absolutes between the solution a1[t] with a1'[t]. I tried to do it as the documentation of NDSolve suggested and with many other ways given on Mathematica StackExchange, but was unable to get the plot.

I also noticed that, when I tried to make a table of values from a1'[t] at different values of t, it failed as well. This again did not happen in the example given in the documentation. Please help me understand what mistakes I have made in my program.

Clear["Global`*"]

w0 = 190*10^12;
wm = 23.4*2*Pi*10^6;
gama = 2*Pi*10^6;
gama2 = 0.8*gama;
gama1 = gama;
g0 = 7.4*10^-5*gama;
gamam = 0.038*2*Pi*gama;
del1 = wm;
J = gama;

driv = 0.5*gama;

eqns = 
 {a1'[t] == (-I*(del1 - Sqrt[2]*g0*x[t]) - gama1/(2))*a1[t] + I*J*a2[t] + driv,
  a2'[t] == (-I*del1 + gama2/(2))*a2[t] + I*J*a1[t], 
  p'[t] == -gamam/2*p[t] - wm*x[t] + Sqrt[2]*g0*Abs[a1[t]]^2,
  x'[t] == wm*p[t], 
  x[0] == 0, a1[0] == 0, a2[0] == 0, p[0] == 0};

s = NDSolve[eqns, {a1[t], a2[t], x[t], p[t]}, {t, 0, 0.00001}, MaxSteps -> ∞]

ParametricPlot[
  Evaluate[{Abs[a1'[t]]^2, Abs[a1[t]]^2} /. s], {t, 0.000008, 0.000009}, 
  PlotRange -> Automatic]

I would be very grateful if you could tell me my mistake in this program.

$\endgroup$
1
  • 4
    $\begingroup$ Ask NDSolve for pure functions if you want to generate derivative later: s = NDSolve[eqns, {a1, a2, x, p}, {t, 0, 0.00001}, MaxSteps -> \[Infinity]] $\endgroup$ – Akku14 Jan 5 '20 at 6:57
2
$\begingroup$

NDSolveValue would allow you to get the requested expressions directly:

sValue = NDSolveValue[eqns, {Abs[a1'[t]]^2, Abs[a1[t]]^2}, {t, 0, 0.00001}];

ParametricPlot[
  sValue, {t, 0.000008, 0.000009},
  PlotRange -> Automatic, AspectRatio -> 0.5
]

parametric plot

$\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.