% -----------------------------------------------------------
% Calculate time-dependent potential for adiabatic switching.
% -----------------------------------------------------------
function poten=pot(mu,omega,x,t,finaltime)

const=0.5.*mu.*omega.*omega;
n=length(x);
alpha=mu*omega;

const3=const*30;
const2=const*5;

% minimum:
% v = const3*x^4-const2*x^2
% v'= 4*const3*x^3-2*const2*x  = 0
% x=0   or   2*const3*x^2-const2 = 0 , i.e. x^2=+- 0.5 const2/const3
% v = -0.25*const2^2/const3

modify=const3.*x.*x.*x.*x-(const2+const).*x.*x+0.25*const2^2/const3;

%poten=const.*x.*x+switch2(t,finaltime)*modify;

%expo=exp(-0.07*alpha.*x.*x);
%poly=-18.*x.*x+1;
%expo=exp(-0.4*alpha.*x.*x);
%poly=-45.*x.*x+1;
expo=exp(-0.2*alpha.*x.*x);
poly=-30.*x.*x+1;


modify2=expo.*poly;

poten=const.*x.*x+switch2(t,finaltime)*modify2;


end


