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

add perturbation to initial conditions in casadi solver #2356

Merged
merged 10 commits into from
Oct 13, 2022

Conversation

valentinsulzer
Copy link
Member

Description

For some reason this fixed a bug in the casadi solver for one particular case I was looking at. Opening PR to check tests and benchmarks.

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

@codecov
Copy link

codecov bot commented Oct 12, 2022

Codecov Report

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

Coverage data is based on head (647d350) compared to base (87c0943).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #2356   +/-   ##
========================================
  Coverage    99.66%   99.66%           
========================================
  Files          269      269           
  Lines        20190    20201   +11     
========================================
+ Hits         20123    20134   +11     
  Misses          67       67           
Impacted Files Coverage Δ
pybamm/solvers/casadi_solver.py 99.67% <100.00%> (+0.01%) ⬆️

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.

Copy link
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.

Looks good, thanks!

# For some reason this helps with convergence
# The actual value of the initial conditions for the algebraic variables
# doesn't matter
y0_alg = y0_alg * (1 + 1e-6 * casadi.DM(np.random.rand(len_alg)))
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to allow users to fiddle with this value or is it very sensitive?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not that sensitive. It's just the first thing I tried and it worked for the specific case I was testing. We can see if other cases come up whether changing that number makes a difference

@valentinsulzer
Copy link
Member Author

Benchmarks are fine but this makes the tests much slower

@valentinsulzer valentinsulzer merged commit 91a97cd into develop Oct 13, 2022
@valentinsulzer valentinsulzer deleted the casadi-solver-perturbation branch October 13, 2022 20:40
valentinsulzer added a commit that referenced this pull request Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants