Conservative Dynamical systems of 1DoF
Harmonic Oscillator

Clear["Global`*"]

Force and vector field

f[x_]=-ω^2 x
graph1=VectorPlot[{y,f[x]/.ω->1/2},{x,-1,1},{y,-1,1},VectorPoints->15, VectorScale->{0.03,1,None}, VectorStyle->Gray, Frame->None]

Analytic solution

deq1=x'[t]==y[t] 
deq2=y'[t]==-ω^2  x[t]
sol=DSolve[{deq1,deq2,x[0]==x0,y[0]==y0},{x,y},t];
xt=x[t]/.sol[[1]];
yt=y[t]/.sol[[1]];
Print["x(t)=",xt]
Print["y(t)=",yt]

Παράδειγμα Τροχιάς

xt1=xt /.{x0->1, y0->0,ω->1/2}
yt1=yt /.{x0->1, y0->0,ω->1/2}
Period=2 Pi/ω /.ω->1/2 //N
Plot[{xt1,yt1},{t,0,Period},PlotStyle->{RGBColor[0,0,1],RGBColor[1,0,0]}]
ParametricPlot[{xt1,yt1},{t,0,Period},PlotStyle->RGBColor[1,0,1], AspectRatio->Automatic]

Potential, Border of motions

V[x_]=-∫-ω^2 x\[DifferentialD]x
Plot[V[x]/.ω->1/2,{x,-3,3}]
Energy[x_,y_]=(1/2)y^2+V[x]

motionBorder=Solve[E0-V[x]==0,x];
x1=x/.motionBorder[[1]]; x2=x/.motionBorder[[2]];
Print["Interval of motion  ",x1,"<= x <= ",x2]

Phase Space

graph2=ContourPlot[Energy[x,y]/.ω->1/2,{x,-1,1}, {y,-1,1}, ContourShading->False, Contours->10]

Show[graph1,graph2]