Skip to main content
Fixed typos, formatting
Source Link
Michael E2
  • 245k
  • 18
  • 351
  • 775

I'm aware that there are a few threads on the topic of solving coupled ODEs using NSolveNDSolve and ManipulateManipulate. Based on those, I wrote the following code, solving my system of equations:

    Manipulate[{Solns = 
   NDSolve[{ee'[t] == -I*c1/2*(ge[t] - eg[t]) - c2*ee[t], 
     gg'[t] == I*c1/2*(ge[t] - eg[t]) + c2*ee[t], 
     ge'[t] == -c2/2*ge[t] + I*c1/2*(gg[t] - ee[t]) - c3/2*ge[t], 
     eg'[t] == -c2/2*eg[t] - I*c1/2*(gg[t] - ee[t]) - c3/2*eg[t], 
     ee[0] == 1, gg[0] == 0, ge[0] == 0, eg[0] == 0}, {ee, gg, ge, 
     eg}, {t, 0, 5}], 
  Plot[{ee[t] /. Solns, gg[t] /. Solns}, {t, 0, 5}]}, {{c1, 0, 
   "Rabi Frequency"}, 0, 10, 
  Appearance -> "Labeled"}, {{c2, 0, "Dephasing"}, 0, 3, 
  Appearance -> "Labeled"}, {{c3, 0, "Spont. Emission"}, 0, 10, 
  Appearance -> "Labeled"}]

However, while the code does run (and gives the correct solution), I get this strange screen where I have a bunch of other stuff in the plot box: enter image description here

I'm not sure why this is happening, so my question is basically what is causing this unwanted stuff to be plotted. I tried looking for things like InterpolatingFunction inside figure, but no results popped up on that.

Oh, as a side note, these equations can also be solved with DsolveDSolve, but I want to make some adjustments that no longer allow that type of solution. I just used this because it is close to what I want, and I know what it looks like. Moreover, if there would be a way to make the plotting go faster, I'd also be interested in that.

I'm aware that there are a few threads on the topic of solving coupled ODEs using NSolve and Manipulate. Based on those, I wrote the following code, solving my system of equations:

    Manipulate[{Solns = 
   NDSolve[{ee'[t] == -I*c1/2*(ge[t] - eg[t]) - c2*ee[t], 
     gg'[t] == I*c1/2*(ge[t] - eg[t]) + c2*ee[t], 
     ge'[t] == -c2/2*ge[t] + I*c1/2*(gg[t] - ee[t]) - c3/2*ge[t], 
     eg'[t] == -c2/2*eg[t] - I*c1/2*(gg[t] - ee[t]) - c3/2*eg[t], 
     ee[0] == 1, gg[0] == 0, ge[0] == 0, eg[0] == 0}, {ee, gg, ge, 
     eg}, {t, 0, 5}], 
  Plot[{ee[t] /. Solns, gg[t] /. Solns}, {t, 0, 5}]}, {{c1, 0, 
   "Rabi Frequency"}, 0, 10, 
  Appearance -> "Labeled"}, {{c2, 0, "Dephasing"}, 0, 3, 
  Appearance -> "Labeled"}, {{c3, 0, "Spont. Emission"}, 0, 10, 
  Appearance -> "Labeled"}]

However, while the code does run (and gives the correct solution), I get this strange screen where I have a bunch of other stuff in the plot box: enter image description here

I'm not sure why this is happening, so my question is basically what is causing this unwanted stuff to be plotted. I tried looking for things like InterpolatingFunction inside figure, but no results popped up on that.

Oh, as a side note, these equations can also be solved with Dsolve, but I want to make some adjustments that no longer allow that type of solution. I just used this because it is close to what I want, and I know what it looks like. Moreover, if there would be a way to make the plotting go faster, I'd also be interested in that.

I'm aware that there are a few threads on the topic of solving coupled ODEs using NDSolve and Manipulate. Based on those, I wrote the following code, solving my system of equations:

  Manipulate[{Solns = 
   NDSolve[{ee'[t] == -I*c1/2*(ge[t] - eg[t]) - c2*ee[t], 
     gg'[t] == I*c1/2*(ge[t] - eg[t]) + c2*ee[t], 
     ge'[t] == -c2/2*ge[t] + I*c1/2*(gg[t] - ee[t]) - c3/2*ge[t], 
     eg'[t] == -c2/2*eg[t] - I*c1/2*(gg[t] - ee[t]) - c3/2*eg[t], 
     ee[0] == 1, gg[0] == 0, ge[0] == 0, eg[0] == 0}, {ee, gg, ge, 
     eg}, {t, 0, 5}], 
  Plot[{ee[t] /. Solns, gg[t] /. Solns}, {t, 0, 5}]}, {{c1, 0, 
   "Rabi Frequency"}, 0, 10, 
  Appearance -> "Labeled"}, {{c2, 0, "Dephasing"}, 0, 3, 
  Appearance -> "Labeled"}, {{c3, 0, "Spont. Emission"}, 0, 10, 
  Appearance -> "Labeled"}]

However, while the code does run (and gives the correct solution), I get this strange screen where I have a bunch of other stuff in the plot box: enter image description here

I'm not sure why this is happening, so my question is basically what is causing this unwanted stuff to be plotted. I tried looking for things like InterpolatingFunction inside figure, but no results popped up on that.

Oh, as a side note, these equations can also be solved with DSolve, but I want to make some adjustments that no longer allow that type of solution. I just used this because it is close to what I want, and I know what it looks like. Moreover, if there would be a way to make the plotting go faster, I'd also be interested in that.

Source Link
user129412
  • 1.3k
  • 1
  • 9
  • 19

Trouble using Manipulate and NDsolve for coupled ODE's

I'm aware that there are a few threads on the topic of solving coupled ODEs using NSolve and Manipulate. Based on those, I wrote the following code, solving my system of equations:

    Manipulate[{Solns = 
   NDSolve[{ee'[t] == -I*c1/2*(ge[t] - eg[t]) - c2*ee[t], 
     gg'[t] == I*c1/2*(ge[t] - eg[t]) + c2*ee[t], 
     ge'[t] == -c2/2*ge[t] + I*c1/2*(gg[t] - ee[t]) - c3/2*ge[t], 
     eg'[t] == -c2/2*eg[t] - I*c1/2*(gg[t] - ee[t]) - c3/2*eg[t], 
     ee[0] == 1, gg[0] == 0, ge[0] == 0, eg[0] == 0}, {ee, gg, ge, 
     eg}, {t, 0, 5}], 
  Plot[{ee[t] /. Solns, gg[t] /. Solns}, {t, 0, 5}]}, {{c1, 0, 
   "Rabi Frequency"}, 0, 10, 
  Appearance -> "Labeled"}, {{c2, 0, "Dephasing"}, 0, 3, 
  Appearance -> "Labeled"}, {{c3, 0, "Spont. Emission"}, 0, 10, 
  Appearance -> "Labeled"}]

However, while the code does run (and gives the correct solution), I get this strange screen where I have a bunch of other stuff in the plot box: enter image description here

I'm not sure why this is happening, so my question is basically what is causing this unwanted stuff to be plotted. I tried looking for things like InterpolatingFunction inside figure, but no results popped up on that.

Oh, as a side note, these equations can also be solved with Dsolve, but I want to make some adjustments that no longer allow that type of solution. I just used this because it is close to what I want, and I know what it looks like. Moreover, if there would be a way to make the plotting go faster, I'd also be interested in that.