Quasi-periodic coupled oscillations

Clear[tmax,k1,k2,kk,ww,ω1,ω2]
Manipulate[
tmax=3 Pi;
dθ1=ω1+k1 Sin[θ2-θ1];(*θ phase*)
dθ2=ω2+k2 Sin[θ1-θ2];
sp=StreamPlot[{dθ1,dθ2},{θ1,0,2 π},{θ2,0,2 π},FrameLabel->{θ1[t],θ2[t]},LabelStyle->17,ImageSize->360];
integ=NDSolve[{
θ1'[t]==ω1+k1 Sin[θ2[t]-θ1[t]],
θ2'[t]==ω2+k2 Sin[θ1[t]-θ2[t]],
θ1[0]==0,θ2[0]==0.1},
{θ1,θ2},{t,0,tmax}];
plot1=ParametricPlot[Evaluate[{θ1[t],θ2[t]}/.integ],{t,0,tmax},AxesLabel->{θ1[t],θ2[t]},PlotStyle->Black,LabelStyle->17];

pplo1=ParametricPlot[Evaluate[{
Cos[θ1[t]],
D[Cos[θ1[t]],t]}/.integ],
{t,0,tmax},
AxesLabel-> {"cos θ1","(∂_t)cos θ1"},PlotLabel->"Phase portrait of cos θ1",PlotRange->{{-1.01,1.01},All},ImageSize->360,AspectRatio->1,LabelStyle->17,PlotStyle->Black];
pplo2=ParametricPlot[Evaluate[{
Sin[θ2[t]],
D[Sin[θ2[t]],t]}/.integ],
{t,0,tmax},
AxesLabel-> {"sin θ2","(∂_t)sin θ2"},PlotLabel->"Phase portrait of sin θ2",PlotRange->{{-1.01,1.01},All},ImageSize->360,AspectRatio->1,LabelStyle->17,PlotStyle->Red];

sinp1=Plot[Evaluate[Cos[θ1[t]]/.integ],{t,0,tmax},AxesLabel-> {t,Cos[θ1]},PlotRange-> All,ImageSize->360,LabelStyle->17,PlotStyle->Black];
sinp2=Plot[Evaluate[Sin[θ2[t]]/.integ],{t,0,tmax},AxesLabel-> {t,Sin[θ2]},PlotRange-> All,ImageSize->360,LabelStyle->17,PlotStyle->Red];

kk=k1+k2;ww=Abs[ω1-ω2];
Grid[
{{Show[sp,plot1],
Column[{
StringForm["Ratio of frequencies ω1/ω2 = ``",ω1/ω2],
StringForm["Is ω1/ω2 rational (ℚ)?:  ``",ω1/ω2∈Rationals],
StringForm["k1 + k2 = ``",k1+k2],
StringForm["Abs[ω1-ω2] = ``.",Abs[ω1-ω2]],
StringForm["\nNB! If Abs[ω1-ω2] ⩾ k1+k2 and ω1/ω2 ∈ ℙ (irrational), then solution is quasi-periodic. Otherwise, periodic or periodic phase-locking solution."],
If[ww≤ kk,
Plot[ω1-ω2-(k1+k2) Sin[ϕ],{ϕ,0,2 π},ImageSize->250,AspectRatio -> 0.5,Frame->True, AxesLabel->{ϕ,"(∂_t)ϕ"},LabelStyle->17,Epilog->{Red,AbsolutePointSize[10],Point[{ϕ,0}/.Quiet[Solve[ω1-ω2-(k1+k2) Sin[ϕ]==0&&ϕ≥0&&ϕ<2 π,ϕ,Reals]]]}],
Plot[ω1-ω2-(k1+k2) Sin[ϕ],{ϕ,0,2 π},ImageSize->250,AspectRatio -> 0.5,Frame->True,AxesLabel->{ϕ,"(∂_t)ϕ"},LabelStyle->17]]
}]},
{pplo1,pplo2},
{sinp1,sinp2}},
Frame->All],

{{k1,1.71,"Coupling constant k1"},0,4,Appearance->"Labeled"},
{{k2,2,"Coupling constant k2"},0,4,Appearance->"Labeled"},
{{ω1,5.0+(Sqrt[π]),"Frequency ω1"},0,10,Appearance->"Labeled"},
{{ω2,1,"Frequency ω2"},1,10,Appearance->"Labeled"},SaveDefinitions->True]

Creation of this notebook was supported by IT Academy program of Information Technology Foundation for Education (HITSA).