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
25 changes: 10 additions & 15 deletions Zero_engine.alpx
Original file line number Diff line number Diff line change
Expand Up @@ -779,35 +779,30 @@
</OptionList>
<OptionList>
<Id>1718560423698</Id>
<Name><![CDATA[OL_ProfileAssetType]]></Name>
<ExcludeFromBuild>true</ExcludeFromBuild>
<Name><![CDATA[OL_ProfileUnits]]></Name>
<Option>
<Id>1718560423699</Id>
<Name><![CDATA[ELECTRICITYBASELOAD]]></Name>
<Name><![CDATA[KWHPQUARTERHOUR]]></Name>
</Option>
<Option>
<Id>1718560423700</Id>
<Name><![CDATA[CHARGING]]></Name>
<Name><![CDATA[YEARLYTOTALFRACTION]]></Name>
</Option>
<Option>
<Id>1718713672051</Id>
<Name><![CDATA[WINDTURBINE]]></Name>
</Option>
<Option>
<Id>1718713684483</Id>
<Name><![CDATA[SOLARPANELS]]></Name>
<Name><![CDATA[NORMALIZEDPOWER]]></Name>
</Option>
<Option>
<Id>1727254638101</Id>
<Name><![CDATA[HEATDEMAND]]></Name>
<Id>1769528317155</Id>
<Name><![CDATA[PRICE_EURPMWH]]></Name>
</Option>
<Option>
<Id>1734018498969</Id>
<Name><![CDATA[METHANEDEMAND]]></Name>
<Id>1769528326971</Id>
<Name><![CDATA[TEMPERATURE_DEGC]]></Name>
</Option>
<Option>
<Id>1753774385666</Id>
<Name><![CDATA[HEATPUMP_ELECTRICITY_CONSUMPTION]]></Name>
<Id>1769674053743</Id>
<Name><![CDATA[KW]]></Name>
</Option>
</OptionList>
<OptionList>
Expand Down
46 changes: 26 additions & 20 deletions _alp/Agents/GridConnection/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
}



/*ALCODEEND*/}

double f_resetStates()
Expand Down Expand Up @@ -309,10 +310,10 @@ else if (productionAsset.energyAssetType == OL_EnergyAssetType.PHOTOTHERMAL){
energyModel.v_liveAssetsMetaData.totalInstalledBatteryStorageCapacity_MWh += capacity_MWh;

}
} else if (j_ea instanceof J_EAProfile profileAsset) {
c_profileAssets.add(profileAsset);
} else if (j_ea instanceof J_EAPetroleumFuelTractor tractor) {
c_profileAssets.add(tractor);
} else if (j_ea instanceof J_EAProfile profileAsset) {
c_profileAssets.add(profileAsset);
} else if (j_ea instanceof J_EAChargingSession chargingSession) {
if(p_chargingManagement == null){
f_addChargingManagement(OL_ChargingAttitude.SIMPLE);
Expand Down Expand Up @@ -606,7 +607,8 @@ else if (j_ea.energyAssetType == OL_EnergyAssetType.PHOTOTHERMAL){
// Keep feedin power within connection capacity
if (fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY) < - v_liveConnectionMetaData.contractedFeedinCapacity_kW) { // overproduction!
for (J_EAProduction j_ea : c_productionAssets) {
j_ea.curtailEnergyCarrierProduction(OL_EnergyCarriers.ELECTRICITY, - fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY) - v_liveConnectionMetaData.contractedFeedinCapacity_kW, this);
J_FlowPacket flowPacket = j_ea.curtailEnergyCarrierProduction(OL_EnergyCarriers.ELECTRICITY, - fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY) - v_liveConnectionMetaData.contractedFeedinCapacity_kW);
f_removeFlows(flowPacket, j_ea);
if (!(fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY) < - v_liveConnectionMetaData.contractedFeedinCapacity_kW)) {
break;
}
Expand All @@ -617,7 +619,8 @@ else if (j_ea.energyAssetType == OL_EnergyAssetType.PHOTOTHERMAL){
if(energyModel.pp_dayAheadElectricityPricing_eurpMWh.getCurrentValue() < 0.0) {
if (fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY) < 0.0) { // Feedin, bring to zero!
for (J_EAProduction j_ea : c_productionAssets) {
j_ea.curtailEnergyCarrierProduction(OL_EnergyCarriers.ELECTRICITY, - fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY), this);
J_FlowPacket flowPacket = j_ea.curtailEnergyCarrierProduction(OL_EnergyCarriers.ELECTRICITY, - fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY));
f_removeFlows(flowPacket, j_ea);
if (!(fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY) < 0.0)) {
break;
}
Expand All @@ -632,7 +635,8 @@ else if (j_ea.energyAssetType == OL_EnergyAssetType.PHOTOTHERMAL){

double v_currentPowerElectricitySetpoint_kW = fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY) * max(0,1+(p_parentNodeElectric.v_currentTotalNodalPrice_eurpkWh-priceTreshold_eur)*5);
for (J_EAProduction j_ea : c_productionAssets) {
j_ea.curtailEnergyCarrierProduction(OL_EnergyCarriers.ELECTRICITY, v_currentPowerElectricitySetpoint_kW - fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY), this);
J_FlowPacket flowPacket = j_ea.curtailEnergyCarrierProduction(OL_EnergyCarriers.ELECTRICITY, v_currentPowerElectricitySetpoint_kW - fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY));
f_removeFlows(flowPacket, j_ea);
if (!(fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY) < v_currentPowerElectricitySetpoint_kW)) {
break;
}
Expand Down Expand Up @@ -703,37 +707,39 @@ else if (j_ea.energyAssetType == OL_EnergyAssetType.PHOTOTHERMAL){
}
/*ALCODEEND*/}

double f_removeFlows(J_FlowsMap flowsMap,double energyUse_kW,J_ValueMap<OL_AssetFlowCategories> assetFlowsMap_kW,J_EA caller)
double f_removeFlows(J_FlowPacket flowPacket,J_EA caller)
{/*ALCODESTART::1722512642645*/
for (OL_EnergyCarriers EC : flowsMap.keySet()) {
fm_currentBalanceFlows_kW.addFlow(EC, -flowsMap.get(EC));
for (OL_EnergyCarriers EC : flowPacket.flowsMap.keySet()) {
fm_currentBalanceFlows_kW.addFlow(EC, -flowPacket.flowsMap.get(EC));

if (flowsMap.get(EC) < 0) {
fm_currentProductionFlows_kW.addFlow(EC, flowsMap.get(EC));
if (flowPacket.flowsMap.get(EC) < 0) {
fm_currentProductionFlows_kW.addFlow(EC, flowPacket.flowsMap.get(EC));
}
else if (flowsMap.get(EC) > 0){
fm_currentConsumptionFlows_kW.addFlow(EC, -flowsMap.get(EC));
else if (flowPacket.flowsMap.get(EC) > 0){
fm_currentConsumptionFlows_kW.addFlow(EC, -flowPacket.flowsMap.get(EC));
}
}

if (caller instanceof J_EAStorageElectric) {
// Only allocate battery losses as consumption. Charging/discharging is neither production nor consumption. Do we need an element in flowsmap indicating power into storage??
fm_currentConsumptionFlows_kW.addFlow(OL_EnergyCarriers.ELECTRICITY, max(0, energyUse_kW));
v_currentFinalEnergyConsumption_kW += max(0, energyUse_kW);
fm_currentConsumptionFlows_kW.addFlow(OL_EnergyCarriers.ELECTRICITY, max(0, flowPacket.energyUse_kW));
v_currentFinalEnergyConsumption_kW += max(0, flowPacket.energyUse_kW);
} else {
double curtailment_kW = max(0, -energyUse_kW);
double lostLoad_kW = max(0, energyUse_kW);
double curtailment_kW = max(0, -flowPacket.energyUse_kW);
double lostLoad_kW = max(0, flowPacket.energyUse_kW);
v_currentEnergyCurtailed_kW += curtailment_kW;
v_currentPrimaryEnergyProduction_kW -= curtailment_kW;
v_currentFinalEnergyConsumption_kW -= lostLoad_kW;
}

if ( caller instanceof J_EAConversionHeatPump ) {
v_currentPrimaryEnergyProductionHeatpumps_kW += energyUse_kW;
}
for(var AC : assetFlowsMap_kW.keySet()) {
fm_currentAssetFlows_kW.addFlow(AC, -assetFlowsMap_kW.get(AC));
v_currentPrimaryEnergyProductionHeatpumps_kW += flowPacket.energyUse_kW;
}
fm_currentAssetFlows_kW.removeFlows(flowPacket.assetFlowsMap);
/*for(var AC : flowPacket.assetFlowsMap.keySet()) {
fm_currentAssetFlows_kW.addFlow(AC, -flowPacket.assetFlowsMap.get(AC));
}*/

/*ALCODEEND*/}

double f_fillLiveDataSets(J_TimeVariables timeVariables)
Expand Down
12 changes: 2 additions & 10 deletions _alp/Agents/GridConnection/Code/Functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -412,16 +412,8 @@
<PresentationFlag>true</PresentationFlag>
<ShowLabel>true</ShowLabel>
<Parameter>
<Name><![CDATA[flowsMap]]></Name>
<Type><![CDATA[J_FlowsMap]]></Type>
</Parameter>
<Parameter>
<Name><![CDATA[energyUse_kW]]></Name>
<Type><![CDATA[double]]></Type>
</Parameter>
<Parameter>
<Name><![CDATA[assetFlowsMap_kW]]></Name>
<Type><![CDATA[J_ValueMap<OL_AssetFlowCategories>]]></Type>
<Name><![CDATA[flowPacket]]></Name>
<Type><![CDATA[J_FlowPacket]]></Type>
</Parameter>
<Parameter>
<Name><![CDATA[caller]]></Name>
Expand Down
15 changes: 9 additions & 6 deletions _alp/Classes/Class.J_BatteryManagementPeakShavingForecast.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,31 +90,34 @@ private double[] getNettoBalanceForecast_kW(J_TimeVariables timeVariables) {

for(J_EAProfile elecConsumptionProfile : elecConsumptionProfiles) {
if(elecConsumptionProfile != null){
double[] tempNettoBalance_kW = ZeroMath.arrayMultiply(Arrays.copyOfRange(elecConsumptionProfile.a_energyProfile_kWh, startTimeDayIndex, endTimeDayIndex), elecConsumptionProfile.getProfileScaling_fr()/timeParameters.getTimeStep_h());
//double[] tempNettoBalance_kW = ZeroMath.arrayMultiply(Arrays.copyOfRange(elecConsumptionProfile.a_energyProfile_kWh, startTimeDayIndex, endTimeDayIndex), elecConsumptionProfile.getProfileScaling_fr()/p_timestep_h);
double[] tempNettoBalance_kW = ZeroMath.arrayMultiply(Arrays.copyOfRange(elecConsumptionProfile.profilePointer.getAllValues(), startTimeDayIndex, endTimeDayIndex), elecConsumptionProfile.getProfileScaling_fr()*elecConsumptionProfile.getProfileUnitScaler_fr());
for (int i = 0; i < tempNettoBalance_kW.length; i++) {
nettoBalanceTotal_kW[i] += tempNettoBalance_kW[i];
}
}
}
for(J_EAProfile elecHeatPumpProfile : elecHeatPumpProfiles) {
if(elecHeatPumpProfile != null){
double[] tempNettoBalance_kW = ZeroMath.arrayMultiply(Arrays.copyOfRange(elecHeatPumpProfile.a_energyProfile_kWh, startTimeDayIndex, endTimeDayIndex), elecHeatPumpProfile.getProfileScaling_fr()/timeParameters.getTimeStep_h());
//double[] tempNettoBalance_kW = ZeroMath.arrayMultiply(Arrays.copyOfRange(elecHeatPumpProfile.a_energyProfile_kWh, startTimeDayIndex, endTimeDayIndex), elecHeatPumpProfile.getProfileScaling_fr()/p_timestep_h);
double[] tempNettoBalance_kW = ZeroMath.arrayMultiply(Arrays.copyOfRange(elecHeatPumpProfile.profilePointer.getAllValues(), startTimeDayIndex, endTimeDayIndex), elecHeatPumpProfile.getProfileScaling_fr()*elecHeatPumpProfile.getProfileUnitScaler_fr());
for (int i = 0; i < tempNettoBalance_kW.length; i++) {
nettoBalanceTotal_kW[i] += tempNettoBalance_kW[i];
}
}
}
for(J_EAProfile elecEVProfile : elecEVProfiles) {
if(elecEVProfile != null){
double[] tempNettoBalance_kW = ZeroMath.arrayMultiply(Arrays.copyOfRange(elecEVProfile.a_energyProfile_kWh, startTimeDayIndex, endTimeDayIndex), elecEVProfile.getProfileScaling_fr()/timeParameters.getTimeStep_h());
double[] tempNettoBalance_kW = ZeroMath.arrayMultiply(Arrays.copyOfRange(elecEVProfile.profilePointer.getAllValues(), startTimeDayIndex, endTimeDayIndex), elecEVProfile.getProfileScaling_fr()*elecEVProfile.getProfileUnitScaler_fr());
for (int i = 0; i < tempNettoBalance_kW.length; i++) {
nettoBalanceTotal_kW[i] += tempNettoBalance_kW[i];
}
}
}
for(J_EAProfile surveyHeatDemandProfile : surveyHeatDemandProfiles) {
if(surveyHeatDemandProfile != null){
double[] heatPower_kW = ZeroMath.arrayMultiply(Arrays.copyOfRange(surveyHeatDemandProfile.a_energyProfile_kWh, startTimeDayIndex, endTimeDayIndex), surveyHeatDemandProfile.getProfileScaling_fr()/timeParameters.getTimeStep_h());
//double[] heatPower_kW = ZeroMath.arrayMultiply(Arrays.copyOfRange(surveyHeatDemandProfile.a_energyProfile_kWh, startTimeDayIndex, endTimeDayIndex), surveyHeatDemandProfile.getProfileScaling_fr()/p_timestep_h);
double[] heatPower_kW = ZeroMath.arrayMultiply(Arrays.copyOfRange(surveyHeatDemandProfile.profilePointer.getAllValues(), startTimeDayIndex, endTimeDayIndex), surveyHeatDemandProfile.getProfileScaling_fr()*surveyHeatDemandProfile.getProfileUnitScaler_fr());
//traceln(heatPower_kW);
double eta_r = parentGC.energyModel.avgc_data.p_avgEfficiencyHeatpump_fr;
double outputTemperature_degC = parentGC.energyModel.avgc_data.p_avgOutputTemperatureElectricHeatpump_degC;
Expand All @@ -136,14 +139,14 @@ private double[] getNettoBalanceForecast_kW(J_TimeVariables timeVariables) {
double COP_r = eta_r * ( 273.15 + outputTemperature_degC ) / ( outputTemperature_degC - baseTemperature_degC );

//traceln(genericHeatDemandProfile.getProfilePointer().getValue(time)*genericHeatDemandProfile.yearlyDemand_kWh);
nettoBalanceTotal_kW[roundToInt((time-energyModel_time_h)/timeParameters.getTimeStep_h())] += genericHeatDemandProfile.getProfilePointer().getValue(time)*genericHeatDemandProfile.yearlyDemand_kWh*genericHeatDemandProfile.getConsumptionScaling_fr() / COP_r;
nettoBalanceTotal_kW[roundToInt((time-energyModel_time_h)/timeParameters.getTimeStep_h())] += genericHeatDemandProfile.getProfilePointer().getValue(time)*genericHeatDemandProfile.getBaseConsumption_kWh()*genericHeatDemandProfile.getConsumptionScaling_fr() / COP_r;
}
}
}
for(J_EAConsumption genericBuildingProfile : genericBuildingProfiles) {
if(genericBuildingProfile != null){ //table function
for(double time = energyModel_time_h; time < energyModel_time_h + 24; time += timeParameters.getTimeStep_h()){
nettoBalanceTotal_kW[roundToInt((time-energyModel_time_h)/timeParameters.getTimeStep_h())] += genericBuildingProfile.getProfilePointer().getValue(time)*genericBuildingProfile.yearlyDemand_kWh*genericBuildingProfile.getConsumptionScaling_fr();
nettoBalanceTotal_kW[roundToInt((time-energyModel_time_h)/timeParameters.getTimeStep_h())] += genericBuildingProfile.getProfilePointer().getValue(time)*genericBuildingProfile.getBaseConsumption_kWh()*genericBuildingProfile.getConsumptionScaling_fr();
}
}
}
Expand Down
74 changes: 54 additions & 20 deletions _alp/Classes/Class.J_EAConsumption.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
/**
* J_EAConsumption
*/
public class J_EAConsumption extends zero_engine.J_EAFixed implements Serializable {
protected J_ProfilePointer profilePointer;
public double yearlyDemand_kWh;
protected OL_EnergyCarriers energyCarrier;
private double consumptionScaling_fr = 1;
public double loadLoad_kWh = 0;
//private J_profilePointer profilePointer;
public class J_EAConsumption extends zero_engine.J_EAProfile implements Serializable {

private double yearlyDemand_kWh;
//public double loadLoad_kWh = 0;
/**
* Default constructor
*/
Expand All @@ -18,18 +15,25 @@ public J_EAConsumption() {
* Constructor initializing the fields
*/
public J_EAConsumption(I_AssetOwner owner, OL_EnergyAssetType type, String name, double yearlyDemand_kWh, OL_EnergyCarriers energyCarrier, J_TimeParameters timeParameters, J_ProfilePointer profile) {
if (profile == null) {
throw new RuntimeException("profile pointer for J_EAConsumption " + name + " is is null");
}
/*if (yearlyDemand_kWh == 0.0) {
throw new RuntimeException("Unable to construct J_EAConsumption: " + name + " because consumption is zero." );
}*/
this.setOwner(owner);
this.timeParameters = timeParameters;
this.timeParameters = timeParameters;
this.energyAssetName = name;
this.energyAssetType = type;

this.yearlyDemand_kWh = yearlyDemand_kWh;
if (profile.getProfileUnits() == OL_ProfileUnits.YEARLYTOTALFRACTION) {
this.profileUnitScaler_r = yearlyDemand_kWh;
this.profilePointer = profile;
} else {
throw new RuntimeException("Invalid OL_ProfileUnits type for J_EAConsumption!");
}
this.energyCarrier = energyCarrier;

profilePointer = profile;

this.activeConsumptionEnergyCarriers.add(this.energyCarrier);

if (this.energyCarrier == OL_EnergyCarriers.ELECTRICITY) {
Expand All @@ -51,38 +55,68 @@ else if (this.energyCarrier == OL_EnergyCarriers.HEAT) {

registerEnergyAsset(timeParameters);
}

public String getAssetName() {
return this.energyAssetName;
}

public void setConsumptionScaling_fr(double consumptionScaling_fr) {
this.consumptionScaling_fr = consumptionScaling_fr;
this.profileScaling_fr = consumptionScaling_fr;
}

public double getConsumptionScaling_fr() {
return this.consumptionScaling_fr;
return this.profileScaling_fr;
}

@Override
public void operate(J_TimeVariables timeVariables) {


/*@Override
public void f_updateAllFlows(double v_powerFraction_fr) {
throw new RuntimeException("J_EAConsumption.f_updateAllFlows() should be called without arguments!");
}

public void f_updateAllFlows() {
double ratioOfCapacity = profilePointer.getCurrentValue();
this.operate(ratioOfCapacity);
if (ratioOfCapacity>0.0) { // Skip when there is no consumption -> saves time?
if (parentAgent instanceof GridConnection) {
//((GridConnection)parentAgent).f_addFlows(arr, this);
((GridConnection)parentAgent).f_addFlows(flowsMap, this.energyUse_kW, assetFlowsMap, this);
}

}
this.lastFlowsMap.cloneMap(this.flowsMap);
this.lastEnergyUse_kW = this.energyUse_kW;
this.clear();
}

@Override
public void operate(double ratioOfCapacity) {

double consumption_kW = ratioOfCapacity * this.yearlyDemand_kWh * this.consumptionScaling_fr;

this.energyUse_kW = consumption_kW;
this.energyUsed_kWh += this.energyUse_kW * this.timeParameters.getTimeStep_h();
this.energyUsed_kWh += this.energyUse_kW * this.timestep_h;

flowsMap.put(this.energyCarrier, consumption_kW);
if (this.assetFlowCategory != null) {
assetFlowsMap.put(this.assetFlowCategory, consumption_kW);
}
}
}*/

public J_ProfilePointer getProfilePointer() {
return this.profilePointer;
}

@Override
public double getBaseConsumption_kWh() {
return yearlyDemand_kWh;
}

@Override
public String toString() {
return
"type = " + this.getClass().toString() + " " +
"owner = " + this.getOwner() +" " +
"energyCarrier = " + this.energyCarrier + " " +
"yearlyDemand_kWh = " + this.yearlyDemand_kWh;
}
Expand Down
15 changes: 15 additions & 0 deletions _alp/Classes/Class.J_EAPetroleumFuelTractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ public J_EAPetroleumFuelTractor(I_AssetOwner owner, double yearlyPetroleumFuelCo
registerEnergyAsset(timeParameters);
}

@Override
public J_FlowPacket f_updateAllFlows(J_TimeVariables timeVariables) {
this.operate(timeVariables);
if (this.assetFlowCategory != null) {
assetFlowsMap.put(this.assetFlowCategory, Math.abs(energyUse_kW));
}
J_FlowsMap flowsMapCopy = new J_FlowsMap();
J_ValueMap assetFlowsMapCopy = new J_ValueMap(OL_AssetFlowCategories.class);
J_FlowPacket flowPacket = new J_FlowPacket(flowsMapCopy.cloneMap(this.flowsMap), this.energyUse_kW, assetFlowsMapCopy.cloneMap(this.assetFlowsMap));
this.lastFlowsMap.cloneMap(this.flowsMap);
this.lastEnergyUse_kW = this.energyUse_kW;
this.clear();
return flowPacket;
}

@Override
public void operate(J_TimeVariables timeVariables) {
if (!shouldWork(timeVariables)) {
Expand Down
Loading