%
% Particle density calculation script
%

global hbar;
hbar = 1.05457148e-34;

ERXA = 4*pi^2*hbar^2/(2*ma*lambdaX^2);
ERTA = 4*pi^2*hbar^2/(2*ma*lambdaT^2);
ERXB = 4*pi^2*hbar^2/(2*mb*lambdaX^2);
ERTB = 4*pi^2*hbar^2/(2*mb*lambdaT^2);

VXA = optpot (d1a,d2a,gammaa,lambdaX,IX);
VTA = optpot (d1a,d2a,gammaa,lambdaT,IT);
VXB = optpot (d1b,d2b,gammab,lambdaX,IX);
VTB = optpot (d1b,d2b,gammab,lambdaT,IT);

disp (['Transverse optical potential VTA/ERTA = ', num2str(VTA/ERTA)]);
disp (['Transverse optical potential VTB/ERTB = ', num2str(VTB/ERTB)]);

JA = jparam(ma,lambdaX,abs(VXA));
UA = uparam(ma,aaa,lambdaX,abs(VXA),abs(VTA));
JB = jparam(mb,lambdaX,abs(VXB));
UB = uparam(mb,abb,lambdaX,abs(VXB),abs(VTB));
UAB = u2param(ma,mb,aab,lambdaX,abs(VXA),abs(VXB),abs(VTA),abs(VTB));

JA = JA./UAB;
JB = JB./UAB;
UA = UA./UAB;
UB = UB./UAB;

TA = 1/8*ma*omegaA^2*lambdaX^2./UAB;
TB = 1/8*mb*omegaB^2*lambdaX^2./UAB;

UAB = 1;

I = 1:size(IX,1);

for i = I
    disp (['Axial optical potential VXA/ERLA = ', num2str(VXA(i)/ERXA)]);
    disp (['Axial optical potential VXB/ERLB = ', num2str(VXB(i)/ERXB)]);
    disp (['JA = ',num2str(JA(i)),', JB = ',num2str(JB(i)),', UA = ',num2str(UA(i)),', UB = ',num2str(UB(i)), ', UAB = 1', ', TA = ',num2str(TA(i)),', TB = ',num2str(TB(i))]);
    [E,DENS] = dmrgbh(JA(i),JB(i),UA(i),UB(i),UAB,TA(i),TB(i),rhoA,rhoB,0,0,N,maxA,maxB,tmax,wlimit,slimit,true);
    
    DATA1(:,i) = DENS(:,1);
    DATA2(:,i) = DENS(:,2);
    save ('dens','DATA1','DATA2');
end
