%Mixer 
% There is perfect mixing, with perfect level control. 

%There are two parts of the mixer: 
% The dynamic part assumes that there is a volume, and therefore, a
% residence time. This affects how the concentration at the outlet behaves.
% As we are assuming constant densities, we are assuming that the
% volumetric flow rates can be easily calculated from the mass flow rates
% and therefore, calculating the mass concentration is easy. 
%This script generates the paramters for function mixerMeOH_O2_dynamic.m

% The steady-state part calculates the mol concentration from the mass
% concentration. It also calculates the total outlet flow, which is
% instantaneous. 

% In the future, someone else can include:
% - A tank with level control and give some dynamics to the total
%  outlet flow
% - Varying densities. 

%Mol weight
MW_MeOH=32.04;              % g/mol
MW_air=28.9647;             % g/mol

tau_mixer=1;               %Residence time of the mixer
rho_MeOH=792;               %kg/m^3 (this could be calculated, but it is less sensitive than air, assuming it is liquid. Maybe it is in vapor phase? or vaporized in the valve?)
V_mixer=16;                 %seconds

%Initial value for MeOH mass concentration
c_MeOH_0=m_MeOH_sp_0/(m_MeOH_sp_0+m_air_sp_0);   % 0.1095

%The volume of the mixer was a very rough calculation using
%q_air=1.944E4m^3/h and q_MeOH=3.7 m^3/h and saying that I want a residence
%time of 3 seconds. This is a very short residence time in a tank, but this
%is almost instant mixing.  The biggest error here is that most probably,
% the MeOH is not completely liquid, and therefore q_MeOH is higher. 
% This would make the actual residence time lower. 

% rho_a  comes from the compressor script
p_mix=[MW_MeOH;MW_air;rho_MeOH;rho_a;V_mixer];