# Phase diagram of a second-order differential equation

45 views (last 30 days)
Richard Wood on 10 Mar 2020
Commented: Richard Wood on 12 Mar 2020
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?
Richard Wood on 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.

darova on 11 Mar 2020
Edited: darova on 11 Mar 2020 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
Richard Wood on 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.