Skip to content

Commit

Permalink
update resilience tests and fix voltage at 100 percent dod
Browse files Browse the repository at this point in the history
  • Loading branch information
brtietz committed Oct 9, 2023
1 parent ed71ab2 commit 3222a5b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions shared/lib_battery_voltage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ double voltage_table_t::calculate_voltage(double DOD, double I) {
row++;
}
//
if (DOD < tolerance) {
I = 0.0; // At full, current must go to zero
if (DOD < tolerance || DOD > 100. - tolerance) {
I = 0.0; // At full or empty, current must go to zero
}

return fmax(slopes[row] * DOD + intercepts[row], 0) - I * params->resistance;
Expand Down
8 changes: 4 additions & 4 deletions test/shared_test/lib_resilience_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,13 @@ TEST_F(ResilienceTest_lib_resilience, VoltageTable)
cap.updateCapacity(current, 1);
volt.updateVoltage(cap.q0(), cap.qmax(), cap.I(), 0, 0.);
EXPECT_NEAR(cap.SOC(), 44.445, 1e-3);
EXPECT_NEAR(volt.cell_voltage(), 1.773, 1e-3);
EXPECT_NEAR(volt.cell_voltage(), 1.873, 1e-3);

current = -1;
cap.updateCapacity(current, 1);
volt.updateVoltage(cap.q0(), cap.qmax(), cap.I(), 0, 0.);
EXPECT_NEAR(cap.SOC(), 88.889, 1e-3);
EXPECT_NEAR(volt.cell_voltage(), 2.777, 1e-3);
EXPECT_NEAR(volt.cell_voltage(), 2.877, 1e-3);
}

TEST_F(ResilienceTest_lib_resilience, DischargeVoltageTable){
Expand All @@ -359,7 +359,7 @@ TEST_F(ResilienceTest_lib_resilience, DischargeVoltageTable){
cap.updateCapacity(req_cur, 1);
volt.updateVoltage(cap.q0(), cap.qmax(), cap.I(), 0, 1);
double v = volt.cell_voltage();
EXPECT_NEAR(req_cur * v, 0.5, 1e-2);
EXPECT_NEAR(req_cur * v, 0.48, 1e-2);

// test max discharge
cap = capacity_lithium_ion_t(2.25, 50, 100, 0, 1);
Expand Down Expand Up @@ -397,7 +397,7 @@ TEST_F(ResilienceTest_lib_resilience, ChargeVoltageTable){
cap.updateCapacity(req_cur, 1);
volt.updateVoltage(cap.q0(), cap.qmax(), cap.I(), 0, 1);
double v = volt.cell_voltage();
EXPECT_NEAR(req_cur * v, -1.5, 1e-2);
EXPECT_NEAR(req_cur * v, -1.58, 1e-2);

// test max charge
double max_p = volt.calculate_max_charge_w(cap.q0(), cap.qmax(), 0, &current);
Expand Down

0 comments on commit 3222a5b

Please sign in to comment.