Skip to content

Commit

Permalink
fix examples
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsulzer committed Feb 20, 2023
1 parent ee69970 commit 3708a08
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
11 changes: 6 additions & 5 deletions examples/notebooks/models/submodel_cracking_DFN_or_SPM.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@
],
"source": [
"# extract voltage\n",
"stress_t_n_surf = solution[\"Negative particle surface tangential stress\"]\n",
"E_n = param[\"Negative electrode Young's modulus [Pa]\"]\n",
"stress_t_n_surf = solution[\"Negative particle surface tangential stress [Pa]\"] / E_n\n",
"x = solution[\"x [m]\"].entries[0:19, 0]\n",
"c_s_n = solution['Negative particle concentration']\n",
"r_n = solution[\"r_n [m]\"].entries[:, 0, 0]\n",
Expand Down Expand Up @@ -209,10 +210,10 @@
"source": [
"label = [\"Crack model\"]\n",
"output_variables = [\n",
" \"Negative particle crack length\", \n",
" \"Positive particle crack length\",\n",
" \"X-averaged negative particle crack length\",\n",
" \"X-averaged positive particle crack length\"\n",
" \"Negative particle crack length [m]\", \n",
" \"Positive particle crack length [m]\",\n",
" \"X-averaged negative particle crack length [m]\",\n",
" \"X-averaged positive particle crack length [m]\"\n",
"]\n",
"quick_plot = pybamm.QuickPlot(solution, output_variables, label,variable_limits='tight')\n",
"quick_plot.dynamic_plot();\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,11 @@
}
],
"source": [
"S_t_n_all = solution[\"X-averaged negative particle surface tangential stress\"].entries\n",
"S_t_p_all = solution[\"X-averaged positive particle surface tangential stress\"].entries\n",
"E_n = param[\"Negative electrode Young's modulus [Pa]\"]\n",
"E_p = param[\"Positive electrode Young's modulus [Pa]\"]\n",
"\n",
"S_t_n_all = solution[\"X-averaged negative particle surface tangential stress [Pa]\"].entries / E_n\n",
"S_t_p_all = solution[\"X-averaged positive particle surface tangential stress [Pa]\"].entries / E_p\n",
"f, (ax1, ax2) = plt.subplots(1, 2 ,figsize=(10,4))\n",
"ax1.plot(t_all, S_t_n_all, label=\"loss of active material model\")\n",
"ax1.set_xlabel(\"Time [h]\")\n",
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/test_models/standard_output_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,8 @@ def test_conservation(self):
# for some reason the Newman-Tobias model has a larger error
# this seems to be linked to using constant concentration but not sure why
decimal = 12
elif self.model.options["particle phases"] == "2":
decimal = 13
else:
decimal = 14
np.testing.assert_array_almost_equal(diff, 0, decimal=decimal)
Expand Down

0 comments on commit 3708a08

Please sign in to comment.