-1

Here is the details of the code to plot.

Clear[x, y, ψ1, ψ2, ψ3, ψ4, eqn, eqnWithInitial,v, j];
eqn = Thread[
       I D[{ψ1[x, y, t], ψ2[x, y, t], ψ3[x, y, t], ψ4[
            x, y, t]}, 
          t] == {v (-I D[ψ3[x, y, t], x] - D[ψ3[x, y, t], y]) + 
          2 Δ ψ4[x, y, t], 
         v (-I D[ψ4[x, y, t], x] - D[ψ4[x, y, t], y]), 
         v (-I D[ψ1[x, y, t], x] + D[ψ1[x, y, t], y]), 
         v (-I D[ψ2[x, y, t], x] + D[ψ2[x, y, t], y]) + 
          2 Δ ψ1[x, y, t]}];
eqnWithInitial = 
      Join[eqn, 
       Thread[{ψ1[x, y, 0], ψ2[x, y, 0], ψ3[x, y, 
           0], ψ4[x, y, 0]} == {1, 1, 1, 
           1} (x + I*y) Exp[-(x^2 + y^2)]], 
       Thread[{ψ1[-5, y, t], ψ2[-5, y, t], ψ3[-5, y, 
           t], ψ4[-5, y, t]} == {ψ1[5, y, t], ψ2[5, y, 
           t], ψ3[5, y, t], ψ4[5, y, t]}], 
       Thread[{ψ1[x, -5, t], ψ2[x, -5, t], ψ3[x, -5, 
           t], ψ4[x, -5, t]} == {ψ1[x, 5, t], ψ2[x, 5, 
           t], ψ3[x, 5, t], ψ4[x, 5, t]}]];

v = 1;
Δ = 1;
tMax = 8;

solution = 
      First @ NDSolve[
        eqnWithInitial, {ψ1[x, y, t], ψ2[x, y, t], ψ3[x, y,
           t], ψ4[x, y, t]}, {x, -5, 5}, {y, -5, 5}, {t, 0, tMax}, 
        Method -> {"MethodOfLines", 
          "SpatialDiscretization" -> {"TensorProductGrid", 
            "DifferenceOrder" -> "Pseudospectral"}}];

Ψ1[x_, y_, t_] = ψ1[x, y, t] /. solution;
Ψ2[x_, y_, t_] = ψ2[x, y, t] /. solution;
Ψ3[x_, y_, t_] = ψ3[x, y, t] /. solution;
Ψ4[x_, y_, t_] = ψ4[x, y, t] /. solution; 

myrotorz1[x_?NumericQ, y_?NumericQ, t_?NumericQ] = 
  I/2 * (-Conjugate[D[Ψ1[x, y, t], y]] * D[Ψ1[x, y, t], x] + 
    D[Ψ1[x, y, t],y] * Conjugate[D[Ψ1[x, y, t], x]] + 
    Conjugate[D[Ψ1[x, y, t], x]] * D[Ψ1[x, y, t], y] - 
    D[Ψ1[x, y, t], x] * Conjugate[D[Ψ1[x, y, t], y]]);

Here is something that may be reasonable as R. M. suggested

NIntegrate[myrotorz1[x, y, 0], {x, -5, 5}, {y, -5, 5},Method -> "Trapezoidal"]

(Debug) During evaluation of In[18]:= NIntegrate::ncvi: NIntegrate failed to converge to prescribed accuracy after 9 iterated refinements in y in the region {{-5.,5.},{-5.,5.}}. NIntegrate obtained 0.012104690946256463` and 0.8391566465710514` for the integral and error estimates. >>

(Debug) Out[18]= 0.0121047

My point is to plot for myrotorz1[x, y, t] as a function of t but takes too much time. Any tips would be greatly appreciated.

Plot[NIntegrate[myrotorz1[x, y, t], {x, -5, 5}, {y, -5, 5},Method -> "Trapezoidal"], {t, 0, 4}]
Quantum_Oli
  • 7,964
  • 2
  • 21
  • 43
user34056
  • 23
  • 7
  • See this answer to the pitfalls question. -- The hint contained in the error message is that the symbols x and y do not have numerical values. – Michael E2 Oct 16 '15 at 10:17
  • Your definition for myrotorz1 is has syntax errors. Perhaps this is because of an error introduced in transferring your code to this site, but it needs to corrected before we can help you further. – m_goldberg Oct 16 '15 at 21:44
  • @m_goldberg, you are right. I have made the correction. – user34056 Oct 17 '15 at 09:40
  • I don't get the error you indicated in the first post. I get only NIntegrate::slwcon (slow convergence). I'm using V10.2. -- What error are you getting? – Michael E2 Oct 17 '15 at 12:30
  • @MichaelE2 slow convergence plus suppressed the output – user34056 Oct 17 '15 at 13:55
  • I get a plot. Here is a proof of concept: http://i.stack.imgur.com/hJ8k1.png -- Your original command will take much longer than I have to spend (please pardon me). I don't see how the output can be suppressed unless you added a semi-colon or the kernel crashed. Note that integrating expressions built on InterpolatingFunction usually converge slowly. – Michael E2 Oct 17 '15 at 14:43
  • Other possibilities: http://mathematica.stackexchange.com/a/77359#77359, http://mathematica.stackexchange.com/a/73339#73339 -- Or this: http://i.stack.imgur.com/YVMMu.png, but at 9-12 sec. per integration, plotting stil takesl prohibitively long. – Michael E2 Oct 17 '15 at 15:19
  • @MichaelE2, i use V8,I couldn't see any plot when I try your comments. – user34056 Oct 17 '15 at 18:24
  • I don't have access to V8, and I can't recall anything relevant that might be different. Sorry, I can't be more help. Because of the difference, you probably should add the version information to your question. Or upgrade ;-) – Michael E2 Oct 17 '15 at 18:31
  • @MichaelE2, this is the error I get:NIntegrate::inumr: The integrand 1000000 Re[myrotorz1[x,y,0.003003]] has evaluated to non-numerical values for all sampling points in the region with boundaries {{-5,5},{-5,5}}. >> – user34056 Oct 17 '15 at 18:54
  • Try changing myrotorz1's definition as myrotorz1[x_?NumericQ, y_?NumericQ, t_?NumericQ] and probably also for all the Ψ and see if that helps. – rm -rf Oct 18 '15 at 16:18
  • @R.M., ok I will check & let you know. – user34056 Oct 18 '15 at 16:19
  • @R.M still running – user34056 Oct 18 '15 at 21:21
  • @R.M.I get a result for (Debug) In[18]:= NIntegrate[ myrotorz1[x, y, 0], {x, -5, 5}, {y, -5, 5}, Method -> "Trapezoidal"]

    (Debug) During evaluation of In[18]:= NIntegrate::ncvi: NIntegrate failed to converge to prescribed accuracy after 9 iterated refinements in y in the region {{-5.,5.},{-5.,5.}}. NIntegrate obtained 0.012104690946256463and 0.8391566465710514 for the integral and error estimates. >>

    (Debug) Out[18]= 0.0121047

    – user34056 Oct 19 '15 at 10:05
  • @R.M. when I try to plot using Plot[NIntegrate[myrotorz1[x, y, t], {x, -5, 5}, {y, -5, 5}, Method -> "Trapezoidal"], {t, 0, 4}] takes too much! – user34056 Oct 19 '15 at 10:06
  • @MichaelE2, I checked your suggestion but I wasn't able to make a plot. I use V8. – user34056 Oct 20 '15 at 18:14
  • As I said, I don't have V8 and I don't have any more suggestions at this point. Sorry. If I think of something I'll let you know. – Michael E2 Oct 20 '15 at 18:24

1 Answers1

0

Nothing much can be said without knowing the form of myrotorz1[x, y, t] I would first include NumericQ to the function. But for a simple function you can do it easily. Considering a simple function, I will do the following.

f[x_, y_, t_] := x^2 + y^2 + t^2
data[t_] := NIntegrate[f[x, y, t], {x, 0, 1}, {y, 0, 1}]
toplot = ParallelTable[data[t], {t, 0, 10}] // ListPlot