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

Add ev tutorial #1150

Draft
wants to merge 55 commits into
base: docs/make-style-modern
Choose a base branch
from
Draft

Add ev tutorial #1150

wants to merge 55 commits into from

Conversation

p-snft
Copy link
Member

@p-snft p-snft commented Jan 13, 2025

Add a tutorial according to point 2 in #1141, but with slight changes:

  • Step 0: Plugged EV as load with pre-calculated charging time series
    Charged EV with predefined trips for load (learning: trivial dispatch, but from battery)
  • Step 1: Unidirektional charging (learning: incentive to re-charge)
  • Step 2: Free charging with PV system at work (learning: dispatch with shifting under simple constraint)
  • Step 3: Fix free charging artefact (learning: looped energy flow as indicator for flawed model)
  • Step 3a: Allow bidirectional use of the battery (learning: understand the "balanced" keyword)
  • Step 4: Variable electricity prices (learning: how to include time series for costs)
  • Step 5: Power-related costs (as a proxy for battery ageing) (needs good adjustment of parameters, nothing for a beginners tutorial)
  • Properly format tutorial document

@pep8speaks
Copy link

pep8speaks commented Jan 13, 2025

Hello @p-snft! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2025-01-22 12:40:19 UTC

import matplotlib to plot the data right away and import solph
"""

from copy import deepcopy

Check notice

Code scanning / CodeQL

Unused import

Import of 'deepcopy' is not used.
@p-snft p-snft marked this pull request as draft January 13, 2025 20:34
@p-snft p-snft changed the base branch from dev to docs/make-style-modern January 14, 2025 14:20
@eliftu
Copy link

eliftu commented Jan 21, 2025

add axis labels within the 'solve_and_plot' function

@p-snft
Copy link
Member Author

p-snft commented Jan 21, 2025

add axis labels within the 'solve_and_plot' function

I don't get this. We do have labels (for both the vertical axis). The horizontal one is a time anyway, so it might not really make sense to have a label, does it?

The example used to be belinear and required gurobi. This, however, is
no longer the case (since solph v0.5.0). Thus, cbc can be used as the
default solver.

(Thanks to Rainer Gaier for finding this issue.)
@eliftu
Copy link

eliftu commented Jan 22, 2025

add axis labels within the 'solve_and_plot' function

I don't get this. We do have labels (for both the vertical axis). The horizontal one is a time anyway, so it might not really make sense to have a label, does it?

Oh sorry, I meant legends. Although they are obvious because of the values, it could be helpful for the first users.

ev_demand.loc[driving_start_morning:driving_end_morning] = 10 # kW

# Evening Driving: 17:00 to 18:00.
# Note that time points work even if they are not in the index.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

driving time in the explanation and the code do not match

"""


def add_domestic_socket_charging(energy_system, b_car):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"To be able to load the battery a electric source e.g. electric grid is necessary. To connect the car while it is at home, we create avalibility data series. 1 means that the car is at home, chargable. When it is set to 0, car is not present (between morning departure and the arrival back home in the evening). The avalibility data will be used in the maximum of the battery. "

"""


def add_11kW_charging(energy_system, b_car):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Same with avalibility data at home charging, we will create a data set for avalibility at work. When it is set to 0, car is not present at the work. When it is set to 1, car is able to connect to work charge station (between morning arrival and the evening departure from work) "

def add_balanced_battery(energy_system, b_car):
car_battery = solph.components.GenericStorage(
label="Car Battery",
nominal_capacity=50,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variable cost is too high there ?

model.solve(solve_kwargs={"tee": False})
results = solph.processing.results(model)

battery_series = solph.views.node(results, "Car Battery")["sequences"]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think it could be helpful to mention briefly the results structure from views? People might have strugle at the start reaching the results to analyse.

Charging and discharging at the same time is almost always a sign that
something is not moddeled accurately in the energy system.
To avoid the energy from looping in the battery, we introduce marginal costs
to battery charging. This is a way to model cyclic aging of the battery.
Copy link

@eliftu eliftu Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we explain a little more on, how we are ingluencing the aging effect?

@eliftu
Copy link

eliftu commented Jan 23, 2025

Would it be valueable to add another block of code to have multiple cars?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants