Skip to main content
edited tags
Link
bbgodfrey
  • 62.1k
  • 18
  • 92
  • 160
added 1303 characters in body
Source Link

I am using a Mac Book with Monterey and 16GB RAM for a calculation with 2 nested For loops. I am relatively new to Mathematika and still trying to learn the language properly, so I hope the problem is relatively small.

Edit: The Code

Liste2 = {};
For[\[Omega] = 0.3, \[Omega] <= 1, \[Omega],
 {Liste = {},
  \[Omega] = \[Omega] + 0.01,
  \[Lambda] = 2*Pi/\[Omega],
  {For[Nz = 0, Nz <= 150, Nz++,
    {F[t_] := 
      Piecewise[{{2*t/\[Lambda], 
         0 < t <= \[Lambda]/2}, {1, \[Lambda]/2 < 
          t <= \[Lambda]*(Nz + 1/2)}, {-2/\[Lambda]*t + 
          2*(Nz + 1), \[Lambda]*(Nz + 1/2) < 
          t <= \[Lambda]*(Nz + 1)}}, 0],
     {xsol, ysol} = 
      NDSolveValue[{x'[t] == -Sin[\[Omega]*t]*Exp[2*I*t]*F[t]*y[t], 
        y'[t] == Sin[\[Omega]*t]*F[t]*Exp[-2*I*t]*x[t], x[0] == 0, 
        y[0] == 1}, {x, y}, {t, 0, 10000}],
     fabs2[t_] := Re[xsol[t]*Conjugate[xsol[t]]],
     Wert = fabs2[10000],
     AppendTo[Liste, {Wert}],
     (*Print[{\[Omega],Max[Liste]}],*)
     max = Max[Liste]
     }]
   },
  AppendTo[Liste2, {\[Omega], max}]}]
(*Print[Liste2]*)
ListLogLogPlot[Liste2, Joined -> True, PlotTheme -> "Scientific", 
 FrameLabel -> {Style["\[Omega] [Einheiten von m]", 20], 
   Style["max(|f(\!\(\*SubscriptBox[\(t\), \
\(e\)]\))\!\(\*SuperscriptBox[\(|\), \(2\)]\))", 20]}, 
 ImageSize -> Large, PlotStyle -> {Purple}]

I am using a Mac Book with Monterey and 16GB RAM for a calculation with 2 nested For loops.

I am using a Mac Book with Monterey and 16GB RAM for a calculation with 2 nested For loops. I am relatively new to Mathematika and still trying to learn the language properly, so I hope the problem is relatively small.

Edit: The Code

Liste2 = {};
For[\[Omega] = 0.3, \[Omega] <= 1, \[Omega],
 {Liste = {},
  \[Omega] = \[Omega] + 0.01,
  \[Lambda] = 2*Pi/\[Omega],
  {For[Nz = 0, Nz <= 150, Nz++,
    {F[t_] := 
      Piecewise[{{2*t/\[Lambda], 
         0 < t <= \[Lambda]/2}, {1, \[Lambda]/2 < 
          t <= \[Lambda]*(Nz + 1/2)}, {-2/\[Lambda]*t + 
          2*(Nz + 1), \[Lambda]*(Nz + 1/2) < 
          t <= \[Lambda]*(Nz + 1)}}, 0],
     {xsol, ysol} = 
      NDSolveValue[{x'[t] == -Sin[\[Omega]*t]*Exp[2*I*t]*F[t]*y[t], 
        y'[t] == Sin[\[Omega]*t]*F[t]*Exp[-2*I*t]*x[t], x[0] == 0, 
        y[0] == 1}, {x, y}, {t, 0, 10000}],
     fabs2[t_] := Re[xsol[t]*Conjugate[xsol[t]]],
     Wert = fabs2[10000],
     AppendTo[Liste, {Wert}],
     (*Print[{\[Omega],Max[Liste]}],*)
     max = Max[Liste]
     }]
   },
  AppendTo[Liste2, {\[Omega], max}]}]
(*Print[Liste2]*)
ListLogLogPlot[Liste2, Joined -> True, PlotTheme -> "Scientific", 
 FrameLabel -> {Style["\[Omega] [Einheiten von m]", 20], 
   Style["max(|f(\!\(\*SubscriptBox[\(t\), \
\(e\)]\))\!\(\*SuperscriptBox[\(|\), \(2\)]\))", 20]}, 
 ImageSize -> Large, PlotStyle -> {Purple}]
Source Link

Mathematica: How can I solve the problem "The Kernel Local has quit (exited) during the course of an evaluation"

I am using a Mac Book with Monterey and 16GB RAM for a calculation with 2 nested For loops.