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 546 convection #635

Merged
merged 81 commits into from
Apr 9, 2020
Merged
Changes from 1 commit
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
eaa88b7
#546 adding transient convection model
valentinsulzer Jul 31, 2019
7f181a7
#546 adding more variables
valentinsulzer Jul 31, 2019
def2758
#546 split convection into through-cell and transverse
valentinsulzer Jul 31, 2019
f959d28
#546 merge
valentinsulzer Aug 1, 2019
186ddaa
#546 leading-order convection working
valentinsulzer Aug 1, 2019
b6702fb
#546 composite convection
valentinsulzer Aug 1, 2019
1f53999
#546 all convections working well
valentinsulzer Aug 1, 2019
94e1604
#546 testing parameters
valentinsulzer Aug 1, 2019
054e665
Merge branch 'issue-546-models' into issue-546-convection
valentinsulzer Aug 1, 2019
e12a777
#546 reformatting FOQS
valentinsulzer Aug 1, 2019
49560c0
#546 merge models branch
valentinsulzer Aug 2, 2019
cbbf76d
Merge branch 'master' into issue-546-convection
valentinsulzer Aug 2, 2019
6f717ad
#546 fix typo in parameter file
valentinsulzer Aug 2, 2019
fd0dc47
comparing comsol for lead acid
valentinsulzer Aug 3, 2019
c4b559e
#546 add new composite model
valentinsulzer Aug 3, 2019
905676f
#546 add dVdz term to full and leading order models
valentinsulzer Aug 3, 2019
4b319d0
#546 add quite conductive model
valentinsulzer Aug 3, 2019
fbe4cb3
progress on 1d
valentinsulzer Aug 3, 2019
f680369
#546 starting 2d results
valentinsulzer Aug 4, 2019
d877644
#546 some 2D results
valentinsulzer Aug 4, 2019
8d3729a
#546 more 2d results
valentinsulzer Aug 4, 2019
9e1b4d7
#546 add x-z plots
valentinsulzer Aug 4, 2019
3524990
#546 fix quite composite averaged model
valentinsulzer Aug 5, 2019
cf3f676
#546 some cleaning up
valentinsulzer Aug 5, 2019
8371073
#546 polish quite conductive results
valentinsulzer Aug 5, 2019
4ea5e0b
#546 timing
valentinsulzer Aug 5, 2019
fd8f520
merge
valentinsulzer Aug 5, 2019
a44567a
#546 more 2d results (poorly conducting and quite conducting done)
valentinsulzer Aug 5, 2019
e879013
#546 merge comsol branch
valentinsulzer Aug 5, 2019
ff8cd40
#546 computing errors
valentinsulzer Aug 6, 2019
4daa698
#546 comparing comsol
valentinsulzer Aug 6, 2019
ec58527
#546 more resolution on RMSE plot
valentinsulzer Aug 6, 2019
1e92c30
#546 voltage comparison with comsol working (a bit meh)
valentinsulzer Aug 6, 2019
4ed7595
Merge branch 'issue-546-convection' of https://github.com/pybamm-team…
valentinsulzer Aug 6, 2019
8bce025
#546 time models
valentinsulzer Aug 6, 2019
92fa7bf
#546 prettier plot
valentinsulzer Aug 6, 2019
6ec973e
#546 more plotting ....
valentinsulzer Aug 6, 2019
2ea7384
merge
valentinsulzer Aug 6, 2019
d3541b1
#546 redoing plots
valentinsulzer Aug 7, 2019
8a28352
#546 A_e algebraic
valentinsulzer Aug 8, 2019
7d9e43a
#546 small edits
valentinsulzer Aug 8, 2019
71150b5
#546 more plots
valentinsulzer Sep 6, 2019
9cc48db
Merge branch 'issue-546-convection' of https://github.com/pybamm-team…
valentinsulzer Sep 6, 2019
004ae59
#546 editing README
valentinsulzer Sep 12, 2019
0aa7dd4
#546 merge master
valentinsulzer Sep 12, 2019
7475fa3
#546 update readme
valentinsulzer Sep 12, 2019
3039961
#546 renaming and labelling changes
valentinsulzer Sep 12, 2019
2ca4ab7
#546 cleaning up
valentinsulzer Sep 12, 2019
ca19833
#546 merge master
valentinsulzer Sep 13, 2019
b057a35
Merge branch 'issue-546-convection' of https://github.com/pybamm-team…
valentinsulzer Sep 24, 2019
3f5db34
#546 merge master
valentinsulzer Sep 24, 2019
73b1d76
#546 more merges
valentinsulzer Sep 25, 2019
c1ec330
#546 make discretised delta function dense
valentinsulzer Sep 25, 2019
107e627
#546 fix delta function
valentinsulzer Sep 26, 2019
b6188ce
#546 redo charge results with delta function
valentinsulzer Sep 26, 2019
01d3f94
#546 merge master
valentinsulzer Sep 26, 2019
392aa24
#546 merge master
valentinsulzer Dec 11, 2019
171de92
#546 fix import
valentinsulzer Dec 11, 2019
0606b24
#546 fix doc
valentinsulzer Dec 11, 2019
a68470e
#546 remove model
valentinsulzer Dec 12, 2019
6335ad3
#546 fix a few tests
valentinsulzer Dec 12, 2019
710b11e
Merge branch 'master' into issue-546-convection
valentinsulzer Dec 12, 2019
c1d9c62
#546 still fixing tests
valentinsulzer Dec 12, 2019
464e86c
move thesis results to separate repository
valentinsulzer Dec 12, 2019
755857e
#546 merge master
valentinsulzer Dec 13, 2019
3855d0e
#546 merge master
valentinsulzer Feb 5, 2020
d71cd6b
#546 merge develop
valentinsulzer Mar 28, 2020
6500ac9
#546 merge #923
valentinsulzer Mar 28, 2020
20b9815
#546 fix tests locally
valentinsulzer Mar 29, 2020
50c4f8c
#546 fix integration tests
valentinsulzer Mar 29, 2020
6f454f2
#546 merge develop
valentinsulzer Mar 30, 2020
90e15d5
Merge branch 'issue-923-reformat-electrolyte' into issue-546-convection
valentinsulzer Mar 31, 2020
9508f6b
Merge branch 'issue-923-reformat-electrolyte' into issue-546-convection
valentinsulzer Apr 5, 2020
8da375b
Merge branch 'develop' into issue-546-convection
valentinsulzer Apr 6, 2020
ce41f00
#546 remove macinnes_tplus
valentinsulzer Apr 6, 2020
85bc1fa
#546 remove levenshtein
valentinsulzer Apr 6, 2020
3bf83df
#546 changelog
valentinsulzer Apr 6, 2020
1302684
#546 rob comments
valentinsulzer Apr 8, 2020
1fcbd4e
#546 fix tests, clean up convection
valentinsulzer Apr 9, 2020
91a3a7b
#546 merge develop
valentinsulzer Apr 9, 2020
db1ba9d
#546 remove thermal cc
valentinsulzer Apr 9, 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
18 changes: 14 additions & 4 deletions results/2019_08_sulzer_thesis/2D/shared_plotting_2D.py
Original file line number Diff line number Diff line change
@@ -346,16 +346,26 @@ def plot_voltage_components(all_variables, t_eval, model, sigmas):


def plot_times(models_times, linestyles=None):
linestyles = linestyles or ["k-", "g--", "r:", "b-."]
linestyles = {
"1+1D Full": "k-",
"1D Full": "k:",
"1+1D Composite": "b-",
"1+1D Composite Averaged": "b--",
# "1D Composite": "b:",
"1+1D LOQS": "g-",
"1D LOQS": "g:",
}
all_npts = defaultdict(list)
solver_times = defaultdict(list)
fig, ax = plt.subplots(1, 1)
for i, (model, times) in enumerate(models_times.items()):
for i, (model, linestyle) in enumerate(linestyles.items()):
times = models_times[model]
for npts, solver_time in times.items():
all_npts[model].append(npts * 3)
solver_times[model].append(solver_time)
ax.loglog(all_npts[model], solver_times[model], label=model)
ax.loglog(all_npts[model], solver_times[model], linestyle, label=model)
ax.set_xlim(min(all_npts[model]), max(all_npts[model]))
ax.set_xlabel("Number of grid points")
ax.set_ylabel("Solver time [s]")
ax.legend(loc="best")
ax.legend(loc="center left", bbox_to_anchor=(1.05, 0.5))
fig.tight_layout()
96 changes: 96 additions & 0 deletions results/2019_08_sulzer_thesis/discharge_times_and_errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#
# Simulations: discharge of a lead-acid battery
#
import argparse
import matplotlib.pyplot as plt
import numpy as np
import pickle
import pybamm
import shared_plotting
from collections import defaultdict
from shared_solutions import model_comparison, convergence_study

try:
from config import OUTPUT_DIR
except ImportError:
OUTPUT_DIR = None


def plot_errors(models_times_and_voltages):
npts = 20
linestyles = ["k-", "g--", "r:", "b-."]
Crates = defaultdict(list)
voltage_errors = defaultdict(list)
fig, ax = plt.subplots(1, 1)
for i, (model, times_and_voltages) in enumerate(models_times_and_voltages.items()):
if model != "Full":
for Crate, variables in times_and_voltages[npts].items():
Crates[model].append(Crate)
full_voltage = models_times_and_voltages["Full"][npts][Crate][
"Battery voltage [V]"
]
reduced_voltage = variables["Battery voltage [V]"]
voltage_errors[model].append(pybamm.rmse(full_voltage, reduced_voltage))
ax.semilogx(
Crates[model], voltage_errors[model], linestyles[i], label=model
)
ax.set_xlabel("C-rate")
ax.set_ylabel("RMSE [V]")
ax.legend(loc="best")
fig.tight_layout()
file_name = "discharge_asymptotics_rmse.eps"
if OUTPUT_DIR is not None:
plt.savefig(OUTPUT_DIR + file_name, format="eps", dpi=1000)


def plot_times(models_times_and_voltages):
shared_plotting.plot_times(models_times_and_voltages, Crate=1)
file_name = "discharge_asymptotics_solver_times.eps"
if OUTPUT_DIR is not None:
plt.savefig(OUTPUT_DIR + file_name, format="eps", dpi=1000)


def discharge_times_and_errors(compute):
savefile = "discharge_asymptotics_times_and_errors.pickle"
if compute:
try:
with open(savefile, "rb") as f:
models_times_and_voltages = pickle.load(f)
except FileNotFoundError:
models_times_and_voltages = pybamm.get_infinite_nested_dict()
models = [
pybamm.lead_acid.NewmanTiedemann(
{"surface form": "algebraic"}, name="Full"
),
pybamm.lead_acid.LOQS(name="LOQS"),
pybamm.lead_acid.FOQS(name="FOQS"),
pybamm.lead_acid.CompositeExtended(name="Composite"),
]
Crates = np.linspace(0.01, 5, 2)
all_npts = [20]
t_eval = np.linspace(0, 1, 100)
new_models_times_and_voltages = convergence_study(
models, Crates, all_npts, t_eval
)
models_times_and_voltages.update(new_models_times_and_voltages)
with open(savefile, "wb") as f:
pickle.dump(models_times_and_voltages, f, pickle.HIGHEST_PROTOCOL)
else:
try:
with open(savefile, "rb") as f:
models_times_and_voltages = pickle.load(f)
except FileNotFoundError:
raise FileNotFoundError(
"Run script with '--compute' first to generate results"
)
plot_errors(models_times_and_voltages)
plot_times(models_times_and_voltages)


if __name__ == "__main__":
pybamm.set_logging_level("INFO")
parser = argparse.ArgumentParser()
parser.add_argument("--compute", action="store_true", help="(Re)-compute results.")
args = parser.parse_args()
discharge_times_and_errors(args.compute)
plt.show()
72 changes: 0 additions & 72 deletions results/2019_08_sulzer_thesis/lead_acid_discharge.py
Original file line number Diff line number Diff line change
@@ -88,82 +88,10 @@ def discharge_states(compute):
plot_voltage_components(all_variables, t_eval)


def plot_errors(models_times_and_voltages):
npts = 20
linestyles = ["k-", "g--", "r:", "b-."]
Crates = defaultdict(list)
voltage_errors = defaultdict(list)
fig, ax = plt.subplots(1, 1)
for i, (model, times_and_voltages) in enumerate(models_times_and_voltages.items()):
if model != "Full":
for Crate, variables in times_and_voltages[npts].items():
Crates[model].append(Crate)
full_voltage = models_times_and_voltages["Full"][npts][Crate][
"Battery voltage [V]"
]
reduced_voltage = variables["Battery voltage [V]"]
voltage_errors[model].append(pybamm.rmse(full_voltage, reduced_voltage))
ax.semilogx(
Crates[model], voltage_errors[model], linestyles[i], label=model
)
ax.set_xlabel("C-rate")
ax.set_ylabel("RMSE [V]")
ax.legend(loc="best")
fig.tight_layout()
file_name = "discharge_asymptotics_rmse.eps"
if OUTPUT_DIR is not None:
plt.savefig(OUTPUT_DIR + file_name, format="eps", dpi=1000)


def plot_times(models_times_and_voltages):
shared_plotting.plot_times(models_times_and_voltages, Crate=1)
file_name = "discharge_asymptotics_solver_times.eps"
if OUTPUT_DIR is not None:
plt.savefig(OUTPUT_DIR + file_name, format="eps", dpi=1000)


def discharge_times_and_errors(compute):
savefile = "discharge_asymptotics_times_and_errors.pickle"
if compute:
try:
with open(savefile, "rb") as f:
models_times_and_voltages = pickle.load(f)
except FileNotFoundError:
models_times_and_voltages = pybamm.get_infinite_nested_dict()
models = [
pybamm.lead_acid.NewmanTiedemann(
{"surface form": "algebraic"}, name="Full"
),
pybamm.lead_acid.LOQS(name="LOQS"),
# pybamm.lead_acid.FOQS(name="FOQS"),
# pybamm.lead_acid.Composite(name="Composite"),
]
Crates = np.linspace(0.01, 5, 2)
all_npts = [20]
t_eval = np.linspace(0, 1, 100)
new_models_times_and_voltages = convergence_study(
models, Crates, all_npts, t_eval
)
models_times_and_voltages.update(new_models_times_and_voltages)
with open(savefile, "wb") as f:
pickle.dump(models_times_and_voltages, f, pickle.HIGHEST_PROTOCOL)
else:
try:
with open(savefile, "rb") as f:
models_times_and_voltages = pickle.load(f)
except FileNotFoundError:
raise FileNotFoundError(
"Run script with '--compute' first to generate results"
)
plot_errors(models_times_and_voltages)
plot_times(models_times_and_voltages)


if __name__ == "__main__":
pybamm.set_logging_level("INFO")
parser = argparse.ArgumentParser()
parser.add_argument("--compute", action="store_true", help="(Re)-compute results.")
args = parser.parse_args()
discharge_states(args.compute)
# discharge_times_and_errors(args.compute)
plt.show()