5 #ifndef _BATTERYLINEARIZETHERMALINTERFACE_H_
6 #define _BATTERYLINEARIZETHERMALINTERFACE_H_
23 template<
class X,
class Diag,
class OffDiag>
38 Field& speciesConcentrationField,
39 Field& potentialField,
63 const XArray& xCell =
dynamic_cast<const XArray&
>(xField[cVarIndex]);
65 XArray& rCell =
dynamic_cast<XArray&
>(rField[cVarIndex]);
69 const XArray& eSpecConcCell =
73 const XArray& ePotentialCell =
85 XArray& rParentCell =
dynamic_cast<XArray&
>(rField[cVarIndexParent]);
88 const TArray& faceAreaMag =
96 XArray& rOtherCell =
dynamic_cast<XArray&
>(rField[cVarIndexOther]);
116 for (
int f=0; f<faces.
getCount(); f++)
119 int c0p = parentFaceCells(f,0);
120 int c1p = parentFaceCells(f,1);
130 const X parentFlux = rParentCell[c1p];
131 const OffDiag dRC0dXC3 = parentmatrix.
getCoeff(c1p, c0p);
132 const Diag dRC0dXC0 = parentdiag[c1p];
135 int c0o = otherFaceCells(f,0);
136 int c1o = otherFaceCells(f,1);
146 const X otherFlux = rOtherCell[c1o];
147 const OffDiag dRC0dXC2 = othermatrix.
getCoeff(c1o, c0o);
148 const OffDiag dRC0dXC1 = otherdiag[c1o];
153 const int c1 = cellCells(f,0);
154 const int c2 = cellCells(f,1);
155 const int c3 = cellCells(f,2);
157 T_Scalar Ce_star = eSpecConcCell[c0];
158 T_Scalar Cs_star = eSpecConcCell[c1];
163 cout <<
"ERROR: Ce_star < 0, Ce_star=" << Ce_star << endl; Ce_star = 0.0;
167 cout <<
"ERROR: Cs_star < 0, Cs_star=" << Cs_star << endl; Cs_star = 0.0;
169 if (Cs_star > csMax){ Cs_star = 0.9*csMax; cout <<
"ERROR: Cs > CsMax" << endl;}
175 U_ref = -0.16 + 1.32*exp(-3.0*SOC)+10.0*exp(-2000.0*SOC);}
177 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));}
179 const T_Scalar Area = faceAreaMag[c0];
180 const T_Scalar Phis_star = ePotentialCell[c1];
181 const T_Scalar Phie_star = ePotentialCell[c0];
184 const T_Scalar U = U_ref - (Temp - 298.0)*dU_dT;
185 const T_Scalar eta_star = Phis_star-Phie_star-U;
186 const T_Scalar C_a = alpha_a*F/R/Temp;
187 const T_Scalar C_c = alpha_c*F/R/Temp;
189 const T_Scalar i0_star = k*F*Area*pow(Ce_star,alpha_c)*pow((csMax-Cs_star),alpha_a)*pow(Cs_star,alpha_c);
190 const T_Scalar i_star = i0_star*(exp(C_a*eta_star)-exp(-1*C_c*eta_star));
195 const T_Scalar dR0_dT_HeatSourceSign = -1.0*(eta_star)*(eta_star+Peltier);
198 if (dR0_dT_HeatSourceSign < 0.0)
200 dI_dTe = -1.0*i0_star*F*eta_star/R/Temp/Temp*(alpha_a*exp(C_a*eta_star)+alpha_c*exp(-1.0*C_c*eta_star));
204 dI_dTs = -1.0*i0_star*F*eta_star/R/Temp/Temp*(alpha_a*exp(C_a*eta_star)+alpha_c*exp(-1.0*C_c*eta_star));
209 OffDiag& offdiagC0_C1 = matrix.
getCoeff(c0, c1);
210 OffDiag& offdiagC0_C2 = matrix.
getCoeff(c0, c2);
211 OffDiag& offdiagC0_C3 = matrix.
getCoeff(c0, c3);
213 rCell[c0] = otherFlux + parentFlux + (eta_star + Peltier)*i_star;
216 offdiagC0_C3 = dRC0dXC3;
217 offdiagC0_C2 = dRC0dXC2;
219 offdiagC0_C1 = dRC0dXC1;
222 diag[c0] += (eta_star + Peltier)*dI_dTe;
223 offdiagC0_C1 += (eta_star + Peltier)*dI_dTs;
227 OffDiag& offdiagC1_C0 = matrix.
getCoeff(c1, c0);
229 rCell[c1] = xCell[c0] - xCell[c1];
234 OffDiag& offdiagC1_C2 = matrix.
getCoeff(c1, c2);
236 OffDiag& offdiagC1_C3 = matrix.
getCoeff(c1, c3);
CCMatrix::DiagArray DiagArray
Matrix & getMatrix(const Index &rowIndex, const Index &colIndex)
const StorageSite & getParentFaceGroupSite() const
OffDiag & getCoeff(const int i, const int j)
Array< Diag > & getDiag()
BatteryLinearizeThermalInterface(const GeomFields &geomFields, Field &varField, Field &speciesConcentrationField, Field &potentialField, const T_Scalar RRConstant, const bool Anode, const bool Cathode)
const T_Scalar _RRConstant
const StorageSite & getOtherFaceGroupSite() const
NumTypeTraits< X >::T_Scalar T_Scalar
pair< const Field *, const StorageSite * > ArrayIndex
const CRConnectivity & getCellCells() const
const StorageSite & getCells() const
const CRConnectivity & getFaceCells(const StorageSite &site) const
CRMatrix< Diag, OffDiag, X > CCMatrix
const GeomFields & _geomFields
Vector< T_Scalar, 3 > VectorT3
Field & _speciesConcentrationField
void discretize(const Mesh &mesh, const Mesh &parentMesh, const Mesh &otherMesh, MultiFieldMatrix &mfmatrix, MultiField &xField, MultiField &rField)
Array< VectorT3 > VectorT3Array