diff --git a/_alp/Agents/GCHouse/Code/Functions.java b/_alp/Agents/GCHouse/Code/Functions.java
index f09ca3d6..91a4bcdd 100644
--- a/_alp/Agents/GCHouse/Code/Functions.java
+++ b/_alp/Agents/GCHouse/Code/Functions.java
@@ -1,60 +1,3 @@
-double f_manageHeatingAssets_overwrite()
-{/*ALCODESTART::1664441996771*/
-v_hotwaterDemand_kW = p_DHWAsset != null ? p_DHWAsset.getLastFlows().get(OL_EnergyCarriers.HEAT) : 0;
-
-//Check if there is hot water being produced by the pt
-double ptProduction_kW = 0; //NEEDS TO BE A LOCAL
-/*for (J_EA j_ea : c_ptAssets) {
- ptProduction_kW -= j_ea.getLastFlows().get(OL_EnergyCarriers.HEAT);
-}*/
-v_hotwaterDemand_kW = max(0, v_hotwaterDemand_kW - ptProduction_kW); // Need to do this, because pt has already compensated the hot water demand in the gc flows, so just need to update this value
-
-if(p_heatBuffer != null){
- double chargeSetpoint_kW = -fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.HEAT);
- p_heatBuffer.v_powerFraction_fr = chargeSetpoint_kW / p_heatBuffer.getCapacityHeat_kW();
- p_heatBuffer.f_updateAllFlows(p_heatBuffer.v_powerFraction_fr);
-
- if(v_hotwaterDemand_kW > 0){//Only if the current pt production, wasnt enough, adjust the hotwater demand with the buffer, cause then the buffer will have discharged
- double heatBufferDischarge_kW = -p_heatBuffer.getLastFlows().get(OL_EnergyCarriers.HEAT);
- v_hotwaterDemand_kW = max(0, v_hotwaterDemand_kW - heatBufferDischarge_kW);
- }
-}
-
-setHeatingTargetTemp();
-
-switch (p_heatingType) {
- case GASBURNER:
- f_heatWithGasburner( );
- break;
- case HEATPUMP_AIR:
- f_heatWithHeatpump( );
- break;
- case HEATPUMP_GASPEAK:
- f_heatWithHybridHeatpump();
- break;
- case HEATPUMP_BOILERPEAK:
- traceln("House " + p_gridConnectionID + " has an unsupported heating asset!");
- break;
- case DISTRICTHEAT:
- f_heatWithDistrictHeat();
- break;
- case LT_DISTRICTHEAT:
- f_heatWithLTDistrictHeat();
- break;
- default:
- traceln("Unsupported heatingtype in household");
- break;
-}
-
-f_manageCookingTracker();
-f_manageAirco();
-
-if (p_BuildingThermalAsset != null && p_primaryHeatingAsset != null) {
- p_primaryHeatingAsset.f_updateAllFlows(p_primaryHeatingAsset.v_powerFraction_fr);
- p_BuildingThermalAsset.f_updateAllFlows(p_BuildingThermalAsset.v_powerFraction_fr);
-}
-/*ALCODEEND*/}
-
double f_operateFlexAssets_overwrite()
{/*ALCODESTART::1664963959146*/
double availablePowerAtPrice_kW = v_liveConnectionMetaData.contractedDeliveryCapacity_kW;
@@ -97,165 +40,6 @@
f_manageBattery();
/*ALCODEEND*/}
-double f_connectToChild_overwrite(Agent ConnectingParentNode)
-{/*ALCODESTART::1665498948452*/
-//assetLinks.connectTo(ConnectingParentNode);
-EnergyAsset EA = (EnergyAsset) ConnectingParentNode;
-J_EA j_instance = EA.j_ea;
-
-//dont add asset to list if it is not a tangible asset (i.e. a heating model for buildings) [GH] How is this not a tangible asset??
-//if(! (j_instance instanceof J_EAStorageHeat && ((J_EAStorageHeat)j_instance).heatStorageType == OL_EAStorageTypes.HEATMODEL_BUILDING)) {
- c_energyAssets.add(EA);
-//}
-
-if (j_instance instanceof J_EAConsumption) {
- //c_consumptionAssets.add(EA);
- if( EA.p_energyAssetType == OL_EnergyAssetType.HOT_WATER_CONSUMPTION ){
- //p_DHWAsset = EA;
- }
- else if (EA.j_ea instanceof J_EADieselVehicle) {
- //c_vehicleAssets.add( EA );
- //c_dieselVehicles.add( EA );
- //c_vehicleAssets.get( v_vehicleIndex ).v_powerFraction_fr = 1; // what's this??
- /*if (c_mobilityTrackers.size() == 0) {
- MobilityTracker m = main.add_mobilityTrackers();
- c_mobilityTrackers.add( m );
- m.p_gridConnection = this;
- m.p_mobilityPatternType = OL_MobilityPatternType.PRIVATE_VEHICLE;
- m.p_vehicleIndex = v_vehicleIndex;
- m.p_energyAsset = c_vehicleAssets.get( v_vehicleIndex );
- m.p_vehicleInstance = (J_EADieselVehicle)EA.j_ea;
- //m.p_vehicleInstance = (J_EADieselVehicle)m.p_vehicleInstance;
-
- m.f_getData();
- } else {
- c_mobilityTrackers.get(v_vehicleIndex).p_vehicleIndex = v_vehicleIndex;
- c_mobilityTrackers.get(v_vehicleIndex).p_energyAsset = c_vehicleAssets.get( v_vehicleIndex );
- c_mobilityTrackers.get(v_vehicleIndex).p_vehicleInstance = (J_EADieselVehicle)EA.j_ea;
- }
- ((J_EADieselVehicle)EA.j_ea).setMobilityTracker( c_mobilityTrackers.get(v_vehicleIndex) );
- */
-
- //v_vehicleIndex ++;
- }
- }
-else if (j_instance instanceof J_EAProduction ) {
- //c_productionAssets.add(EA);
- if (EA.p_energyAssetType == OL_EnergyAssetType.PHOTOVOLTAIC) {
- v_hasPV = true;
- traceln("PV system connected to House!");
- }
-}
-else if (j_instance instanceof J_EAStorage ) {
- //traceln("storage asset type connecting to House: " + j_instance);
- if (j_instance instanceof J_EABuilding) {
-
- //p_BuildingThermalAsset = EA;
-
- if ( p_isolationLabel != null & p_gridConnectionType != null){ // Get building thermals from lookup table when isolation label and house type are available
- double lossFactor_WpK2 = main.v_buildingThermalPars.path( p_gridConnectionType.name() ).path(p_isolationLabel.name()).path("lossFactor_WpK").doubleValue();
- double heatCapacity_JpK2 = main.v_buildingThermalPars.path( p_gridConnectionType.name() ).path(p_isolationLabel.name()).path("heatCapacity_JpK").doubleValue();
- ((J_EABuilding)EA.j_ea).lossFactor_WpK = lossFactor_WpK2;
- ((J_EABuilding)EA.j_ea).heatCapacity_JpK = heatCapacity_JpK2;
- traceln("House thermal model updated!");
- traceln("House type: %s, energy label: %s", p_gridConnectionType, p_isolationLabel);
- traceln("lossfactor %s, heatcapacity %s", lossFactor_WpK2, heatCapacity_JpK2);
- }
- //traceln( "Household heat model has kWh: " + ((J_EAStorageHeat) j_instance).getStorageCapacity());
- }
- else if (j_instance instanceof J_EAEV) {
- //c_storageAssets.add(EA);
- //c_vehicleAssets.add( j_instance );
- //EA.v_powerFraction_fr = 1;
- /*if (c_mobilityTrackers.size() == 0) {
- MobilityTracker m = main.add_mobilityTrackers();
- c_mobilityTrackers.add( m );
- m.p_vehicleIndex = v_vehicleIndex;
- m.p_gridConnection = this;
- m.p_energyAsset = EA;
- m.p_vehicleInstance = (J_EAEV)EA.j_ea;
-
- m.p_mobilityPatternType = PRIVATE_VEHICLE;
- m.f_getData();
- } else {
- traceln("Vehicle index in House " + p_gridConnectionID + " is: " + v_vehicleIndex);
- c_mobilityTrackers.get(v_vehicleIndex).p_vehicleIndex = v_vehicleIndex;
- c_mobilityTrackers.get(v_vehicleIndex).p_energyAsset = c_vehicleAssets.get( v_vehicleIndex );
- c_mobilityTrackers.get(v_vehicleIndex).p_vehicleInstance = EA.j_ea;
- }
- ((J_EAEV)EA.j_ea).setMobilityTracker( c_mobilityTrackers.get(v_vehicleIndex) );
- */
- //p_householdEV = EA;
- //v_vehicleIndex ++;
- }
- else if(j_instance instanceof J_EAStorageElectric && ((J_EAStorageElectric)j_instance).getStorageCapacity_kWh() !=0) {
- //p_batteryAsset = EA;
- //c_storageAssets.add(EA);
- v_batterySOC_fr = p_batteryAsset.getCurrentStateOfCharge();
- }
- else if ( j_instance instanceof J_EAStorageHeat ) {
- if ( ((J_EAStorageHeat)j_instance).heatStorageType == OL_EAStorageTypes.HEATBUFFER ) {
- //c_storageAssets.add(EA);
- //p_heatBuffer = EA;
- //traceln( "Heatbuffer has kWH: " +((J_EAStorageHeat) j_instance).getStorageCapacity());
- }
- }
- else{
- traceln(getName() + "storage asset create that cannot be identified (i.e. its not an EV and not an heatstorage");
- }
-}
-else if (j_instance instanceof J_EAConversion) {
- c_conversionAssets.add((J_EAConversion)EA.j_ea );
- if (EA.p_energyAssetType == OL_EnergyAssetType.GAS_BURNER || EA.j_ea instanceof J_EAConversionHeatPump || EA.j_ea instanceof J_EAConversionHeatDeliverySet || EA.j_ea instanceof J_EAConversionElectricHeater ) {
- switch (p_heatingType) {
- case HEATPUMP_AIR:
- p_primaryHeatingAsset = (J_EAConversion)EA.j_ea;
- break;
- case HEATPUMP_GASPEAK:
- p_primaryHeatingAsset = p_primaryHeatingAsset == null && EA.j_ea instanceof J_EAConversionHeatPump? (J_EAConversion)EA.j_ea : p_primaryHeatingAsset;
- p_secondaryHeatingAsset = p_secondaryHeatingAsset == null && EA.j_ea instanceof J_EAConversionGasBurner? (J_EAConversion)EA.j_ea : p_secondaryHeatingAsset;
- break;
- case HEATPUMP_BOILERPEAK: // ambigue wat we met boiler bedoelen; eboiler of grootschalige DH_boiler = gasburner!
- p_primaryHeatingAsset = p_primaryHeatingAsset == null && EA.j_ea instanceof J_EAConversionHeatPump? (J_EAConversion)EA.j_ea : p_primaryHeatingAsset;
- p_secondaryHeatingAsset = p_secondaryHeatingAsset == null && EA.j_ea instanceof J_EAConversionGasBurner? (J_EAConversion)EA.j_ea : p_secondaryHeatingAsset;
- p_secondaryHeatingAsset = p_secondaryHeatingAsset == null && EA.j_ea instanceof J_EAConversionElectricHeater? (J_EAConversion)EA.j_ea : p_secondaryHeatingAsset;
- break;
- case GASBURNER:
- p_primaryHeatingAsset = p_primaryHeatingAsset == null && EA.j_ea instanceof J_EAConversionGasBurner? (J_EAConversion)EA.j_ea : p_primaryHeatingAsset;
- p_secondaryHeatingAsset = p_secondaryHeatingAsset == null && EA.j_ea instanceof J_EAConversionGasCHP? (J_EAConversion)EA.j_ea : p_secondaryHeatingAsset;
- break;
- case DISTRICTHEAT:
- if( EA.j_ea instanceof J_EAConversionHeatDeliverySet ){
- p_primaryHeatingAsset = (J_EAConversion)EA.j_ea;
- }
- else {
- p_secondaryHeatingAsset = (J_EAConversion)EA.j_ea;
- // set water/water heatpump source energy-asset
- //if( EA.j_ea instanceof J_EAConversionHeatPump && ((J_EAConversionHeatPump)EA.j_ea).getAmbientTempType().equals("WATER") && p_primaryHeatingAsset.j_ea instanceof J_EAConversionHeatDeliverySet ) {
- if( EA.j_ea instanceof J_EAConversionHeatPump ){
- //EA.p_linkedSourceEnergyAsset = p_primaryHeatingAsset; Still need to rebuild link with class-based energy assets!!
- //EA.j_ea.updateAmbientTemperature( EA.p_linkedSourceEnergyAsset.j_ea.getCurrentTemperature() );
- }
- }
- break;
- default: throw new IllegalStateException("Invalid DistrictHeating HeatingType: " + p_heatingType);
- }
- }
- else if ( EA.p_energyAssetType == OL_EnergyAssetType.GAS_PIT){
- //f_connectToJ_EA(EA.j_ea);
- //p_hasElectricHob = false;
- }
- else if (EA.p_energyAssetType == OL_EnergyAssetType.ELECTRIC_HOB) {
- //f_connectToJ_EA(EA.j_ea);
- //p_hasElectricHob = true;
- }
-}
-
-else {
- traceln("f_connectToChild in EnergyAsset: Exception! EnergyAsset " + ConnectingParentNode.getId() + " is of unknown type or null! ");
-}
-/*ALCODEEND*/}
-
double f_createThermalStorageModel()
{/*ALCODESTART::1669203453155*/
OL_EAPresetStorageAssets isolationLevel;
@@ -440,6 +224,10 @@ else if (lastLoopsPriceLevel.equals("low") && powerAvailableAtLastLoop_kW > p_mi
case SIMPLE:
f_simpleCharging();
break;
+ case V1G:
+ case MAX_SPREAD:
+ f_maxSpreadCharging();
+ break;
case CHEAP:
f_chargeOnPrice( v_currentElectricityPriceConsumption_eurpkWh, max(0, availableChargingCapacity));
break;
@@ -502,173 +290,6 @@ else if (energyModel.t_h*60 < chargeDeadline_min ){
v_vehicleChargingNeed = p_householdEV.chargingNeed;
}
-/*ALCODEEND*/}
-
-double f_heatWithHeatpump()
-{/*ALCODESTART::1676477303264*/
-double powerFraction_heatBuffer_fr = 0;
-//double powerFraction_heatPump_fr = 0;
-double avgElectricityPrice_eurpkWh = 10;
-J_EAConversionHeatPump hp = (J_EAConversionHeatPump)p_primaryHeatingAsset;
-v_copHeatpump = hp.getCOP();
-
-/*
-if ( p_smartHeatingEnabled ) {
- if ( p_owner != null) {
- avgElectricityPrice_eurpkWh = p_owner.f_getAveragedElectricityPrice( (fm_currentConsumptionFlows_kW.get(OL_EnergyCarriers.ELECTRICITY) - fm_currentProductionFlows_kW.get(OL_EnergyCarriers.ELECTRICITY)), hp.getInputCapacity_kW() );
- //traceln("avg electircity rprice for HP: " + avgElectricityPrice_eurpkWh);
- }
-}
-
-//heat the buffer if it requires heat
-if ( p_heatBuffer != null ){
- if ( p_heatBuffer.requiresHeat ){
- powerFraction_heatPump_fr = 1;
- powerFraction_heatBuffer_fr = hp.getOutputCapacity_kW() / p_heatBuffer.getCapacityHeat_kW() ;
- //traceln(getName() + " heat buffer cus of need");
- } else if( p_smartHeatingEnabled && avgElectricityPrice_eurpkWh < v_electricityPriceLowPassed_eurpkWh - p_pricelevelLowDifFromAvg_eurpkWh
- //also heat the buffer if the price is cheap, the buffer has some room and the vehicle does not need charging
- && p_heatBuffer.getCurrentStateOfCharge() < 0.7)
- {
- if( p_householdEV == null ){
- powerFraction_heatPump_fr = 1;
- powerFraction_heatBuffer_fr = hp.getOutputCapacity_kW() / p_heatBuffer.getCapacityHeat_kW();
- } else if (p_householdEV.chargingNeed != OL_EVChargingNeed.HIGH){
- powerFraction_heatPump_fr = 1;
- //traceln("heat buffer cus cheap");
- powerFraction_heatBuffer_fr = hp.getOutputCapacity_kW() / p_heatBuffer.getCapacityHeat_kW();
- }
- }
- //reduce the powerfraction in the buffer with the hot water demand.
- powerFraction_heatBuffer_fr += -v_hotwaterDemand_kW / p_heatBuffer.getCapacityHeat_kW();
-}
-*/
-
-//heat the house
-//if( powerFraction_heatPump_fr == 0 ){ // Why this check? <- to make sure the heatpump is only used for househeating if it is not ALREADY heating the buffer (Peter)
- if (p_BuildingThermalAsset.getCurrentTemperature() < v_tempSetpoint_degC - p_heatingKickinTreshold_degC ) {
- hp.v_powerFraction_fr = 1;
- p_BuildingThermalAsset.v_powerFraction_fr = (hp.getOutputCapacity_kW() - v_hotwaterDemand_kW) / p_BuildingThermalAsset.getCapacityHeat_kW();
- }
- if (v_hotwaterDemand_kW > p_primaryHeatingAsset.getOutputCapacity_kW() ) {
- traceln("Warning! Hotwaterdemand exceeds available heating power of house! Will lead to shortage of heat on GC!");
- }
- /*
- else if( p_smartHeatingEnabled && avgElectricityPrice_eurpkWh < v_electricityPriceLowPassed_eurpkWh - p_pricelevelLowDifFromAvg_eurpkWh
- && p_BuildingThermalAsset.getCurrentTemperature() < v_tempSetpoint_degC + 1) {
- //also heat the house if the price is cheap, the the house is colder than desired + 1 and the vehicle does not need charging
- if( p_householdEV == null ){
- powerFraction_heatPump_fr = 1;
- p_BuildingThermalAsset.v_powerFraction_fr = hp.getOutputCapacity_kW() / p_BuildingThermalAsset.getCapacityHeat_kW();
- }
- else if (p_householdEV.chargingNeed != OL_EVChargingNeed.HIGH){ // only use heatpump if the vehicle is not about to charge
- powerFraction_heatPump_fr = 1;
- //traceln("heat house cus of cheap");
- p_BuildingThermalAsset.v_powerFraction_fr = hp.getOutputCapacity_kW() / p_BuildingThermalAsset.getCapacityHeat_kW();
- }
- }*/
- else {
- hp.v_powerFraction_fr = v_hotwaterDemand_kW/hp.getOutputCapacity_kW();
- p_BuildingThermalAsset.v_powerFraction_fr = 0;
- }
-//}
-/*
-else {
- p_BuildingThermalAsset.v_powerFraction_fr = 0; // Whut?
-}
-if ( p_heatBuffer != null ){
- p_heatBuffer.v_powerFraction_fr = powerFraction_heatBuffer_fr;
- p_heatBuffer.f_updateAllFlows(powerFraction_heatBuffer_fr);
-}*/
-//p_primaryHeatingAsset.v_powerFraction_fr = powerFraction_heatPump_fr;
-//traceln( "heatpump power fraction: " + hp.v_powerFraction_fr );
-
-/*ALCODEEND*/}
-
-double f_heatWithHybridHeatpump()
-{/*ALCODESTART::1676976246060*/
-if ( p_primaryHeatingAsset instanceof J_EAConversionHeatPump & p_secondaryHeatingAsset instanceof J_EAConversionGasBurner) { // Heatpump and gasburner, switch based on heatpump COP)
- J_EAConversionHeatPump HP = (J_EAConversionHeatPump)p_primaryHeatingAsset;
- v_copHeatpump = HP.getCOP();
- if (p_BuildingThermalAsset.getCurrentTemperature() < v_tempSetpoint_degC - p_heatingKickinTreshold_degC) {
- //HP.updateAmbientTemp(main.v_currentAmbientTemperature_degC); // update heatpump temp levels! <-- waarom dit gebeurt al in de main (peter 21-02-23)
- boolean gasCheaper = f_calcCheapestHeatingPrice();
- if ( gasCheaper ) { // heat with gas
- traceln("gas is cheaper");
- double powerDemand_kW = v_hotwaterDemand_kW + (v_tempSetpoint_degC - p_BuildingThermalAsset.getCurrentTemperature()) * p_BuildingThermalAsset.getHeatCapacity_JpK() / 3.6e6;
- p_primaryHeatingAsset.v_powerFraction_fr = 0;
- p_secondaryHeatingAsset.v_powerFraction_fr = min(1, powerDemand_kW / p_secondaryHeatingAsset.getOutputCapacity_kW());
- p_BuildingThermalAsset.v_powerFraction_fr = (p_secondaryHeatingAsset.v_powerFraction_fr * p_secondaryHeatingAsset.getOutputCapacity_kW() - v_hotwaterDemand_kW ) / p_BuildingThermalAsset.getCapacityHeat_kW();
- } else { // heat with heatpump
- //double powerDemand_kW = (v_tempSetpoint_degC - houseTemp) * ((J_EAStorageHeat)p_BuildingThermalAsset.j_ea).getHeatCapacity_JpK() / 3.6e6;
- p_primaryHeatingAsset.v_powerFraction_fr = 1;//min(1,powerDemand_kW / p_primaryHeatingAsset.j_ea.getHeatCapacity_kW());
- p_secondaryHeatingAsset.v_powerFraction_fr = min(1,v_hotwaterDemand_kW / p_secondaryHeatingAsset.getOutputCapacity_kW());
- p_BuildingThermalAsset.v_powerFraction_fr = HP.getOutputCapacity_kW() / p_BuildingThermalAsset.getCapacityHeat_kW();
- traceln("HP is cheaper");
- }
- } else { // Just supply DHW demand with gas burner
- p_secondaryHeatingAsset.v_powerFraction_fr = v_hotwaterDemand_kW / p_secondaryHeatingAsset.getOutputCapacity_kW();
- p_primaryHeatingAsset.v_powerFraction_fr = 0;
- p_BuildingThermalAsset.v_powerFraction_fr = 0;
- traceln("just DHW");
- }
- p_secondaryHeatingAsset.f_updateAllFlows( p_secondaryHeatingAsset.v_powerFraction_fr );
-} else if( p_primaryHeatingAsset instanceof J_EAConversionHeatDeliverySet && ( p_secondaryHeatingAsset instanceof J_EAConversionElectricHeater || p_secondaryHeatingAsset instanceof J_EAConversionHeatPump ) && p_heatBuffer instanceof J_EAStorageHeat ) { // Heat Delivery Set and booster water/water heatpump with buffer for hotwater, )
- p_primaryHeatingAsset.v_powerFraction_fr = 0;
- p_secondaryHeatingAsset.v_powerFraction_fr = 0;
- p_heatBuffer.v_powerFraction_fr = 0;
-
- traceln("bivalent DH system with buffer operating mode");
- double v_bufferTemp_degC = p_heatBuffer.getCurrentTemperature();
- double houseTemperature_degC = p_BuildingThermalAsset.getCurrentTemperature();
-
- // buffer instead of heatpump! TODO: change to refill buffer! double secondaryDemand_kW = v_hotwaterDemand_kW;
- traceln(" thermalstoragetemp "+ p_BuildingThermalAsset.getCurrentTemperature() + ", v_setpoint_degC " + v_tempSetpoint_degC);
-
- // 1) w/w heatpump feeds (only) the local heat buffer for tapwater when temperature is beneath buffer setpoint:
- boolean b_bufferTempBelowSetpoint = v_bufferTemp_degC < p_heatBuffer.getSetTemperature_degC();
-
- p_secondaryHeatingAsset.v_powerFraction_fr = b_bufferTempBelowSetpoint ? 1 : 0;
- p_secondaryHeatingAsset.f_updateAllFlows( p_secondaryHeatingAsset.v_powerFraction_fr );
-
- double heatSupplyToBuffer_kW = -p_secondaryHeatingAsset.getLastFlows().get(OL_EnergyCarriers.HEAT);
-
- // 2) supply tapwater from local heatbuffer on demand, AND take in heat from the heatpump
- p_heatBuffer.v_powerFraction_fr = ( - v_hotwaterDemand_kW + heatSupplyToBuffer_kW ) / p_heatBuffer.getCapacityHeat_kW();
- p_heatBuffer.f_updateAllFlows( p_heatBuffer.v_powerFraction_fr );
-
- // 3) heat the house from heat delivery set directly, and take care to add this heat load to the existing heat flow from w/w heatpump consumption!
- boolean b_houseTempBelowSetpoint = houseTemperature_degC < v_tempSetpoint_degC? true : false;
-
- p_primaryHeatingAsset.v_powerFraction_fr += b_houseTempBelowSetpoint? 1 : 0; // maybe cap for maximum 1?
- //p_primaryHeatingAsset.f_updateAllFlows( p_primaryHeatingAsset.v_powerFraction_fr );
-
- double heatFlowToHouse_kW = p_primaryHeatingAsset.getOutputCapacity_kW() * p_primaryHeatingAsset.v_powerFraction_fr - p_secondaryHeatingAsset.getLastFlows().get(OL_EnergyCarriers.HEAT);
- p_BuildingThermalAsset.v_powerFraction_fr = (heatFlowToHouse_kW / p_BuildingThermalAsset.getCapacityHeat_kW() );
- //p_primaryHeatingAsset.v_powerFraction_fr = p_BuildingThermalAsset.j_ea.getCurrentTemperature() < v_tempSetpoint_degC ? 1 : 0;
- //traceln("b_primaryOperate = "+ b_primaryOperate + ", GCHouse f_heatWithHybridHeatpump: p_secondaryHeatingAsset.j_ea.capacityHeat_kW = " + p_secondaryHeatingAsset.j_ea.capacityHeat_kW + ". p_secondaryHeatingAsset.j_ea = "+p_secondaryHeatingAsset.j_ea.toString());
-
- //boolean b_primaryOperate = houseTemperature_degC < v_tempSetpoint_degC ? true : false;
-
-
- //p_secondaryHeatingAsset.v_powerFraction_fr = secondaryDemand_kW / p_secondaryHeatingAsset.j_ea.getHeatCapacity_kW();
-
-
- //p_BuildingThermalAsset.v_powerFraction_fr = p_primaryHeatingAsset.j_ea.capacityHeat_kW * p_primaryHeatingAsset.v_powerFraction_fr;
-
- //traceln("GCHouse f_heatwithhybrid... -> p_primaryHeatingAsset.v_powerFraction_fr = " + p_primaryHeatingAsset.v_powerFraction_fr + ", p_secondaryHeatingAsset.v_powerFraction_fr = " + p_secondaryHeatingAsset.v_powerFraction_fr + ", p_BuildingThermalAsset.v_powerFraction_fr" + p_BuildingThermalAsset.v_powerFraction_fr);
- //p_secondaryHeatingAsset.f_updateAllFlows(p_secondaryHeatingAsset.v_powerFraction_fr);
- //p_primaryHeatingAsset.f_updateAllFlows(p_primaryHeatingAsset.v_powerFraction_fr);
- //p_BuildingThermalAsset.f_updateAllFlows(p_BuildingThermalAsset.v_powerFraction_fr);
-
-} else {
- traceln("**** EXCEPTION ****: Unsupported combination of heatings systems in house " + p_gridConnectionID);
- p_primaryHeatingAsset.v_powerFraction_fr = 0;
- p_secondaryHeatingAsset.v_powerFraction_fr = 0;
- p_BuildingThermalAsset.v_powerFraction_fr = 0;
-}
-
-
/*ALCODEEND*/}
double f_chargeOnPriceSimpler(double availablePowerOnGc_kW)
@@ -787,30 +408,6 @@ else if ( v_batterySOC_fr < 0.6 && v_currentPowerElectricity_kW < 1 && v_current
traceln("Placeholder function f_setEnergyLabel called! Nothing will happen.");
/*ALCODEEND*/}
-double setHeatingTargetTemp()
-{/*ALCODESTART::1702369252216*/
-if ( energyModel.t_hourOfDay > v_heatingOn_time && energyModel.t_hourOfDay < v_heatingOff_time){
- v_tempSetpoint_degC = v_dayTempSetpoint_degC ;
-}
-else {
- v_tempSetpoint_degC = v_nightTempSetpoint_degC;
-}
-/*ALCODEEND*/}
-
-boolean f_calcCheapestHeatingPrice()
-{/*ALCODESTART::1702369294416*/
-double HP_COP = ((J_EAConversionHeatPump)p_primaryHeatingAsset).getCOP();
-boolean isGasCheaper = false;
-
-if( p_owner != null ) {
- v_gasHeatingCost_eurpkWh_TEMPORARY = p_owner.f_getMethanePrice();
- v_eHeatingCost_eurpkWh_TEMPORARY = p_owner.f_getAveragedElectricityPrice( fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY), p_primaryHeatingAsset.getInputCapacity_kW() ) / HP_COP;
- isGasCheaper = v_gasHeatingCost_eurpkWh_TEMPORARY < v_eHeatingCost_eurpkWh_TEMPORARY ? true:false;
-}
-
-return isGasCheaper;
-/*ALCODEEND*/}
-
double f_removeCurrentHeatingSystem()
{/*ALCODESTART::1726129903799*/
p_heatingType = OL_GridConnectionHeatingType.NONE;
@@ -826,50 +423,6 @@ boolean f_calcCheapestHeatingPrice()
}
/*ALCODEEND*/}
-double f_heatWithGasburner()
-{/*ALCODESTART::1726301776809*/
-if ( p_primaryHeatingAsset instanceof J_EAConversionGasBurner && p_BuildingThermalAsset != null) {
- if (p_BuildingThermalAsset.getCurrentTemperature() < v_tempSetpoint_degC - p_heatingKickinTreshold_degC) {
- double powerDemand_kW = v_hotwaterDemand_kW + (v_tempSetpoint_degC - p_BuildingThermalAsset.getCurrentTemperature()) * p_BuildingThermalAsset.getHeatCapacity_JpK() / 3.6e6;
- p_primaryHeatingAsset.v_powerFraction_fr = min(1, powerDemand_kW / p_primaryHeatingAsset.getOutputCapacity_kW() );
- p_BuildingThermalAsset.v_powerFraction_fr = max(0, (p_primaryHeatingAsset.v_powerFraction_fr * p_primaryHeatingAsset.getOutputCapacity_kW() - v_hotwaterDemand_kW) / p_BuildingThermalAsset.getCapacityHeat_kW() );
- if (v_hotwaterDemand_kW > p_primaryHeatingAsset.getOutputCapacity_kW() ) {
- traceln("Warning! Hotwaterdemand exceeds available heating power of house! Will lead to shortage of heat on GC!");
- }
- }
- else { // Just supply DHW
- p_primaryHeatingAsset.v_powerFraction_fr = v_hotwaterDemand_kW / p_primaryHeatingAsset.getOutputCapacity_kW();
- p_BuildingThermalAsset.v_powerFraction_fr = 0;
- }
-}
-else if (p_primaryHeatingAsset instanceof J_EAConversionGasBurner && p_BuildingThermalAsset == null){
- double powerDemand_kW = fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.HEAT); //TODO Where does this v_currentPowerHeat_kW come from? (Peter 14-09-2024),
- p_primaryHeatingAsset.v_powerFraction_fr = min(1,powerDemand_kW / p_primaryHeatingAsset.getOutputCapacity_kW());
- traceln("Household is heating with gasburner without thermal building asset, check if this is correct @f_heatWithGasBurner");
- //p_primaryHeatingAsset.v_powerFraction_fr = v_hotwaterDemand_kW / p_primaryHeatingAsset.getHeatCapacity_kW();
-}
-
-/*ALCODEEND*/}
-
-double f_heatWithDistrictHeat()
-{/*ALCODESTART::1726301785545*/
-if ( p_primaryHeatingAsset instanceof J_EAConversionHeatDeliverySet && p_BuildingThermalAsset != null) {
- if (p_BuildingThermalAsset.getCurrentTemperature() < v_tempSetpoint_degC - p_heatingKickinTreshold_degC) {
- double powerDemand_kW = v_hotwaterDemand_kW + (v_tempSetpoint_degC - p_BuildingThermalAsset.getCurrentTemperature()) * p_BuildingThermalAsset.getHeatCapacity_JpK() / 3.6e6;
- p_primaryHeatingAsset.v_powerFraction_fr = min(1, powerDemand_kW / p_primaryHeatingAsset.getOutputCapacity_kW() );
- p_BuildingThermalAsset.v_powerFraction_fr = max(0, ( p_primaryHeatingAsset.v_powerFraction_fr * p_primaryHeatingAsset.getOutputCapacity_kW() - v_hotwaterDemand_kW ) / p_BuildingThermalAsset.getCapacityHeat_kW());
- }
- else {
- p_primaryHeatingAsset.v_powerFraction_fr = v_hotwaterDemand_kW / p_primaryHeatingAsset.getOutputCapacity_kW();
- p_BuildingThermalAsset.v_powerFraction_fr = 0;
- }
- v_districtHeatDelivery_kW = p_primaryHeatingAsset.v_powerFraction_fr * p_primaryHeatingAsset.getOutputCapacity_kW();
-}
-else {
- traceln("House " + p_gridConnectionID + " has heatingtype DISTRICT HEAT, but no delivery set or building asset!");
-}
-/*ALCODEEND*/}
-
double f_manageCookingTracker()
{/*ALCODESTART::1726334759211*/
// Add heat from cooking assets to house
@@ -938,22 +491,3 @@ else if (p_primaryHeatingAsset instanceof J_EAConversionGasBurner && p_BuildingT
}
/*ALCODEEND*/}
-double f_heatWithLTDistrictHeat()
-{/*ALCODESTART::1752073360816*/
-if ( p_primaryHeatingAsset instanceof J_EAConversionHeatPump && p_BuildingThermalAsset != null) {
- // The only supported combination is currently a heatpump as booster and heatdemand from a building asset (and hot water)
- if (p_BuildingThermalAsset.getCurrentTemperature() < v_tempSetpoint_degC - p_heatingKickinTreshold_degC) {
- double powerDemand_kW = v_hotwaterDemand_kW + (v_tempSetpoint_degC - p_BuildingThermalAsset.getCurrentTemperature()) * p_BuildingThermalAsset.getHeatCapacity_JpK() / 3.6e6;
- p_primaryHeatingAsset.v_powerFraction_fr = min(1, powerDemand_kW / p_primaryHeatingAsset.getOutputCapacity_kW() );
- p_BuildingThermalAsset.v_powerFraction_fr = max(0, ( p_primaryHeatingAsset.v_powerFraction_fr * p_primaryHeatingAsset.getOutputCapacity_kW() - v_hotwaterDemand_kW ) / p_BuildingThermalAsset.getCapacityHeat_kW());
- }
- else {
- p_primaryHeatingAsset.v_powerFraction_fr = v_hotwaterDemand_kW / p_primaryHeatingAsset.getOutputCapacity_kW();
- p_BuildingThermalAsset.v_powerFraction_fr = 0;
- }
-}
-else {
- throw new RuntimeException("House " + p_gridConnectionID + " has heatingtype LT DISTRICTHEAT, but no booster or building asset!");
-}
-/*ALCODEEND*/}
-
diff --git a/_alp/Agents/GCHouse/Code/Functions.xml b/_alp/Agents/GCHouse/Code/Functions.xml
index 8d9f4951..1b859245 100644
--- a/_alp/Agents/GCHouse/Code/Functions.xml
+++ b/_alp/Agents/GCHouse/Code/Functions.xml
@@ -1,22 +1,5 @@
-
- VOID
- double
- 1664441996771
-
- true
- 920
- 420
-
- false
- true
- true
-
-
VOID
double
@@ -33,35 +16,14 @@
true
-
- VOID
- double
- 1665498948452
-
- true
- 820
- -100
-
- false
- true
- true
-
-
-
-
-
-
VOID
double
1669203453155
true
- 820
- -210
+ 940
+ -90
-
- VOID
- double
- 1676477303264
-
- true
- 1700
- 110
-
- 10
- 0
-
- false
- true
- true
-
-
-
- VOID
- double
- 1676976246060
-
- true
- 1700
- 170
-
- 10
- 0
-
- false
- true
- true
-
-
VOID
double
@@ -270,40 +198,6 @@
true
-
- VOID
- double
- 1702369252216
-
- true
- 1700
- 90
-
- 10
- 0
-
- false
- true
- true
-
-
-
- RETURNS_VALUE
- boolean
- 1702369294416
-
- true
- 1720
- 190
-
- 10
- 0
-
- false
- true
- true
-
-
VOID
double
@@ -321,40 +215,6 @@
true
-
- VOID
- double
- 1726301776809
-
- true
- 1700
- 130
-
- 10
- 0
-
- false
- true
- true
-
-
-
- VOID
- double
- 1726301785545
-
- true
- 1700
- 150
-
- 10
- 0
-
- false
- true
- true
-
-
VOID
double
@@ -407,21 +267,4 @@
-
- VOID
- double
- 1752073360816
-
- true
- 1700
- 210
-
- 10
- 0
-
- false
- true
- true
-
-
diff --git a/_alp/Agents/GCHouse/Variables.xml b/_alp/Agents/GCHouse/Variables.xml
index 1df4fb8c..6ce592a0 100644
--- a/_alp/Agents/GCHouse/Variables.xml
+++ b/_alp/Agents/GCHouse/Variables.xml
@@ -202,75 +202,6 @@
-
- 1704447555067
-
- true
- 1460
- 210
-
- 10
- 0
-
- false
- true
- true
-
-
-
-
-
-
-
-
- 1704447555069
-
- true
- 1460
- -40
-
- 10
- 0
-
- false
- true
- true
-
-
-
-
-
-
-
-
- 1704447555071
-
- true
- 1460
- -20
-
- 10
- 0
-
- false
- true
- true
-
-
-
-
-
-
-
1704447555073
diff --git a/_alp/Agents/GridConnection/Code/Functions.java b/_alp/Agents/GridConnection/Code/Functions.java
index 2f2b1eb8..b6d21ff6 100644
--- a/_alp/Agents/GridConnection/Code/Functions.java
+++ b/_alp/Agents/GridConnection/Code/Functions.java
@@ -207,122 +207,35 @@
/*ALCODEEND*/}
-double f_manageHeatingAssets_OLD()
-{/*ALCODESTART::1669025846794*/
-// TODO: This only works for fixed heat demands; also need to implement heating of a building modeled as a ThermalStorageAsset! [GH 21/11/2022]
-if(p_heatBuffer != null){
- double chargeSetpoint_kW = -fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.HEAT);
- p_heatBuffer.v_powerFraction_fr = chargeSetpoint_kW / p_heatBuffer.getCapacityHeat_kW();
- p_heatBuffer.f_updateAllFlows(p_heatBuffer.v_powerFraction_fr);
-}
-
-double powerDemand_kW = fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.HEAT);
-
-if(powerDemand_kW < 0 && v_liveAssetsMetaData.activeAssetFlows.contains(OL_AssetFlowCategories.ptProductionHeat_kW)){//If there is 'overproduction' of heat, that can not be collected by the heat buffer: no power demand -> will be curtailed.
- powerDemand_kW = 0;
-}
-
-if ( p_BuildingThermalAsset == null ) {
- if ( p_secondaryHeatingAsset == null ) { // Just one heating asset
- if ( p_primaryHeatingAsset== null ) {
- if (powerDemand_kW > 0) {
- traceln("No heating assets for GridConnection " + p_gridConnectionID);
- }
- } else {
- if ( p_primaryHeatingAsset instanceof J_EAConversionGasBurner || p_primaryHeatingAsset instanceof J_EAConversionHeatDeliverySet || p_primaryHeatingAsset instanceof J_EAConversionHydrogenBurner || p_primaryHeatingAsset instanceof J_EAConversionHeatPump) { // when there is only a gas burner or DH set
- p_primaryHeatingAsset.v_powerFraction_fr = min(1,powerDemand_kW / p_primaryHeatingAsset.getOutputCapacity_kW());
- }
- else if(p_primaryHeatingAsset instanceof J_EAConversionGasCHP){
- p_primaryHeatingAsset.v_powerFraction_fr = min(1,powerDemand_kW / ((J_EAConversionGasCHP)p_primaryHeatingAsset).getOutputHeatCapacity_kW());
- }
- else {
- traceln("GridConnection " + p_gridConnectionID + " has a single unsupported heating asset!");
- }
- }
- }
- else if (p_primaryHeatingAsset== null && p_secondaryHeatingAsset != null && v_hasQuarterHourlyValues){
- if(p_secondaryHeatingAsset instanceof J_EAConversionGasBurner){
- p_secondaryHeatingAsset.v_powerFraction_fr = min(1,powerDemand_kW / p_secondaryHeatingAsset.getOutputCapacity_kW());
- p_secondaryHeatingAsset.f_updateAllFlows(p_secondaryHeatingAsset.v_powerFraction_fr);
- } else {
- traceln("GridConnection " + p_gridConnectionID + " has a single unsupported secondary heating asset!");
- }
- } else { // Two heating assets
- if ( p_primaryHeatingAsset instanceof J_EAConversionHeatPump && p_secondaryHeatingAsset instanceof J_EAConversionGasBurner) { // Heatpump and gasburner, switch based on heatpump COP)
- //((J_EAConversionHeatPump)p_primaryHeatingAsset.j_ea).updateAmbientTemp(main.v_currentAmbientTemperature_degC); // update heatpump temp levels! <-- waarom dit gebeurt al in de main (peter 21-02-23)
- double HP_COP = ((J_EAConversionHeatPump)p_primaryHeatingAsset).getCOP();
- double COP_tres = 3.5; // TODO: Make data agnostic! Also, this line doesn't have to be evaluated every timestep.
- if ( HP_COP < COP_tres ) { // switch to gasburner when HP COP is below treshold
- //traceln("Hybrid HP: Switching to gas burner");
- p_primaryHeatingAsset.v_powerFraction_fr = 0;
- p_secondaryHeatingAsset.v_powerFraction_fr = min(1,powerDemand_kW / p_secondaryHeatingAsset.getOutputCapacity_kW());
- } else { // heatpump when COP is above treshold
- //traceln("Hybrid HP: Using heatpump with COP " + HP_COP);
- p_primaryHeatingAsset.v_powerFraction_fr = min(1,powerDemand_kW / p_primaryHeatingAsset.getOutputCapacity_kW());
- p_secondaryHeatingAsset.v_powerFraction_fr = 0;//min(1,currentDHWdemand_kW / p_secondaryHeatingAsset.j_ea.getHeatCapacity_kW());
- }
- } else {
- traceln("**** EXCEPTION ****: Unsupported combination of heatings systems in house " + p_gridConnectionID);
- p_primaryHeatingAsset.v_powerFraction_fr = 0;
- p_secondaryHeatingAsset.v_powerFraction_fr = 0;
- //p_BuildingThermalAsset.v_powerFraction_fr = 0;
- }
- p_secondaryHeatingAsset.f_updateAllFlows(p_secondaryHeatingAsset.v_powerFraction_fr);
- //v_conversionPowerElectric_kW += p_primaryHeatingAsset.electricityConsumption_kW - p_primaryHeatingAsset.electricityProduction_kW;// traceln("heatpump electricity consumption: " + (p_primaryHeatingAsset.electricityConsumption_kW - p_primaryHeatingAsset.electricityProduction_kW));
- /*if (p_secondaryHeatingAsset instanceof J_EAConversionHeatPump) {
- v_heatPumpElectricityConsumption_kW += p_primaryHeatingAsset.electricityConsumption_kW - p_primaryHeatingAsset.electricityProduction_kW;
- }*/
- }
- if (p_primaryHeatingAsset != null) {
- p_primaryHeatingAsset.f_updateAllFlows(p_primaryHeatingAsset.v_powerFraction_fr);
- //v_conversionPowerElectric_kW += flowsArray[4] - flowsArray[0]; //p_primaryHeatingAsset.electricityConsumption_kW - p_primaryHeatingAsset.electricityProduction_kW;
- /*if (p_primaryHeatingAsset instanceof J_EAConversionHeatPump) {
- v_heatPumpElectricityConsumption_kW += flowsArray[4] - flowsArray[0];
- }*/
- }
-} else { // TODO: Implement thermostat functionality for thermal storage asset. Where to get temp setpoint?
- traceln("No thermostat functionality available to manage p_BuildingThermalAsset!!");
- p_primaryHeatingAsset.f_updateAllFlows(0);
- /* v_conversionPowerElectric_kW += flowsArray[4] - flowsArray[0]; //p_primaryHeatingAsset.electricityConsumption_kW - p_primaryHeatingAsset.electricityProduction_kW;
- if (p_primaryHeatingAsset instanceof J_EAConversionHeatPump) {
- v_heatPumpElectricityConsumption_kW += flowsArray[4] - flowsArray[0];
- }*/
- p_secondaryHeatingAsset.f_updateAllFlows(0);
- /*v_conversionPowerElectric_kW += flowsArray[4] - flowsArray[0]; //p_primaryHeatingAsset.electricityConsumption_kW - p_primaryHeatingAsset.electricityProduction_kW;
- if (p_secondaryHeatingAsset instanceof J_EAConversionHeatPump) {
- v_heatPumpElectricityConsumption_kW += flowsArray[4] - flowsArray[0];
- }*/
- p_BuildingThermalAsset.f_updateAllFlows(0);
-}
-/*ALCODEEND*/}
-
double f_manageCharging()
{/*ALCODESTART::1671095995172*/
-double availableCapacityFromBatteries = p_batteryAsset == null ? 0 : p_batteryAsset.getCapacityAvailable_kW();
-//double availableChargingCapacity = v_allowedCapacity_kW + availableCapacityFromBatteries - v_currentPowerElectricity_kW;
-double availableChargingCapacity = v_liveConnectionMetaData.contractedDeliveryCapacity_kW + availableCapacityFromBatteries - fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY);
-switch (p_chargingAttitudeVehicles) {
- case SIMPLE:
- f_simpleCharging();
- break;
- case MAX_SPREAD:
- f_maxSpreadCharging();
- break;
- case MAX_POWER:
- f_maxPowerCharging( max(0, availableChargingCapacity));
- break;
- case CHEAP:
- v_currentElectricityPriceConsumption_eurpkWh = p_owner.f_getElectricityPrice(v_liveConnectionMetaData.contractedDeliveryCapacity_kW);
- v_electricityPriceLowPassed_eurpkWh += v_lowPassFactor_fr * ( v_currentElectricityPriceConsumption_eurpkWh - v_electricityPriceLowPassed_eurpkWh );
- f_chargeOnPrice( v_currentElectricityPriceConsumption_eurpkWh, max(0, availableChargingCapacity));
- break;
- case V2G:
- v_currentElectricityPriceConsumption_eurpkWh = p_owner.f_getElectricityPrice(v_liveConnectionMetaData.contractedDeliveryCapacity_kW);
- v_electricityPriceLowPassed_eurpkWh += v_lowPassFactor_fr * ( v_currentElectricityPriceConsumption_eurpkWh - v_electricityPriceLowPassed_eurpkWh );
- f_chargeOnPrice_V2G( v_currentElectricityPriceConsumption_eurpkWh, max(0, availableChargingCapacity));
- break;
+if(c_electricVehicles.size() > 0){
+ double availableCapacityFromBatteries = p_batteryAsset == null ? 0 : p_batteryAsset.getCapacityAvailable_kW();
+ //double availableChargingCapacity = v_allowedCapacity_kW + availableCapacityFromBatteries - v_currentPowerElectricity_kW;
+ double availableChargingCapacity = v_liveConnectionMetaData.contractedDeliveryCapacity_kW + availableCapacityFromBatteries - fm_currentBalanceFlows_kW.get(OL_EnergyCarriers.ELECTRICITY);
+
+ switch (p_chargingAttitudeVehicles) {
+ case SIMPLE:
+ f_simpleCharging();
+ break;
+ case MAX_SPREAD:
+ f_maxSpreadCharging();
+ break;
+ case MAX_POWER:
+ f_maxPowerCharging( max(0, availableChargingCapacity));
+ break;
+ case CHEAP:
+ v_currentElectricityPriceConsumption_eurpkWh = p_owner.f_getElectricityPrice(v_liveConnectionMetaData.contractedDeliveryCapacity_kW);
+ v_electricityPriceLowPassed_eurpkWh += v_lowPassFactor_fr * ( v_currentElectricityPriceConsumption_eurpkWh - v_electricityPriceLowPassed_eurpkWh );
+ f_chargeOnPrice( v_currentElectricityPriceConsumption_eurpkWh, max(0, availableChargingCapacity));
+ break;
+ case V2G:
+ v_currentElectricityPriceConsumption_eurpkWh = p_owner.f_getElectricityPrice(v_liveConnectionMetaData.contractedDeliveryCapacity_kW);
+ v_electricityPriceLowPassed_eurpkWh += v_lowPassFactor_fr * ( v_currentElectricityPriceConsumption_eurpkWh - v_electricityPriceLowPassed_eurpkWh );
+ f_chargeOnPrice_V2G( v_currentElectricityPriceConsumption_eurpkWh, max(0, availableChargingCapacity));
+ break;
+ }
}
-
/*ALCODEEND*/}
double f_simpleCharging()
@@ -553,9 +466,7 @@ else if (p_primaryHeatingAsset== null && p_secondaryHeatingAsset != null && v_ha
OL_AssetFlowCategories AC = j_ea.assetFlowCategory;
v_liveAssetsMetaData.activeAssetFlows.add(AC);
if (energyModel.b_isInitialized && v_isActive) {
- f_addAssetFlow(AC);
- energyModel.f_addAssetFlow(AC);
- c_parentCoops.forEach(x->x.f_addAssetFlow(AC));
+ f_addAssetFlow(AC);
}
}
@@ -569,9 +480,9 @@ else if (p_primaryHeatingAsset== null && p_secondaryHeatingAsset != null && v_ha
} else if (vehicle instanceof J_EAHydrogenVehicle) {
c_hydrogenVehicles.add((J_EAHydrogenVehicle)vehicle);
} else if (vehicle instanceof J_EAEV) {
+ c_electricVehicles.add((J_EAEV)vehicle);
c_vehiclesAvailableForCharging.add((J_EAEV)vehicle);
energyModel.c_EVs.add((J_EAEV)vehicle);
- //c_EvAssets.add(j_ea);
}
c_vehicleAssets.add(vehicle);
J_ActivityTrackerTrips tripTracker = vehicle.getTripTracker();
@@ -602,17 +513,13 @@ else if (p_primaryHeatingAsset== null && p_secondaryHeatingAsset != null && v_ha
p_DHWAsset = (J_EAConsumption)j_ea;
}
if( j_ea.energyAssetType == OL_EnergyAssetType.ELECTRICITY_DEMAND ) {
- //c_fixedConsumptionElectricAssets.add(j_ea);
}
if( j_ea.energyAssetType == OL_EnergyAssetType.ELECTRIC_HOB ) {
- //c_electricHobAssets.add(j_ea);
}
} else if (j_ea instanceof J_EAProduction) {
c_productionAssets.add((J_EAProduction)j_ea);
- //energyModel.c_productionAssets.add((J_EAProduction)j_ea);
-
+
if (j_ea.energyAssetType == OL_EnergyAssetType.PHOTOVOLTAIC) {
- //v_liveAssetsMetaData.hasPV = true;
double capacity_kW = ((J_EAProduction)j_ea).getCapacityElectric_kW();
v_liveAssetsMetaData.totalInstalledPVPower_kW += capacity_kW;
if ( p_parentNodeElectric != null ) {
@@ -620,10 +527,8 @@ else if (p_primaryHeatingAsset== null && p_secondaryHeatingAsset != null && v_ha
}
c_parentCoops.forEach( coop -> coop.v_liveAssetsMetaData.totalInstalledPVPower_kW += capacity_kW);
energyModel.v_liveAssetsMetaData.totalInstalledPVPower_kW += capacity_kW;
- //c_pvAssets.add(j_ea);
}
else if (j_ea.energyAssetType == OL_EnergyAssetType.WINDMILL) {
- //v_liveAssetsMetaData.hasWindturbine = true;
double capacity_kW = ((J_EAProduction)j_ea).getCapacityElectric_kW();
v_liveAssetsMetaData.totalInstalledWindPower_kW += capacity_kW;
if ( p_parentNodeElectric != null ) {
@@ -631,11 +536,8 @@ else if (j_ea.energyAssetType == OL_EnergyAssetType.WINDMILL) {
}
c_parentCoops.forEach( coop -> coop.v_liveAssetsMetaData.totalInstalledWindPower_kW += capacity_kW);
energyModel.v_liveAssetsMetaData.totalInstalledWindPower_kW += capacity_kW;
- //c_windAssets.add(j_ea);
}
else if (j_ea.energyAssetType == OL_EnergyAssetType.PHOTOTHERMAL){
- //v_liveAssetsMetaData.hasPT = true;
- //c_ptAssets.add(j_ea);
if (p_heatingManagement != null) {
p_heatingManagement.notInitialized();
}
@@ -645,8 +547,6 @@ else if (j_ea.energyAssetType == OL_EnergyAssetType.PHOTOTHERMAL){
// Non Heating Assets
if ( j_ea.energyAssetType == OL_EnergyAssetType.GAS_PIT || j_ea.energyAssetType == OL_EnergyAssetType.ELECTRIC_HOB){
if (j_ea.energyAssetType == OL_EnergyAssetType.ELECTRIC_HOB) {
- //c_electricHobAssets.add(j_ea);
- //c_conversionElectricAssets.add(j_ea);
}
if (p_cookingTracker == null) {
int rowIndex = uniform_discr(2, 300);
@@ -665,9 +565,7 @@ else if (j_ea.energyAssetType == OL_EnergyAssetType.PHOTOTHERMAL){
// Special Heating Assets
if (j_ea instanceof J_EAConversionHeatPump) {
energyModel.c_ambientDependentAssets.add(j_ea);
- //c_electricHeatpumpAssets.add(j_ea);
} else if (j_ea instanceof J_EAConversionGasCHP) {
- //c_chpAssets.add(j_ea);
}
}
} else if (j_ea instanceof J_EAStorage) {
@@ -691,7 +589,6 @@ else if (j_ea.energyAssetType == OL_EnergyAssetType.PHOTOTHERMAL){
p_gasBuffer = (J_EAStorageGas)j_ea;
} else if (j_ea instanceof J_EAStorageElectric) {
p_batteryAsset = (J_EAStorageElectric)j_ea;
- //c_batteryAssets.add(j_ea);
double capacity_MWh = ((J_EAStorageElectric)j_ea).getStorageCapacity_kWh()/1000;
v_liveAssetsMetaData.totalInstalledBatteryStorageCapacity_MWh += capacity_MWh;
c_parentCoops.forEach( coop -> coop.v_liveAssetsMetaData.totalInstalledBatteryStorageCapacity_MWh += capacity_MWh);
@@ -699,13 +596,11 @@ else if (j_ea.energyAssetType == OL_EnergyAssetType.PHOTOTHERMAL){
}
} else if (j_ea instanceof J_EAProfile) {
- //p_energyProfile = (J_EAProfile)j_ea;
c_profileAssets.add((J_EAProfile)j_ea);
} else if (j_ea instanceof J_EADieselTractor) {
c_profileAssets.add((J_EAProfile)j_ea);
} else if (j_ea instanceof J_EACharger) {
c_chargers.add((J_EACharger)j_ea);
- //c_EvAssets.add(j_ea);
} else {
if (!(this instanceof GCHouse && j_ea instanceof J_EAAirco)) {
traceln("Unrecognized energy asset %s in gridconnection %s", j_ea, this);
@@ -759,7 +654,7 @@ else if (j_ea.energyAssetType == OL_EnergyAssetType.PHOTOTHERMAL){
double V2G_WTR_offset_eurpkWh = 0.05;
double chargeSetpoint_kW = 0;
- if ( energyModel.t_h*60 >= chargeDeadline_min & chargeNeedForNextTrip_kWh > 0) { // Must-charge time at max charging power
+ if ( energyModel.t_h*60 >= chargeDeadline_min - 15 && chargeNeedForNextTrip_kWh > 0) { // Must-charge time at max charging power
//traceln("Urgency charging! May exceed connection capacity!");
chargeSetpoint_kW = maxChargingPower_kW;
} else if ( vehicle.getCurrentStateOfCharge_fr() < 0.15 ) {
@@ -1315,7 +1210,8 @@ else if (flowsMap.get(EC) > 0){
v_isActive = setActive; // v_isActive must be true before calling updateActiveAssetData!
v_liveAssetsMetaData.updateActiveAssetData(new ArrayList<>(List.of(this)));
v_liveAssetsMetaData.activeAssetFlows.forEach(x->energyModel.f_addAssetFlow(x));
-
+ v_liveAssetsMetaData.activeAssetFlows.forEach(x-> c_parentCoops.forEach(coop -> coop.f_addAssetFlow(x)));
+
// update GN parents' wind / solar totals (will be wrong if you changed your totals while paused)
p_parentNodeElectric.f_updateTotalInstalledProductionAssets(OL_EnergyAssetType.PHOTOVOLTAIC, v_liveAssetsMetaData.totalInstalledPVPower_kW, true);
p_parentNodeElectric.f_updateTotalInstalledProductionAssets(OL_EnergyAssetType.WINDMILL, v_liveAssetsMetaData.totalInstalledWindPower_kW, true);
@@ -1333,11 +1229,7 @@ else if (flowsMap.get(EC) > 0){
double startTime = energyModel.v_liveData.dsm_liveDemand_kW.get(OL_EnergyCarriers.ELECTRICITY).getXMin();
double endTime = energyModel.v_liveData.dsm_liveDemand_kW.get(OL_EnergyCarriers.ELECTRICITY).getXMax();
v_liveData.resetLiveDatasets(startTime, endTime, energyModel.p_timeStep_h);
- //v_isActive = setActive; //
}
-
-//Update the 'isActive' variable
-
/*ALCODEEND*/}
double f_getChargeDeadline(J_EAEV ev)
@@ -1355,20 +1247,11 @@ else if (flowsMap.get(EC) > 0){
v_liveData.dsm_liveSupply_kW.createEmptyDataSets(v_activeProductionEnergyCarriers, (int)(168 / energyModel.p_timeStep_h));
v_liveData.dsm_liveAssetFlows_kW.createEmptyDataSets(v_liveData.assetsMetaData.activeAssetFlows, (int)(168 / energyModel.p_timeStep_h));
-/*
-dsm_dailyAverageDemandDataSets_kW.createEmptyDataSets(v_activeEnergyCarriers, 365);
-dsm_dailyAverageSupplyDataSets_kW.createEmptyDataSets(v_activeEnergyCarriers, 365);
-
-dsm_summerWeekDemandDataSets_kW.createEmptyDataSets(v_activeEnergyCarriers, (int)(168 / energyModel.p_timeStep_h));
-dsm_summerWeekSupplyDataSets_kW.createEmptyDataSets(v_activeEnergyCarriers, (int)(168 / energyModel.p_timeStep_h));
-dsm_winterWeekDemandDataSets_kW.createEmptyDataSets(v_activeEnergyCarriers, (int)(168 / energyModel.p_timeStep_h));
-dsm_winterWeekSupplyDataSets_kW.createEmptyDataSets(v_activeEnergyCarriers, (int)(168 / energyModel.p_timeStep_h));
-*/
/*ALCODEEND*/}
double f_manageChargers()
{/*ALCODESTART::1750258434630*/
-if ( c_chargers.size() > 0 ) { // && v_isActiveCharger ) {
+if ( c_chargers.size() > 0 ) {
switch (p_chargingAttitudeVehicles) {
case V1G:
case MAX_POWER:
@@ -1497,29 +1380,51 @@ EnergyCoop f_addProductionEnergyCarrier(OL_EnergyCarriers EC)
EnergyCoop f_addAssetFlow(OL_AssetFlowCategories AC)
{/*ALCODESTART::1754380684467*/
-DataSet dsAsset = new DataSet( (int)(168 / energyModel.p_timeStep_h) );
-double startTime = v_liveData.dsm_liveDemand_kW.get(OL_EnergyCarriers.ELECTRICITY).getXMin();
-double endTime = v_liveData.dsm_liveDemand_kW.get(OL_EnergyCarriers.ELECTRICITY).getXMax();
-for (double t = startTime; t <= endTime; t += energyModel.p_timeStep_h) {
- dsAsset.add( t, 0);
-}
-v_liveData.dsm_liveAssetFlows_kW.put( AC, dsAsset);
-
-if (AC == OL_AssetFlowCategories.batteriesChargingPower_kW) { // also add batteriesDischarging!
- v_liveAssetsMetaData.activeAssetFlows.add(OL_AssetFlowCategories.batteriesDischargingPower_kW);
- dsAsset = new DataSet( (int)(168 / energyModel.p_timeStep_h) );
+if (!v_liveAssetsMetaData.activeAssetFlows.contains(AC)) {
+ DataSet dsAsset = new DataSet( (int)(168 / energyModel.p_timeStep_h) );
+ double startTime = v_liveData.dsm_liveDemand_kW.get(OL_EnergyCarriers.ELECTRICITY).getXMin();
+ double endTime = v_liveData.dsm_liveDemand_kW.get(OL_EnergyCarriers.ELECTRICITY).getXMax();
for (double t = startTime; t <= endTime; t += energyModel.p_timeStep_h) {
dsAsset.add( t, 0);
}
- v_liveData.dsm_liveAssetFlows_kW.put( OL_AssetFlowCategories.batteriesDischargingPower_kW, dsAsset);
-}
-if (AC == OL_AssetFlowCategories.V2GPower_kW) { // also add evCharging!
- v_liveAssetsMetaData.activeAssetFlows.add(OL_AssetFlowCategories.evChargingPower_kW);
- dsAsset = new DataSet( (int)(168 / energyModel.p_timeStep_h) );
- for (double t = startTime; t <= endTime; t += energyModel.p_timeStep_h) {
- dsAsset.add( t, 0);
+ v_liveData.dsm_liveAssetFlows_kW.put( AC, dsAsset);
+
+ if (AC == OL_AssetFlowCategories.batteriesChargingPower_kW) { // also add batteriesDischarging!
+ v_liveAssetsMetaData.activeAssetFlows.add(OL_AssetFlowCategories.batteriesDischargingPower_kW);
+ dsAsset = new DataSet( (int)(168 / energyModel.p_timeStep_h) );
+ for (double t = startTime; t <= endTime; t += energyModel.p_timeStep_h) {
+ dsAsset.add( t, 0);
+ }
+ v_liveData.dsm_liveAssetFlows_kW.put( OL_AssetFlowCategories.batteriesDischargingPower_kW, dsAsset);
+ }
+ if (AC == OL_AssetFlowCategories.V2GPower_kW && !v_liveAssetsMetaData.activeAssetFlows.contains(OL_AssetFlowCategories.evChargingPower_kW)) { // also add evCharging!
+ v_liveAssetsMetaData.activeAssetFlows.add(OL_AssetFlowCategories.evChargingPower_kW);
+ dsAsset = new DataSet( (int)(168 / energyModel.p_timeStep_h) );
+ for (double t = startTime; t <= endTime; t += energyModel.p_timeStep_h) {
+ dsAsset.add( t, 0);
+ }
+ v_liveData.dsm_liveAssetFlows_kW.put( OL_AssetFlowCategories.evChargingPower_kW, dsAsset);
}
- v_liveData.dsm_liveAssetFlows_kW.put( OL_AssetFlowCategories.evChargingPower_kW, dsAsset);
+
+ //Add asset flow also to aggregators
+ c_parentCoops.forEach(x -> x.f_addAssetFlow(OL_AssetFlowCategories.V2GPower_kW));
+ energyModel.f_addAssetFlow(OL_AssetFlowCategories.V2GPower_kW);
}
/*ALCODEEND*/}
+double f_activateV2GChargingMode()
+{/*ALCODESTART::1754582754934*/
+if(energyModel.b_isInitialized){
+ //Check needed to make sure v2g is displayed correctly in the graphs
+ if(p_chargingAttitudeVehicles == OL_ChargingAttitude.V2G){
+ c_electricVehicles.forEach(ev -> ev.setV2GActive(true));
+ c_chargers.forEach(charger -> charger.setV2GActive(true));
+ f_addAssetFlow(OL_AssetFlowCategories.V2GPower_kW);
+ }
+ else{
+ c_electricVehicles.forEach(ev -> ev.setV2GActive(false));
+ c_chargers.forEach(charger -> charger.setV2GActive(false));
+ }
+}
+/*ALCODEEND*/}
+
diff --git a/_alp/Agents/GridConnection/Code/Functions.xml b/_alp/Agents/GridConnection/Code/Functions.xml
index f9ee7253..1e788c39 100644
--- a/_alp/Agents/GridConnection/Code/Functions.xml
+++ b/_alp/Agents/GridConnection/Code/Functions.xml
@@ -96,23 +96,6 @@
true
-
- VOID
- double
- 1669025846794
-
- true
- 920
- 290
-
- 10
- 0
-
- false
- true
- true
-
-
VOID
double
@@ -619,7 +602,7 @@
1753099764237
920
- 400
+ 290
10
0
@@ -699,8 +682,8 @@
1754393382442
- 1430
- 40
+ 580
+ 100
10
0
@@ -782,4 +765,20 @@
+
+ VOID
+ double
+ 1754582754934
+
+ 290
+ 140
+
+ 10
+ 0
+
+ false
+ true
+ true
+
+
diff --git a/_alp/Agents/GridConnection/Variables.xml b/_alp/Agents/GridConnection/Variables.xml
index e6e28bfa..9359f3d9 100644
--- a/_alp/Agents/GridConnection/Variables.xml
+++ b/_alp/Agents/GridConnection/Variables.xml
@@ -607,29 +607,6 @@
-
- 1722584654288
-
- true
- 370
- 380
-
- 10
- 0
-
- false
- true
- true
-
-
-
-
-
-
-
1725968910310
@@ -1032,29 +1009,6 @@
-
- 1753110629668
-
- true
- 570
- 840
-
- 10
- 0
-
- false
- true
- true
-
-
-
-
-
-
-
1753970741239
@@ -1278,6 +1232,7 @@
+ f_activateV2GChargingMode()
1668693393496
TEXT_BOX
@@ -1291,7 +1246,7 @@
1668695364192
600
- 450
+ 490
10
0
@@ -1344,7 +1299,7 @@
1676449763319
600
- 430
+ 470
10
0
@@ -1369,7 +1324,7 @@
1684919785784
600
- 490
+ 530
10
0
@@ -1394,7 +1349,7 @@
1692878211840
620
- 270
+ 290
10
0
@@ -1444,7 +1399,7 @@
1692973005119
621
- 288
+ 308
10
0
@@ -1775,8 +1730,8 @@
1753099355801
- 580
- 100
+ 600
+ 120
10
0
@@ -1801,7 +1756,7 @@
1752752664510
620
- 470
+ 510
10
0
@@ -1854,7 +1809,7 @@
1659962626903
580
- 170
+ 190
10
0
@@ -1872,7 +1827,7 @@
1659962626907
600
- 310
+ 330
10
0
@@ -1890,7 +1845,7 @@
1659962626909
600
- 210
+ 230
10
0
@@ -1908,7 +1863,7 @@
1659962626911
600
- 230
+ 250
10
0
@@ -1926,7 +1881,7 @@
1659962626913
600
- 250
+ 270
10
0
@@ -1944,7 +1899,7 @@
1667746389220
600
- 330
+ 350
10
0
@@ -1961,8 +1916,8 @@
1668359033654
- 620
- 370
+ 640
+ 410
10
0
@@ -1980,7 +1935,7 @@
1669115948280
620
- 390
+ 430
10
0
@@ -1998,7 +1953,7 @@
1692864624612
620
- 350
+ 370
10
0
@@ -2016,7 +1971,7 @@
1700044359363
600
- 188
+ 208
10
0
@@ -2052,7 +2007,7 @@
1711012701187
620
- 410
+ 450
10
0
@@ -2278,7 +2233,7 @@
1750258408126
600
- 511
+ 551
10
0
@@ -2316,7 +2271,7 @@
580
- 120
+ 140
10
0
@@ -2330,4 +2285,22 @@
String
+
+ 1754581015887
+
+ 620
+ 390
+
+ 10
+ 0
+
+ false
+ true
+ true
+
+ ArrayList
+ J_EAEV
+ String
+
+
diff --git a/_alp/Classes/Class.J_ChargingSession.java b/_alp/Classes/Class.J_ChargingSession.java
index 8d026c93..0d74d2af 100644
--- a/_alp/Classes/Class.J_ChargingSession.java
+++ b/_alp/Classes/Class.J_ChargingSession.java
@@ -121,6 +121,7 @@ public void requestV1G(int timeStepsV1G) {
V1GRemainingTimesteps = timeStepsV1G;
}
+
public double getShiftedLoadV1GCurrentTimestep() {
return shiftedLoadV1GThisTimestep;
}
diff --git a/_alp/Classes/Class.J_EACharger.java b/_alp/Classes/Class.J_EACharger.java
index 155fdc61..97acdc3e 100644
--- a/_alp/Classes/Class.J_EACharger.java
+++ b/_alp/Classes/Class.J_EACharger.java
@@ -8,6 +8,7 @@ public class J_EACharger extends zero_engine.J_EA implements Serializable {
public List chargerProfile;
public boolean V1GCapable;
public boolean V2GCapable;
+ private boolean V2GActive = false;
private int currentChargingSessionIndexSocket1;
private J_ChargingSession currentChargingSessionSocket1;
@@ -39,7 +40,7 @@ public J_EACharger(Agent parentAgent, double electricCapacity_kW, double timeste
this.V2GCapable = V2GCapable;
this.activeProductionEnergyCarriers.add(OL_EnergyCarriers.ELECTRICITY);
this.activeConsumptionEnergyCarriers.add(OL_EnergyCarriers.ELECTRICITY);
- if(V2GCapable) {
+ if(V2GCapable && this.V2GActive) {
this.assetFlowCategory = OL_AssetFlowCategories.V2GPower_kW;
} else {
this.assetFlowCategory = OL_AssetFlowCategories.evChargingPower_kW;
@@ -49,7 +50,7 @@ public J_EACharger(Agent parentAgent, double electricCapacity_kW, double timeste
public void f_updateAllFlows( double t_h, boolean doV1G, boolean doV2G) {
// Powerfraction is calculated below, argument is the current time (energyModel.t_h)
-
+
// Check if the charger is capable of smart charging
doV1G = doV1G && this.V1GCapable;
doV2G = doV2G && this.V2GCapable;
@@ -92,8 +93,23 @@ public void operate(double ratioOfCapacity) {
flowsMap.put(OL_EnergyCarriers.ELECTRICITY, electricityConsumption_kW - electricityProduction_kW);
// Split charging and discharing power 'at the source'!
+
assetFlowsMap.put(OL_AssetFlowCategories.evChargingPower_kW, electricityConsumption_kW);
- assetFlowsMap.put(OL_AssetFlowCategories.V2GPower_kW, electricityProduction_kW);
+ if(V2GActive) {
+ assetFlowsMap.put(OL_AssetFlowCategories.V2GPower_kW, electricityProduction_kW);
+ }
+
+ if (charge_kW > 0) { // charging
+ assetFlowsMap.put(OL_AssetFlowCategories.evChargingPower_kW, electricityConsumption_kW);
+ } else if(charge_kW < 0){
+ if(this.V2GCapable && this.V2GActive) {
+ assetFlowsMap.put(OL_AssetFlowCategories.V2GPower_kW, electricityProduction_kW);
+ }
+ else {
+ throw new RuntimeException("Trying to discharge into a charger, that does not have the capability or where v2g is not activated!");
+ }
+ }
+
}
private void manageSocket1() {
@@ -193,6 +209,16 @@ public void restoreStates() {
totalShiftedLoadV2G_kWh = totalShiftedLoadV2GStored_kWh;
}
+ public void setV2GActive(boolean activateV2G) {
+ this.V2GActive = activateV2G;
+ if(this.V2GCapable && activateV2G) {
+ this.assetFlowCategory = OL_AssetFlowCategories.V2GPower_kW;
+ }
+ else {
+ this.assetFlowCategory = OL_AssetFlowCategories.evChargingPower_kW;
+ }
+ }
+
@Override
public String toString() {
return "Power: " + getLastFlows().get(OL_EnergyCarriers.ELECTRICITY) + " kW, capacity: " + capacityElectric_kW + " kW" ;
diff --git a/_alp/Classes/Class.J_EAEV.java b/_alp/Classes/Class.J_EAEV.java
index bfec036c..a327a48d 100644
--- a/_alp/Classes/Class.J_EAEV.java
+++ b/_alp/Classes/Class.J_EAEV.java
@@ -14,6 +14,10 @@ public class J_EAEV extends J_EAVehicle implements Serializable {
protected double capacityElectric_kW;
private double storageCapacity_kWh;
+ private boolean V2GCapable = true; // For now default true: Add to constructor, where constructor calls: setV2GCapable(boolean isV2GCapable) to adjust min rato of capacity accordingly
+ private boolean V2GActive = false;
+ private double minimumRatioOfChargeCapacity_r = -1; // If Negative, it also allowes discharging (V2G)
+
// Should this be in here?
public double energyNeedForNextTrip_kWh;
public OL_EVChargingNeed chargingNeed;
@@ -51,17 +55,24 @@ public J_EAEV(Agent parentAgent, double capacityElectricity_kW, double storageCa
}
this.activeProductionEnergyCarriers.add(this.storageMedium);
this.activeConsumptionEnergyCarriers.add(this.storageMedium);
- this.assetFlowCategory = OL_AssetFlowCategories.evChargingPower_kW;
+
+ if(V2GCapable && this.V2GActive) {
+ this.assetFlowCategory = OL_AssetFlowCategories.V2GPower_kW;
+ } else {
+ this.assetFlowCategory = OL_AssetFlowCategories.evChargingPower_kW;
+ }
+
registerEnergyAsset();
}
@Override
public void operate(double ratioOfChargeCapacity_r) {
//traceln( "ratio: " + ratioOfChargeCapacity_r);
-
- double chargeSetpoint_kW = min(1,max(-1,ratioOfChargeCapacity_r)) * (capacityElectric_kW * vehicleScaling); // capped between -1 and 1. (does this already happen in f_updateAllFlows()?
+
+
+ double chargeSetpoint_kW = min(1,max(this.minimumRatioOfChargeCapacity_r ,ratioOfChargeCapacity_r)) * (capacityElectric_kW * vehicleScaling); // capped between -1 and 1. (does this already happen in f_updateAllFlows()?
double chargePower_kW = max(min(chargeSetpoint_kW, (1 - stateOfCharge_fr) * storageCapacity_kWh * vehicleScaling / timestep_h), -stateOfCharge_fr * storageCapacity_kWh * vehicleScaling / timestep_h); // Limit charge power to stay within SoC 0-100
-
+
/*double deltaEnergy_kWh; // to check the request with the energy currently in storage
deltaEnergy_kWh = ( ratioOfChargeCapacity_r * (capacityElectric_kW * vehicleScaling) * timestep_h ) ;
@@ -72,7 +83,6 @@ public void operate(double ratioOfChargeCapacity_r) {
deltaEnergy_kWh = max(deltaEnergy_kWh, -ratioOfChargeCapacity_r * (capacityElectric_kW * vehicleScaling) * timestep_h ); // prevent discharging faster than allowed
deltaEnergy_kWh = min(deltaEnergy_kWh, (1 - stateOfCharge_fr) * (storageCapacity_kWh * vehicleScaling) ); // Prevent overcharge
*/
-
//traceln("state of charge: " + stateOfCharge_fr * storageCapacity_kWh + ", charged: " + discharge_kW / 4+ " kWh, charging power kW: " + discharge_kW);
double electricityProduction_kW = max(-chargePower_kW, 0);
double electricityConsumption_kW = max(chargePower_kW, 0);
@@ -82,10 +92,15 @@ public void operate(double ratioOfChargeCapacity_r) {
flowsMap.put(OL_EnergyCarriers.ELECTRICITY, electricityConsumption_kW - electricityProduction_kW);
// Split charging and discharing power 'at the source'!
- if (chargePower_kW >= 0) { // charging
+ if (chargePower_kW > 0) { // charging
assetFlowsMap.put(OL_AssetFlowCategories.evChargingPower_kW, electricityConsumption_kW);
- } else {
- assetFlowsMap.put(OL_AssetFlowCategories.V2GPower_kW, electricityProduction_kW);
+ } else if(chargePower_kW < 0){
+ if(this.V2GCapable && this.V2GActive) {
+ assetFlowsMap.put(OL_AssetFlowCategories.V2GPower_kW, electricityProduction_kW);
+ }
+ else {
+ throw new RuntimeException("Trying to discharge an EV, that does not have the capability or where v2g is not activated!");
+ }
}
}
@@ -196,6 +211,31 @@ public double getChargingTimeToFull_MIN() {
public double getEnergyChargedOutsideModelArea_kWh() {
return energyChargedOutsideModelArea_kWh;
}
+
+ public void setV2GCapable(boolean isV2GCapable) {
+ this.V2GCapable = isV2GCapable;
+ if(isV2GCapable) {
+ minimumRatioOfChargeCapacity_r = -1;
+ }
+ else {
+ minimumRatioOfChargeCapacity_r = 0;
+ }
+ }
+
+ public boolean getV2GActive() {
+ return this.V2GActive;
+ }
+
+ public void setV2GActive(boolean activateV2G) {
+ this.V2GActive = activateV2G;
+ if(this.V2GCapable && activateV2G) {
+ this.assetFlowCategory = OL_AssetFlowCategories.V2GPower_kW;
+ }
+ else {
+ this.assetFlowCategory = OL_AssetFlowCategories.evChargingPower_kW;
+ }
+ }
+
@Override
public void storeStatesAndReset() {
// Each energy asset that has some states should overwrite this function!