-
-
Notifications
You must be signed in to change notification settings - Fork 554
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split the models into separate classes
- Loading branch information
1 parent
c79113e
commit ee27daf
Showing
23 changed files
with
602 additions
and
105 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
.virtual_documents/docs/source/examples/notebooks/models/tortuosity_models.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
import pybamm | ||
import numpy as np | ||
|
||
|
||
sols = [] | ||
te_opts = pybamm.BatteryModelOptions({}).possible_options["transport efficiency"] | ||
parameter_values = pybamm.ParameterValues("Marquis2019") | ||
print(te_opts) | ||
|
||
|
||
parameter_values.search("porosity") | ||
|
||
|
||
parameter_values.search("Bruggeman") | ||
|
||
|
||
|
||
|
||
|
||
parameter_values.update({'Negative electrode tortuosity factor (electrolyte)': 0.3**(-0.5), | ||
'Positive electrode tortuosity factor (electrolyte)': 0.3**(-0.5), | ||
'Negative electrode tortuosity factor (electrode)': 0.7**(-0.5), | ||
'Positive electrode tortuosity factor (electrode)': 0.7**(-0.5), | ||
'Separator tortuosity factor (electrolyte)': 1.0}, check_already_exists=False) | ||
|
||
|
||
|
||
|
||
|
||
for t_label in te_opts: | ||
model = pybamm.lithium_ion.DFN(options={'transport efficiency': t_label}) # Doyle-Fuller-Newman model | ||
sim = pybamm.Simulation(model, parameter_values=parameter_values) | ||
sols.append(sim.solve([0, 3600])) # solve for 1 hour | ||
|
||
|
||
pybamm.dynamic_plot(sols,labels=te_opts) | ||
|
||
|
||
|
||
|
||
|
||
np.allclose(sols[0]["Terminal voltage [V]"].data, sols[4]["Terminal voltage [V]"].data) | ||
|
||
|
||
|
||
|
||
|
||
parameter_values.update({'Negative electrode tortuosity factor (electrolyte)': 4.0, | ||
'Positive electrode tortuosity factor (electrolyte)': 4.0, | ||
'Negative electrode tortuosity factor (electrode)': 3.0, | ||
'Positive electrode tortuosity factor (electrode)': 3.0, | ||
'Separator tortuosity factor (electrolyte)': 1.5}, check_already_exists=False) | ||
|
||
|
||
model = pybamm.lithium_ion.DFN(options={'transport efficiency': "tortuosity factor"}) # Doyle-Fuller-Newman model | ||
sim = pybamm.Simulation(model, parameter_values=parameter_values) | ||
sols.append(sim.solve([0, 3600])) | ||
|
||
|
||
pybamm.dynamic_plot(sols,labels=te_opts+["higher tortuosity factor"]) | ||
|
||
|
||
|
||
|
||
|
||
pybamm.print_citations() |
5 changes: 5 additions & 0 deletions
5
docs/source/api/models/submodels/transport_efficiency/bruggeman.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Bruggeman Transport Efficiency Model | ||
==================================== | ||
|
||
.. autoclass:: pybamm.transport_efficiency.Bruggeman | ||
:members: |
5 changes: 5 additions & 0 deletions
5
docs/source/api/models/submodels/transport_efficiency/cation_exchange_membrane.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Cation-Exchange Membrane Transport Efficiency Model | ||
=================================================== | ||
|
||
.. autoclass:: pybamm.transport_efficiency.CationExchangeMembrane | ||
:members: |
5 changes: 0 additions & 5 deletions
5
...urce/api/models/submodels/transport_efficiency/general_transport_efficiency.rst
This file was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
docs/source/api/models/submodels/transport_efficiency/heterogeneous_catalyst.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Heterogeneous Catalyst Transport Efficiency Model | ||
================================================= | ||
|
||
.. autoclass:: pybamm.transport_efficiency.HeterogeneousCatalyst | ||
:members: |
5 changes: 5 additions & 0 deletions
5
docs/source/api/models/submodels/transport_efficiency/hyperbola_of_revolution.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Hyperbola of Revolution Transport Efficiency Model | ||
================================================== | ||
|
||
.. autoclass:: pybamm.transport_efficiency.HyperbolaOfRevolution | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
docs/source/api/models/submodels/transport_efficiency/ordered_packing.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Ordered Packing Transport Efficiency Model | ||
========================================== | ||
|
||
.. autoclass:: pybamm.transport_efficiency.OrderedPacking | ||
:members: |
5 changes: 5 additions & 0 deletions
5
docs/source/api/models/submodels/transport_efficiency/overlapping_spheres.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Overlapping Spheres Transport Efficiency Model | ||
============================================== | ||
|
||
.. autoclass:: pybamm.transport_efficiency.OverlappingSpheres | ||
:members: |
5 changes: 5 additions & 0 deletions
5
...urce/api/models/submodels/transport_efficiency/random_overlapping_cylinders.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Random Overlapping Cylinders Transport Efficiency Model | ||
======================================================= | ||
|
||
.. autoclass:: pybamm.transport_efficiency.RandomOverlappingCylinders | ||
:members: |
5 changes: 5 additions & 0 deletions
5
docs/source/api/models/submodels/transport_efficiency/tortuosity_factor.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Tortuosity Factor Transport Efficiency Model | ||
============================================ | ||
|
||
.. autoclass:: pybamm.transport_efficiency.TortuosityFactor | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
from .base_transport_efficiency import BaseModel | ||
from .general_transport_efficiency import GeneralTransportEfficiency | ||
from .bruggeman import Bruggeman | ||
from .cation_exchange_membrane import CationExchangeMembrane | ||
from .heterogeneous_catalyst import HeterogeneousCatalyst | ||
from .hyperbola_of_revolution import HyperbolaOfRevolution | ||
from .ordered_packing import OrderedPacking | ||
from .overlapping_spheres import OverlappingSpheres | ||
from .random_overlapping_cylinders import RandomOverlappingCylinders | ||
from .tortuosity_factor import TortuosityFactor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# | ||
# Class for Bruggeman transport_efficiency | ||
# | ||
import pybamm | ||
from .base_transport_efficiency import BaseModel | ||
|
||
|
||
class Bruggeman(BaseModel): | ||
"""Submodel for transport_efficiency | ||
Parameters | ||
---------- | ||
param : parameter class | ||
The parameters to use for this submodel | ||
component : str | ||
The material for the model ('electrolyte' or 'electrode'). | ||
options : dict, optional | ||
A dictionary of options to be passed to the model. | ||
""" | ||
|
||
def __init__(self, param, component, options=None): | ||
super().__init__(param, component, options=options) | ||
|
||
def get_coupled_variables(self, variables): | ||
if self.component == "Electrolyte": | ||
tor_dict = {} | ||
for domain in self.options.whole_cell_domains: | ||
Domain = domain.capitalize() | ||
eps_k = variables[f"{Domain} porosity"] | ||
pybamm.citations.register("bruggeman1935berechnung") | ||
b_k = self.param.domain_params[domain.split()[0]].b_e | ||
tor_k = eps_k**b_k | ||
tor_dict[domain] = tor_k | ||
elif self.component == "Electrode": | ||
tor_dict = {} | ||
for domain in self.options.whole_cell_domains: | ||
if domain == "separator": | ||
tor_k = pybamm.FullBroadcast(0, "separator", "current collector") | ||
else: | ||
Domain = domain.capitalize() | ||
phi_k = (1 - variables[f"{Domain} porosity"]) | ||
pybamm.citations.register("bruggeman1935berechnung") | ||
b_k = self.param.domain_params[domain.split()[0]].b_s | ||
tor_k = phi_k**b_k | ||
tor_dict[domain] = tor_k | ||
variables.update(self._get_standard_transport_efficiency_variables(tor_dict)) | ||
|
||
return variables | ||
|
||
|
Oops, something went wrong.