Custom model ShapeError debugging #3810
-
Hello everyone, I am trying to program a custom model in pybamm. It simulates a full Li-ion cell, and solves the mass and charge balances on the macroscale (I do not discretise within electrode particles). I have been replicating the basic_dfn file in the pybamm package as much as possible and using the examples on the webpage. However, when it comes to the discretisation step:
I am getting a ShapeError. From debugging, it looks like a vector of length 61 called disc_left and a MatrixMultiplication of shape (59,1) called disc_right are created by the discretisation script, which I guess is the source of the error, but I don't know how to fix it. Any pointers on things I could try would be great!
if you have read this far.. sorry for the code style, I just wanted to get everything working before I started formatting the class :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
This kind of off-by-two shape error is usually because you are trying to add together a gradient (which is defined on cell edges in the finite volume method) to a variable (which is defined on cell centres), so I'd look at checking your equations to see if you are accidentally doing this anywhere. You can add |
Beta Was this translation helpful? Give feedback.
PyBaMM looks for boundary conditions with keys matching what's inside
grad
. In your case you likely had a boundary condition forc_e
, not forlog(c_e)
.