Phase diagram of a second-order differential equation

13 visualizzazioni (ultimi 30 giorni)
Hello everyone
I have solved a second-order differential equation, and as a result of it I have obtained the values of an angle, phi, and its first derivative on time, phidot, assuming that a time equal to zero both are zero. Now, I would like to do a phase diagram as the one that I have attached. Which is the most suitable function to plot and what I need?
Any suggestion?
  6 Commenti
darova
darova il 11 Mar 2020
  • After that, you define a variable F, which depends on the previous meshgrid, and where you are going to evaluate an expression depending only on Y (maybe Y depends on X somehow)
Variable F in this case is just a derivative (depends on y only, but should be 2 inputs for ode45)
  • After that, you define DY, evaluating F on the X=1 point for all the values created on the meshgrid on Y
The correct form would be as following (i think)
DY = F([],Y); % doesn't matter what X=1 (equation doesn't have X variable)
  • and then you define DX somehow (I do not understand that point at all).
I evaluated , but to plot quiver i need u and v (dx and dy)
So i assign dx=1(always) and dy=4y-16
  • Up to which point do you that this approach is compatible with the variables that I have already? Could I use this script directly taking into account that I have already the values of the angular variable and its derivative already calculated?
please show your equation
Richard Wood
Richard Wood il 11 Mar 2020
Modificato: Richard Wood il 11 Mar 2020
Thank you very much for your comment. I think that it could be better for our mutual understanding if I provide you with as much information of my real problem as possible. First of all, I have attached some data, Example.m. There, the first column corresponds to time (the variable with the respect to which the derivatives are performed), the second column corresponds to the angular values and the third one to its time derivative. This values has been calculated from the following equation:
The values involved are the following:
Ss=5/2;
mu0=4*pi*10^(-7); %H/m
gamma=2.21*10^5; %m/(A*s)
kB=1.38064852*10^(-23); %J/K
a0=3.328*10^(-10); %m
c=8.539*10^(-10); %m
V=c*(a0^2); %m^3
Hx=0;
Hy=40.*(40*79.5774715459)); % A/m
muB=9.27400994*10^(-24); %(T^2*m^3)/J
mu=4*muB; %(T^2*m^3)/J
Ms=mu/V; %T^2/J
K4parallel=1.8548*(10^(-25))/V; %J/m^3
alpha=0.001;
Omegae=(2*gamma*abs(4*(-396*kB/V)-532*kB/V))/(mu0*Ms); %s^-1
Omega4parallel=(2*gamma*K4parallel)/(mu0*Ms); %s^-1
OmegaR=sqrt(2*Omegae*Omega4parallel);
Maybe there are some parameters that are not needed, sorry if that it is the case. So at the end, this is what I have to face the quiver plot.

Accedi per commentare.

Risposta accettata

darova
darova il 11 Mar 2020
Modificato: darova il 11 Mar 2020
It's your equation
Assume you have a curve
Then to create a quiver or streamline you need ( ϕ, , u, v )
I looked here and see that (ϕ, ) in [ ]
What is the connection between u, v and ?
So substituting (ϕ, ) in we have angle
I assume u=1, then v=a
I used parameters you gave
F = @(phi,dphi) -OmegaR^2/4*sin(4*phi) -2*Omegae*gamma*Hy*cos(phi) -2*Omegae*alpha*dphi;
xx = -pi:0.3:pi;
[p,dp] = meshgrid(xx); % grid for phi and dphi
v = F(p,dp)./dp;
u = v*0 + 1;
quiver(p,dp,u,v,'b')
hold on
streamline(p,dp,u,v,xx,xx,'r')
hold off
i got this
streamline somehow didn't work
  9 Commenti
darova
darova il 12 Mar 2020
Try this
x = 0:0.1:10;
y = sin(x);
u = diff(x);
v = diff(y);
ii = 1:10:length(u); % how many arrows
plot(x,y)
hold on
quiver(x(ii),y(ii),u(ii),v(ii))
hold off
Richard Wood
Richard Wood il 12 Mar 2020
Thank you again for your comment. But I think we are not understanding each other, surely because of me. In your last code, where is the role of my solution of phy and phidot (or dphi, as you called it at the beginning)? I suppose that you create your y function to play the role of phidot, and so x to be my phi variable. It is not neccesary for you to answer me again, probably I am wasting your time. If you run my code, eliminating the last line and the line of the outputdir you will see exactly what I have, how many elements on each array of phi and phidot, and the number of columns being the same as the number of elements of the Temperature variable.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by