Added cost calculation. It works pretty good but not 100% accurate and specific to my setup.
This commit is contained in:
@@ -12,8 +12,6 @@ namespace BattSim.Models
|
|||||||
public SimulatedBatteryEnergyData(SimulatedBatteryEnergyData simulatedBatteryEnergyData) : base(simulatedBatteryEnergyData)
|
public SimulatedBatteryEnergyData(SimulatedBatteryEnergyData simulatedBatteryEnergyData) : base(simulatedBatteryEnergyData)
|
||||||
{
|
{
|
||||||
BatteryCharge = simulatedBatteryEnergyData.BatteryCharge;
|
BatteryCharge = simulatedBatteryEnergyData.BatteryCharge;
|
||||||
SimulatedConsumption = simulatedBatteryEnergyData.SimulatedConsumption;
|
|
||||||
SimulatedProduction = simulatedBatteryEnergyData.SimulatedProduction;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,16 +103,16 @@
|
|||||||
@if (SimulationDataDaily.Length != 0)
|
@if (SimulationDataDaily.Length != 0)
|
||||||
{
|
{
|
||||||
<RadzenChart>
|
<RadzenChart>
|
||||||
<RadzenAreaSeries Smooth=true Data="@SimulationDataDaily" CategoryProperty="Time" Title="Consumption" ValueProperty="Consumption">
|
<RadzenAreaSeries Smooth=true Data="@FluviusDataDaily" CategoryProperty="Time" Title="Consumption" ValueProperty="Consumption">
|
||||||
<RadzenChartTooltipOptions Visible="true"/>
|
<RadzenChartTooltipOptions Visible="true"/>
|
||||||
</RadzenAreaSeries>
|
</RadzenAreaSeries>
|
||||||
<RadzenAreaSeries Smooth=true Data="@SimulationDataDaily" CategoryProperty="Time" Title="Production" ValueProperty="Production">
|
<RadzenAreaSeries Smooth=true Data="@FluviusDataDaily" CategoryProperty="Time" Title="Production" ValueProperty="Production">
|
||||||
<RadzenChartTooltipOptions Visible="true"/>
|
<RadzenChartTooltipOptions Visible="true"/>
|
||||||
</RadzenAreaSeries>
|
</RadzenAreaSeries>
|
||||||
<RadzenAreaSeries Smooth=true Data="@SimulationDataDaily" CategoryProperty="Time" Title="SimulatedConsumption" ValueProperty="SimulatedConsumption">
|
<RadzenAreaSeries Smooth=true Data="@SimulationDataDaily" CategoryProperty="Time" Title="SimulatedConsumption" ValueProperty="Consumption">
|
||||||
<RadzenChartTooltipOptions Visible="true"/>
|
<RadzenChartTooltipOptions Visible="true"/>
|
||||||
</RadzenAreaSeries>
|
</RadzenAreaSeries>
|
||||||
<RadzenAreaSeries Smooth=true Data="@SimulationDataDaily" CategoryProperty="Time" Title="SimulatedProduction" ValueProperty="SimulatedProduction">
|
<RadzenAreaSeries Smooth=true Data="@SimulationDataDaily" CategoryProperty="Time" Title="SimulatedProduction" ValueProperty="Production">
|
||||||
<RadzenChartTooltipOptions Visible="true"/>
|
<RadzenChartTooltipOptions Visible="true"/>
|
||||||
</RadzenAreaSeries>
|
</RadzenAreaSeries>
|
||||||
<RadzenAreaSeries Smooth=true Data="@SimulationDataDaily" CategoryProperty="Time" Title="BatteryCharge" ValueProperty="BatteryCharge">
|
<RadzenAreaSeries Smooth=true Data="@SimulationDataDaily" CategoryProperty="Time" Title="BatteryCharge" ValueProperty="BatteryCharge">
|
||||||
@@ -149,4 +149,88 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<h2>Calculate Cost</h2>
|
<h2>Bereken kosten</h2>
|
||||||
|
<div>
|
||||||
|
<p>
|
||||||
|
Uitleg
|
||||||
|
</p>
|
||||||
|
<p>Vaste Vergoeding</p>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<p>Vaste vergoeding: <InputNumber @bind-value="calculator.BasePayment" /> €/jaar</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<p>Energiekosten</p>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<p>Energiekost: <InputNumber @bind-value="calculator.EnergyCost" /> c€/kWh</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<p>Terugleveringsvergoeding: <InputNumber @bind-value="calculator.ReturnCost" /> c€/kWh</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<p>Heffingen Groene Stroom</p>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<p>Groene stroomcertificaten: <InputNumber @bind-value="calculator.GreenCertificateCost" /> c€/kWh</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<p>Warmtekracht certificaten: <InputNumber @bind-value="calculator.HeatingCertificateCost" /> c€/kWh</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
<p>Net- en distributiekosten</p>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<p>Tarief databeheer: <InputNumber @bind-value="calculator.DataManagementCost" /> €/jaar</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<p>Capaciteitstarief: <InputNumber @bind-value="calculator.CapacityCost" /> €/kWh/jaar</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<p>Afnametarief: <InputNumber @bind-value="calculator.UsageTariff" /> c€/kWh</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
<p>Heffingen en Toeslagen</p>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<p>Energiebijdrage: <InputNumber @bind-value="calculator.EnergyContribution" /> c€/kWh</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<p>Bijzondere accijns elektriciteit: <InputNumber @bind-value="calculator.SpecialTariffs" /> c€/kWh</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<p>Vlaamse energieheffing elektriciteit: <InputNumber @bind-value="calculator.FlemishEnergyTariff" /> €/jaar</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<Button @onclick="Calculate">Calculate</Button>
|
||||||
|
@if (_isCalculating) { <p>Calculating...</p> }
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<p>The original price is: €@normalCost</p>
|
||||||
|
<p>The simulated price is: €@simulatedCost</p>
|
||||||
|
<p>The costsaving is: €@(normalCost - simulatedCost)</p>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
EnergyCostCalculator calculator = new();
|
||||||
|
double normalCost = 0.0;
|
||||||
|
double simulatedCost = 0.0;
|
||||||
|
bool _isCalculating = false;
|
||||||
|
|
||||||
|
private void Calculate()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Calculating...");
|
||||||
|
_isCalculating = true;
|
||||||
|
normalCost = calculator.CalculateCostOfEnergyUsage(FluviusDataRaw);
|
||||||
|
simulatedCost = calculator.CalculateCostOfEnergyUsage(SimulationData);
|
||||||
|
_isCalculating = false;
|
||||||
|
Console.WriteLine("Done Calculating!");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,6 @@ using Radzen;
|
|||||||
using Microsoft.AspNetCore.Components.Web;
|
using Microsoft.AspNetCore.Components.Web;
|
||||||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
||||||
|
|
||||||
// Setup Frontend
|
|
||||||
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
||||||
builder.RootComponents.Add<App>("#app");
|
builder.RootComponents.Add<App>("#app");
|
||||||
builder.RootComponents.Add<HeadOutlet>("head::after");
|
builder.RootComponents.Add<HeadOutlet>("head::after");
|
||||||
|
|||||||
@@ -17,14 +17,14 @@ namespace BattSim.Services
|
|||||||
// Simulate charging the battery based on production
|
// Simulate charging the battery based on production
|
||||||
double excessProduction = batteryCharge + e.Production - batteryCapacity;
|
double excessProduction = batteryCharge + e.Production - batteryCapacity;
|
||||||
batteryCharge = double.Min(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
|
// Simulate discharging the battery based on consumption
|
||||||
double availableEnergy = batteryCharge * efficiency;
|
double availableEnergy = batteryCharge * efficiency;
|
||||||
double deficit = e.Consumption - availableEnergy;
|
double deficit = e.Consumption - availableEnergy;
|
||||||
double energyDrawn = Math.Min(e.Consumption, availableEnergy);
|
double energyDrawn = Math.Min(e.Consumption, availableEnergy);
|
||||||
batteryCharge = batteryCharge - (energyDrawn / efficiency); // Adjust for loss
|
batteryCharge = batteryCharge - (energyDrawn / efficiency); // Adjust for loss
|
||||||
simulatedBatteryEnergyData.SimulatedConsumption = Math.Max(deficit, 0);
|
simulatedBatteryEnergyData.Consumption = Math.Max(deficit, 0);
|
||||||
|
|
||||||
// Register the current charge
|
// Register the current charge
|
||||||
simulatedBatteryEnergyData.BatteryCharge = batteryCharge;
|
simulatedBatteryEnergyData.BatteryCharge = batteryCharge;
|
||||||
@@ -51,8 +51,6 @@ namespace BattSim.Services
|
|||||||
// If key exists, aggregate the values
|
// If key exists, aggregate the values
|
||||||
existing.Consumption += simulationPoint.Consumption;
|
existing.Consumption += simulationPoint.Consumption;
|
||||||
existing.Production += simulationPoint.Production;
|
existing.Production += simulationPoint.Production;
|
||||||
existing.SimulatedConsumption += simulationPoint.SimulatedConsumption;
|
|
||||||
existing.SimulatedProduction += simulationPoint.SimulatedProduction;
|
|
||||||
existing.BatteryCharge = double.Max(existing.BatteryCharge, simulationPoint.BatteryCharge);
|
existing.BatteryCharge = double.Max(existing.BatteryCharge, simulationPoint.BatteryCharge);
|
||||||
return existing;
|
return existing;
|
||||||
}
|
}
|
||||||
|
|||||||
85
Services/EnergyCostCalculator.cs
Normal file
85
Services/EnergyCostCalculator.cs
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection.PortableExecutable;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using BattSim.Models;
|
||||||
|
using Microsoft.AspNetCore.Components.Forms;
|
||||||
|
|
||||||
|
namespace BattSim.Services
|
||||||
|
{
|
||||||
|
public class EnergyCostCalculator
|
||||||
|
{
|
||||||
|
public double BasePayment { get; set; } = 35;
|
||||||
|
public double EnergyCost { get; set; } = 0.1364;
|
||||||
|
public double ReturnCost { get; set; } = 0.0266;
|
||||||
|
public double GreenCertificateCost { get; set; } = 0.01172;
|
||||||
|
public double HeatingCertificateCost { get; set; } = 0.00415;
|
||||||
|
public double DataManagementCost { get; set; } = 18.77;
|
||||||
|
public double CapacityCost { get; set; } = 58.20;
|
||||||
|
public double UsageTariff { get; set; } = 0.0637;
|
||||||
|
public double EnergyContribution { get; set; } = 0.00205;
|
||||||
|
public double SpecialTariffs { get; set; } = 0.0502;
|
||||||
|
public double FlemishEnergyTariff { get; set; } = 118.56;
|
||||||
|
|
||||||
|
public double CalculateCostOfEnergyUsage(EnergyData[] energyData, bool print = false) {
|
||||||
|
int amountOfDays = energyData.Last().Time.Subtract(energyData.First().Time).Days;
|
||||||
|
double yearfactor = amountOfDays / 365.0;
|
||||||
|
double energyConsumption = energyData.Sum(e => e.Consumption);
|
||||||
|
double energyProduction = energyData.Sum(e => e.Production);
|
||||||
|
|
||||||
|
double baseCost = yearfactor * BasePayment;
|
||||||
|
if(print) Console.WriteLine($"Base Cost: €{baseCost}");
|
||||||
|
|
||||||
|
double energyCost = energyConsumption * EnergyCost;
|
||||||
|
if (print) Console.WriteLine($"Energy Cost: €{energyCost}");
|
||||||
|
|
||||||
|
double returnCost = energyProduction * ReturnCost;
|
||||||
|
if (print) Console.WriteLine($"Return Cost: € -{returnCost}");
|
||||||
|
|
||||||
|
double greenCertificateCost = energyConsumption * GreenCertificateCost;
|
||||||
|
if (print) Console.WriteLine($"Green Certificate Cost: €{greenCertificateCost}");
|
||||||
|
|
||||||
|
double heatingCertificateCost = energyConsumption * HeatingCertificateCost;
|
||||||
|
if (print) Console.WriteLine($"Heating Certificate Cost: €{heatingCertificateCost}");
|
||||||
|
|
||||||
|
double dataManagmentCost = yearfactor * DataManagementCost;
|
||||||
|
if (print) Console.WriteLine($"Data Management Cost: €{dataManagmentCost}");
|
||||||
|
|
||||||
|
double capacityCost = CalculateYearCapacity(energyData) * yearfactor;
|
||||||
|
if (print) Console.WriteLine($"Capacity Cost: €{capacityCost}");
|
||||||
|
|
||||||
|
double usageTariffCost = energyConsumption * UsageTariff;
|
||||||
|
if (print) Console.WriteLine($"Usage Tariff Cost: €{usageTariffCost}");
|
||||||
|
|
||||||
|
double energyContributionCost = energyConsumption * EnergyContribution;
|
||||||
|
if (print) Console.WriteLine($"Energy Contribution Cost: €{energyContributionCost}");
|
||||||
|
|
||||||
|
double specialTariffsCost = energyConsumption * SpecialTariffs;
|
||||||
|
if (print) Console.WriteLine($"Special Tariffs Cost: €{specialTariffsCost}");
|
||||||
|
|
||||||
|
double flemishEnergyTarif = yearfactor * FlemishEnergyTariff;
|
||||||
|
if (print) Console.WriteLine($"Flemish Tariff: €{specialTariffsCost}");
|
||||||
|
|
||||||
|
return baseCost + energyCost - returnCost + greenCertificateCost + heatingCertificateCost + dataManagmentCost +
|
||||||
|
capacityCost + usageTariffCost + energyContributionCost + specialTariffsCost + flemishEnergyTarif;
|
||||||
|
}
|
||||||
|
private double CalculateYearCapacity(EnergyData[] energyData)
|
||||||
|
{
|
||||||
|
double peakSum = 0;
|
||||||
|
int months = 0;
|
||||||
|
for(int i = 0; i<12; i++)
|
||||||
|
{
|
||||||
|
var monthData = energyData.Where(e => e.Time.Month == i);
|
||||||
|
if (monthData.Count() == 0) continue;
|
||||||
|
peakSum += monthData.Max(e => e.Consumption) * 4;
|
||||||
|
months++;
|
||||||
|
}
|
||||||
|
return (peakSum / months) * CapacityCost;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
19585
data/Verbruikshistoriek_tot_eind_feb.csv
Normal file
19585
data/Verbruikshistoriek_tot_eind_feb.csv
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user