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

#1077 update quickplot for fem #1078

Merged
merged 2 commits into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -12,6 +12,7 @@

## Bug fixes

- Fix `QuickPlot` to display variables discretised by FEM (in y-z) properly ([#1078](https://github.com/pybamm-team/PyBaMM/pull/1078))
- Add length scales to `EffectiveResistance` models ([#1071](https://github.com/pybamm-team/PyBaMM/pull/1071))
- Allowed for pybamm functions exp, sin, cos, sqrt to be used in expression trees that
are converted to casadi format ([#1067](https://github.com/pybamm-team/PyBaMM/pull/1067)
Expand Down
42 changes: 32 additions & 10 deletions pybamm/plotting/quick_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def set_output_variables(self, output_variables, solutions):

# Set the x variable (i.e. "x" or "r" for any one-dimensional variables)
if first_variable.dimensions == 1:
(spatial_var_name, spatial_var_value,) = self.get_spatial_var(
(spatial_var_name, spatial_var_value) = self.get_spatial_var(
variable_tuple, first_variable, "first"
)
self.spatial_variable_dict[variable_tuple] = {
Expand Down Expand Up @@ -579,10 +579,21 @@ def plot(self, t):
)
vmin, vmax = self.variable_limits[key]
# store the plot and the var data (for testing) as cant access
# z data from QuadContourSet object
self.plots[key][0][0] = ax.contourf(
x, y, var, levels=100, vmin=vmin, vmax=vmax, cmap="coolwarm"
)
# z data from QuadMesh or QuadContourSet object
if self.is_y_z[key] is True:
self.plots[key][0][0] = ax.pcolormesh(
x,
y,
var,
vmin=vmin,
vmax=vmax,
cmap="coolwarm",
shading="gouraud",
)
else:
self.plots[key][0][0] = ax.contourf(
x, y, var, levels=100, vmin=vmin, vmax=vmax, cmap="coolwarm"
)
self.plots[key][0][1] = var
if vmin is None and vmax is None:
vmin = ax_min(var)
Expand Down Expand Up @@ -710,11 +721,22 @@ def slider_update(self, t):
var = variable(time_in_seconds, **spatial_vars, warn=False)
else:
var = variable(time_in_seconds, **spatial_vars, warn=False).T
# store the plot and the updated var data (for testing) as cant
# access z data from QuadContourSet object
self.plots[key][0][0] = ax.contourf(
x, y, var, levels=100, vmin=vmin, vmax=vmax, cmap="coolwarm"
)
# store the plot and the var data (for testing) as cant access
# z data from QuadMesh or QuadContourSet object
if self.is_y_z[key] is True:
self.plots[key][0][0] = ax.pcolormesh(
x,
y,
var,
vmin=vmin,
vmax=vmax,
cmap="coolwarm",
shading="gouraud",
)
else:
self.plots[key][0][0] = ax.contourf(
x, y, var, levels=100, vmin=vmin, vmax=vmax, cmap="coolwarm"
)
self.plots[key][0][1] = var
if (vmin, vmax) == (None, None):
vmin = ax_min(var)
Expand Down