co2 = mat.parse(`
c = {T:[],P:[],D:[],H:[],S:[]}; # the cycle that will contain everything
state = [];
p(prop, state) = props(prop, refrigerant, state);
# 1 - after evaporator
state[1] = {'T|gas':evaporator.temp, Q:1}
c.H[1] = p('H', state[1]);
c.S[1] = p('S', state[1]);
c.P[1] = p('P', state[1]);
c.D[1] = p('D', state[1]);
c.T[1] = p('T', state[1]);
# 2 - after IHX cold outlet
c.P[2] = c.P[1];
H_eta = p('H', {T: gasCooler.in_T, P:c.P[2]});
c.H[2] = IHX.epsilon * (H_eta - c.H[1]) + c.H[1];
state[2] = {P:c.P[2], H:c.H[2]}
c.T[2] = p('T', state[2]);
c.D[2] = p('D', state[2]);
c.S[2] = p('S', state[2]);
# 3 - after compressor
P_high = gasCooler.P_out;
c.P[3] = P_high + gasCooler.P_drop;
H_i = p('H', { P: c.P[3], S: c.S[2] });
c.H[3] = (H_i - c.H[2]) / etaS + c.H[2];
state[3] = {P:c.P[3], H:c.H[3]};
c.T[3] = p('T', state[3]);
c.S[3] = p('S', state[3]);
c.D[3] = p('D', state[3]);
# 4 - after gas cooler
c.P[4] = P_high;
c.T[4] = gasCooler.in_T;
state[4] = {P:c.P[4], T:c.T[4]};
c.D[4] = p('D',state[4]);
c.S[4] = p('S',state[4]);
c.H[4] = p('H',state[4]);
# 5 after IHX hot outloet
c.H[5] = c.H[1] - c.H[2] + c.H[4];
c.P[5] = c.P[4];
state[5] = {H:c.H[5],P:c.P[5]};
c.T[5] = p('T', state[5]);
c.D[5] = p('D', state[5]);
c.S[5] = p('S', state[5]);
# 6 after expansion
c.H[6] = c.H[5];
c.P[6] = c.P[1]+evaporator.P_drop;
state[6] = {H:c.H[5], P:c.P[5]};
c.T[6] = p('T', state[6]);
c.D[6] = p('D', state[6]);
c.S[6] = p('S', state[6]);
# Compressor's power
W_comp = mDot * (c.H[3] - c.H[2]);
# Condenser heat out
Q_h = mDot * (c.H[4] - c.H[3]);
# Recuperator heat exchange
Q_IHX = mDot * (c.H[2] - c.H[1]);
# Evaporator heat in:
Q_c = mDot * (c.H[1] - c.H[6])
# Evap COP with recuperator
evap_COP = Q_c / W_comp
# Exapo COP without recuperator
H_i_w = p('H', { 'P': c.P[3], 'S': c.S[1] });
H_w = (H_i_w - c.H[1]) / etaS + c.H[1];
qNoIHX = c.H[1] - c.H[4];
wNoIHX = H_w - c.H[1];
# Evap COP without recuperator
noIHX_COP = qNoIHX / wNoIHX
`)