Skip to content
4 changes: 2 additions & 2 deletions _alp/Agents/UI_EnergyHub/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@
if (zero_Interface.p_selectedProjectType == OL_ProjectType.RESIDENTIAL) {
((tabElectricity)uI_Tabs.pop_tabElectricity.get(0)).getGroupElectricityDemandSliders_ResidentialArea().setVisible(true);
((tabHeating)uI_Tabs.pop_tabHeating.get(0)).getGroupHeatDemandSlidersResidentialArea().setVisible(true);
((tabMobility)uI_Tabs.pop_tabMobility.get(0)).getGroupMobilityDemandSliders().setVisible(true);
((tabMobility)uI_Tabs.pop_tabMobility.get(0)).getGr_mobilitySliders_residential().setVisible(true);
}
else {
((tabElectricity)uI_Tabs.pop_tabElectricity.get(0)).getGroupElectricityDemandSliders_Businesspark().setVisible(true);
((tabHeating)uI_Tabs.pop_tabHeating.get(0)).getGroupHeatDemandSlidersCompanies().setVisible(true);
((tabMobility)uI_Tabs.pop_tabMobility.get(0)).getGroupMobilityDemandSliders().setVisible(true);
((tabMobility)uI_Tabs.pop_tabMobility.get(0)).getGr_mobilitySliders_default().setVisible(true);
}

//Initialize slider gcs and set sliders
Expand Down
20 changes: 20 additions & 0 deletions _alp/Agents/UI_Tabs/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,23 @@ List<GCPublicCharger> f_getPausedSliderGridConnections_chargers()
}
/*ALCODEEND*/}

List<GCPublicCharger> f_getAllSliderGridConnections_chargers()
{/*ALCODESTART::1758278620331*/
List<GCPublicCharger> chargerGridConnections = new ArrayList<>();

for(GridConnection GC : v_sliderGridConnections){
if(GC instanceof GCPublicCharger){
chargerGridConnections.add((GCPublicCharger)GC);
}
}
if(v_pausedSliderGridConnections != null){
for(GridConnection GC : v_pausedSliderGridConnections){
if(GC instanceof GCPublicCharger){
chargerGridConnections.add((GCPublicCharger)GC);
}
}
}

return chargerGridConnections;
/*ALCODEEND*/}

16 changes: 16 additions & 0 deletions _alp/Agents/UI_Tabs/Code/Functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,20 @@
<ShowLabel>true</ShowLabel>
<Body xmlns:al="http://anylogic.com"/>
</Function>
<Function AccessType="default" StaticFunction="false">
<ReturnModificator>RETURNS_VALUE</ReturnModificator>
<ReturnType>List&lt;GCPublicCharger&gt;</ReturnType>
<Id>1758278620331</Id>
<Name><![CDATA[f_getAllSliderGridConnections_chargers]]></Name>
<X>540</X>
<Y>330</Y>
<Label>
<X>10</X>
<Y>0</Y>
</Label>
<PublicFlag>false</PublicFlag>
<PresentationFlag>true</PresentationFlag>
<ShowLabel>true</ShowLabel>
<Body xmlns:al="http://anylogic.com"/>
</Function>
</Functions>
13 changes: 7 additions & 6 deletions _alp/Agents/Zero_Interface/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -2343,13 +2343,13 @@ Pair<ShapeEmbeddedObjectPresentation, Point> f_getPresentationPositionIteration(

for (GridConnection gc : energyModel.f_getActiveGridConnections()) {
for (J_EAChargePoint charger : gc.c_chargers) {
if (charger.V1GCapable) {
if (charger.getV1GCapable()) {
c_orderedV1GChargers.add(0, charger);
}
else {
c_orderedV1GChargers.add(charger);
}
if (charger.V2GCapable) {
if (charger.getV2GCapable()) {
c_orderedV2GChargers.add(0, charger);
}
else {
Expand All @@ -2360,13 +2360,13 @@ Pair<ShapeEmbeddedObjectPresentation, Point> f_getPresentationPositionIteration(

for (GridConnection gc : energyModel.f_getPausedGridConnections()) {
for (J_EAChargePoint charger : gc.c_chargers) {
if (charger.V1GCapable) {
if (charger.getV1GCapable()) {
c_inactiveV1GChargers.add(0, charger);
}
else {
c_inactiveV1GChargers.add(charger);
}
if (charger.V2GCapable) {
if (charger.getV2GCapable()) {
c_inactiveV2GChargers.add(0, charger);
}
else {
Expand Down Expand Up @@ -3152,19 +3152,20 @@ ArrayList<GridConnection> f_updateJ_EAlistAfterDeserialisation(ArrayList<J_EA> E

uI_Tabs.add_pop_tabElectricity();
uI_Tabs.add_pop_tabHeating();
uI_Tabs.add_pop_tabMobility();

// Group visibilities
// When using an extension of a generic tab don't forget to typecast it!
if (p_selectedProjectType == OL_ProjectType.RESIDENTIAL) {
((tabElectricity)uI_Tabs.pop_tabElectricity.get(0)).getGroupElectricityDemandSliders_ResidentialArea().setVisible(true);
((tabHeating)uI_Tabs.pop_tabHeating.get(0)).getGroupHeatDemandSlidersResidentialArea().setVisible(true);
((tabMobility)uI_Tabs.pop_tabMobility.get(0)).getGr_mobilitySliders_residential().setVisible(true);
}
else {
uI_Tabs.add_pop_tabMobility();
uI_Tabs.add_pop_tabEHub();
((tabElectricity)uI_Tabs.pop_tabElectricity.get(0)).getGroupElectricityDemandSliders_Businesspark().setVisible(true);
((tabHeating)uI_Tabs.pop_tabHeating.get(0)).getGroupHeatDemandSlidersCompanies().setVisible(true);
((tabMobility)uI_Tabs.pop_tabMobility.get(0)).getGroupMobilityDemandSliders().setVisible(true);
((tabMobility)uI_Tabs.pop_tabMobility.get(0)).getGr_mobilitySliders_default().setVisible(true);
((tabEHub)uI_Tabs.pop_tabEHub.get(0)).getGroupHubSliders().setVisible(true);
}
/*ALCODEEND*/}
Expand Down
10 changes: 10 additions & 0 deletions _alp/Agents/Zero_Loader/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -3107,6 +3107,16 @@ J_ChargingSession f_createChargingSession(String chargingSessionData)
double chargingPower_kW = Double.parseDouble(chargingSessionInfo[5]);
int socket = Integer.parseInt(chargingSessionInfo[6]);

/*
if(chargingDemand_kWh > (chargingPower_kW * (endIndex - startIndex)*0.25)){
chargingDemand_kWh = (chargingPower_kW * (endIndex - startIndex)*0.25); //Cap this to prevent errors with data
}*/
chargingDemand_kWh = min(chargingPower_kW * (endIndex - startIndex) * 0.25, chargingDemand_kWh);
double avgPower_kW = chargingDemand_kWh / ((endIndex - startIndex)*0.25);
if (avgPower_kW > 20.0) {
traceln("Session charging power (data): %s kW, session average charging power: %s kW, duration %s h", chargingPower_kW, avgPower_kW, (endIndex - startIndex)*0.25);
}

return new J_ChargingSession(startIndex, endIndex, chargingDemand_kWh, batteryCap_kWh, chargingPower_kW, socket, 0.25);
/*ALCODEEND*/}

Expand Down
199 changes: 0 additions & 199 deletions _alp/Agents/tabElectricity/Code/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -447,173 +447,11 @@ else if ( gc instanceof GCUtility ) {
zero_Interface.f_resetSettings();
/*ALCODEEND*/}

double f_setPublicChargingStations(double publicChargers_pct)
{/*ALCODESTART::1750063382330*/
int totalNbChargers = zero_Interface.c_orderedPublicChargers.size();
int currentNbChargers = count(zero_Interface.c_orderedPublicChargers, x -> x.v_isActive);
int nbChargersGoal = roundToInt(publicChargers_pct / 100 * totalNbChargers) ;

while ( currentNbChargers > nbChargersGoal ) {
GCPublicCharger gc = findFirst(zero_Interface.c_orderedPublicChargers, x -> x.v_isActive);
if (gc != null) {
gc.f_setActive(false);
zero_Interface.c_orderedPublicChargers.remove(gc);
zero_Interface.c_orderedPublicChargers.add(0, gc);
currentNbChargers--;

for (J_EADieselVehicle car : zero_Interface.c_mappingOfVehiclesPerCharger.get(gc)) {
car.reRegisterEnergyAsset();
}
}
else {
throw new RuntimeException("Charger slider error: there are not sufficient chargers to remove");
}
}
while ( currentNbChargers < nbChargersGoal){
GCPublicCharger gc = findFirst(zero_Interface.c_orderedPublicChargers, x -> !x.v_isActive);
if (gc != null) {
gc.f_setActive(true);
zero_Interface.c_orderedPublicChargers.remove(gc);
zero_Interface.c_orderedPublicChargers.add(0, gc);
currentNbChargers++;

for (J_EADieselVehicle car : zero_Interface.c_mappingOfVehiclesPerCharger.get(gc)) {
J_ActivityTrackerTrips tripTracker = car.getTripTracker(); //Needed, as triptracker is removed when removeEnergyAsset is called.
car.removeEnergyAsset();
car.setTripTracker(tripTracker);//Re-set the triptracker again, for storing.
}
}
else {
throw new RuntimeException("Charger slider error: there are no more chargers to add");
}
}

//Update variable to change to custom scenario
if(!zero_Interface.b_runningMainInterfaceScenarios){
zero_Interface.b_changeToCustomScenario = true;
}

zero_Interface.f_resetSettings();

/*ALCODEEND*/}

double f_setV1GChargerCapabilities(double goal_pct)
{/*ALCODESTART::1750259219309*/
int totalNbChargers = zero_Interface.c_orderedV1GChargers.size();
int currentNbChargers = count(zero_Interface.c_orderedV1GChargers, x -> x.V1GCapable);
int nbChargersGoal = roundToInt(goal_pct / 100.0 * totalNbChargers);

while (currentNbChargers < nbChargersGoal) {
J_EAChargePoint j_ea = findFirst(zero_Interface.c_orderedV1GChargers, x -> !x.V1GCapable);
j_ea.V1GCapable = true;
currentNbChargers++;
zero_Interface.c_orderedV1GChargers.remove(j_ea);
zero_Interface.c_orderedV1GChargers.add(0, j_ea);

}
while (currentNbChargers > nbChargersGoal) {
J_EAChargePoint j_ea = findFirst(zero_Interface.c_orderedV1GChargers, x -> x.V1GCapable);
j_ea.V1GCapable = false;
currentNbChargers--;
zero_Interface.c_orderedV1GChargers.remove(j_ea);
zero_Interface.c_orderedV1GChargers.add(0, j_ea);
}

// Update variable to change to custom scenario
if(!zero_Interface.b_runningMainInterfaceScenarios){
zero_Interface.b_changeToCustomScenario = true;
}

zero_Interface.f_resetSettings();
/*ALCODEEND*/}

double f_setV2GChargerCapabilities(double goal_pct)
{/*ALCODESTART::1750259468109*/
int totalNbChargers = zero_Interface.c_orderedV2GChargers.size();
int currentNbChargers = count(zero_Interface.c_orderedV2GChargers, x -> x.V2GCapable);
int nbChargersGoal = roundToInt(goal_pct / 100.0 * totalNbChargers);

while (currentNbChargers < nbChargersGoal) {
J_EAChargePoint j_ea = findFirst(zero_Interface.c_orderedV2GChargers, x -> !x.V2GCapable);
j_ea.V2GCapable = true;
currentNbChargers++;
zero_Interface.c_orderedV2GChargers.remove(j_ea);
zero_Interface.c_orderedV2GChargers.add(0, j_ea);

}
while (currentNbChargers > nbChargersGoal) {
J_EAChargePoint j_ea = findFirst(zero_Interface.c_orderedV2GChargers, x -> x.V2GCapable);
j_ea.V2GCapable = false;
currentNbChargers--;
zero_Interface.c_orderedV2GChargers.remove(j_ea);
zero_Interface.c_orderedV2GChargers.add(0, j_ea);
}

// Update variable to change to custom scenario
if(!zero_Interface.b_runningMainInterfaceScenarios){
zero_Interface.b_changeToCustomScenario = true;
}

zero_Interface.f_resetSettings();
/*ALCODEEND*/}

double f_setDemandIncrease(List<GridConnection> gcList,double demandReduction_pct)
{/*ALCODESTART::1750326729005*/
f_setDemandReduction(gcList, -demandReduction_pct);
/*ALCODEEND*/}

double f_setVehiclesPrivateParking(List<GCHouse> gcListHouses,double privateParkingEV_pct)
{/*ALCODESTART::1750328750011*/
List<J_EAVehicle> gcListOrderedVehiclesPrivateParking = findAll( zero_Interface.c_orderedVehiclesPrivateParking, h -> gcListHouses.contains(h.getParentAgent()));

int nbOfPrivateParkedEV = (int)sum(findAll(gcListHouses, gc -> gc.p_eigenOprit), x -> x.c_electricVehicles.size());
int desiredNbOfPrivateParkedEV = roundToInt(privateParkingEV_pct / 100 * gcListOrderedVehiclesPrivateParking.size());


// we scale the consumption instead of getting the diesel/EV parameter from avgc data to represent the 'size' of the car
double ratioEVToDieselConsumption = zero_Interface.energyModel.avgc_data.p_avgEVEnergyConsumptionCar_kWhpkm / zero_Interface.energyModel.avgc_data.p_avgDieselConsumptionCar_kWhpkm;

while ( nbOfPrivateParkedEV > desiredNbOfPrivateParkedEV){
J_EAVehicle j_ea = findFirst( gcListOrderedVehiclesPrivateParking, h -> h instanceof J_EAEV);
if (j_ea.vehicleScaling != 1) {
throw new RuntimeException("f_setVehiclesPrivateParking does not work with vehicles that have a vehicleScaling other than 1");
}
J_ActivityTrackerTrips triptracker = j_ea.tripTracker;
double energyConsumption_kWhpkm = j_ea.getEnergyConsumption_kWhpkm() / ratioEVToDieselConsumption;
j_ea.removeEnergyAsset();
gcListOrderedVehiclesPrivateParking.remove(j_ea);
zero_Interface.c_orderedVehiclesPrivateParking.remove(j_ea);
J_EADieselVehicle dieselCar = new J_EADieselVehicle(j_ea.getParentAgent(), energyConsumption_kWhpkm, zero_Interface.energyModel.p_timeStep_h, 1, OL_EnergyAssetType.DIESEL_VEHICLE, triptracker);
gcListOrderedVehiclesPrivateParking.add(dieselCar);
zero_Interface.c_orderedVehiclesPrivateParking.add(dieselCar);
nbOfPrivateParkedEV --;
}
while ( nbOfPrivateParkedEV < desiredNbOfPrivateParkedEV){
J_EAVehicle j_ea = findFirst( gcListOrderedVehiclesPrivateParking, h -> h instanceof J_EADieselVehicle);
if (j_ea.vehicleScaling != 1) {
throw new RuntimeException("f_setVehiclesPrivateParking does not work with vehicles that have a vehicleScaling other than 1");
}
J_ActivityTrackerTrips triptracker = j_ea.tripTracker;
double energyConsumption_kWhpkm = j_ea.getEnergyConsumption_kWhpkm() * ratioEVToDieselConsumption;
j_ea.removeEnergyAsset();
gcListOrderedVehiclesPrivateParking.remove(j_ea);
zero_Interface.c_orderedVehiclesPrivateParking.remove(j_ea);
double capacityElectricity_kW = randomTrue(0.6) ? randomTrue(0.4) ? 3.2 : 5.6 : 11.0;
double storageCapacity_kWh = uniform_discr(65,90);
J_EAEV ev = new J_EAEV(j_ea.getParentAgent(), capacityElectricity_kW, storageCapacity_kWh, 1, zero_Interface.energyModel.p_timeStep_h, energyConsumption_kWhpkm, 1, OL_EnergyAssetType.ELECTRIC_VEHICLE, triptracker);
gcListOrderedVehiclesPrivateParking.add(ev);
zero_Interface.c_orderedVehiclesPrivateParking.add(ev);
nbOfPrivateParkedEV++;
}

//Update variable to change to custom scenario
if(!zero_Interface.b_runningMainInterfaceScenarios){
zero_Interface.b_changeToCustomScenario = true;
}

zero_Interface.f_resetSettings();
/*ALCODEEND*/}

double f_updateSliders_Electricity()
{/*ALCODESTART::1754926103683*/
if(gr_electricitySliders_default.isVisible()){
Expand Down Expand Up @@ -726,22 +564,16 @@ else if(productionGC.v_liveAssetsMetaData.activeAssetFlows.contains(OL_AssetFlow
double f_updateElectricitySliders_residential()
{/*ALCODESTART::1754926103687*/
List<GCHouse> houseGridConnections = new ArrayList<>();
List<GCPublicCharger> chargerGridConnections = new ArrayList<>();
List<GCGridBattery> gridBatteryGridConnections = new ArrayList<>();

for (GridConnection GC : findAll(uI_Tabs.f_getSliderGridConnections_all(), gc -> gc.v_isActive)) {
if(GC instanceof GCHouse){
houseGridConnections.add((GCHouse)GC);
}
else if(GC instanceof GCPublicCharger){
chargerGridConnections.add((GCPublicCharger)GC);
}
else if(GC instanceof GCGridBattery){
gridBatteryGridConnections.add((GCGridBattery)GC);
}
}
chargerGridConnections.addAll(uI_Tabs.f_getPausedSliderGridConnections_chargers());


int nbHouses = houseGridConnections.size();
int nbHousesWithPV = count(houseGridConnections, x -> x.v_liveAssetsMetaData.activeAssetFlows.contains(OL_AssetFlowCategories.pvProductionElectric_kW));
Expand Down Expand Up @@ -782,37 +614,6 @@ else if(GC instanceof GCGridBattery){
sl_electricityDemandIncreaseResidentialArea_pct.setValue(roundToInt(electricityDemandIncrease_pct), false);


//Private EV
if (zero_Interface.c_orderedVehiclesPrivateParking.size() > 0) {
int nbPrivateEVs = count(zero_Interface.c_orderedVehiclesPrivateParking, x -> x instanceof J_EAEV);
double privateEVs_pct = 100.0 * nbPrivateEVs / zero_Interface.c_orderedVehiclesPrivateParking.size();
sl_privateEVsResidentialArea_pct.setValue(roundToInt(privateEVs_pct), false);
}
else{
sl_privateEVsResidentialArea_pct.setEnabled(false);
}


//Chargers
int nbPublicChargers = chargerGridConnections.size();
if(nbPublicChargers > 0 ){
int nbActivePublicChargers = count(chargerGridConnections, x -> x.v_isActive);
double activePublicChargers_pct = 100.0 * nbActivePublicChargers / nbPublicChargers;
sl_publicChargersResidentialArea_pct.setValue(activePublicChargers_pct, false);

int nbV1GChargers = count(zero_Interface.c_orderedV1GChargers, x -> chargerGridConnections.contains(x) && x.V1GCapable);
int nbV2GChargers =count(zero_Interface.c_orderedV2GChargers, x -> chargerGridConnections.contains(x) && x.V2GCapable);
double V1G_pct = 100.0 * nbV1GChargers / nbPublicChargers;
double V2G_pct = 100.0 * nbV2GChargers / nbPublicChargers;
sl_chargersThatSupportV1G_pct.setValue(V1G_pct, false);
sl_chargersThatSupportV2G_pct.setValue(V2G_pct, false);
}
else{
sl_publicChargersResidentialArea_pct.setEnabled(false);
sl_chargersThatSupportV1G_pct.setEnabled(false);
sl_chargersThatSupportV2G_pct.setEnabled(false);
}

//Gridbatteries
double averageNeighbourhoodBatterySize_kWh = 0;
for (GCGridBattery gc : gridBatteryGridConnections) {
Expand Down
Loading