Skip to main content

differential equations - How to find period of the interpolating function


Code is:


m[t_] := {mx[t], my[t], mz[t]}

γ = 28;

h = 6.62*10^-34;

e = 1.6*10^-19;


Subscript[μ, 0] = 1.25*10^-6;

Subscript[μM, 0] = 800*10^-3;

Subscript[M, 0] = 0.64*10^6;

Subscript[r, 0] = 100*10^-9;

Subscript[l, 0] = 3*10^-9;


Subscript[I, dc] = 1*10^-3;

Subscript[B, dc] = 200*10^-3;

Subscript[α, G] = 0.01;

p = {0, 0, 1};

σ =(γ*h/2*e)*1/(Subscript[M, 0]*Pi*(Subscript[r, 0])^2)*Subscript[l, 0];


Subscript[B, eff] = {Subscript[B, dc], 0, 0}-Subscript[μM, 0]*(m[t]*p);

system1 ={D[m[t], t] ==γ*(Cross[Subscript[B, eff], m[t]]) + Subscript[α, G]*(Cross[m[t], D[m[t], t]]) +σ*Subscript[I, dc]*(Cross[m[t], Cross[m[t], p]]),(m[t] /. t -> 0) == {0, 1, 0}};

s1 = NDSolve[system1, m[t], {t, 0, 50}]

Plot[Evaluate[{mx[t], my[t], mz[t]} /. s1], {t, 0, 50},AxesLabel -> {t, m}]

Plot[Evaluate[mx[t] /. s1], {t, 0, 50}, AxesLabel -> {t, mx}]


I need for mx (t) calculate how changes the magnetization of the oscillation frequency f 0 during the time of 50 ns and plot a graph f (t).



Answer



We can sow the minima of each coordinate and look at the intervals near the end of integration.


{s1, {{x0}, {y0}, {z0}}} = Reap[
NDSolve[{system1,
WhenEvent[mx'[t] > 0, Sow[t, "x"]], (* minima of x *)
WhenEvent[my'[t] > 0, Sow[t, "z"]], (* minima of y *)
WhenEvent[mz'[t] > 0, Sow[t, "y"]]}, (* minima of z *)
m[t], {t, 0, 50}],
{"x", "y", "z"}];


Here are the approximate periods:


Table[Mean@ Differences@ min[[-Round[Length@min/4] ;;]], {min, {x0, y0, z0}}]
(* {0.25092, 0.501841, 0.501841} *)

We can see that mx has twice the frequency of the other components:


Plot[Evaluate[{2000 (mx[t] - 1), my[t], mz[t]} /. s1], {t, 45, 50}, 
AxesLabel -> {t, m}]

Mathematica graphics



Comments

Popular posts from this blog

plotting - Filling between two spheres in SphericalPlot3D

Manipulate[ SphericalPlot3D[{1, 2 - n}, {θ, 0, Pi}, {ϕ, 0, 1.5 Pi}, Mesh -> None, PlotPoints -> 15, PlotRange -> {-2.2, 2.2}], {n, 0, 1}] I cant' seem to be able to make a filling between two spheres. I've already tried the obvious Filling -> {1 -> {2}} but Mathematica doesn't seem to like that option. Is there any easy way around this or ... Answer There is no built-in filling in SphericalPlot3D . One option is to use ParametricPlot3D to draw the surfaces between the two shells: Manipulate[ Show[SphericalPlot3D[{1, 2 - n}, {θ, 0, Pi}, {ϕ, 0, 1.5 Pi}, PlotPoints -> 15, PlotRange -> {-2.2, 2.2}], ParametricPlot3D[{ r {Sin[t] Cos[1.5 Pi], Sin[t] Sin[1.5 Pi], Cos[t]}, r {Sin[t] Cos[0 Pi], Sin[t] Sin[0 Pi], Cos[t]}}, {r, 1, 2 - n}, {t, 0, Pi}, PlotStyle -> Yellow, Mesh -> {2, 15}]], {n, 0, 1}]

plotting - Plot 4D data with color as 4th dimension

I have a list of 4D data (x position, y position, amplitude, wavelength). I want to plot x, y, and amplitude on a 3D plot and have the color of the points correspond to the wavelength. I have seen many examples using functions to define color but my wavelength cannot be expressed by an analytic function. Is there a simple way to do this? Answer Here a another possible way to visualize 4D data: data = Flatten[Table[{x, y, x^2 + y^2, Sin[x - y]}, {x, -Pi, Pi,Pi/10}, {y,-Pi,Pi, Pi/10}], 1]; You can use the function Point along with VertexColors . Now the points are places using the first three elements and the color is determined by the fourth. In this case I used Hue, but you can use whatever you prefer. Graphics3D[ Point[data[[All, 1 ;; 3]], VertexColors -> Hue /@ data[[All, 4]]], Axes -> True, BoxRatios -> {1, 1, 1/GoldenRatio}]

plotting - Adding a thick curve to a regionplot

Suppose we have the following simple RegionPlot: f[x_] := 1 - x^2 g[x_] := 1 - 0.5 x^2 RegionPlot[{y < f[x], f[x] < y < g[x], y > g[x]}, {x, 0, 2}, {y, 0, 2}] Now I'm trying to change the curve defined by $y=g[x]$ into a thick black curve, while leaving all other boundaries in the plot unchanged. I've tried adding the region $y=g[x]$ and playing with the plotstyle, which didn't work, and I've tried BoundaryStyle, which changed all the boundaries in the plot. Now I'm kinda out of ideas... Any help would be appreciated! Answer With f[x_] := 1 - x^2 g[x_] := 1 - 0.5 x^2 You can use Epilog to add the thick line: RegionPlot[{y < f[x], f[x] < y < g[x], y > g[x]}, {x, 0, 2}, {y, 0, 2}, PlotPoints -> 50, Epilog -> (Plot[g[x], {x, 0, 2}, PlotStyle -> {Black, Thick}][[1]]), PlotStyle -> {Directive[Yellow, Opacity[0.4]], Directive[Pink, Opacity[0.4]],