Added cost calculation. It works pretty good but not 100% accurate and specific to my setup.
This commit is contained in:
@@ -17,14 +17,14 @@ namespace BattSim.Services
|
||||
// Simulate charging the battery based on production
|
||||
double excessProduction = batteryCharge + e.Production - batteryCapacity;
|
||||
batteryCharge = double.Min(batteryCharge + e.Production, batteryCapacity);
|
||||
simulatedBatteryEnergyData.SimulatedProduction = double.Max(excessProduction, 0);
|
||||
simulatedBatteryEnergyData.Production = double.Max(excessProduction, 0);
|
||||
|
||||
// Simulate discharging the battery based on consumption
|
||||
double availableEnergy = batteryCharge * efficiency;
|
||||
double deficit = e.Consumption - availableEnergy;
|
||||
double energyDrawn = Math.Min(e.Consumption, availableEnergy);
|
||||
batteryCharge = batteryCharge - (energyDrawn / efficiency); // Adjust for loss
|
||||
simulatedBatteryEnergyData.SimulatedConsumption = Math.Max(deficit, 0);
|
||||
simulatedBatteryEnergyData.Consumption = Math.Max(deficit, 0);
|
||||
|
||||
// Register the current charge
|
||||
simulatedBatteryEnergyData.BatteryCharge = batteryCharge;
|
||||
@@ -51,8 +51,6 @@ namespace BattSim.Services
|
||||
// If key exists, aggregate the values
|
||||
existing.Consumption += simulationPoint.Consumption;
|
||||
existing.Production += simulationPoint.Production;
|
||||
existing.SimulatedConsumption += simulationPoint.SimulatedConsumption;
|
||||
existing.SimulatedProduction += simulationPoint.SimulatedProduction;
|
||||
existing.BatteryCharge = double.Max(existing.BatteryCharge, simulationPoint.BatteryCharge);
|
||||
return existing;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user