Systems of 1 DofF ,x''=f(x)
Example 3 - Yukawa’s Potential

Clear["Global`*"]

System definition

a=1; b=1; c=1/2;
V=-a Exp[-b x]/x
U=((c^2)/(x^2))-((a (E^(-b x)))/(b x))
Plot[U,{x,0.2,2}]
Energy[x_,y_]=y^2/2+U

Equilibrium point

f=-D[U,x]

eqp=FindRoot[f==0,{x,0.5}];
x0=x/.eqp[[1]]
E0=Energy[x0,0]

Stability index and period of small oscillations

k=D[U,{x,2}] /.x->x0
Period0=2 π /(Sqrt[k])

Phase space diagram

phasespace=ContourPlot[Energy[x,p],{x,0.1,2},{p,-2,2},ContourShading->False, Contours->{E0+0.001,-0.2, -0.15, -0.1,  -0.5, 0, 0.3, 1},PlotPoints->100,FrameLabel->{"x","p"}]

Period for a selected energy value

Ev=-0.1 
Ev-U==0
root1=FindRoot[Ev-U==0,{x,0.4}]
root2=FindRoot[Ev-U==0,{x,1.0}]
x1=x/.root1;
x2=x/.root2;
period=2*NIntegrate[(2*(Ev-U))^(-1/2),{x,x1,x2}]

Period as function of Energy  (Ε0<Ε<0)

Initial parameters

Emin=E0; Emax=-0.01;
DE=0.01;  (* Energy step *) 
δ=0.0000000001; (* small shift to avoid complex period values*)
data={{E0,Period0}}   (* list for saving pairs E,T *)
(* Approximated limits xmin and xmax at E=Εmin+DE *)
energy=Emin+DE;
x1=x0-0.01; x2=x0+0.01;

Επαναληπτική διαδικασία με αύξηση ενέργειας κατά DE

While[energy<Emax, 
root1=FindRoot[energy-U==0,{x,x1}];
root2=FindRoot[energy-U==0,{x,x2}];
x1=x/.root1;
x2=x/.root2;
period=2*NIntegrate[(2*(energy-U))^(-1/2),{x,x1+δ,x2-δ}]  ;
Print["E=",energy,"   T=",period];
AppendTo[data,{energy,period}];
energy+=DE
]

ListPlot[data, Joined->True, Frame->True]