Skip to content

Commit

Permalink
#858 misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
martinjrobins committed Mar 7, 2020
1 parent 5a0da61 commit 9ba63f6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions pybamm/discretisations/discretisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,10 @@ def check_initial_conditions_rhs(self, model):
y0 = model.concatenated_initial_conditions
# Individual
for var in model.rhs.keys():
print('rhs')
print(model.rhs[var])
print('init')
print(model.initial_conditions[var])
assert (
model.rhs[var].shape == model.initial_conditions[var].shape
), pybamm.ModelError(
Expand Down
3 changes: 2 additions & 1 deletion pybamm/expression_tree/symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ def shape(self):
try:
y = np.linspace(0.1, 0.9, int(1e4))
evaluated_self = self.evaluate(0, y, y, u="shape test")
print('evaluated self is ',evaluated_self)
# If that fails, fall back to calculating how big y should really be
except ValueError:
state_vectors_in_node = [
Expand All @@ -726,7 +727,7 @@ def shape(self):
)
# Pick a y that won't cause RuntimeWarnings
y = np.linspace(0.1, 0.9, min_y_size)
evaluated_self = self.evaluate(0, y)
evaluated_self = self.evaluate(0, y, y)

# Return shape of evaluated object
if isinstance(evaluated_self, numbers.Number):
Expand Down
1 change: 0 additions & 1 deletion pybamm/solvers/base_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ def report(string):
else:
# Process with CasADi
report(f"Converting {name} to CasADi")
print(u_casadi)
func = func.to_casadi(t_casadi, y_casadi, u=u_casadi)
if use_jacobian:
report(f"Calculating jacobian for {name} using CasADi")
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/test_parameters/test_parameters_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,11 @@ def test_list_params(self):
# ./input/parameters/lithium-ion/cathodes/tmp_dir
# but must not intefere with existing input dir if it exists
# in the current dir...

if __name__ == "__main__":
print("Add -v for more debug output")
import sys

if "-v" in sys.argv:
debug = True
unittest.main()
1 change: 0 additions & 1 deletion tests/unit/test_solvers/test_casadi_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,5 +337,4 @@ def test_model_solver_with_dvdt(self):
if "-v" in sys.argv:
debug = True
pybamm.settings.debug_mode = True
pybamm.set_logging_level("DEBUG")
unittest.main()

0 comments on commit 9ba63f6

Please sign in to comment.