5 #ifndef _BATTERYLINEARIZESPECIESINTERFACE_H_
6 #define _BATTERYLINEARIZESPECIESINTERFACE_H_
23 template<
class X,
class Diag,
class OffDiag>
42 Field& speciesConcElectricModel,
43 Field& elecPotentialField,
44 Field& temperatureField):
65 const XArray& speciesConcElecModel =
71 const XArray& xCell =
dynamic_cast<const XArray&
>(xField[cVarIndex]);
73 XArray& rCell =
dynamic_cast<XArray&
>(rField[cVarIndex]);
94 XArray& rParentCell =
dynamic_cast<XArray&
>(rField[cVarIndexParent]);
97 const TArray& faceAreaMag =
105 XArray& rOtherCell =
dynamic_cast<XArray&
>(rField[cVarIndexOther]);
122 for (
int f=0; f<faces.
getCount(); f++)
125 int c0p = parentFaceCells(f,0);
126 int c1p = parentFaceCells(f,1);
136 const X parentFlux = rParentCell[c1p];
137 const OffDiag dRC0dXC3 = parentmatrix.
getCoeff(c1p, c0p);
138 const Diag dRC0dXC0 = parentdiag[c1p];
141 int c0o = otherFaceCells(f,0);
142 int c1o = otherFaceCells(f,1);
152 const X otherFlux = rOtherCell[c1o];
153 const OffDiag dRC0dXC2 = othermatrix.
getCoeff(c1o, c0o);
154 const OffDiag dRC0dXC1 = otherdiag[c1o];
159 const int c1 = cellCells(f,0);
160 const int c2 = cellCells(f,1);
161 const int c3 = cellCells(f,2);
163 const T_Scalar Temp = eTempCell[c0];
164 const T_Scalar C_a = alpha_a*F/R/Temp;
165 const T_Scalar C_c = alpha_c*F/R/Temp;
166 const T_Scalar Area = faceAreaMag[c0];
172 if (cs_star < 0.0){ cout <<
"ERROR: Cs < 0, Cs=" << cs_star << endl; cs_star = 0.0;}
173 if (ce_star < 0.0){ cout <<
"ERROR: Ce < 0, Ce=" << ce_star << endl; ce_star = 0.0;}
174 if (cs_star > csMax){ cout <<
"ERROR: Cs > CsMax, Cs=" << cs_star << endl; cs_star = csMax;}
176 const T_Scalar SOC = speciesConcElecModel[c1]/csMax;
180 U_ref = -0.16 + 1.32*exp(-3.0*SOC)+10.0*exp(-2000.0*SOC);
182 {U_ref = 0.0; cout <<
"U_ref < 0" << endl;}
184 {U_ref = 1.2; cout <<
"U_ref > 1.2" << endl;}
187 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));
189 {U_ref = 0.0; cout <<
"U_ref < 0" << endl;}
191 {U_ref = 5.0; cout <<
"U_ref > 5.0" << endl;}
194 const T_Scalar U = U_ref - (Temp - 298.0)*dU_dT;
195 const T_Scalar eta_star = ePotCell[c1] - ePotCell[c0] - U;
198 T_Scalar C_0 = exp(C_a*eta_star)-exp(-1.0*C_c*eta_star);
200 const T_Scalar i_star = C_0*k*F*Area*pow(ce_star,alpha_c)*pow((csMax-cs_star),alpha_a)*pow(cs_star,alpha_c);
207 const T_Scalar dC0dEta = (C_a*exp(C_a*eta_star) + C_c*exp(-1*C_c*eta_star));
210 dC_0dCS = dC0dEta*(-1.0)*(-20000.0*exp(-2000.0*SOC) - 3.96*exp(-3.0*SOC))*(1.0/csMax);
214 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);
217 const T_Scalar dIdCS_star = i_star*(alpha_c/cs_star - alpha_a/(csMax-cs_star)+ dC_0dCS/C_0);
219 const T_Scalar dIdCE_star = i_star*alpha_c/ce_star;
223 OffDiag& offdiagC0_C1 = matrix.
getCoeff(c0, c1);
224 OffDiag& offdiagC0_C2 = matrix.
getCoeff(c0, c2);
225 OffDiag& offdiagC0_C3 = matrix.
getCoeff(c0, c3);
227 rCell[c0] = F*otherFlux + F*parentFlux;
228 offdiagC0_C1 = F*dRC0dXC1;
229 offdiagC0_C3 = F*dRC0dXC3;
230 offdiagC0_C2 = F*dRC0dXC2;
231 diag[c0] = F*dRC0dXC0;
235 OffDiag& offdiagC1_C0 = matrix.
getCoeff(c1, c0);
236 OffDiag& offdiagC1_C2 = matrix.
getCoeff(c1, c2);
238 rCell[c1] = otherFlux*F - (i_star + dIdCS_star*(xCell[c1]-cs_star) + dIdCE_star*(xCell[c0]-ce_star));
239 offdiagC1_C0 = -1*dIdCE_star;
240 offdiagC1_C2 = F*dRC0dXC2;
242 if (dIdCS_star > 0.0)
244 diag[c1] = F*dRC0dXC1 - dIdCS_star;
248 diag[c1] = F*dRC0dXC1;
252 OffDiag& offdiagC1_C3 = matrix.
getCoeff(c1, c3);
Matrix & getMatrix(const Index &rowIndex, const Index &colIndex)
Field & _temperatureField
const StorageSite & getParentFaceGroupSite() const
Array< VectorT3 > VectorT3Array
const T_Scalar _RRConstant
Vector< T_Scalar, 3 > VectorT3
OffDiag & getCoeff(const int i, const int j)
const GeomFields & _geomFields
Array< Diag > & getDiag()
void discretize(const Mesh &mesh, const Mesh &parentMesh, const Mesh &otherMesh, MultiFieldMatrix &mfmatrix, MultiField &xField, MultiField &rField)
Field & _elecPotentialField
const StorageSite & getOtherFaceGroupSite() const
pair< const Field *, const StorageSite * > ArrayIndex
const CRConnectivity & getCellCells() const
BatteryLinearizeSpeciesInterface(const GeomFields &geomFields, const T_Scalar RRConstant, const T_Scalar interfaceUnderRelax, const bool Anode, const bool Cathode, Field &varField, Field &speciesConcElectricModel, Field &elecPotentialField, Field &temperatureField)
const StorageSite & getCells() const
NumTypeTraits< X >::T_Scalar T_Scalar
CCMatrix::DiagArray DiagArray
const CRConnectivity & getFaceCells(const StorageSite &site) const
CRMatrix< Diag, OffDiag, X > CCMatrix
Field & _speciesConcElectricModel
const T_Scalar _interfaceUnderRelax