Skip to content

Commit

Permalink
reverted to changes with the temperature ghost points
Browse files Browse the repository at this point in the history
  • Loading branch information
lightningclaw001 committed Feb 3, 2023
1 parent dad93bf commit 3880d4d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 14 additions & 3 deletions mpet/mod_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ def __init__(self, config, Name, Parent=None, Description=""):
self.c_lyteGP_L = dae.daeVariable("c_lyteGP_L", conc_t, self, "c_lyte left BC GP")
self.phi_lyteGP_L = dae.daeVariable(
"phi_lyteGP_L", elec_pot_t, self, "phi_lyte left BC GP")
self.T_lyteGP_L = dae.daeVariable(
"T_lyteGP_L", temp_t, self, "T_lyte left BC GP")
self.T_lyteGP_R = dae.daeVariable(
"T_lyteGP_R", temp_t, self, "T_lyte left BC GP")
self.phi_applied = dae.daeVariable(
"phi_applied", elec_pot_t, self,
"Overall battery voltage (at anode current collector)")
Expand Down Expand Up @@ -338,7 +342,7 @@ def DeclareEquations(self):
# Ghost points on the left and no-gradients on the right
ctmp = np.hstack((self.c_lyteGP_L(), cvec, cvec[-1]))
# temperature uses a constant boundary condition
Ttmp = np.hstack((config["T"], Tvec, config["T"]))
Ttmp = np.hstack((self.T_lyteGP_L(), Tvec, self.T_lyteGP_R()))
phitmp = np.hstack((self.phi_lyteGP_L(), phivec, phivec[-1]))

Nm_edges, i_edges, q_edges = get_lyte_internal_fluxes(ctmp, phitmp, Ttmp, disc,
Expand Down Expand Up @@ -377,6 +381,12 @@ def DeclareEquations(self):
eqC.Residual = ctmp[0] - ctmp[1]
eqP.Residual = phitmp[0] - phitmp[1]

# boundary equation for temperature variables. per volume
eqTL = self.CreateEquation("GhostPointT_L")
eqTR = self.CreateEquation("GhostPointT_R")
eqTL.Residual = Ttmp[0] - config["T"]
eqTR.Residual = Ttmp[-1] - config["T"]

dvgNm = np.diff(Nm_edges)/disc["dxvec"]
dvgi = np.diff(i_edges)/disc["dxvec"]
dvgq = np.diff(q_edges)/disc["dxvec"]
Expand Down Expand Up @@ -551,8 +561,9 @@ def get_lyte_internal_fluxes(c_lyte, phi_lyte, T_lyte, disc, config, Nvol):
Dm = eps_o_tau_edges * config["Dm"]
Nm_edges_int = num*(-Dm*np.diff(c_lyte)/dxd1
- Dm/T_edges_int*zm*c_edges_int*np.diff(phi_lyte)/dxd1)
i_edges_int = (-((nup*zp*Dp + num*zm*Dm)*np.diff(c_lyte)/dxd1) - (nup*zp
** 2*Dp + num*zm**2*Dm)/T_edges_int*c_edges_int*np.diff(phi_lyte)/dxd1)
i_edges_int = (-((nup*zp*Dp + num*zm*Dm)*np.diff(c_lyte)/dxd1)
- (nup*zp**2*Dp + num*zm**2*Dm)/T_edges_int
* c_edges_int*np.diff(phi_lyte)/dxd1)
elif config["elyteModelType"] == "SM":
SMset = config["SMset"]
elyte_function = utils.import_function(config["SMset_filename"], SMset,
Expand Down
2 changes: 2 additions & 0 deletions mpet/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ def SetUpVariables(self):
if not self.m.SVsim:
self.m.c_lyteGP_L.SetInitialGuess(config["c0"])
self.m.phi_lyteGP_L.SetInitialGuess(0)
self.m.T_lyteGP_L.SetInitialGuess(config["T"])
self.m.T_lyteGP_R.SetInitialGuess(config["T"])

# Separator electrolyte initialization
if config["have_separator"]:
Expand Down

0 comments on commit 3880d4d

Please sign in to comment.