# Real dumped pendulum: initial unlimited oscillations (pend_re_un_o)
library(phaseR)
#Set parameters for integration
t.end<- 50  #integrate from t=0 to t.end
delta<-0.05
pend<-function(t,y,parameters){
x <- y[1]
y <- y[2]
a<-parameters[1]
b<-parameters[2]
c<-parameters[3]
d<-parameters[4]
dy<-numeric(2)
dy[1]<-a*x+b*y
dy[2]<-c*sin(x)+d*y
list(dy)
}
omega2<- 2.
gamma<-  0.2
parms<-c(0,1,-omega2,-gamma) #parameter values
x0<- pi/2
y0<- 7
xy0<-cbind(x0,y0) #initial conditions
plot(0,0,type="n" ,xlim=c(0,30),ylim=c(-4,8),
cex.axis=1.2,cex.lab=1.5,font.lab=3
,xlab="x",ylab="y")
flow<-trajectory(pend,y0=xy0,t.end=t.end,t.step=delta,parameters=parms,
lwd=2,lty=1,colour="black",add=TRUE  )
seq_pi<-seq(pi,+10*pi,by=2*pi)
seq_pi
segments(seq_pi,-4,seq_pi,8,col="blue",lwd=2,lty=4)
arrows<-flowField(pend,lwd=2,x.lim=c(0,30),y.lim=c(-4,8),
parameters=parms,points=19,arrow.head=0.05,frac=1,colour="gray60",add=TRUE)