1
$\begingroup$

The problem is the following:

There is system of differential equations

V = -1; G = 0.1; x[t] = a*Exp[-Sqrt[-1]*p*t]; 
y[t] = b*Exp[-Sqrt[-1]*p*t]; p = -2 Cos[k];
s = ParametricNDSolveValue[{Sqrt[-1]*x'[t] == 
     V*x[t] - F*x[t]*Abs[x[t]]^2 - G*y[t], 
    Sqrt[-1]*y'[t] == V*y[t] - F*y[t]*Abs[y[t]]^2 - G*x[t], x[0] == 0, 
    y[0] == 1}, {x, y}, {t, 0, 15}, {F}];

The constraint on $a$ and $b$ is that $a^2+b^2=2$. Mathematica solves this without problem but then I want to get a plot for $F$ on x-axis vs $V-p$ on y-axis, which I am unable to plot. I tried with parametric plot but it gives errors. Any help will be greatly appreciated. Thanks.

$\endgroup$
  • $\begingroup$ Hi AtoZ and welcome! To make the most of Mma.SE start by taking the tour now. It will help us to help you if you write an excellent question. Edit if improvable, show due diligence, give brief context, include minimal working example of code and data in formatted form. As you receive give back, vote and answer questions, keep the site useful, be kind, correct mistakes and share what you have learned. $\endgroup$ – rhermans Jul 7 '18 at 7:33
  • $\begingroup$ $V-p$ is a constant, what do you mean with plotting vs $V-p$? $\endgroup$ – rhermans Jul 7 '18 at 8:02
  • $\begingroup$ essentially this is the energy $V$ is the local energy of an atom, for example. $p$ is coming from the stationary solutions in the form of x[t] = aExp[-Sqrt[-1]*pt], This (stationary) ansatz will lead to a stationary equation and we have a factor $V-p$. I think I made a mistake I should leave $p$ then as a function of $k$? just like in the edited version of my question? $\endgroup$ – AtoZ Jul 7 '18 at 8:07
  • $\begingroup$ Is the problem for which you need help about plotting, writing the equation or about the physics? $\endgroup$ – rhermans Jul 7 '18 at 8:09
  • 1
    $\begingroup$ There are things to do after your question is answered. But wait! It's a good idea to stay vigilant for some time, better approaches may come later improving over previous replies. Experienced users may point alternatives, caveats or limitations. New users should test answers before voting and wait 24 hours before accepting the best one. Participation is essential for the site, please do your part. And don't forget about the tour. $\endgroup$ – rhermans Jul 7 '18 at 8:18
1
$\begingroup$

Code

is much more readable if indented, please in the future show as readable code. You save yourself all sort of troubles if you limit the scope of you definitions using Module.

psol = Module[
   {
    V = -1,
    G = 0.1,
    x, y, s, p
    },
   p = -2 Cos[k];
   s = ParametricNDSolveValue[
     {
      x'[t] == V*x[t] - F*x[t]*Abs[x[t]]^2 - G*y[t], 
      y'[t] == V*y[t] - F*y[t]*Abs[y[t]]^2 - G*x[t],
      x[0] == 0,
      y[0] == 1
      }
     , {x, y}
     , {t, 0, 15}
     , {F}
     ]
   ];

Plot

Manipulate[
 Plot[
  Evaluate@Through[psol[F][t]]
  , {t, 0, 15}
  , PlotRange -> All
  ]
 , {{F, 0}, -0.99, 1}
 ]

enter image description here

ParametricPlot

Manipulate[
 ParametricPlot[
  Evaluate@Through[psol[F][t]]
  , {t, 0, 15}
  , AspectRatio -> 1
  , PlotRange -> {{-0.1, 0}, {0, 1}}
  , PlotTheme -> "Scientific"
  ]
 , {{F, 0}, -0.99, 1}
 ]

enter image description here

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