function v = CalcBlock_cascade(d,p,u)
% static calculation block to solve for u = f(v,x,d,p)

rho  = p(2);                                              % [m3/kg] density
cp   = p(3);                                      % [kJ/kg/K] specific heat

T0   = d(1);                                       % inlet flow temperature

% switch variables to change between case
MV     = p(6);                           % switch between MVs; 1:u=q; 2=u=Q

switch MV                                          % select if q or Q is MV
    case 1                                               % q is MV, Q is DV
        q = u;                                           % [m3/s] flow rate
        Q = d(2);                                     % [kW] heat flow rate
    case 2                                               % q is DV, Q is MV
        q = d(2);                                        % [m3/s] flow rate
        Q = u;                                        % [kW] heat flow rate
    otherwise
end

v = T0+Q/q/rho/cp;