Public
Edited
Oct 17
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
cycle = res.state.map((e, i) => ({
P: mat.number(e.P, "Pa"),
H: mat.number(e.H, "J/(kg)"),
T: mat.number(e.T, "K"),
text: i + 1
}))
Insert cell
cycle_ref = res.state_ref.map((e, i) => ({
P: mat.number(e.P, "Pa"),
H: mat.number(e.H, "J/(kg)"),
T: mat.number(e.T, "K"),
text: i + 1
}))
Insert cell
improvementWithIHX = (res.COP / res.COP_ref - 1) * 100
Insert cell
temps = {
const temps = mat.range(res.tlow.toNumber('K') - 5, tCrit, 5, true).toArray();
if (temps.slice(-1) < tCrit) temps.push(tCrit);
return temps;
}
Insert cell
Insert cell
Insert cell
state
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
state = res.state.map((e) => ({
"P [bar]": e.P.toNumber("bar"),
"T [C]": e.T.toNumber("degC"),
"H [J/kg]": e.H.toNumber("J/kg"),
"S [J/ (kg K)": e.S.toNumber("J/kg/ K"),
"D [kg/m^3]": e.D.toNumber("kg/m^3")
}))
Insert cell
scope = new Map([
["fluid", refrigerant],
["mDot", mat.unit(mDot, "kg/hour")],
[
"evap",
{
T: mat.unit(evapT, "degC"),
P_drop: mat.unit(evapPd, "Pa"),
superHeating: mat.unit(evapSH, "K")
}
],
[
"cond",
{
T: mat.unit(condT, "degC"),
P_drop: mat.unit(condPd, "Pa"),
subCooling: mat.unit(condSC, "K")
}
],
["etaS", etaS],
["etaS1", etaS1],
[
"IHX",
{
epsilon: IHXeta,
thickness: mat.unit(IHXthickness, "mm"),
cellSize: mat.unit(IHXcellSize, "mm"),
k: mat.unit(IHXcond, "W/(m K)")
}
]
])
Insert cell
res = {
cycleCalculation.evaluate(scope);
IHX_calc.evaluate(scope);
secondCycleCalculation.evaluate(scope);
return {
tlow: scope.get("evap").T,
COP: scope.get("evap_COP"),
COP_ref: scope.get("evap_COP_ref"),
state: scope.get("c").toArray(),
state_ref: scope.get("c_ref").toArray(),
Q: scope.get("Q_c"),
IHX: scope.get("IHX"),
Q_ref: scope.get("Q_c_ref"),
W_comp: scope.get("W_comp"),
W_comp_ref: scope.get("W_comp_ref"),
Q_IHX: scope.get("Q_IHX")
}
}
Insert cell
cycleCalculation = mat.parse(`
c = [{},{},{},{},{},{}]; # cycle with IHX

# Short function to get fluid properties
prop(DesiredProperty, FluidState) = props(DesiredProperty, fluid, FluidState);

# Define low and high pressure
sat_gas = {'T|gas': evap.T, Q: 100%}
pLow = prop('P', sat_gas );
sat_liq = {'T|liquid': cond.T, Q: 0%}
pHigh = prop('P', sat_liq);

# 6 to 1 Evaporation
c[1].P = pLow;
c[1].T = evap.T + evap.superHeating;
c[1].D = prop('D', {'T|gas':c[1].T, P:c[1].P});
c[1].H = prop('H', {'T|gas':c[1].T, P:c[1].P});
c[1].S = prop('S', {'T|gas':c[1].T, P:c[1].P});

# 1 to 2 IHX Low
c[2].P = c[1].P;
H_eta = prop('H', {T: cond.T, P:c[2].P});
c[2].H = IHX.epsilon * (H_eta - c[1].H) + c[1].H;
c[2].T = prop('T', c[2]);
c[2].D = prop('D', c[2]);
c[2].S = prop('S', c[2]);

# 2 to 3 Compression of vapor
c[3].P = pHigh + cond.P_drop;
H_i = prop('H', { 'P': c[3].P, 'S': c[2].S });
c[3].H = (H_i - c[2].H) / etaS + c[2].H;
c[3].T = prop('T', c[3]);
c[3].D = prop('D', c[3]);
c[3].S = prop('S', c[3]);

# 3 to 4 Condensation
c[4].T = cond.T-cond.subCooling;
c[4].P = pHigh;
c[4].D = prop('D', {"T|liquid":c[4].T, P: c[4].P});
c[4].H = prop('H', {"T|liquid":c[4].T, P: c[4].P});
c[4].S = prop('S', {"T|liquid":c[4].T, P: c[4].P});

# 4 to 5 IHX high
c[5].H = c[1].H - c[2].H + c[4].H;
c[5].P = c[4].P;
c[5].T = prop('T', c[5]);
c[5].D = prop('D', c[5]);
c[5].S = prop('S', c[5]);

# 5 to 6 Expansion
c[6].H = c[5].H;
c[6].P = c[1].P + evap.P_drop;
c[6].T = prop('T', c[6]);
c[6].D = prop('D', c[6]);
c[6].S = prop('S', c[6]);

# Work, Energy and Performance
W_comp = mDot*(c[3].H - c[2].H);
# Q_h = mDot*(c[4].H - c[5].H);
Q_c = mDot*(c[1].H - c[6].H);
Q_IHX = mDot*(c[2].H-c[1].H);

evap_COP = Q_c/W_comp;
# cond_COP = Q_h/W_comp;
`)
Insert cell
Insert cell
secondCycleCalculation = mat.parse(`
# Without IHX
c_ref = [{},{},{},{}]; # cycle without IHX

c_ref[1].P = pLow;
c_ref[1].T = evap.T + evap.superHeating;
c_ref[1].D = prop('D', {'T|gas':c_ref[1].T, P:c_ref[1].P});
c_ref[1].H = prop('H', {'T|gas':c_ref[1].T, P:c_ref[1].P});
c_ref[1].S = prop('S', {'T|gas':c_ref[1].T, P:c_ref[1].P});

# 1 to 2 Compresison of vapor
c_ref[2].P = pHigh + cond.P_drop;;
H_i = prop('H', { 'P': c_ref[2].P, 'S': c_ref[1].S });
c_ref[2].H = (H_i - c_ref[1].H) / etaS1 + c_ref[1].H;
c_ref[2].T = prop('T', c_ref[2]);
c_ref[2].D = prop('D', c_ref[2]);
c_ref[2].S = prop('S', c_ref[2]);

# 2 to 3 Condensation
c_ref[3].T = cond.T-cond.subCooling;
c_ref[3].P = pHigh;
c_ref[3].D = prop('D', {"T|liquid":c_ref[3].T, P: c_ref[3].P});
c_ref[3].H = prop('H', {"T|liquid":c_ref[3].T, P: c_ref[3].P});
c_ref[3].S = prop('S', {"T|liquid":c_ref[3].T, P: c_ref[3].P});

# 3 to 4 Expansion
c_ref[4].H = c_ref[3].H;
c_ref[4].P = c_ref[1].P + evap.P_drop;
c_ref[4].T = prop('T', c_ref[3]);
c_ref[4].D = prop('D', c_ref[3]);
c_ref[4].S = prop('S', c_ref[3]);

# Work, Energy and Performance
W_comp_ref = mDot*(c_ref[2].H - c_ref[1].H);
Q_c_ref = mDot*(c_ref[1].H - c_ref[4].H);

evap_COP_ref = Q_c_ref/W_comp_ref;
`)
Insert cell
Insert cell
Insert cell
import {mat, cp} from "@dvd101x/coolprop"
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more