Public
Edited
Nov 6, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof etaS = Inputs.range([.7,.95], {value:0.75, step:0.01, label:'Isentropic Efficiency of the Compressor'})
Insert cell
((scope.get('evap_COP')/scope.get('noIHX_COP')-1)*100).toFixed(2)+" %"
Insert cell
scope = {
const scope = new Map();
scope.set("refrigerant", refrigerant);
scope.set("evaporator", {
temp: mat.unit(evapTemp, "degC"),
P_drop: mat.unit(evapPdrop, "psi")
});
scope.set("gasCooler", {
in_T: mat.unit(gasCooler_InletTemperature, "degC"),
P_drop: mat.unit(gasCoolerPdrop, "psi"),
P_out: mat.unit(gasCoolerP, "psi")
});
scope.set("IHX", { epsilon: IHX_epsilon });
scope.set("etaS", etaS);
scope.set("mDot", mat.unit(mDot, "lbm/h"));
co2.evaluate(scope);
return scope;
}
Insert cell
refrigerant = "CO2"
Insert cell
tCrit = cp.PropsSI('Tcrit','',0,'',0, refrigerant)
Insert cell
mat.unit(tCrit,'K').to('degC').format(2)
Insert cell
temps = {
const temps = mat.range(mat.unit(evapTemp,'degC').toNumber('K') - 5, tCrit, 5, true).toArray();
if (temps.slice(-1) < tCrit) temps.push(tCrit);
return temps;
}
Insert cell
saturatedLiquid = temps.map( T => ({
P:cp.PropsSI('P','T|liquid', T,'Q',0, refrigerant),
H:cp.PropsSI('H','T|liquid', T,'Q',0, refrigerant),
T:T
}))
Insert cell
saturatedGas = temps.map((T) => ({
P: cp.PropsSI("P", "T|gas", T, "Q", 1, refrigerant),
H: cp.PropsSI("H", "T|gas", T, "Q", 1, refrigerant),
T
}))
Insert cell
scope.get("c")
Insert cell
cycle = scope
.get("c")
.H.map((H, i) => ({
H: H.toNumber("J/kg"),
P: mat.number(scope.get("c").P.get(i), "Pa"),
T: mat.number(scope.get("c").T.get(i), "degC"),
D: mat.number(scope.get("c").D.get(i), "kg/m^3"),
S: mat.number(scope.get("c").S.get(i), "J/(kg K)"),
}))
.toArray()
Insert cell
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
`)
Insert cell
import {mat, cp} from "@dvd101x/coolprop"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more