Refine diffuser runtime and tests
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const { outputUtils, configManager } = require('generalFunctions');
|
||||
const { outputUtils } = require('generalFunctions');
|
||||
const Specific = require('./specificClass');
|
||||
|
||||
class nodeClass {
|
||||
@@ -16,16 +16,21 @@ class nodeClass {
|
||||
}
|
||||
|
||||
_loadConfig(uiConfig) {
|
||||
const cfgMgr = new configManager();
|
||||
const suffix = uiConfig.number !== undefined && uiConfig.number !== '' ? `_${uiConfig.number}` : '';
|
||||
const resolvedUiConfig = {
|
||||
...uiConfig,
|
||||
name: uiConfig.name ? `${uiConfig.name}${suffix}` : this.name,
|
||||
unit: uiConfig.unit || 'kg o2/h',
|
||||
};
|
||||
const resolvedName = uiConfig.name ? `${uiConfig.name}${suffix}` : this.name;
|
||||
|
||||
this.config = cfgMgr.buildConfig(this.name, resolvedUiConfig, this.node.id, {
|
||||
this.config = {
|
||||
general: {
|
||||
name: resolvedName,
|
||||
id: this.node.id,
|
||||
unit: uiConfig.unit || 'kg o2/h',
|
||||
logging: {
|
||||
enabled: uiConfig.enableLog,
|
||||
logLevel: uiConfig.logLevel,
|
||||
},
|
||||
},
|
||||
functionality: {
|
||||
positionVsParent: uiConfig.positionVsParent || 'atEquipment',
|
||||
softwareType: this.name,
|
||||
role: 'aeration diffuser',
|
||||
},
|
||||
@@ -38,8 +43,9 @@ class nodeClass {
|
||||
headerPressure: Number(uiConfig.i_pressure) || 0,
|
||||
localAtmPressure: Number(uiConfig.i_local_atm_pressure) || 1013.25,
|
||||
waterDensity: Number(uiConfig.i_water_density) || 997,
|
||||
zoneVolume: Number(uiConfig.i_zone_volume) || 0,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
this._output = new outputUtils();
|
||||
}
|
||||
@@ -52,6 +58,7 @@ class nodeClass {
|
||||
_registerChild() {
|
||||
setTimeout(() => {
|
||||
this.node.send([
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
{
|
||||
@@ -73,8 +80,19 @@ class nodeClass {
|
||||
const raw = this.source.getOutput();
|
||||
const processMsg = this._output.formatMsg(raw, this.config, 'process');
|
||||
const influxMsg = this._output.formatMsg(raw, this.config, 'influxdb');
|
||||
const reactorOtr = this.source.getReactorOtr(this.config.diffuser?.zoneVolume);
|
||||
const controlMsg = {
|
||||
topic: 'OTR',
|
||||
payload: reactorOtr,
|
||||
meta: {
|
||||
source: 'diffuser',
|
||||
diffuser: this.config.general?.name,
|
||||
zoneVolume: this.config.diffuser?.zoneVolume,
|
||||
oKgo2H: raw.oKgo2H,
|
||||
},
|
||||
};
|
||||
this.node.status(this.source.getStatus());
|
||||
this.node.send([processMsg, influxMsg, null]);
|
||||
this.node.send([processMsg, influxMsg, controlMsg, null]);
|
||||
}
|
||||
|
||||
_attachInputHandler() {
|
||||
|
||||
@@ -10,7 +10,6 @@ class Diffuser {
|
||||
);
|
||||
|
||||
this.interpolation = new interpolation({ type: 'linear' });
|
||||
this.fysics = gravity.fysics;
|
||||
this.convert = convert;
|
||||
this.specs = this.loadSpecs();
|
||||
|
||||
@@ -27,12 +26,12 @@ class Diffuser {
|
||||
this.i_m_water = this.normalizeNumber(this.config.diffuser?.waterHeight, 0);
|
||||
this.i_flow = 0;
|
||||
|
||||
this.n_kg = this.fysics.calc_air_dens(1013.25, 0, 20);
|
||||
this.n_kg = this.calcAirDensityMbar(1013.25, 0, 20);
|
||||
|
||||
this.n_flow = 0;
|
||||
this.o_otr = 0;
|
||||
this.o_p_flow = 0;
|
||||
this.o_p_water = this.fysics.heigth_to_pressure(this.i_water_density, this.i_m_water);
|
||||
this.o_p_water = this.heightToPressureMbar(this.i_water_density, this.i_m_water);
|
||||
this.o_p_total = this.o_p_water;
|
||||
this.o_kg = 0;
|
||||
this.o_kg_h = 0;
|
||||
@@ -71,7 +70,7 @@ class Diffuser {
|
||||
|
||||
setWaterHeight(value) {
|
||||
this.i_m_water = Math.max(0, this.normalizeNumber(value, this.i_m_water));
|
||||
this.o_p_water = this.fysics.heigth_to_pressure(this.i_water_density, this.i_m_water);
|
||||
this.o_p_water = this.heightToPressureMbar(this.i_water_density, this.i_m_water);
|
||||
this.recalculate();
|
||||
}
|
||||
|
||||
@@ -190,9 +189,28 @@ class Diffuser {
|
||||
return Math.max(0, eff1 * eff2 * 100);
|
||||
}
|
||||
|
||||
calcAirDensityMbar(pressureMbar, RH, tempC) {
|
||||
const Rd = 287.05;
|
||||
const Rv = 461.495;
|
||||
const T = tempC + 273.15;
|
||||
const A = 8.07131;
|
||||
const B = 1730.63;
|
||||
const C = 233.426;
|
||||
const e_s = Math.pow(10, (A - (B / (C + tempC))));
|
||||
const e = RH * e_s / 100;
|
||||
const pressurePa = this.convert(pressureMbar).from('mbar').to('Pa');
|
||||
const p_d = pressurePa - (e * 100);
|
||||
return (p_d / (Rd * T)) + ((e * 100) / (Rv * T));
|
||||
}
|
||||
|
||||
heightToPressureMbar(density, height) {
|
||||
const pressurePa = gravity.getStandardGravity() * density * height;
|
||||
return this.convert(pressurePa).from('Pa').to('mbar');
|
||||
}
|
||||
|
||||
calcOtrPressure(flow) {
|
||||
const totalInputPressureMbar = this.i_local_atm_pressure + this.i_pressure;
|
||||
this.o_kg = this.fysics.calc_air_dens(totalInputPressureMbar, 0, 20);
|
||||
this.o_kg = this.calcAirDensityMbar(totalInputPressureMbar, 0, 20);
|
||||
this.o_kg_h = this.o_kg * flow;
|
||||
this.n_flow = (this.o_kg / this.n_kg) * flow;
|
||||
this.o_flow_element = Math.round((this.n_flow / this.i_n_elements) * 100) / 100;
|
||||
@@ -290,6 +308,14 @@ class Diffuser {
|
||||
};
|
||||
}
|
||||
|
||||
getReactorOtr(zoneVolumeM3) {
|
||||
const volume = Number(zoneVolumeM3);
|
||||
if (!Number.isFinite(volume) || volume <= 0) {
|
||||
return 0;
|
||||
}
|
||||
return this.o_kgo2_h * 1000 * 24 / volume;
|
||||
}
|
||||
|
||||
loadSpecs() {
|
||||
return {
|
||||
supplier: 'GVA',
|
||||
|
||||
Reference in New Issue
Block a user