Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Zero_engine.alpx
Original file line number Diff line number Diff line change
Expand Up @@ -1876,11 +1876,6 @@ EXCLUDE_PV => Use PV profile to preprocess gridnode profile to create a more acc
<Name><![CDATA[J_HeatingFunctionLibrary]]></Name>
<Folder>1762850578079</Folder>
</JavaClass>
<JavaClass>
<Id>1763570262548</Id>
<Name><![CDATA[J_GlobalParameters]]></Name>
<Folder>1764938574089</Folder>
</JavaClass>
<JavaClass>
<Id>1764337491572</Id>
<Name><![CDATA[I_ChargingRequest]]></Name>
Expand Down Expand Up @@ -1956,6 +1951,11 @@ EXCLUDE_PV => Use PV profile to preprocess gridnode profile to create a more acc
<Name><![CDATA[J_EAChargingSession]]></Name>
<Folder>1752677832758</Folder>
</JavaClass>
<JavaClass>
<Id>1770210283060</Id>
<Name><![CDATA[DoubleCompare]]></Name>
<Folder>1764938574089</Folder>
</JavaClass>
</JavaClasses>
<RequiredLibraryReference>
<LibraryName>com.anylogic.libraries.modules.markup_descriptors</LibraryName>
Expand Down
2 changes: 1 addition & 1 deletion _alp/Agents/GridConnection/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
41 changes: 41 additions & 0 deletions _alp/Classes/Class.DoubleCompare.java
Original file line number Diff line number Diff line change
@@ -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);
//}

}
4 changes: 2 additions & 2 deletions _alp/Classes/Class.J_EABuilding.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions _alp/Classes/Class.J_EAConversion.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 0 additions & 7 deletions _alp/Classes/Class.J_GlobalParameters.java

This file was deleted.