Skip to content

Commit

Permalink
Propability->Probability
Browse files Browse the repository at this point in the history
  • Loading branch information
NormannK committed Jan 15, 2025
1 parent 10703bb commit 34bcd48
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 93 deletions.
4 changes: 2 additions & 2 deletions src/akkudoktoreos/devices/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from akkudoktoreos.devices.devicesabc import DevicesBase
from akkudoktoreos.devices.generic import HomeAppliance
from akkudoktoreos.devices.inverter import Inverter
from akkudoktoreos.prediction.interpolator import SelfConsumptionPropabilityInterpolator
from akkudoktoreos.prediction.interpolator import SelfConsumptionProbabilityInterpolator
from akkudoktoreos.utils.datetimeutil import to_duration

logger = get_logger(__name__)
Expand Down Expand Up @@ -164,7 +164,7 @@ def total_losses_wh(self) -> float:
ev: ClassVar[Battery] = Battery(provider_id="GenericBEV")
home_appliance: ClassVar[HomeAppliance] = HomeAppliance(provider_id="GenericDishWasher")
inverter: ClassVar[Inverter] = Inverter(
self_consumption_predictor=SelfConsumptionPropabilityInterpolator,
self_consumption_predictor=SelfConsumptionProbabilityInterpolator,
battery=battery,
provider_id="GenericInverter",
)
Expand Down
4 changes: 2 additions & 2 deletions src/akkudoktoreos/optimization/genetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
)
from akkudoktoreos.devices.generic import HomeAppliance, HomeApplianceParameters
from akkudoktoreos.devices.inverter import Inverter, InverterParameters
from akkudoktoreos.prediction.interpolator import SelfConsumptionPropabilityInterpolator
from akkudoktoreos.prediction.interpolator import SelfConsumptionProbabilityInterpolator
from akkudoktoreos.utils.utils import NumpyEncoder

logger = get_logger(__name__)
Expand Down Expand Up @@ -573,7 +573,7 @@ def optimierung_ems(
)

# 1h Load to Sub 1h Load Distribution -> SelfConsumptionRate
sc = SelfConsumptionPropabilityInterpolator(
sc = SelfConsumptionProbabilityInterpolator(
Path(__file__).parent.resolve() / ".." / "data" / "regular_grid_interpolator.pkl"
)

Expand Down
2 changes: 1 addition & 1 deletion src/akkudoktoreos/prediction/interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from scipy.interpolate import RegularGridInterpolator


class SelfConsumptionPropabilityInterpolator:
class SelfConsumptionProbabilityInterpolator:
def __init__(self, filepath: str | Path):
self.filepath = filepath
# Load the RegularGridInterpolator
Expand Down
100 changes: 50 additions & 50 deletions tests/test_class_ems.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
)
from akkudoktoreos.devices.generic import HomeAppliance, HomeApplianceParameters
from akkudoktoreos.devices.inverter import Inverter, InverterParameters
from akkudoktoreos.prediction.interpolator import SelfConsumptionPropabilityInterpolator
from akkudoktoreos.prediction.interpolator import SelfConsumptionProbabilityInterpolator

start_hour = 1

Expand All @@ -38,7 +38,7 @@ def create_ems_instance(config_eos) -> EnergieManagementSystem:
)

# 1h Load to Sub 1h Load Distribution -> SelfConsumptionRate
sc = SelfConsumptionPropabilityInterpolator(
sc = SelfConsumptionProbabilityInterpolator(
Path(__file__).parent.resolve()
/ ".."
/ "src"
Expand Down Expand Up @@ -283,69 +283,69 @@ def test_simulation(create_ems_instance):
assert SimulationResult(**result) is not None

# Check the length of the main arrays
assert (
len(result["Last_Wh_pro_Stunde"]) == 47
), "The length of 'Last_Wh_pro_Stunde' should be 48."
assert (
len(result["Netzeinspeisung_Wh_pro_Stunde"]) == 47
), "The length of 'Netzeinspeisung_Wh_pro_Stunde' should be 48."
assert (
len(result["Netzbezug_Wh_pro_Stunde"]) == 47
), "The length of 'Netzbezug_Wh_pro_Stunde' should be 48."
assert (
len(result["Kosten_Euro_pro_Stunde"]) == 47
), "The length of 'Kosten_Euro_pro_Stunde' should be 48."
assert (
len(result["akku_soc_pro_stunde"]) == 47
), "The length of 'akku_soc_pro_stunde' should be 48."
assert len(result["Last_Wh_pro_Stunde"]) == 47, (
"The length of 'Last_Wh_pro_Stunde' should be 48."
)
assert len(result["Netzeinspeisung_Wh_pro_Stunde"]) == 47, (
"The length of 'Netzeinspeisung_Wh_pro_Stunde' should be 48."
)
assert len(result["Netzbezug_Wh_pro_Stunde"]) == 47, (
"The length of 'Netzbezug_Wh_pro_Stunde' should be 48."
)
assert len(result["Kosten_Euro_pro_Stunde"]) == 47, (
"The length of 'Kosten_Euro_pro_Stunde' should be 48."
)
assert len(result["akku_soc_pro_stunde"]) == 47, (
"The length of 'akku_soc_pro_stunde' should be 48."
)

# Verify specific values in the 'Last_Wh_pro_Stunde' array
assert (
result["Last_Wh_pro_Stunde"][1] == 1527.13
), "The value at index 1 of 'Last_Wh_pro_Stunde' should be 1527.13."
assert (
result["Last_Wh_pro_Stunde"][2] == 1468.88
), "The value at index 2 of 'Last_Wh_pro_Stunde' should be 1468.88."
assert (
result["Last_Wh_pro_Stunde"][12] == 1132.03
), "The value at index 12 of 'Last_Wh_pro_Stunde' should be 1132.03."
assert result["Last_Wh_pro_Stunde"][1] == 1527.13, (
"The value at index 1 of 'Last_Wh_pro_Stunde' should be 1527.13."
)
assert result["Last_Wh_pro_Stunde"][2] == 1468.88, (
"The value at index 2 of 'Last_Wh_pro_Stunde' should be 1468.88."
)
assert result["Last_Wh_pro_Stunde"][12] == 1132.03, (
"The value at index 12 of 'Last_Wh_pro_Stunde' should be 1132.03."
)

# Verify that the value at index 0 is 'None'
# Check that 'Netzeinspeisung_Wh_pro_Stunde' and 'Netzbezug_Wh_pro_Stunde' are consistent
assert (
result["Netzbezug_Wh_pro_Stunde"][1] == 0
), "The value at index 1 of 'Netzbezug_Wh_pro_Stunde' should be 0."
assert result["Netzbezug_Wh_pro_Stunde"][1] == 0, (
"The value at index 1 of 'Netzbezug_Wh_pro_Stunde' should be 0."
)

# Verify the total balance
assert (
abs(result["Gesamtbilanz_Euro"] - 1.958185274567674) < 1e-5
), "Total balance should be 1.958185274567674."
assert abs(result["Gesamtbilanz_Euro"] - 1.958185274567674) < 1e-5, (
"Total balance should be 1.958185274567674."
)

# Check total revenue and total costs
assert (
abs(result["Gesamteinnahmen_Euro"] - 1.168863124510214) < 1e-5
), "Total revenue should be 1.168863124510214."
assert (
abs(result["Gesamtkosten_Euro"] - 3.127048399077888) < 1e-5
), "Total costs should be 3.127048399077888 ."
assert abs(result["Gesamteinnahmen_Euro"] - 1.168863124510214) < 1e-5, (
"Total revenue should be 1.168863124510214."
)
assert abs(result["Gesamtkosten_Euro"] - 3.127048399077888) < 1e-5, (
"Total costs should be 3.127048399077888 ."
)

# Check the losses
assert (
abs(result["Gesamt_Verluste"] - 2871.5330639359036) < 1e-5
), "Total losses should be 2871.5330639359036 ."
assert abs(result["Gesamt_Verluste"] - 2871.5330639359036) < 1e-5, (
"Total losses should be 2871.5330639359036 ."
)

# Check the values in 'akku_soc_pro_stunde'
assert (
result["akku_soc_pro_stunde"][-1] == 42.151590909090906
), "The value at index -1 of 'akku_soc_pro_stunde' should be 42.151590909090906."
assert (
result["akku_soc_pro_stunde"][1] == 60.08659090909091
), "The value at index 1 of 'akku_soc_pro_stunde' should be 60.08659090909091."
assert result["akku_soc_pro_stunde"][-1] == 42.151590909090906, (
"The value at index -1 of 'akku_soc_pro_stunde' should be 42.151590909090906."
)
assert result["akku_soc_pro_stunde"][1] == 60.08659090909091, (
"The value at index 1 of 'akku_soc_pro_stunde' should be 60.08659090909091."
)

# Check home appliances
assert (
sum(ems.home_appliance.get_load_curve()) == 2000
), "The sum of 'ems.home_appliance.get_load_curve()' should be 2000."
assert sum(ems.home_appliance.get_load_curve()) == 2000, (
"The sum of 'ems.home_appliance.get_load_curve()' should be 2000."
)

assert (
np.nansum(
Expand Down
76 changes: 38 additions & 38 deletions tests/test_class_ems_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)
from akkudoktoreos.devices.generic import HomeAppliance, HomeApplianceParameters
from akkudoktoreos.devices.inverter import Inverter, InverterParameters
from akkudoktoreos.prediction.interpolator import SelfConsumptionPropabilityInterpolator
from akkudoktoreos.prediction.interpolator import SelfConsumptionProbabilityInterpolator

start_hour = 0

Expand All @@ -37,7 +37,7 @@ def create_ems_instance(config_eos) -> EnergieManagementSystem:
)

# 1h Load to Sub 1h Load Distribution -> SelfConsumptionRate
sc = SelfConsumptionPropabilityInterpolator(
sc = SelfConsumptionProbabilityInterpolator(
Path(__file__).parent.resolve()
/ ".."
/ "src"
Expand Down Expand Up @@ -214,43 +214,43 @@ def test_simulation(create_ems_instance):
assert key in result, f"The key '{key}' should be present in the result."

# Check the length of the main arrays
assert (
len(result["Last_Wh_pro_Stunde"]) == 48
), "The length of 'Last_Wh_pro_Stunde' should be 48."
assert (
len(result["Netzeinspeisung_Wh_pro_Stunde"]) == 48
), "The length of 'Netzeinspeisung_Wh_pro_Stunde' should be 48."
assert (
len(result["Netzbezug_Wh_pro_Stunde"]) == 48
), "The length of 'Netzbezug_Wh_pro_Stunde' should be 48."
assert (
len(result["Kosten_Euro_pro_Stunde"]) == 48
), "The length of 'Kosten_Euro_pro_Stunde' should be 48."
assert (
len(result["akku_soc_pro_stunde"]) == 48
), "The length of 'akku_soc_pro_stunde' should be 48."
assert len(result["Last_Wh_pro_Stunde"]) == 48, (
"The length of 'Last_Wh_pro_Stunde' should be 48."
)
assert len(result["Netzeinspeisung_Wh_pro_Stunde"]) == 48, (
"The length of 'Netzeinspeisung_Wh_pro_Stunde' should be 48."
)
assert len(result["Netzbezug_Wh_pro_Stunde"]) == 48, (
"The length of 'Netzbezug_Wh_pro_Stunde' should be 48."
)
assert len(result["Kosten_Euro_pro_Stunde"]) == 48, (
"The length of 'Kosten_Euro_pro_Stunde' should be 48."
)
assert len(result["akku_soc_pro_stunde"]) == 48, (
"The length of 'akku_soc_pro_stunde' should be 48."
)

# Verfify DC and AC Charge Bins
assert (
abs(result["akku_soc_pro_stunde"][2] - 44.70681818181818) < 1e-5
), "'akku_soc_pro_stunde[2]' should be 44.70681818181818."
assert (
abs(result["akku_soc_pro_stunde"][10] - 10.0) < 1e-5
), "'akku_soc_pro_stunde[10]' should be 10."

assert (
abs(result["Netzeinspeisung_Wh_pro_Stunde"][10] - 3946.93) < 1e-3
), "'Netzeinspeisung_Wh_pro_Stunde[11]' should be 4000."

assert (
abs(result["Netzeinspeisung_Wh_pro_Stunde"][11] - 0.0) < 1e-3
), "'Netzeinspeisung_Wh_pro_Stunde[11]' should be 0.0."

assert (
abs(result["akku_soc_pro_stunde"][20] - 10) < 1e-5
), "'akku_soc_pro_stunde[20]' should be 10."
assert (
abs(result["Last_Wh_pro_Stunde"][20] - 6050.98) < 1e-3
), "'Netzeinspeisung_Wh_pro_Stunde[11]' should be 0.0."
assert abs(result["akku_soc_pro_stunde"][2] - 44.70681818181818) < 1e-5, (
"'akku_soc_pro_stunde[2]' should be 44.70681818181818."
)
assert abs(result["akku_soc_pro_stunde"][10] - 10.0) < 1e-5, (
"'akku_soc_pro_stunde[10]' should be 10."
)

assert abs(result["Netzeinspeisung_Wh_pro_Stunde"][10] - 3946.93) < 1e-3, (
"'Netzeinspeisung_Wh_pro_Stunde[11]' should be 4000."
)

assert abs(result["Netzeinspeisung_Wh_pro_Stunde"][11] - 0.0) < 1e-3, (
"'Netzeinspeisung_Wh_pro_Stunde[11]' should be 0.0."
)

assert abs(result["akku_soc_pro_stunde"][20] - 10) < 1e-5, (
"'akku_soc_pro_stunde[20]' should be 10."
)
assert abs(result["Last_Wh_pro_Stunde"][20] - 6050.98) < 1e-3, (
"'Netzeinspeisung_Wh_pro_Stunde[11]' should be 0.0."
)

print("All tests passed successfully.")

0 comments on commit 34bcd48

Please sign in to comment.