From 6ec0d917c4aba4eb77ba983a45abaabd193df759 Mon Sep 17 00:00:00 2001 From: Brian Malone Date: Tue, 5 Oct 2021 13:46:36 -0400 Subject: [PATCH] Fixed battery variable --- model/battery_test.mdl | 24 +++++++-------- run/battery_test.run | 70 +++++++++++++++++++++--------------------- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/model/battery_test.mdl b/model/battery_test.mdl index d41fd7d..7c8aad2 100644 --- a/model/battery_test.mdl +++ b/model/battery_test.mdl @@ -77,12 +77,12 @@ Element TMS{ Q_O.HeatTransferRate = Q_cool; } } -linkPorts("TMS.Q_O","Li_ion_cell.Q_I","Q1"); +linkPorts("TMS.Q_O","Li_ion_battery.Q_I","Q1"); //------------------------------------------------------------------------------------------------- // Component Linkages //------------------------------------------------------------------------------------------------- -linkPortI( "Li_ion_cell.EP_O", "Cable_Single.EP_I" ); +linkPortI( "Li_ion_battery.EP_O", "Cable_Single.EP_I" ); linkPortI( "Cable_Single.EP_O", "CLoad.EP_I" ); // linkPortI( "CableLeft.EP_O", "DeltaDC.EP_I" ); // linkPortI( "DeltaDC.EP_O", "CableRight.EP_I" ); @@ -90,21 +90,21 @@ linkPortI( "Cable_Single.EP_O", "CLoad.EP_I" ); findSourcesAndPropagate(); -solverSequence = { "Cable_Single", "Li_ion_cell", "CLoad", "TMS" }; +solverSequence = { "Cable_Single", "Li_ion_battery", "CLoad", "TMS" }; void BFPrintOutput() { cout << " Case = " << CASE << endl; - cout << " Battery open circuit voltage = " << Li_ion_cell.Voc << endl; - cout << " Battery output voltage (actual/guess) = " << Li_ion_cell.Vout << "/" << Li_ion_cell.Vout_guess << endl; - cout << " Battery heat balance (Qin/Oout) = " << Li_ion_cell.Q_heat << "/" << Li_ion_cell.Q_I.HeatTransferRate << endl; - // cout << " Battery output Resistance (R_0, R_Th) = " << Li_ion_cell.R_0 << ", " << Li_ion_cell.R_Th << endl; - // cout << " Battery current (calc) = " << (Li_ion_cell.Voc-Li_ion_cell.Vout)/Li_ion_cell.RTotal << endl; - cout << " Battery current/power = " << Li_ion_cell.EP_O.I.r << "/" << Li_ion_cell.EP_O.S.r << endl; + cout << " Battery open circuit voltage = " << Li_ion_battery.Voc << endl; + cout << " Battery output voltage (actual/guess) = " << Li_ion_battery.Vout << "/" << Li_ion_battery.Vout_guess << endl; + cout << " Battery heat balance (Qin/Oout) = " << Li_ion_battery.Q_heat << "/" << Li_ion_battery.Q_I.HeatTransferRate << endl; + // cout << " Battery output Resistance (R_0, R_Th) = " << Li_ion_battery.R_0 << ", " << Li_ion_battery.R_Th << endl; + // cout << " Battery current (calc) = " << (Li_ion_battery.Voc-Li_ion_battery.Vout)/Li_ion_battery.RTotal << endl; + cout << " Battery current/power = " << Li_ion_battery.EP_O.I.r << "/" << Li_ion_battery.EP_O.S.r << endl; cout << " Load power = " << CLoad.P << endl; - cout << " Number of series cells in battery = " << Li_ion_cell.S_map.num_series << endl; - cout << " Number of parallel cells in battery = " << Li_ion_cell.S_map.num_parallel << endl; - cout << " Battery temperature/temp state (oC) = " << Li_ion_cell.T_batt << "/" << (Li_ion_cell.S_eThermMass.T - 491.67)*5./9. << endl; + cout << " Number of series cells in battery = " << Li_ion_battery.S_map.num_series << endl; + cout << " Number of parallel cells in battery = " << Li_ion_battery.S_map.num_parallel << endl; + cout << " Battery temperature/temp state (oC) = " << Li_ion_battery.T_batt << "/" << (Li_ion_battery.S_eThermMass.T - 491.67)*5./9. << endl; // cout << " Cable current (output port) = " << Cable_Single.EP_O.I.r << endl; // cout << " Load input voltage = " << CLoad.EP_I.V.r << endl; // cout << " Load input power = " << CLoad.EP_I.S.r << endl; diff --git a/run/battery_test.run b/run/battery_test.run index c6c7a9c..6e6a57c 100644 --- a/run/battery_test.run +++ b/run/battery_test.run @@ -82,12 +82,12 @@ run(); // do another steady-state run just to initialize us. TMS.R_cool = 0; // Also start out the temperature at 22 C to match the data -Li_ion_cell.T_batt = 22; -Li_ion_cell.S_eThermMass.T = 22. * 9./5. + 491.67; // 22 C converted to R +Li_ion_battery.T_batt = 22; +Li_ion_battery.S_eThermMass.T = 22. * 9./5. + 491.67; // 22 C converted to R // Turn on integrator for battery SOC -Li_ion_cell.ind_SOC.autoSetup = TRUE; -Li_ion_cell.integ_SOC.autoSetup = TRUE; +Li_ion_battery.ind_SOC.autoSetup = TRUE; +Li_ion_battery.integ_SOC.autoSetup = TRUE; setOption("switchDes","OFFDESIGN"); setOption("solutionMode", "TRANSIENT"); @@ -107,46 +107,46 @@ cout << "Transient Solver Vars = " << endl << solver.dependentNames << endl << s OutFileStream transientCSVStream { filename = "output/batt_transient.csv"; } // Write the CSV headers -transientCSVStream << "Li_ion_cell.Voc,"; -transientCSVStream << "Li_ion_cell.Vout,"; -transientCSVStream << "Li_ion_cell.Q_heat,"; -transientCSVStream << "Li_ion_cell.R_0,"; -transientCSVStream << "Li_ion_cell.R_Th,"; -transientCSVStream << "Li_ion_cell.EP_O.I.r,"; -transientCSVStream << "Li_ion_cell.EP_O.S.r,"; -transientCSVStream << "Li_ion_cell.T_batt,"; -transientCSVStream << "Li_ion_cell.S_eThermMass.T,"; -transientCSVStream << "Li_ion_cell.SOC,"; -transientCSVStream << "Li_ion_cell.dSOCqdt,"; -transientCSVStream << "Li_ion_cell.C_rate,"; +transientCSVStream << "Li_ion_battery.Voc,"; +transientCSVStream << "Li_ion_battery.Vout,"; +transientCSVStream << "Li_ion_battery.Q_heat,"; +transientCSVStream << "Li_ion_battery.R_0,"; +transientCSVStream << "Li_ion_battery.R_Th,"; +transientCSVStream << "Li_ion_battery.EP_O.I.r,"; +transientCSVStream << "Li_ion_battery.EP_O.S.r,"; +transientCSVStream << "Li_ion_battery.T_batt,"; +transientCSVStream << "Li_ion_battery.S_eThermMass.T,"; +transientCSVStream << "Li_ion_battery.SOC,"; +transientCSVStream << "Li_ion_battery.dSOCqdt,"; +transientCSVStream << "Li_ion_battery.C_rate,"; transientCSVStream << "time" << endl; // Use a variable to print only every 100 timesteps. real time_old = 0; void csvTransientPrint() { - transientCSVStream << Li_ion_cell.Voc << ", "; - transientCSVStream << Li_ion_cell.Vout << ", "; - transientCSVStream << Li_ion_cell.Q_heat << ", "; - transientCSVStream << Li_ion_cell.R_0 << ", "; - transientCSVStream << Li_ion_cell.R_Th << ", "; - transientCSVStream << Li_ion_cell.EP_O.I.r << ", "; - transientCSVStream << Li_ion_cell.EP_O.S.r << ", "; - transientCSVStream << Li_ion_cell.T_batt << ", "; - transientCSVStream << Li_ion_cell.S_eThermMass.T << ", "; - transientCSVStream << Li_ion_cell.SOC << ", "; - transientCSVStream << Li_ion_cell.dSOCqdt << ", "; - transientCSVStream << Li_ion_cell.C_rate << ", "; + transientCSVStream << Li_ion_battery.Voc << ", "; + transientCSVStream << Li_ion_battery.Vout << ", "; + transientCSVStream << Li_ion_battery.Q_heat << ", "; + transientCSVStream << Li_ion_battery.R_0 << ", "; + transientCSVStream << Li_ion_battery.R_Th << ", "; + transientCSVStream << Li_ion_battery.EP_O.I.r << ", "; + transientCSVStream << Li_ion_battery.EP_O.S.r << ", "; + transientCSVStream << Li_ion_battery.T_batt << ", "; + transientCSVStream << Li_ion_battery.S_eThermMass.T << ", "; + transientCSVStream << Li_ion_battery.SOC << ", "; + transientCSVStream << Li_ion_battery.dSOCqdt << ", "; + transientCSVStream << Li_ion_battery.C_rate << ", "; transientCSVStream << time << endl; if (time-time_old >= 300) { - cout << "T_batt (oC), " << Li_ion_cell.T_batt << ", "; - //cout << "HeatRate (BTU/s), " << Li_ion_cell.Q_heat << ", "; - cout << "BattCurrent (A), " << Li_ion_cell.EP_O.I.r << ", "; - cout << "BattSOC, " << Li_ion_cell.SOC << ", "; - cout << "BattVoltage (V), " << Li_ion_cell.EP_O.V.r << ", "; - cout << "C-rate, " << Li_ion_cell.C_rate << ", "; + cout << "T_batt (oC), " << Li_ion_battery.T_batt << ", "; + //cout << "HeatRate (BTU/s), " << Li_ion_battery.Q_heat << ", "; + cout << "BattCurrent (A), " << Li_ion_battery.EP_O.I.r << ", "; + cout << "BattSOC, " << Li_ion_battery.SOC << ", "; + cout << "BattVoltage (V), " << Li_ion_battery.EP_O.V.r << ", "; + cout << "C-rate, " << Li_ion_battery.C_rate << ", "; cout << "CASE, " << CASE << ", "; cout << "time (s), " << time << endl; time_old = time; @@ -168,7 +168,7 @@ void transient_profile() { else if ( time < 6600 ){ CLoad.Pdemand = 0.;} // Stop if battery gets fully drained (or close to it) - if (Li_ion_cell.SOC <= 0.01) { + if (Li_ion_battery.SOC <= 0.01) { // quit(); } }