Skip to content

Commit

Permalink
Fixes battery plot labels (#117)
Browse files Browse the repository at this point in the history
* FIX: fixed alignment of voltage plot labels and reran examples

* MAINT: minor tweaks to unify volume for binary/ternary electrodes
  • Loading branch information
ml-evs authored Oct 16, 2020
1 parent 8424382 commit f069cb2
Show file tree
Hide file tree
Showing 12 changed files with 291 additions and 217 deletions.
21 changes: 0 additions & 21 deletions examples/interactive/voltage/Li-bcc.res

This file was deleted.

69 changes: 0 additions & 69 deletions examples/interactive/voltage/LiP-ColCode23621.res

This file was deleted.

21 changes: 0 additions & 21 deletions examples/interactive/voltage/LiP-CollCode165990.res

This file was deleted.

21 changes: 0 additions & 21 deletions examples/interactive/voltage/LiP-CollCode182159.res

This file was deleted.

45 changes: 0 additions & 45 deletions examples/interactive/voltage/LiP-CollCode60774.res

This file was deleted.

1 change: 1 addition & 0 deletions examples/interactive/voltage/LiP_structures
9 changes: 0 additions & 9 deletions examples/interactive/voltage/P-CollCode150873.res

This file was deleted.

1 change: 1 addition & 0 deletions examples/interactive/voltage/ternary_structures
302 changes: 280 additions & 22 deletions examples/interactive/voltage/voltage_from_res_files.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions matador/battery/electrode.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def voltage_summary(self, csv=False):
with open(fname, 'w') as f:
f.write(data_str)

return 'Voltage data:\n\n{}'.format(data_str)
return f"\nVoltage data:\n\n{data_str}"

def __repr__(self):
self.voltage_summary(csv=False)
return self.voltage_summary(csv=False)
6 changes: 3 additions & 3 deletions matador/hull/hull.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,13 +689,13 @@ def _calculate_ternary_voltage_curve(self, hull_cursor):
self.voltage_data.append(profile)

if not self._non_elemental:
self.volume_data['x'].append(capacities)
self.volume_data['Q'].append(capacities)
self.volume_data['x'].append(capacities[:-1])
self.volume_data['Q'].append(capacities[:-1])
self.volume_data['electrode_volume'].append(volumes)
self.volume_data['endstoichs'].append(endstoichs[reaction_ind])
self.volume_data['volume_ratio_with_bulk'].append(np.asarray(volumes) / volumes[0])
self.volume_data['volume_expansion_percentage'].append(((np.asarray(volumes) / volumes[0]) - 1) * 100)
self.volume_data['hull_distances'].append(np.zeros_like(capacities))
self.volume_data['hull_distances'].append(np.zeros_like(self.volume_data["x"][-1]))

def _calculate_binary_volume_curve(self):
""" Take stable compositions and volume and calculate volume
Expand Down
8 changes: 4 additions & 4 deletions matador/plotting/battery_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def plot_voltage_curve(
if labels:
if len(profiles) > 1:
print("Only labelling first voltage profile.")
for ind, reaction in enumerate(profiles[0].reactions):
for ind, reaction in enumerate(profiles[0].reactions[:-1]):
_labels = []
for phase in reaction:
if phase[0] is None or phase[0] == 1.0:
Expand All @@ -111,7 +111,7 @@ def plot_voltage_curve(
_label += "{}".format(phase[1])
_labels.append(_label)
_label = '+'.join(_labels)
_position = (profiles[0].capacities[ind], profiles[0].voltages[ind] + max(profiles[0].voltages)*0.01)
_position = (profiles[0].capacities[ind+1], profiles[0].voltages[ind+1] + max(profiles[0].voltages)*0.01)
ax.annotate(_label, xy=_position, textcoords="data", ha="center", zorder=9999)

if expt or len(profiles) > 1:
Expand Down Expand Up @@ -206,13 +206,13 @@ def plot_volume_curve(hull, ax=None, show=True, legend=False, as_percentages=Fal
raise RuntimeError("This plot does not support --hull_cutoff.")

ax.plot(
[q for ind, q in enumerate(hull.volume_data['Q'][j][:-1]) if stable_hull_dist[ind] == 0],
[q for ind, q in enumerate(hull.volume_data['Q'][j]) if stable_hull_dist[ind] == 0],
[v for ind, v in enumerate(hull.volume_data[volume_key][j]) if stable_hull_dist[ind] == 0],
marker='o', markeredgewidth=1.5, markeredgecolor='k', c=c, zorder=1000, lw=0,
)

ax.plot(
[q for ind, q in enumerate(hull.volume_data['Q'][j][:-1]) if stable_hull_dist[ind] == 0],
[q for ind, q in enumerate(hull.volume_data['Q'][j]) if stable_hull_dist[ind] == 0],
[v for ind, v in enumerate(hull.volume_data[volume_key][j]) if stable_hull_dist[ind] == 0],
lw=2, c=c,
label=("{}"
Expand Down

0 comments on commit f069cb2

Please sign in to comment.