MCPcopy Create free account
hub / github.com/ahalev/python-microgrid / BatteryModule

Class BatteryModule

src/pymgrid/modules/battery/battery_module.py:10–388  ·  view source on GitHub ↗

A battery module. Battery modules are fixed: when calling ``Microgrid.run``, you must pass a control for batteries. Parameters ---------- min_capacity : float Minimum energy that must be contained in the battery. max_capacity : float Maximum energy that ca

Source from the content-addressed store, hash-verified

8
9
10class BatteryModule(BaseMicrogridModule):
11 """
12 A battery module.
13
14 Battery modules are fixed: when calling ``Microgrid.run``, you must pass a control for batteries.
15
16 Parameters
17 ----------
18 min_capacity : float
19 Minimum energy that must be contained in the battery.
20
21 max_capacity : float
22 Maximum energy that can be contained in the battery.
23 If ``soc=1``, capacity is at this maximum.
24
25 max_charge : float
26 Maximum amount the battery can be charged in one step.
27
28 .. warning::
29 This amount is the maximum the battery can be charged internally, dependent on the
30 ``battery_transition_model``. The amount the battery can be charged externally (e.g. the amount of
31 energy the battery can absorb) is defined as the negative of :attr:`.min_act`.
32
33 max_discharge : float
34 Maximum amount the battery can be discharged in one step.
35
36 .. warning::
37 This amount is the maximum the battery can be discharged internally, dependent on the
38 ``battery_transition_model``. The amount the battery can be discharged externally (e.g. the amount of
39 energy the battery can provide) is defined as :attr:`.max_act`.
40
41 efficiency : float
42 Efficiency of the battery.
43 See :meth:`BatteryModule.model_transition` for details.
44
45 battery_cost_cycle : float, default 0.0
46 Marginal cost of charging and discharging.
47
48 battery_transition_model : callable or None, default None
49 Function to model the battery's transition.
50 If None, :class:`.BatteryTransitionModel` is used.
51
52 .. note::
53 If you define a battery_transition_model, it must be YAML-serializable if you plan to serialize
54 your battery module or any microgrid containing your battery.
55
56 For example, you can define it as a class with a ``__call__`` method and ``yaml.YAMLObject`` as its metaclass.
57 See the `PyYAML documentation <https://pyyaml.org/wiki/PyYAMLDocumentation>`_ for details and
58 :class:`.BatteryTransitionModel` for an example.
59
60 init_charge : float or None, default None
61 Initial charge of the battery.
62 One of ``init_charge`` or ``init_soc`` must be passed, else an exception is raised.
63 If both are passed, ``init_soc`` is ignored and ``init_charge`` is used.
64
65 init_soc : float or None, default None
66 Initial state of charge of the battery.
67 One of ``init_charge`` or ``init_soc`` must be passed, else an exception is raised.

Callers 4

get_battery_moduleFunction · 0.90
get_modular_microgridFunction · 0.90
test_clip_actionMethod · 0.90
get_batteryFunction · 0.90

Calls

no outgoing calls

Tested by 2

test_clip_actionMethod · 0.72
get_batteryFunction · 0.72