diff --git a/Zero_engine.alpx b/Zero_engine.alpx
index 42027ee..1cf78ba 100644
--- a/Zero_engine.alpx
+++ b/Zero_engine.alpx
@@ -1876,11 +1876,6 @@ EXCLUDE_PV => Use PV profile to preprocess gridnode profile to create a more acc
1762850578079
-
- 1763570262548
-
- 1764938574089
-
1764337491572
@@ -1956,6 +1951,11 @@ EXCLUDE_PV => Use PV profile to preprocess gridnode profile to create a more acc
1752677832758
+
+ 1770210283060
+
+ 1764938574089
+
com.anylogic.libraries.modules.markup_descriptors
diff --git a/_alp/Agents/GridConnection/Code/Functions.java b/_alp/Agents/GridConnection/Code/Functions.java
index ce0840e..1972565 100644
--- a/_alp/Agents/GridConnection/Code/Functions.java
+++ b/_alp/Agents/GridConnection/Code/Functions.java
@@ -35,7 +35,7 @@
double f_connectionMetering(J_TimeVariables timeVariables,boolean isRapidRun)
{/*ALCODESTART::1660212665961*/
-if ( abs(fm_currentConsumptionFlows_kW.get(OL_EnergyCarriers.HEAT) - fm_currentProductionFlows_kW.get(OL_EnergyCarriers.HEAT)) > 0.1 && p_parentNodeHeat == null ) {
+if ( DoubleCompare.greaterThanZero(abs(fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.HEAT))) && p_parentNodeHeat == null ) {
//if (p_BuildingThermalAsset == null || !p_BuildingThermalAsset.hasHeatBuffer()) {
traceln("heat consumption: %s kW", fm_currentConsumptionFlows_kW.get(OL_EnergyCarriers.HEAT));
traceln("heat production: %s kW", fm_currentProductionFlows_kW.get(OL_EnergyCarriers.HEAT));
diff --git a/_alp/Classes/Class.DoubleCompare.java b/_alp/Classes/Class.DoubleCompare.java
new file mode 100644
index 0000000..5bd74f7
--- /dev/null
+++ b/_alp/Classes/Class.DoubleCompare.java
@@ -0,0 +1,41 @@
+import java.lang.Math;
+/**
+ * DoubleCompare
+ */
+public class DoubleCompare {
+ private final static int FLOATINGPOINTPRECISION = 10;
+ private final static double EPSILON = 1e-10;
+
+ public static boolean equalsZero(double d) {
+ //d = round(d);
+ //return d == 0.0;
+
+ return Math.abs(d) < EPSILON;
+ }
+
+ public static boolean lessThanZero(double d) {
+ //d = round(d);
+ //return d < 0.0;
+ return d < -EPSILON;
+ }
+
+ public static boolean greaterThanZero(double d) {
+ //d = round(d);
+ //return d > 0.0;
+ return d > EPSILON;
+ }
+
+ public static boolean equals(double a, double b) {
+
+ //a = round(a);
+ //b = round(b);
+ //return a == b;
+ return Math.abs(a - b) < EPSILON;
+
+ }
+
+ //private static double round(double d) {
+ //return Math.floor(d * Math.pow(10, FLOATINGPOINTPRECISION) + 0.5) / Math.pow(10, FLOATINGPOINTPRECISION);
+ //}
+
+}
\ No newline at end of file
diff --git a/_alp/Classes/Class.J_EABuilding.java b/_alp/Classes/Class.J_EABuilding.java
index 61b7fdc..61a3df5 100644
--- a/_alp/Classes/Class.J_EABuilding.java
+++ b/_alp/Classes/Class.J_EABuilding.java
@@ -73,10 +73,10 @@ public J_FlowPacket f_updateAllFlows(double powerFraction_fr, J_TimeVariables ti
@Override
public void operate(double powerFraction_fr, J_TimeVariables timeVariables) {
- if (powerFraction_fr < 0) {
+
+ if (DoubleCompare.lessThanZero(powerFraction_fr)) {
throw new RuntimeException("Cooling of the J_EABuilding is not yet supported.");
}
-
double lossPower_kW = calculateLoss(); // Heat exchange with environment through convection
double solarHeating_kW = solarHeating(); // Heat influx from sunlight
this.energyUse_kW = lossPower_kW - solarHeating_kW;
diff --git a/_alp/Classes/Class.J_EAConversion.java b/_alp/Classes/Class.J_EAConversion.java
index ce4c630..018b15c 100644
--- a/_alp/Classes/Class.J_EAConversion.java
+++ b/_alp/Classes/Class.J_EAConversion.java
@@ -43,11 +43,10 @@ private void construct(I_AssetOwner owner, OL_EnergyAssetType energyAssetType, d
@Override
public J_FlowPacket f_updateAllFlows(double powerFraction_fr, J_TimeVariables timeVariables) {
- powerFraction_fr = roundToDecimal(powerFraction_fr, J_GlobalParameters.floatingPointPrecision);
- if(powerFraction_fr < 0) {
+ if(DoubleCompare.lessThanZero(powerFraction_fr)) {
throw new RuntimeException("Impossible to operate conversion asset with negative powerfraction.");
}
- else if ( powerFraction_fr == 0 ) {
+ else if ( DoubleCompare.equalsZero(powerFraction_fr) ) {
this.lastFlowsMap.clear();
this.lastEnergyUse_kW = 0;
J_FlowsMap flowsMapCopy = new J_FlowsMap();
diff --git a/_alp/Classes/Class.J_GlobalParameters.java b/_alp/Classes/Class.J_GlobalParameters.java
deleted file mode 100644
index b81fb54..0000000
--- a/_alp/Classes/Class.J_GlobalParameters.java
+++ /dev/null
@@ -1,7 +0,0 @@
-/**
- * J_GlobalParameters
- */
-public abstract class J_GlobalParameters {
- //public final static double floatingPointErrorMargin = 1e-15;
- public final static int floatingPointPrecision = 10;
-}
\ No newline at end of file