5 #ifndef _BATTERYLINEARIZEPOTENTIALINTERFACE_H_
6 #define _BATTERYLINEARIZEPOTENTIALINTERFACE_H_
23 template<
class X,
class Diag,
class OffDiag>
38 Field& speciesConcentrationField,
39 Field& temperatureField,
63 const XArray& xCell =
dynamic_cast<const XArray&
>(xField[cVarIndex]);
65 XArray& rCell =
dynamic_cast<XArray&
>(rField[cVarIndex]);
69 const XArray& eSpecConcCell =
85 XArray& rParentCell =
dynamic_cast<XArray&
>(rField[cVarIndexParent]);
88 const TArray& faceAreaMag =
96 XArray& rOtherCell =
dynamic_cast<XArray&
>(rField[cVarIndexOther]);
114 for (
int f=0; f<faces.
getCount(); f++)
117 int c0p = parentFaceCells(f,0);
118 int c1p = parentFaceCells(f,1);
128 const X parentFlux = rParentCell[c1p];
129 const OffDiag dRC0dXC3 = parentmatrix.
getCoeff(c1p, c0p);
130 const Diag dRC0dXC0 = parentdiag[c1p];
133 int c0o = otherFaceCells(f,0);
134 int c1o = otherFaceCells(f,1);
144 const X otherFlux = rOtherCell[c1o];
145 const OffDiag dRC0dXC2 = othermatrix.
getCoeff(c1o, c0o);
146 const OffDiag dRC0dXC1 = otherdiag[c1o];
151 const int c1 = cellCells(f,0);
152 const int c2 = cellCells(f,1);
153 const int c3 = cellCells(f,2);
155 const T_Scalar Temp = eTempCell[c0];
156 const T_Scalar C_a = alpha_a*F/R/Temp;
157 const T_Scalar C_c = alpha_c*F/R/Temp;
158 const T_Scalar Area = faceAreaMag[c0];
159 T_Scalar Ce_star = eSpecConcCell[c0];
160 T_Scalar Cs_star = eSpecConcCell[c1];
167 cout <<
"ERROR: Ce_star < 0, Ce_star=" << Ce_star << endl; Ce_star = 0.0;
171 cout <<
"ERROR: Cs_star < 0, Cs_star=" << Cs_star << endl; Cs_star = 0.0;
173 if (Cs_star > csMax){ Cs_star = 0.9*csMax; cout <<
"ERROR: Cs > CsMax" << endl;}
179 U_ref = -0.16 + 1.32*exp(-3.0*SOC)+10.0*exp(-2000.0*SOC);}
181 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));}
183 const T_Scalar i0_star = k*F*Area*pow(Ce_star,alpha_c)*pow((csMax-Cs_star),alpha_a)*pow(Cs_star,alpha_c);
185 const T_Scalar Phis_star = xCell[c1];
186 const T_Scalar Phie_star = xCell[c0];
187 const T_Scalar U = U_ref - (Temp - 298.0)*dU_dT;
188 T_Scalar eta_star = Phis_star-Phie_star-U;
192 const T_Scalar i_star = i0_star*(exp(C_a*eta_star)-exp(-1*C_c*eta_star));
193 const T_Scalar dIdPhiS_star = i0_star*(C_a*exp(C_a*eta_star)+C_c*exp(-1*C_c*eta_star));
194 const T_Scalar dIdPhiE_star = -1*i0_star*(C_a*exp(C_a*eta_star)+C_c*exp(-1*C_c*eta_star));
198 OffDiag& offdiagC0_C1 = matrix.
getCoeff(c0, c1);
199 OffDiag& offdiagC0_C2 = matrix.
getCoeff(c0, c2);
200 OffDiag& offdiagC0_C3 = matrix.
getCoeff(c0, c3);
202 rCell[c0] = otherFlux + parentFlux;
203 offdiagC0_C1 = dRC0dXC1;
204 offdiagC0_C3 = dRC0dXC3;
205 offdiagC0_C2 = dRC0dXC2;
210 OffDiag& offdiagC1_C0 = matrix.
getCoeff(c1, c0);
211 OffDiag& offdiagC1_C2 = matrix.
getCoeff(c1, c2);
213 rCell[c1] = otherFlux - (i_star + dIdPhiS_star*(xCell[c1]-Phis_star) + dIdPhiE_star*(xCell[c0]-Phie_star));
214 offdiagC1_C0 = -1*dIdPhiE_star;
215 offdiagC1_C2 = dRC0dXC2;
216 diag[c1] = dRC0dXC1 - dIdPhiS_star;
221 cout <<
"Warning: Diag > 0" << endl;
225 OffDiag& offdiagC1_C3 = matrix.
getCoeff(c1, c3);
const T_Scalar _RRConstant
Matrix & getMatrix(const Index &rowIndex, const Index &colIndex)
CCMatrix::DiagArray DiagArray
const StorageSite & getParentFaceGroupSite() const
OffDiag & getCoeff(const int i, const int j)
const GeomFields & _geomFields
CRMatrix< Diag, OffDiag, X > CCMatrix
Array< Diag > & getDiag()
Field & _temperatureField
const StorageSite & getOtherFaceGroupSite() const
pair< const Field *, const StorageSite * > ArrayIndex
Field & _speciesConcentrationField
const CRConnectivity & getCellCells() const
const StorageSite & getCells() const
const CRConnectivity & getFaceCells(const StorageSite &site) const
BatteryLinearizePotentialInterface(const GeomFields &geomFields, Field &varField, Field &speciesConcentrationField, Field &temperatureField, const T_Scalar RRConstant, const bool Anode, const bool Cathode)
Vector< T_Scalar, 3 > VectorT3
Array< VectorT3 > VectorT3Array
NumTypeTraits< X >::T_Scalar T_Scalar
void discretize(const Mesh &mesh, const Mesh &parentMesh, const Mesh &otherMesh, MultiFieldMatrix &mfmatrix, MultiField &xField, MultiField &rField)