Skip to content

Commit

Permalink
limit charged energy by battery capacity ref #14473
Browse files Browse the repository at this point in the history
Signed-off-by: m-kro <m.barthauer@t-online.de>
  • Loading branch information
m-kro committed Mar 6, 2024
1 parent 9a28efd commit 7973c31
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/microsim/devices/MSDevice_Battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,10 @@ bool MSDevice_Battery::notifyMove(SUMOTrafficObject& tObject, double /* oldPos *
myActChargingStation->setChargingVehicle(true);

// Calulate energy charged
myEnergyCharged = myActChargingStation->getChargingPower(myTrackFuel) * myActChargingStation->getEfficency() * TS;
myEnergyCharged = MIN2(myActChargingStation->getChargingPower(myTrackFuel) * myActChargingStation->getEfficency() * TS, getMaximumBatteryCapacity() - getActualBatteryCapacity());

// Update Battery charge
if ((myEnergyCharged + getActualBatteryCapacity()) > getMaximumBatteryCapacity()) {
setActualBatteryCapacity(getMaximumBatteryCapacity());
} else {
setActualBatteryCapacity(getActualBatteryCapacity() + myEnergyCharged);
}
setActualBatteryCapacity(getActualBatteryCapacity() + myEnergyCharged);
}
// add charge value for output to myActChargingStation
myActChargingStation->addChargeValueForOutput(myEnergyCharged, this);
Expand Down

0 comments on commit 7973c31

Please sign in to comment.