Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the deviation only for vehicles with a larger deviation #1978

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions packages/control/algorithm/surplus_controlled.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,17 @@ def _fix_deviating_evse_current(self, chargepoint: Chargepoint) -> float:
Wenn die Soll-Stromstärke nicht angepasst worden ist, nicht den ungenutzten EVSE-Strom aufschlagen. Wenn das
Auto nur in 1A-Schritten regeln kann, rundet es und lädt immer etwas mehr oder weniger als Soll-Strom. Schlägt
man den EVSE-Strom auf, pendelt die Regelung um diesen 1A-Schritt."""
MAX_DEVIATION = 1.1
evse_current = chargepoint.data.get.evse_current
if evse_current and chargepoint.data.set.current != chargepoint.set_current_prev:
formatted_evse_current = evse_current if evse_current < 32 else evse_current / 100
current_with_offset = chargepoint.data.set.current + \
formatted_evse_current - max(chargepoint.data.get.currents)
current = min(current_with_offset, chargepoint.data.control_parameter.required_current)
if current != chargepoint.data.set.current:
log.debug(f"Ungenutzten Soll-Strom aufschlagen ergibt {current}A.")
chargepoint.data.set.current = current
offset = formatted_evse_current - max(chargepoint.data.get.currents)
if abs(offset) >= MAX_DEVIATION:
current_with_offset = chargepoint.data.set.current + offset
current = min(current_with_offset, chargepoint.data.control_parameter.required_current)
if current != chargepoint.data.set.current:
log.debug(f"Ungenutzten Soll-Strom aufschlagen ergibt {current}A.")
chargepoint.data.set.current = current

def check_submode_pv_charging(self) -> None:
evu_counter = data.data.counter_all_data.get_evu_counter()
Expand Down
18 changes: 9 additions & 9 deletions packages/control/algorithm/surplus_controlled_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,24 +101,24 @@ def test_set_required_current_to_max(phases: int,


@pytest.mark.parametrize(
"evse_current, limited_current, required_current, expected_current",
"evse_current, limited_current, expected_current",
[
pytest.param(None, 6, 16, 6, id="Kein Soll-Strom aus der EVSE ausgelesen"),
pytest.param(15, 15, 16, 15, id="Auto lädt mit Soll-Stromstärke"),
pytest.param(14.5, 14.5, 14.5, 14, id="Auto lädt mit mehr als Soll-Stromstärke"),
pytest.param(15.5, 15.5, 16, 16, id="Auto lädt mit weniger als Soll-Stromstärke"),
pytest.param(16, 16, 16, 16,
pytest.param(None, 6, 6, id="Kein Soll-Strom aus der EVSE ausgelesen"),
pytest.param(13, 13, 13, id="Auto lädt mit Soll-Stromstärke"),
pytest.param(12.5, 12.5, 12.5, id="Auto lädt mit 0.5A Abweichung von der Soll-Stromstärke"),
pytest.param(11.8, 11.8, 10.600000000000001, id="Auto lädt mit mehr als Soll-Stromstärke"),
pytest.param(14.2, 14.2, 15.399999999999999, id="Auto lädt mit weniger als Soll-Stromstärke"),
pytest.param(15, 15, 16,
id="Auto lädt mit weniger als Soll-Stromstärke, aber EVSE-Begrenzung ist erreicht.")
])
def test_add_unused_evse_current(evse_current: float,
limited_current: float,
required_current: float,
expected_current: float):
# setup
c = Chargepoint(0, None)
c.data.get.currents = [15]*3
c.data.get.currents = [13]*3
c.data.get.evse_current = evse_current
c.data.control_parameter.required_current = required_current
c.data.control_parameter.required_current = 16
c.data.set.current = limited_current

# execution
Expand Down