Skip to main content
added 4 characters in body
Source Link
Quantum_Oli
  • 8k
  • 2
  • 21
  • 44

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

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

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

Plot[NIntegrate[myrotorz1[x, y, t], {x, -5, 5}, {y, -5, 5},Method -> "Trapezoidal"], {t, 0, 4}]
I changed myrotorz1's definition as myrotorz1[x_?NumericQ, y_?NumericQ, t_?NumericQ] as suggested by R.M.
Source Link
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_] 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]]);

I would like to plot for myrotorz1[x, y, t]Here is something that may be reasonable as a function of t but shows an errorR. Any tips would be greatly appreciatedM. suggested

Plot[Re[NIntegrate[myrotorz1[xNIntegrate[myrotorz1[x, y, t]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 {t{-5.,5.},{-5.,5.}}. NIntegrate obtained 0,.012104690946256463` 6}]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}]

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_, y_,t_] = 
  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]]);

I would like to plot for myrotorz1[x, y, t] as a function of t but shows an error. Any tips would be greatly appreciated.

Plot[Re[NIntegrate[myrotorz1[x, y, t], {x, -5, 5}, {y, -5, 5}]], {t, 0, 6}]
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}]

Post Reopened by bbgodfrey, Karsten7, Michael E2, dr.blochwave, Artes
I just corrected the syntax error in the code
Source Link
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_, y_,t_] = 
  I/2 * (-Conjugate[D[Ψ1[x, y, t], y]] * D[Ψ1[x, y, t], x] + 
    D[Ψ1[x, y, t],y] * Conjugate[D[[Ψ1[xConjugate[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[Ψ1[xConjugate[D[Ψ1[x, y, t], y]]);
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_, y_,t_] = 
  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[Ψ1[x, y, t], y]]);
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_, y_,t_] = 
  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]]);
I corrected in the expressipn myrotorz1
Source Link
Loading
Improved formatting
Source Link
m_goldberg
  • 108.1k
  • 16
  • 104
  • 259
Loading
added 55 characters in body
Source Link
Loading
added 899 characters in body
Source Link
Loading
Post Closed as "Not suitable for this site" by m_goldberg, MarcoB, Artes, user9660, ilian
I substitute an explict value for t first for the NIntegrate statement to be successful and putting it inside the Plot statement.
Source Link
Loading
modifying the title
Link
Loading
Source Link
Loading