function [w] = MassFrac(wNH3,R)

% This functions calculates the mass fractions based on a defined inlet
% mass fraction of ammonia and a molar ratio of hydrogen and nitrogen.

import casadi.*

if isa(wNH3,'casadi.MX')
    w = MX.zeros(3,numel(wNH3));
else
    w = zeros(3,numel(wNH3));
end
w(1,:) = (1-wNH3').*2.*R'./(28+2*R'); 
w(2,:) = (1-wNH3').*28./(28+2*R'); 
w(3,:) = wNH3';