Skip to content

Commit

Permalink
#613 add dfn paper, and make casadi not default
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsulzer committed Feb 11, 2020
1 parent 6606630 commit a4d9b04
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
12 changes: 12 additions & 0 deletions pybamm/CITATIONS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
doi = {10.1007/s12532-018-0139-4}
}

@article{doyle1993modeling,
title={Modeling of galvanostatic charge and discharge of the lithium/polymer/insertion cell},
author={Doyle, M and Fuller, TF and Newman, J},
journal={Journal of the Electrochemical society},
volume={140},
number={6},
pages={1526--1533},
year={1993},
publisher={The Electrochemical Society},
note = {\href{ http://dx.doi.org/10.1149/1.2221597}{doi: 10.1149/1.2221597}},
}

@techreport{hindmarsh2000pvode,
title={The {PVODE} and {IDA} algorithms},
author={Hindmarsh, AC},
Expand Down
3 changes: 1 addition & 2 deletions pybamm/citations.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ def _reset(self):
"Reset citations to default only (only for testing purposes)"
# Initialize empty papers to cite
self._papers_to_cite = set()
# Register the PyBaMM and CasADi papers
# Register the PyBaMM paper
self.register("sulzer2020python")
self.register("Andersson2019")

def read_citations(self):
"Read the citations text file"
Expand Down
2 changes: 2 additions & 0 deletions pybamm/expression_tree/operations/convert_to_casadi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class CasadiConverter(object):
def __init__(self, casadi_symbols=None):
self._casadi_symbols = casadi_symbols or {}

pybamm.citations.register("Andersson2019")

def convert(self, symbol, t=None, y=None, u=None):
"""
This function recurses down the tree, converting the PyBaMM expression tree to
Expand Down
2 changes: 2 additions & 0 deletions pybamm/models/full_battery_models/lithium_ion/dfn.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def __init__(self, options=None, name="Doyle-Fuller-Newman model", build=True):
if build:
self.build_model()

pybamm.citations.register("doyle1993modeling")

def set_porosity_submodel(self):

self.submodels["porosity"] = pybamm.porosity.Constant(self.param)
Expand Down
16 changes: 14 additions & 2 deletions tests/unit/test_citations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ def test_citations(self):
citations = pybamm.citations
citations._reset()
# Default papers should be in both _all_citations dict and in the papers to cite
self.assertIn("Andersson2019", citations._all_citations.keys())
self.assertIn("Andersson2019", citations._papers_to_cite)
self.assertIn("sulzer2020python", citations._all_citations.keys())
self.assertIn("sulzer2020python", citations._papers_to_cite)
# Non-default papers should only be in the _all_citations dict
Expand All @@ -28,6 +26,13 @@ def test_print_citations(self):
pybamm.citations._papers_to_cite = set()
pybamm.print_citations()

def test_Andersson_2019(self):
citations = pybamm.citations
citations._reset()
self.assertNotIn("Andersson2019", citations._papers_to_cite)
pybamm.CasadiConverter()
self.assertIn("Andersson2019", citations._papers_to_cite)

def test_marquis_2019(self):
# Test that calling relevant bits of code adds the right paper to citations
citations = pybamm.citations
Expand All @@ -45,6 +50,13 @@ def test_marquis_2019(self):
pybamm.ParameterValues(chemistry=pybamm.parameter_sets.Marquis2019)
self.assertIn("marquis2019asymptotic", citations._papers_to_cite)

def test_doyle_1993(self):
citations = pybamm.citations
citations._reset()
self.assertNotIn("doyle1993modeling", citations._papers_to_cite)
pybamm.lithium_ion.DFN(build=False)
self.assertIn("doyle1993modeling", citations._papers_to_cite)

def test_sulzer_2019(self):
# Test that calling relevant bits of code adds the right paper to citations
citations = pybamm.citations
Expand Down

0 comments on commit a4d9b04

Please sign in to comment.