test/shared_test/lib_battery_test.cpp
/// Test  lithium ion battery capacity response
Test  lithium ion battery capacity response
Test lithium ion battery capacity response
TEST_F(BatteryTest, LithiumIonCapacityTest_lib_battery)
{
	q = 100;
	SOC_init = 100;
	SOC_min = 20;
	SOC_max = 100;
	if (capacityModel) {
		delete capacityModel;
	}
	capacityModel = new capacity_lithium_ion_t(q, SOC_init, SOC_max, SOC_min);
	EXPECT_EQ(capacityModel->SOC(), SOC_max);
	double I = 10;
	capacityModel->updateCapacity(I, 1);
	EXPECT_EQ(capacityModel->SOC(), 90);
	EXPECT_EQ(capacityModel->q0(), 90);
	I = -10;
	capacityModel->updateCapacity(I, 1);
	EXPECT_EQ(capacityModel->SOC(), 100);
	EXPECT_EQ(capacityModel->q0(), 100);
	capacityModel->updateCapacityForThermal(95);
	capacityModel->check_SOC();
	EXPECT_EQ(capacityModel->q0(), 95);
	EXPECT_EQ(capacityModel->qmax(), 100);
	capacityModel->updateCapacityForThermal(100);
	capacityModel->check_SOC();
	capacityModel->updateCapacityForLifetime(95);
	EXPECT_EQ(capacityModel->q0(), 95);
	EXPECT_EQ(capacityModel->qmax(), 95);
	capacityModel->replace_battery(100);
	EXPECT_EQ(capacityModel->SOC(), SOC_max);
	EXPECT_EQ(capacityModel->q0(), 100);
	EXPECT_EQ(capacityModel->qmax(), 100);
	capacityModel->updateCapacity(I, 1);
	EXPECT_EQ(capacityModel->q0(), 100);
	EXPECT_EQ(capacityModel->SOC(), SOC_max);
	I = 110;
	capacityModel->updateCapacity(I, 1);
	EXPECT_EQ(capacityModel->q0(), 20);
	EXPECT_EQ(capacityModel->SOC(), SOC_min);
}
TEST_F ( BatteryTest , LithiumIonCapacityTest_lib_battery ) { q = 100 ; SOC_init = 100 ; SOC_min = 20 ; SOC_max = 100 ; if ( capacityModel ) { delete capacityModel ; } capacityModel = new capacity_lithium_ion_t ( q , SOC_init , SOC_max , SOC_min ) ; EXPECT_EQ ( capacityModel -> SOC ( ) , SOC_max ) ; double I = 10 ; capacityModel -> updateCapacity ( I , 1 ) ; EXPECT_EQ ( capacityModel -> SOC ( ) , 90 ) ; EXPECT_EQ ( capacityModel -> q0 ( ) , 90 ) ; I = -10 ; capacityModel -> updateCapacity ( I , 1 ) ; EXPECT_EQ ( capacityModel -> SOC ( ) , 100 ) ; EXPECT_EQ ( capacityModel -> q0 ( ) , 100 ) ; capacityModel -> updateCapacityForThermal ( 95 ) ; capacityModel -> check_SOC ( ) ; EXPECT_EQ ( capacityModel -> q0 ( ) , 95 ) ; EXPECT_EQ ( capacityModel -> qmax ( ) , 100 ) ; capacityModel -> updateCapacityForThermal ( 100 ) ; capacityModel -> check_SOC ( ) ; capacityModel -> updateCapacityForLifetime ( 95 ) ; EXPECT_EQ ( capacityModel -> q0 ( ) , 95 ) ; EXPECT_EQ ( capacityModel -> qmax ( ) , 95 ) ; capacityModel -> replace_battery ( 100 ) ; EXPECT_EQ ( capacityModel -> SOC ( ) , SOC_max ) ; EXPECT_EQ ( capacityModel -> q0 ( ) , 100 ) ; EXPECT_EQ ( capacityModel -> qmax ( ) , 100 ) ; capacityModel -> updateCapacity ( I , 1 ) ; EXPECT_EQ ( capacityModel -> q0 ( ) , 100 ) ; EXPECT_EQ ( capacityModel -> SOC ( ) , SOC_max ) ; I = 110 ; capacityModel -> updateCapacity ( I , 1 ) ; EXPECT_EQ ( capacityModel -> q0 ( ) , 20 ) ; EXPECT_EQ ( capacityModel -> SOC ( ) , SOC_min ) ; }
Test  lithium ion battery capacity response
Test lithium ion battery capacity response
// Check that initial capacity is equal to max // Check that discharge of battery results in correct capacity // check that charge of battery results in correct capacity // check that updating thermal behavior changes capacity as expected // check that updating lifetime degradation changes capacity // check that battery replacement works // check that model correctly detects overcharge, undercharge