Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 760 better processed variable #781

Merged
merged 38 commits into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1221ace
#760 add mesh to variable when discretising
valentinsulzer Dec 13, 2019
74ef7c5
#760 remove processed variable in examples and results
valentinsulzer Dec 13, 2019
9b8d517
#760 merge master
valentinsulzer Dec 13, 2019
930d551
#760 merge master + 492
valentinsulzer Dec 14, 2019
bc31eef
#760 create __getitem__ and start tests
valentinsulzer Dec 14, 2019
b00f762
#760 remove post_process_variables and use solution for that instead
valentinsulzer Dec 14, 2019
65e0650
#760 putting update back in
valentinsulzer Dec 20, 2019
372724f
Merge branch 'master' into issue-760-better-processed-variable
valentinsulzer Dec 22, 2019
5589429
#760 fix inputs and known evals
valentinsulzer Dec 22, 2019
6f6a587
Merge branch 'issue-763-compare-comsol' into issue-760-better-process…
valentinsulzer Dec 22, 2019
6a677dd
#760 fixing tests
valentinsulzer Dec 24, 2019
da859ea
#760 fix more processed variable tests
valentinsulzer Dec 26, 2019
cb05787
#760 merge 771
valentinsulzer Jan 6, 2020
f029078
#760 merge 771
valentinsulzer Jan 7, 2020
e7c21a3
Merge branch 'issue-774-remove-outer-kron' into issue-760-better-proc…
valentinsulzer Jan 8, 2020
cf3840d
#760 SPM tests pass
valentinsulzer Jan 8, 2020
feea6af
#760 fixing tests
valentinsulzer Jan 8, 2020
909b68f
#760 fixing examples
valentinsulzer Jan 8, 2020
5ae33d8
Merge branch 'issue-774-remove-outer-kron' into issue-760-better-proc…
valentinsulzer Jan 9, 2020
392944e
#760 fixing more examples
valentinsulzer Jan 9, 2020
5965e96
Merge branch 'issue-774-remove-outer-kron' into issue-760-better-proc…
valentinsulzer Jan 9, 2020
b5ed147
#760 remove remaining processed variables from examples
valentinsulzer Jan 9, 2020
7bd50db
Merge branch 'issue-771-secondary-broadcast' into issue-760-better-pr…
valentinsulzer Jan 9, 2020
04baaa3
#760 fix some tests and examples
valentinsulzer Jan 10, 2020
8ef9c0c
#760 fix integration tests
valentinsulzer Jan 10, 2020
b4792fd
Merge branch 'master' into issue-760-better-processed-variable
valentinsulzer Jan 10, 2020
a3126dd
#760 add test for solution length
valentinsulzer Jan 10, 2020
751dcf9
Merge branch 'issue-749-cache-symbol-shape' into issue-760-better-pro…
valentinsulzer Jan 10, 2020
613cb28
Merge branch 'master' into issue-760-better-processed-variable
valentinsulzer Jan 10, 2020
4d59541
#760 changelog
valentinsulzer Jan 10, 2020
6b9c4cc
#760 do the solution length check inside processed variable
valentinsulzer Jan 11, 2020
154042e
#760 fix known evals
valentinsulzer Jan 12, 2020
d1e03bb
#760 fix known evals
valentinsulzer Jan 13, 2020
ec253f6
add example on solution data
TomTranter Jan 13, 2020
4d0e8f2
change t-eval
TomTranter Jan 15, 2020
ac68112
merge master
valentinsulzer Jan 15, 2020
62dfe5a
#760 update append
valentinsulzer Jan 15, 2020
5fed948
Merge remote-tracking branch 'refs/remotes/origin/issue-760-better-pr…
valentinsulzer Jan 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Features

- Added the harmonic mean to the Finite Volume method, which is now used when computing fluxes ([#783](https://github.com/pybamm-team/PyBaMM/pull/783))
- Refactored `Solution` to make it a dictionary that contains all of the solution variables. This automatically creates `ProcessedVariable` objects when required, so that the solution can be obtained much more easily. ([#781](https://github.com/pybamm-team/PyBaMM/pull/781))
- Added notebook to explain broadcasts ([#776](https://github.com/pybamm-team/PyBaMM/pull/776))
- Added a step to discretisation that automatically compute the inverse of the mass matrix of the differential part of the problem so that the underlying DAEs can be provided in semi-explicit form, as required by the CasADi solver ([#769](https://github.com/pybamm-team/PyBaMM/pull/769))
- Added the gradient operation for the Finite Element Method ([#767](https://github.com/pybamm-team/PyBaMM/pull/767))
Expand Down
2 changes: 0 additions & 2 deletions docs/source/processed_variable.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
Post-Process Variables
======================

.. autofunction:: pybamm.post_process_variables

.. autoclass:: pybamm.ProcessedVariable
:members:
12 changes: 6 additions & 6 deletions examples/notebooks/change-input-current.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"solution = solver.solve(model, t_eval)\n",
"\n",
"# plot\n",
"quick_plot = pybamm.QuickPlot(model, mesh, solution)\n",
"quick_plot = pybamm.QuickPlot(solution)\n",
"\n",
"import ipywidgets as widgets\n",
"widgets.interact(quick_plot.plot, t=widgets.FloatSlider(min=0,max=solution.t[-1],step=0.005,value=0));"
Expand All @@ -107,7 +107,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The one case where we would change \"Current function\" instead of \"Typical current [A]\" is for a simulation at zero-current, since \"Typical current [A]\" cannot be zero (as it is used for non-dimensionalisation). In this case, the current function should be set to zero instead:"
"PyBaMM can also simulate rest behaviour by setting the current function to zero:"
]
},
{
Expand Down Expand Up @@ -154,7 +154,7 @@
"solution = solver.solve(model, t_eval)\n",
"\n",
"# plot\n",
"quick_plot = pybamm.QuickPlot(model, mesh, solution)\n",
"quick_plot = pybamm.QuickPlot(solution)\n",
"\n",
"import ipywidgets as widgets\n",
"widgets.interact(quick_plot.plot, t=widgets.FloatSlider(min=0,max=solution.t[-1],step=0.005,value=0));"
Expand Down Expand Up @@ -216,7 +216,7 @@
"solution = solver.solve(model, t_eval)\n",
"\n",
"# plot\n",
"quick_plot = pybamm.QuickPlot(model, mesh, solution)\n",
"quick_plot = pybamm.QuickPlot(solution)\n",
"\n",
"import ipywidgets as widgets\n",
"widgets.interact(quick_plot.plot, t=widgets.FloatSlider(min=0,max=solution.t[-1],step=0.001,value=0));"
Expand Down Expand Up @@ -331,7 +331,7 @@
"\n",
"# plot current and voltage\n",
"output_variables = [\"Current [A]\", \"Terminal voltage [V]\"]\n",
"quick_plot = pybamm.QuickPlot(model, mesh, solution, output_variables, label)\n",
"quick_plot = pybamm.QuickPlot(solution, output_variables, label)\n",
"\n",
"import ipywidgets as widgets\n",
"widgets.interact(quick_plot.plot, t=widgets.FloatSlider(min=0,max=solution.t[-1],step=solution.t[-1]/20,value=0));"
Expand Down Expand Up @@ -366,4 +366,4 @@
},
"nbformat": 4,
"nbformat_minor": 2
}
}
87 changes: 46 additions & 41 deletions examples/notebooks/change-settings.ipynb

Large diffs are not rendered by default.

29 changes: 21 additions & 8 deletions examples/notebooks/compare-comsol-discharge-curve.ipynb

Large diffs are not rendered by default.

10 changes: 3 additions & 7 deletions examples/notebooks/create-model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -576,12 +576,8 @@
"solution = solver.solve(model, t)\n",
"\n",
"# Extract output variables\n",
"L_out = pybamm.ProcessedVariable(\n",
" model.variables[\"SEI thickness\"], solution.t, solution.y, mesh\n",
")\n",
"c_out = pybamm.ProcessedVariable(\n",
" model.variables[\"Solvent concentration\"], solution.t, solution.y, mesh\n",
")\n",
"L_out = solution[\"SEI thickness\"]\n",
"c_out = solution[\"Solvent concentration\"]\n",
"x = np.linspace(0, 1, 100)"
]
},
Expand All @@ -600,7 +596,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "521ab96b2c074ac0a709cb3ae87b051e",
"model_id": "0f7f4e8850354ea3a745351e85077a75",
"version_major": 2,
"version_minor": 0
},
Expand Down
2 changes: 1 addition & 1 deletion examples/notebooks/models/DFN.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
}
],
"source": [
"quick_plot = pybamm.QuickPlot(model, mesh, solution)\n",
"quick_plot = pybamm.QuickPlot(solution)\n",
"\n",
"import ipywidgets as widgets\n",
"widgets.interact(quick_plot.plot, t=widgets.FloatSlider(min=0,max=solution.t[-1],step=0.05,value=0));"
Expand Down
117 changes: 74 additions & 43 deletions examples/notebooks/models/SPM.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/notebooks/models/SPMe.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
}
],
"source": [
"quick_plot = pybamm.QuickPlot(model, mesh, solution)\n",
"quick_plot = pybamm.QuickPlot(solution)\n",
"\n",
"import ipywidgets as widgets\n",
"widgets.interact(quick_plot.plot, t=widgets.FloatSlider(min=0,max=solution.t[-1],step=0.05,value=0));"
Expand Down Expand Up @@ -273,7 +273,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
"version": "3.7.3"
}
},
"nbformat": 4,
Expand Down
50 changes: 33 additions & 17 deletions examples/notebooks/models/compare-lithium-ion.ipynb

Large diffs are not rendered by default.

89 changes: 43 additions & 46 deletions examples/notebooks/models/lead-acid.ipynb

Large diffs are not rendered by default.

Binary file modified examples/notebooks/models/spm1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/notebooks/models/spm2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 12 additions & 12 deletions examples/notebooks/parameter-values.ipynb

Large diffs are not rendered by default.

493 changes: 493 additions & 0 deletions examples/notebooks/solution-data-and-processed-variables.ipynb

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions examples/notebooks/solvers/scikits-dae-solver.ipynb

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions examples/notebooks/solvers/scikits-ode-solver.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/notebooks/unsteady_heat_equation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"After solving, we can process variables using the class `pybamm.ProcessedVariable`. This returns a callable object which can be evaluated at any time and position by means of interpolating the solution. Processed variables provide a convinient way of comparing the solution to solutions from different models, or to exact solutions. Since all of the variables are names with informative strings, the user doesn't need to keep track of where they are stored in the state vector `solution.y`. This is particularly useful in complex models with lots of variables. Here we create `T_out` which is the processed temperature. In order to do so, we pass the variable, solution times, solution states, and the mesh to `pybamm.ProcessedVariable`."
"After solving, we can process variables using the class `pybamm.ProcessedVariable`. This returns a callable object which can be evaluated at any time and position by means of interpolating the solution. Processed variables provide a convinient way of comparing the solution to solutions from different models, or to exact solutions. Since all of the variables are names with informative strings, the user doesn't need to keep track of where they are stored in the state vector `solution.y`. This is particularly useful in complex models with lots of variables, and is automatically handled by the solution dictionary."
]
},
{
Expand All @@ -276,7 +276,7 @@
"metadata": {},
"outputs": [],
"source": [
"T_out = pybamm.ProcessedVariable(model.variables[\"Temperature\"], solution.t, solution.y, mesh)"
"T_out = solution[\"Temperature\"]"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions examples/notebooks/using-model-options_thermal-example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
" \"X-averaged cell temperature [K]\",\n",
" \"Cell temperature [K]\",\n",
"]\n",
"quick_plot = pybamm.QuickPlot(model, mesh, solution, output_variables)\n",
"quick_plot = pybamm.QuickPlot(solution, output_variables)\n",
"\n",
"import ipywidgets as widgets\n",
"widgets.interact(quick_plot.plot, t=widgets.FloatSlider(min=0,max=1,step=0.05,value=0));"
Expand Down Expand Up @@ -209,4 +209,4 @@
},
"nbformat": 4,
"nbformat_minor": 2
}
}
Loading