5 #ifndef _BATTERYPCLINEARIZEINTERFACE_BV_H_
6 #define _BATTERYPCLINEARIZEINTERFACE_BV_H_
23 template<
class X,
class Diag,
class OffDiag,
class otherMeshDiag>
44 const bool bInterfaceHeatSource,
66 const XArray& xCell =
dynamic_cast<const XArray&
>(xField[cVarIndex]);
68 XArray& rCell =
dynamic_cast<XArray&
>(rField[cVarIndex]);
79 XArray& rParentCell =
dynamic_cast<XArray&
>(rField[cVarIndexParent]);
82 const TArray& faceAreaMag =
90 XArray& rOtherCell =
dynamic_cast<XArray&
>(rField[cVarIndexOther]);
108 for (
int f=0; f<faces.
getCount(); f++)
110 int c0p = parentFaceCells(f,0);
111 int c1p = parentFaceCells(f,1);
121 int c0o = otherFaceCells(f,0);
122 int c1o = otherFaceCells(f,1);
141 const X parentFlux = rParentCell[c1p];
142 const X otherFlux = rOtherCell[c1o];
145 const otherMeshDiag dRC0dXC3_DiagTens = parentmatrix.
getCoeff(c1p, c0p);
146 const otherMeshDiag dRC0dXC0_DiagTens = parentdiag[c1p];
149 const otherMeshDiag dRC0dXC2_DiagTens = othermatrix.
getCoeff(c1o, c0o);
150 const otherMeshDiag dRC0dXC1_DiagTens = otherdiag[c1o];
152 dRC0dXC3(0,0) = dRC0dXC3_DiagTens[0];
153 dRC0dXC3(1,1) = dRC0dXC3_DiagTens[1];
154 dRC0dXC2(0,0) = dRC0dXC2_DiagTens[0];
155 dRC0dXC2(1,1) = dRC0dXC2_DiagTens[1];
156 dRC0dXC1(0,0) = dRC0dXC1_DiagTens[0];
157 dRC0dXC1(1,1) = dRC0dXC1_DiagTens[1];
158 dRC0dXC0(0,0) = dRC0dXC0_DiagTens[0];
159 dRC0dXC0(1,1) = dRC0dXC0_DiagTens[1];
163 dRC0dXC3(2,2) = dRC0dXC3_DiagTens[2];
164 dRC0dXC2(2,2) = dRC0dXC2_DiagTens[2];
165 dRC0dXC1(2,2) = dRC0dXC1_DiagTens[2];
166 dRC0dXC0(2,2) = dRC0dXC0_DiagTens[2];
170 const int c1 = cellCells(f,0);
171 const int c2 = cellCells(f,1);
172 const int c3 = cellCells(f,2);
173 const T_Scalar Area = faceAreaMag[f];
174 bool turnOffBV =
false;
178 const T_Scalar phis_star = (xCell[c1])[0];
179 const T_Scalar phie_star = (xCell[c0])[0];
182 if (cs_star < 0.0){ cout <<
"ERROR: Cs < 0, Cs=" << cs_star << endl; cs_star = 0.0;}
183 if (ce_star < 0.0){ cout <<
"ERROR: Ce < 0, Ce=" << ce_star << endl; ce_star = 0.0;}
185 if (cs_star > csMax){ cout <<
"ERROR: Cs > CsMax, Cs=" << cs_star << endl; turnOffBV =
true;}
194 U_ref = -0.16 + 1.32*exp(-3.0*SOC)+10.0*exp(-2000.0*SOC);
196 {U_ref = 0.0; cout <<
"U_ref < 0" << endl;}
198 {U_ref = 1.2; cout <<
"U_ref > 1.2" << endl;}
201 U_ref = 4.19829 + 0.0565661*tanh(-14.5546*SOC + 8.60942) - 0.0275479*(1.0/pow((0.998432-SOC),0.492465) - 1.90111) - 0.157123*exp(-0.04738*pow(SOC,8.0)) + 0.810239*exp(-40.0*(SOC-0.133875));
203 {U_ref = 0.0; cout <<
"U_ref < 0" << endl;}
205 {U_ref = 5.0; cout <<
"U_ref > 5.0" << endl;}
214 Temp = (xCell[c0])[2];
216 const T_Scalar C_a = alpha_a*F/R/Temp;
217 const T_Scalar C_c = alpha_c*F/R/Temp;
219 const T_Scalar U = U_ref - (Temp - 298.0)*dU_dT;
220 const T_Scalar eta_star = phis_star - phie_star - U;
222 const T_Scalar C_0 = exp(C_a*eta_star)-exp(-1.0*C_c*eta_star);
224 T_Scalar i0_star = k*F*Area*pow(ce_star,alpha_c)*pow((csMax-cs_star),alpha_a)*pow(cs_star,alpha_c);
228 const T_Scalar i_star = C_0*i0_star;
235 const T_Scalar dC0dEta = (C_a*exp(C_a*eta_star) + C_c*exp(-1*C_c*eta_star));
238 dC_0dCS = dC0dEta*(-1.0)*(-20000.0*exp(-2000.0*SOC) - 3.96*exp(-3.0*SOC))*(1.0/csMax);
242 dC_0dCS = dC0dEta*(-1.0)*(-0.0135664/pow((0.998432-SOC),1.49247) - 0.823297/pow(cosh(8.60942-14.5546*SOC),2.0) + 0.0595559*exp(-0.04738*pow(SOC,8.0))*pow(SOC,7.0) - 6859.94*exp(-40.0*SOC))*(1.0/csMax);
245 const T_Scalar dIdCS_star = i_star*(alpha_c/cs_star - alpha_a/(csMax-cs_star)+ dC_0dCS/C_0);
246 const T_Scalar dIdCE_star = i_star*alpha_c/ce_star;
248 const T_Scalar dIdPhiS_star = i0_star*(C_a*exp(C_a*eta_star)+C_c*exp(-1*C_c*eta_star));
249 const T_Scalar dIdPhiE_star = -1*i0_star*(C_a*exp(C_a*eta_star)+C_c*exp(-1*C_c*eta_star));
251 const T_Scalar dIdTe_star = -0.5*i0_star*F*eta_star/R/Temp/Temp*(alpha_a*exp(C_a*eta_star)+alpha_c*exp(-1*C_c*eta_star));
252 const T_Scalar dIdTs_star = -0.5*i0_star*F*eta_star/R/Temp/Temp*(alpha_a*exp(C_a*eta_star)+alpha_c*exp(-1*C_c*eta_star));
259 OffDiag& offdiagC0_C1 = matrix.
getCoeff(c0, c1);
260 OffDiag& offdiagC0_C2 = matrix.
getCoeff(c0, c2);
261 OffDiag& offdiagC0_C3 = matrix.
getCoeff(c0, c3);
263 rCell[c0] = otherFlux + parentFlux;
264 offdiagC0_C1 = dRC0dXC1;
265 offdiagC0_C3 = dRC0dXC3;
266 offdiagC0_C2 = dRC0dXC2;
273 (offdiagC0_C1)(1,1) *= F;
274 (offdiagC0_C3)(1,1) *= F;
275 (offdiagC0_C2)(1,1) *= F;
276 (diag[c0])(1,1) *= F;
282 (rCell[c0])[2] += (eta_star + Peltier)*i_star;
283 (diag[c0])(2,2) += (eta_star + Peltier)*dIdTe_star;
284 (offdiagC0_C1)(2,2) += (eta_star + Peltier)*dIdTs_star;
288 (diag[c0])(2,0) = (eta_star + Peltier)*dIdPhiE_star - i_star;
289 (diag[c0])(2,1) = (eta_star + Peltier)*dIdCE_star;
290 (offdiagC0_C1)(2,0) = i_star + (eta_star + Peltier)*dIdPhiS_star;
291 (offdiagC0_C1)(2,1) = i_star*dC_0dCS/dC0dEta + (eta_star + Peltier)*dIdCS_star;
297 OffDiag& offdiagC1_C0 = matrix.
getCoeff(c1, c0);
298 OffDiag& offdiagC1_C2 = matrix.
getCoeff(c1, c2);
304 (rCell[c1])[1] = F*otherFlux[1] - i_star;
305 offdiagC1_C0(1,1) = -1*dIdCE_star;
306 offdiagC1_C2(1,1) = F*dRC0dXC2(1,1);
309 if (dIdCS_star > 0.0)
311 (diag[c1])(1,1) = F*dRC0dXC1(1,1) - dIdCS_star;
315 (diag[c1])(1,1) = F*dRC0dXC1(1,1);
322 (rCell[c1])[0] = otherFlux[0] - i_star;
323 offdiagC1_C0(0,0) = -1*dIdPhiE_star;
324 offdiagC1_C2(0,0) = dRC0dXC2(0,0);
325 (diag[c1])(0,0) = dRC0dXC1(0,0) - dIdPhiS_star;
328 if ((diag[c1])(0,0) > 0.0)
330 cout <<
"Warning: Potential Diag > 0" << endl;
340 (rCell[c1])[2] = Factor*((xCell[c0])[2] - (xCell[c1])[2]);
341 offdiagC1_C0(2,2) = Factor;
342 offdiagC1_C2(2,2) = 0.0;
343 (diag[c1])(2,2) = -1.0*Factor;
349 (diag[c1])(0,1) = -1*dIdCS_star;
350 (diag[c1])(1,0) = -1*dIdPhiS_star;
351 offdiagC1_C0(0,1) = -1*dIdCE_star;
352 offdiagC1_C0(1,0) = -1*dIdPhiE_star;
356 (diag[c1])(0,2) = -1*dIdTs_star;
357 (diag[c1])(1,2) = -1*dIdTs_star;
358 offdiagC1_C0(0,2) = -1*dIdTe_star;
359 offdiagC1_C0(1,2) = -1*dIdTe_star;
363 OffDiag& offdiagC1_C3 = matrix.
getCoeff(c1, c3);
371 cout <<
"r[c1]: " << (rCell[c1])[0] << (rCell[c1])[1] << endl;
372 cout <<
"r[c0]: " << (rCell[c0])[0] << (rCell[c1])[1] << endl;
384 cout <<
"Cs0: " << cs_star << endl;
Matrix & getMatrix(const Index &rowIndex, const Index &colIndex)
const T_Scalar _RRConstant
const StorageSite & getParentFaceGroupSite() const
BatteryPCLinearizeInterface_BV(const GeomFields &geomFields, const T_Scalar RRConstant, const T_Scalar interfaceUnderRelax, const bool Anode, const bool Cathode, const bool bInterfaceHeatSource, Field &varField)
void discretize(const Mesh &mesh, const Mesh &parentMesh, const Mesh &otherMesh, MultiFieldMatrix &mfmatrix, MultiField &xField, MultiField &rField)
CRMatrix< otherMeshDiag, otherMeshDiag, X > CCMatrix_DiagTensors
OffDiag & getCoeff(const int i, const int j)
const T_Scalar _interfaceUnderRelax
Array< Diag > & getDiag()
const StorageSite & getOtherFaceGroupSite() const
CCMatrix::DiagArray DiagArray
pair< const Field *, const StorageSite * > ArrayIndex
const CRConnectivity & getCellCells() const
const StorageSite & getCells() const
CRMatrix< Diag, OffDiag, X > CCMatrix
const CRConnectivity & getFaceCells(const StorageSite &site) const
CCMatrix_DiagTensors::DiagArray DiagArray_DiagTensors
NumTypeTraits< X >::T_Scalar T_Scalar
const GeomFields & _geomFields
const bool _bInterfaceHeatSource