writing core class
This commit is contained in:
@@ -19,19 +19,20 @@ class pumpingStation {
|
||||
windowSize: this.config.smoothing.smoothWindow
|
||||
});
|
||||
|
||||
// pumpingStation-specific properties
|
||||
this.flowrate = null; // Function to calculate flow rate based on water level rise or fall
|
||||
this.timeBeforeOverflow = null; // Time before the basin overflows at current inflow rate
|
||||
this.timeBeforeEmpty = null; // Time before the basin empties at current outflow rate
|
||||
this.heightInlet = null; // Height of the inlet pipe from the bottom of the basin
|
||||
this.heightOutlet = null; // Height of the outlet pipe from the bottom of the basin
|
||||
this.heightOverflow = null; // Height of the overflow point from the bottom of the basin
|
||||
this.volume = null; // Total volume of water in the basin, calculated from water level and basin dimensions
|
||||
this.emptyVolume = null; // Volume in the basin when empty (at level of outlet pipe)
|
||||
this.fullVolume = null; // Volume in the basin when at level of overflow point
|
||||
this.crossSectionalArea = null; // Cross-sectional area of the basin, used to calculate volume from water level
|
||||
// init basin object in pumping station
|
||||
this.basin = {
|
||||
volumeWater : null,// Total volume of water in the basin, calculated from water level and basin di
|
||||
emptyVolume : null,// Volume in the basin when empty (at level of outlet pipe)
|
||||
fullVolume : null,// Volume in the basin when at level of overflow point
|
||||
crossSectionalArea: null,// Cross-sectional area of the basin, used to calculate volume from water level
|
||||
};
|
||||
|
||||
// Initialize basin-specific properties from config
|
||||
// pumping station specifics
|
||||
this.calculatedFlowrate = null,// Function to calculate flow rate based on water level rise or fall NO MEASUREMENT this is the predicted value which should match a flowrate if we have it and we have to check mass balance ? Look at the pumps connected to the group controller or directly to this node and check incoming vs outgoing?
|
||||
this.timeBeforeOverflow = null,// Time before the basin overflows at current inflow rate at level of heightOutlet
|
||||
this.timeBeforeEmpty = null,// Time before the basin empties at current outflow rate at level of heightInlet
|
||||
|
||||
// Initialize basin-specific properties and calculate used parameters
|
||||
this.initBasinProperties();
|
||||
|
||||
}
|
||||
@@ -96,6 +97,7 @@ class pumpingStation {
|
||||
// context handler for pressure updates
|
||||
updateMeasuredPressure(value, position, context = {}) {
|
||||
|
||||
// init temp
|
||||
let kelvinTemp = null;
|
||||
|
||||
//pressure updates come from pressure boxes inside the basin they get converted to a level and stored as level measured at position inlet or outlet
|
||||
@@ -117,20 +119,50 @@ class pumpingStation {
|
||||
}
|
||||
this.logger.debug(`Using temperature: ${kelvinTemp} K for calculations`);
|
||||
const density = coolprop.PropsSI('D','T',kelvinTemp,'P',101325,'Water'); //density in kg/m3 at temp and surface pressure
|
||||
const g =
|
||||
const g = 9.80665;
|
||||
|
||||
//calculate how muc flow went in or out based on pressure difference
|
||||
this.logger.debug(`Using pressure: ${pressure} for calculations`);
|
||||
}
|
||||
|
||||
initBasinProperties() {
|
||||
// Initialize basin-specific properties from config
|
||||
this.heightInlet = this.config.basin.heightInlet || 0; // Default to 0 if not specified
|
||||
this.heightOutlet = this.config.basin.heightOutlet || 0; // Default to 0 if not specified
|
||||
this.heightOverflow = this.config.basin.heightOverflow || 0; // Default to 0 if not specified
|
||||
this.crossSectionalArea = this.config.basin.crossSectionalArea || 1; // Default to 1 m² if not specified
|
||||
|
||||
// Load and calc basic params
|
||||
const volEmptyBasin = this.config.basin.volume;
|
||||
const heightBasin = this.config.basin.height;
|
||||
const heightInlet = this.config.basin.heightInlet;
|
||||
const heightOutlet = this.config.basin.heightOutlet;
|
||||
const heightOverflow = this.config.basin.heightOverflow;
|
||||
//calculated params
|
||||
const surfaceArea = volEmptyBasin / heightBasin;
|
||||
const maxVol = heightBasin * surfaceArea; // if Basin where to ever fill up completely this is the water volume
|
||||
const maxVolOverflow = heightOverflow * surfaceArea ; // Max water volume before you start loosing water to overflow
|
||||
const minVol = heightInlet * surfaceArea;
|
||||
const minVolOut = heightOutlet * surfaceArea ; // this will indicate if its an open end or a closed end.
|
||||
|
||||
this.basin.volEmptyBasin = volEmptyBasin ;
|
||||
this.basin.heightBasin = heightBasin ;
|
||||
this.basin.heightInlet = heightInlet ;
|
||||
this.basin.heightOutlet = heightOutlet ;
|
||||
this.basin.heightOverflow = heightOverflow ;
|
||||
this.basin.surfaceArea = surfaceArea ;
|
||||
this.basin.maxVol = maxVol ;
|
||||
this.basin.maxVolOverflow = maxVolOverflow;
|
||||
this.basin.minVol = minVol ;
|
||||
this.basin.minVolOut = minVolOut ;
|
||||
|
||||
this.logger.debug(
|
||||
`Basin initialized | area=${surfaceArea.toFixed(2)} m², max=${maxVol.toFixed(2)} m³, overflow=${maxVolOverflow.toFixed(2)} m³`
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
_calcVolumeFromLevel(level) {
|
||||
const surfaceArea = this.basin.surfaceArea;
|
||||
return Math.max(level, 0) * surfaceArea;
|
||||
}
|
||||
|
||||
|
||||
getOutput() {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user