1
$\begingroup$

I'm trying to visualize numerical solution of 4 differential equations (these are the coordinates of a wave function in a quantum mechanical system):

i*с00'[t] == с10[t] + с01[t] + с00[t] + с00[t],
i*с01'[t] == с11[t] + с00[t] + с01[t] - с01[t],
i*с10'[t] == с00[t] + с11[t] - с10[t] + с10[t],
i*с11'[t] == с01[t] + с10[t] - с11[t] - с11[t],

where "i" stands for

\[ImaginaryI]

The initial conditions are:

с00[0] == Sqrt[0.25],
с01[0] == Sqrt[0.25],
с10[0] == Sqrt[0.25],
с11[0] == Sqrt[0.25]

The functions I want to visualize are quite bulky (If one is interested, this method is based on visualization of density matrix (reduced matrix in this case) using isomorphism of SU(2) and SO(3) and is described e.g. here):

x:   с01[t] Conjugate[с00[t]] + с11[t] Conjugate[с10[t]] + с00[t] Conjugate[с01[t]] + с10[t] Conjugate[с11[t]]
y:   -I*(с01[t] Conjugate[с00[t]] + с11[t] Conjugate[с10[t]] - с00[t] Conjugate[с01[t]] + с10[t] Conjugate[с11[t]])
z:   с00[t] Conjugate[с00[t]] + с10[t] Conjugate[с10[t]] - с01[t] Conjugate[с01[t]] + с11[t] Conjugate[с11[t]]

*In the following part of my question I just replace them with x[t], y[t] and z[t].

The solution of this system returns something like this (so, I suppose, the problem is not here):

Out[999]= {{c00->InterpolationFunction[{{0.,100.}},<>], c01 -> ... 

Then I try to visualize mentioned functions:

ParametricPlot3D[{Evaluate[{x[t], y[t], z[t]} /. sol}], {t, 0, 100}]

The last input returns an empty box, no expected curves. (Instead of x[t], y[t], z[t] I actually wrote those bulky expressions).

I've already tried writing

sol[[1]] 

instead of sol, but it doesn't help. Will be grateful for any comments or suggestions.

The full code:

sol1 = NDSolve[{
I*с00'[t] == с10[t] + с01[t] + с00[t] + с00[t],
I*с01'[t] == с11[t] + с00[t] + с01[t] - с01[t],
I*с10'[t] == с00[t] + с11[t] - с10[t] + с10[t],
I*с11'[t] == с01[t] + с10[t] - с11[t] - с11[t],
с00[0] == Sqrt[0.25],
с01[0] == Sqrt[0.25],
с10[0] == Sqrt[0.25],
с11[0] == Sqrt[0.25]}, {с00, с01, с10, с11}, {t, 0, 100}]]


ParametricPlot3D[
Evaluate[
{с01[t] Conjugate[с00[t]] + с11[t] Conjugate[с10[t]] + с00[t] Conjugate[с01[t]] + с10[t] Conjugate[с11[t]],
-I*(с01[t] Conjugate[с00[t]] + c11[t] Conjugate[с10[t]] - с00[t] Conjugate[с01[t]] + с10[t] Conjugate[с11[t]]), 
с00[t] Conjugate[с00[t]] + с10[t] Conjugate[с10[t]] - с01[t] Conjugate[с01[t]] + с11[t] Conjugate[с11[t]]} /. sol1[[1]]], 
{t, 0, 100}]
$\endgroup$
  • $\begingroup$ The key to debugging: break it down to pieces and test each piece separately. Take the expression you are trying to plot, plug in a numerical value for t and see if it evaluates to a triplet of real numbers. If this doesn't help, post a self-contained small example that shows the problem. $\endgroup$ – Szabolcs Jun 23 '16 at 14:33
  • $\begingroup$ Mathematica uses I, capital i for imaginary. Please post your actual complete code you're trying. $\endgroup$ – Feyre Jun 23 '16 at 14:41
  • $\begingroup$ Thank you, @Feyre. Just posted to the end of the question. (sol1 and ParametricPlot3D are in separate cells, if this matters) $\endgroup$ – David Jun 23 '16 at 14:49
  • $\begingroup$ Welcome! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – user9660 Jun 23 '16 at 15:13
1
$\begingroup$

Your problem is twofold.


The first part is very subtle and sneaky. Your "c" characters are actually typed in as the Unicode Character 'cyrillic small letter es' (U+0441) in the NDSolve expression, as you can see from the following:

Inactive[NDSolve][{
   I*с00'[t] == с10[t] + с01[t] + с00[t] + с00[t],
   I*с01'[t] == с11[t] + с00[t] + с01[t] - с01[t],
   I*с10'[t] == с00[t] + с11[t] - с10[t] + с10[t],
   I*с11'[t] == с01[t] + с10[t] - с11[t] - с11[t],
   с00[0] == Sqrt[0.25], с01[0] == Sqrt[0.25], с10[0] == Sqrt[0.25], 
   с11[0] == Sqrt[0.25]},
  {с00, с01, с10, с11}, {t, 0, 100}
  ] // FullForm

(* Out: 
Inactive[NDSolve][List[Equal[Times[Complex[0, 1], Derivative[1][\:044100][t]], 
Plus[Times[2, \:044100[t]], с:044101[t],  
\:044110[t]]], Equal[Times[Complex[0, 1], Derivative[1][с:044101][t]], 
Plus[\:044100[t], \:044111[t]]], Equal[Times[Complex[0, 1], Derivative[1][\:044110][t]], 
Plus[\:044100[t], \:044111[t]]], Equal[Times[Complex[0, 1], Derivative[1][\:044111][t]], 
Plus[с:044101[t], \:044110[t], Times[-2, \:044111[t]]]], 
Equal[\:044100[0], 0.5`], Equal[с:044101[0], 0.5`], Equal[\:044110[0], 0.5`], 
Equal[\:044111[0], 0.5`]], List[\:044100, с:044101, \:044110, \:044111], List[t, 0, 100]]
*)

You maintained this formatting almost everywhere in your Evaluate expression in the ParametricPlot3D, except in one case:

{
  с01[t] Conjugate[с00[t]] + с11[t] Conjugate[с10[t]] + с00[t] Conjugate[с01[t]] + с10[t] Conjugate[с11[t]],
  -I*(с01[t] Conjugate[с00[t]] + c11[t] Conjugate[с10[t]] - с00[t] Conjugate[с01[t]] + с10[t] Conjugate[с11[t]]),
  с00[t] Conjugate[с00[t]] + с10[t] Conjugate[с10[t]] - с01[t] Conjugate[с01[t]] + с11[t] Conjugate[с11[t]]
} // FullForm

(* Out:
List[Plus[Times[\:044101[t], Conjugate[\:044100[t]]], Times[\:044100[t], Conjugate[\:044101[t]]], Times[\:044111[t], Conjugate[\:044110[t]]], Times[\:044110[t], Conjugate[\:044111[t]]]], Times[Complex[0, -1], Plus[Times[\:044101[t], Conjugate[\:044100[t]]], Times[-1, \:044100[t], Conjugate[\:044101[t]]], 

     Times[c11[t], Conjugate[\:044110[t]]], (* HERE IS THE PROBLEM *)

     Times[\:044110[t], Conjugate[\:044111[t]]]]], Plus[Times[\:044100[t], Conjugate[\:044100[t]]], Times[-1, \:044101[t], Conjugate[\:044101[t]]], Times[\:044110[t], Conjugate[\:044110[t]]], Times[\:044111[t], Conjugate[\:044111[t]]]]]
*)

This "c11[t]" is different from the otherwise visually identical "c11[t]" in the NDSolve solution, and does not get replaced.

Taking your code to a text editor and replacing all the occurrences of the Unicode character with a Latin c fixes that part, but unfortunately does not fix your overall problem, because of....


The second part of your problem: part of the expression you are trying to plot evaluates to complex numbers, which of course cannot be plotted:

{
  c01[t] Conjugate[c00[t]] + c11[t] Conjugate[c10[t]] + c00[t] Conjugate[c01[t]] + c10[t] Conjugate[c11[t]],
  -I*(c01[t] Conjugate[c00[t]] + c11[t] Conjugate[c10[t]] - c00[t] Conjugate[c01[t]] + c10[t] Conjugate[c11[t]]),
  c00[t] Conjugate[c00[t]] + c10[t] Conjugate[c10[t]] - c01[t] Conjugate[c01[t]] + c11[t] Conjugate[c11[t]]
} /. sol1[[1]] /. t -> 100 // Chop

(* Out: {0.997559, 0.0351601 - 0.497545 I, 0.50002} *)
$\endgroup$
  • $\begingroup$ Thanks a lot, @MarcoB! Due to this mistake I wasn't able to check the values of expressions. It was really subtle. You saved me a lot of time! $\endgroup$ – David Jun 23 '16 at 21:28
  • $\begingroup$ @DavidAznaurov Glad to help! $\endgroup$ – MarcoB Jun 23 '16 at 21:41

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.