function xprime=cola_lv_nonideal1(t,X) 
global UU dyndata i tend NI sstt sstt1 au stages_Temperature Temp_nom
indmat_Yes_S1

% [VB,e5] = Controller_PI(X(im_xr(2)+NI),0,dyndata.u_nom(2),X(5),0,100);
% [L,e6] = Controller_PI(X(im_xt(3)+NI),0,dyndata.u_nom(1),X(6),0,100);

[D,e1] = Controller_PI(X(im_mt+NI),dyndata.x_nom(im_mt),dyndata.u_nom(end-1),X(1),1,1001,0,2);
[B,e2] = Controller_PI(X(im_mr+NI),dyndata.x_nom(im_mr),dyndata.u_nom(end),X(2),1,1001,0,2);


%get Temperatures for current timestep
Temp_current=get_Temperature(stages_Temperature,1,X);

%Controller
au=0;
[L,e3] = Controller_PI(Temp_current(1),Temp_nom(1),...
            dyndata.u_nom(1)+0.01,X(3),0.477*au,6.7,0,4);

[S1,e4] = Controller_PI(Temp_current(2),Temp_nom(2),...
            dyndata.u_nom(5),X(4),-1.459*au,4.76,0,4);

% [S12,e9] = Controller_PI(log((X(im_xS1(1)+NI))),log((dyndata.x_nom(im_xS1(1)))+sstt1),...
%             dyndata.u_nom(5),X(4),-0.1*au,320,0,4);
        
% S1=max(S11, S12);
[RL,e5] = Controller_PI(Temp_current(3),Temp_nom(3),...
            dyndata.u_nom(3),X(5),-0.282*au,23,0,4);

% [RLL,e8] = Controller_PI(log(X(im_x2(coldata.Nt(2))+NI)),...
%             log(dyndata.x_nom(im_x2(coldata.Nt(2)))),...
%             dyndata.u_nom(3)*10000,X(6),0.03*au*0,320,0,4);
Rl=RL;%Rl=min(RL,RLL);


[RV,e7] = Controller_PI(Temp_current(4),Temp_nom(4),...
            dyndata.u_nom(4),X(7),0.125*au,20,0,4);



[VBB1,e8] = Controller_PI(Temp_current(5),Temp_nom(5),...
            dyndata.u_nom(2),X(8),-0.048*au,60,0,4);
[VBB2,e6] = Controller_PI(Temp_current(6),Temp_nom(6),...
            dyndata.u_nom(2),X(6),-0.564*au,4,0,4);
%[VBB2,e6] = Controller_PI(log(X(im_x2(coldata.Nt(2))+NI)),...
%            log(dyndata.x_nom(im_x2(coldata.Nt(2)))),...
%            dyndata.u_nom(2),X(6),0.03*au,320,0,4);
VBB=VBB2;
%VBB=max(VBB1,VBB2);



if i==0 || (t>0.01 && rem(i+1,1)==0) || t==tend
%     t
UU=[UU; t [L;VBB;Rl;RV;S1;dyndata.u_nom(6:9); D; B;VBB1;VBB2;RL]'];
end
i=i+1;

xprime=genkaibel_run_No_Fv(t,[L;VBB;Rl;RV;S1;...
    dyndata.u_nom(6);...
    dyndata.u_nom(7);...
    dyndata.u_nom(8);...
    dyndata.u_nom(9);...
    D; B ;X(NI+1:end)]);
xprime=[e1;e2;e3;e4;e5;e6;e7;e8;xprime];

% xprime=[e1;e2;e3;e4;e5;e6;e7;e8;xprime];
% [VT,e2] = Controller_PI(x(INDEX.im_xr1(2)),dyndata.x_nom(INDEX.im_xr1(2)),dyndata.u_nom(11),x(end-1),0.1284,216);