Skip to content

Commit

Permalink
fixed FlorisStandin testing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary committed Mar 25, 2024
1 parent 95d3702 commit 5bffd63
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
11 changes: 4 additions & 7 deletions hercules/python_simulators/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
March 2024
References:
[1] M.-K. Tran et al., “A comprehensive equivalent circuit model for lithium-ion
batteries, incorporating the effects of state of health, state of charge, and
temperature on model parameters,” Journal of Energy Storage, vol. 43, p. 103252,
[1] M.-K. Tran et al., “A comprehensive equivalent circuit model for lithium-ion
batteries, incorporating the effects of state of health, state of charge, and
temperature on model parameters,” Journal of Energy Storage, vol. 43, p. 103252,
Nov. 2021, doi: 10.1016/j.est.2021.103252.
"""

Expand Down Expand Up @@ -34,9 +34,6 @@ def __init__(self, input_dict, dt):
def step(self, inputs):
return self.battery.step(inputs)

def return_inputs(self):
return self.battery.return_inputs()

def return_outputs(self):
return self.battery.return_outputs()

Expand Down Expand Up @@ -223,7 +220,7 @@ def step(self, inputs: dict):
Inputs:
- inputs: dictionary of inputs for the current time step which must have:
- setpoints:{battery:{signal: ___ }} [kW] charging/discharging power desired
- setpoints:{inputs:{battery_signal: ___ }} [kW] charging/discharging power desired
- py_sims:{inputs:{available_power: ___ }} [kW] power available for charging/discharging
Outputs:
Expand Down
19 changes: 4 additions & 15 deletions tests/python_simulators_test/battery_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def LI():
def step_inputs(P_avail, P_signal):
return dict(
{
"setpoints": {"battery": {"signal": P_signal}},
"py_sims": {"inputs": {"available_power": P_avail}},
# "setpoints": {"battery": {"signal": P_signal}},
"py_sims": {"inputs": {"available_power": P_avail, "battery_signal": P_signal}},
}
)

Expand Down Expand Up @@ -121,23 +121,17 @@ def test_SB_control_energy_constraint(SB: SimpleBattery):


def test_SB_step(SB: SimpleBattery):
step_inputs = {
"setpoints": {"battery": {"signal": 1e3}},
"py_sims": {"inputs": {"available_power": 1e3}},
}

SB.step(step_inputs)
SB.step(step_inputs(P_avail=1e3, P_signal=1e3))

assert_almost_equal(SB.E, 29377000, decimal=0)
assert_almost_equal(SB.current_batt_state, 8160.27, decimal=1)
assert_almost_equal(SB.SOC, 0.102003472, decimal=8)
assert SB.P_charge == 1e3

SB.E = SB.E_min + 5e3
step_inputs["setpoints"]["battery"].update({"signal": -2e3})

for i in range(4):
SB.step(step_inputs)
SB.step(step_inputs(P_avail=1e3, P_signal=-2e3))

assert SB.E == 28800000
assert SB.current_batt_state == 8000
Expand Down Expand Up @@ -182,7 +176,6 @@ def test_LI_post_init():


def test_LI_OCV(LI):

LI.SOC = 0.25
assert LI.OCV() == 3.2654698427383457

Expand All @@ -207,7 +200,6 @@ def test_LI_build_SS(LI):


def test_LI_step_cell(LI):

V_RC = np.zeros(5)
for i in range(5):
V_RC[i] = LI.V_RC
Expand Down Expand Up @@ -236,7 +228,6 @@ def test_LI_calc_power(LI):


def test_LI_step(LI):

P_avail = 1.5e3
P_signal = 1e3

Expand All @@ -248,7 +239,6 @@ def test_LI_step(LI):


def test_LI_control(LI):

P_avail = 1.5e3
P_signal = 1e3
I_charge, I_reject = LI.control(P_signal, P_avail)
Expand All @@ -264,7 +254,6 @@ def test_LI_control(LI):


def test_LI_constraints(LI):

# no constraints applied
I_charge, I_reject = LI.constraints(I_signal=400, I_avail=500)
assert I_charge == 400
Expand Down

0 comments on commit 5bffd63

Please sign in to comment.