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 2334 reformat parameters #2342

Merged
merged 32 commits into from
Oct 11, 2022
Merged

Conversation

valentinsulzer
Copy link
Member

@valentinsulzer valentinsulzer commented Oct 4, 2022

Description

Change parameters to python files (+ some csv files). Breaking change.

Fixes #2334
Fixes #2077

Type of change

Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist:

  • No style issues: $ flake8
  • All tests pass: $ python run-tests.py --unit
  • The documentation builds: $ cd docs and then $ make clean; make html

You can run all three at once, using $ python run-tests.py --quick.

Further checks:

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@valentinsulzer valentinsulzer marked this pull request as draft October 4, 2022 18:26
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@codecov
Copy link

codecov bot commented Oct 6, 2022

Codecov Report

Base: 99.65% // Head: 99.65% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (408db86) compared to base (cb8a757).
Patch coverage: 100.00% of modified lines in pull request are covered.

❗ Current head 408db86 differs from pull request most recent head c3b0676. Consider uploading reports for the commit c3b0676 to get more accurate results

Additional details and impacted files
@@            Coverage Diff            @@
##           develop    #2342    +/-   ##
=========================================
  Coverage    99.65%   99.65%            
=========================================
  Files          361      269    -92     
  Lines        19948    20079   +131     
=========================================
+ Hits         19879    20010   +131     
  Misses          69       69            
Impacted Files Coverage Δ
pybamm/input/parameters/lead_acid/Sulzer2019.py 100.00% <100.00%> (ø)
pybamm/input/parameters/lithium_ion/Ai2020.py 100.00% <100.00%> (ø)
pybamm/input/parameters/lithium_ion/Chen2020.py 100.00% <100.00%> (ø)
...input/parameters/lithium_ion/Chen2020_composite.py 100.00% <100.00%> (ø)
pybamm/input/parameters/lithium_ion/Ecker2015.py 100.00% <100.00%> (ø)
pybamm/input/parameters/lithium_ion/Marquis2019.py 100.00% <100.00%> (ø)
pybamm/input/parameters/lithium_ion/Mohtat2020.py 100.00% <100.00%> (ø)
pybamm/input/parameters/lithium_ion/NCA_Kim2011.py 100.00% <100.00%> (ø)
pybamm/input/parameters/lithium_ion/OKane2022.py 100.00% <100.00%> (ø)
pybamm/input/parameters/lithium_ion/ORegan2022.py 100.00% <100.00%> (ø)
... and 71 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@valentinsulzer valentinsulzer marked this pull request as ready for review October 7, 2022 03:19
Copy link
Contributor

@rtimms rtimms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, this is much simpler!

pybamm/input/parameters/lithium_ion/Ai2020.py Outdated Show resolved Hide resolved
"""
m_ref = (
1 * 10 ** (-11) * pybamm.constants.F
) # (A/m2)(mol/m3)**1.5 - includes ref concentrations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment is wrong everywhere and has been forever haha. Shouldn't the units be (A/m2)(m3/mol)**1.5 or equivalent?

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Rob. I think it makes sense to leave the units, corrected though, as a quick sanity check.

output = preamble + "\n\n" + output

# Add pybamm. to functions that didn't have it in function body before
for funcname in [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add a broader set of "standard" functions here or wait and add them until people need them?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure ... also not sure whether we really need this function at all tbh?

Copy link
Sponsor Member

@brosaplanella brosaplanella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing! Thanks @tinosulzer :)

pybamm/input/parameters/lithium_ion/Ai2020.py Outdated Show resolved Hide resolved
"""
m_ref = (
1 * 10 ** (-11) * pybamm.constants.F
) # (A/m2)(mol/m3)**1.5 - includes ref concentrations
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Rob. I think it makes sense to leave the units, corrected though, as a quick sanity check.

Comment on lines +50 to +62
parameter_values = pybamm.ParameterValues(
{
"chemistry": "lithium_ion",
"cell": "Enertech_Ai2020",
"negative electrode": "graphite_Ai2020",
"separator": "separator_Ai2020",
"positive electrode": "lico2_Ai2020",
"electrolyte": "lipf6_Enertech_Ai2020",
"experiment": "1C_discharge_from_full_Ai2020",
"sei": "example",
"citation": "Ai2019",
}
)
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

@@ -35,7 +35,7 @@ def test_load_params(self):
for solvent in ["EC_DMC_1_1", "EC_EMC_3_7", "EMC_FEC_19_1"]:
root = pybamm.root_dir()
p = (
"pybamm/input/parameters/lithium_ion/electrolytes/lipf6_"
"pybamm/input/parameters/lithium_ion/testing_only/electrolytes/lipf6_"
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe related to the previous comment, but why is testing_only needed?

@valentinsulzer
Copy link
Member Author

@brosaplanella I kept the testing_only parameters and tests so that it still works with the old split structure in case people are still using that. I don't know if anyone is, nobody raised any complaints about this change. Do you think I should just remove it?

Comment on lines +499 to +505
# Load data in the appropriate format
path, _ = os.path.split(os.path.abspath(__file__))
graphite_ocp_Enertech_Ai2020 = pybamm.parameters.process_1D_data(
"graphite_ocp_Enertech_Ai2020.csv", path=path
)
lico2_ocp_Ai2020 = pybamm.parameters.process_1D_data("lico2_ocp_Ai2020.csv", path=path)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinjrobins what do you think of this approach?

@brosaplanella
Copy link
Sponsor Member

@brosaplanella I kept the testing_only parameters and tests so that it still works with the old split structure in case people are still using that. I don't know if anyone is, nobody raised any complaints about this change. Do you think I should just remove it?

Makes sense, I agree we should keep it at least for a while.

@valentinsulzer
Copy link
Member Author

Merging since all tests pass. We can refactor where we put the "data" parameters if needed

@valentinsulzer valentinsulzer merged commit 924ee9e into develop Oct 11, 2022
@valentinsulzer valentinsulzer deleted the issue-2334-reformat-parameters branch October 11, 2022 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants