% 01.12.2018. determine steady-state values

syms  Q1 Q2 UA UA2 TG1 TG2                             % Symbolic variables

% parameters
%M       = 1000;                                         % [kg], drum holdup
m0      = 5.9748;                                        % [kg/s], water flow in
T0      = 45+273.15;                        % [degC], water temperature of flow in
dHvap45 = 2400e3;                             % [J] vaporisation heat at T0
H0      = 0;
h0      = m0*H0;                                    % [J], flow in enthalpy
mG      = 7;                                        % [kg/s], gas mass flow
cpG     = 3e3;                            % [J/kg/K], methane specific heat
cpSteam = 2e3;                              % [J/kg/K], steam specific heat

m1      = m0;                                      % perfect level control
T1      = 584.0396;                                   % [degC], drum temperature

H1      = dHvap45 + cpSteam*(T1-T0);
h1      = m1*H1;                                % [J], enthalpy of flow out

T2      = 876.7378;                       % [degC] superheated steam temperature
H2      = dHvap45 + cpSteam*(T2-T0);
h2      = m1*H2;                               % [kJ], enthalpy of flow out

TG0     = 1000+273.15;                                     % inlet gas temperature

eqn(1) = Q1-mG*cpG*(TG1-TG2)==0;      % Energy balance gas side (algebraic)
eqn(2) = mG*cpG*(TG1-TG2)-UA*((TG1+TG2)/2-T1)==0;  % Q = UA Delta T = Q gas 
eqn(3) = h0-h1+Q1==0;                 % Energy balance steam side (dynamic)

eqn(4) = Q2-mG*cpG*(TG0-TG1)==0; % energy balance SH
eqn(5) = mG*cpG*(TG0-TG1)-UA2*((TG0+TG1)/2-(T1+T2)/2)==0;
eqn(6) = h1-h2+Q2 == 0; 

sol    = solve(eqn,UA,UA2,Q1,Q2, TG2,TG1);
UA     = sol.UA                                          % [W/m2/K], boiler
UA2    = sol.UA2                                    % [W/m2/K], superheater
Q1     = sol.Q1                        % [J], heat transfered in the boiler
TG2    = sol.TG2                 % [degC], gas temperature at boiler outlet
Q2     = sol.Q2                   % [J], heat transfered in the superheater
TG1    = sol.TG1            % [degC], gas temperature at superheater outlet








