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

Solve Drive Cycle (A,V,W) in Experiment #1524

Merged
merged 2 commits into from
Nov 10, 2021

Conversation

alibh95
Copy link
Contributor

@alibh95 alibh95 commented Jun 25, 2021

Description

PR Status: (Work in Progress)

This PR provides the functionality of solving the drive cycle using the experiment only if the first input of the experiment is the drive cycle.

Issues in PR:

  • When two consecutive drive cycles are given in the experiment, only the first one solves but the second one only returns 0 current.

  • If the drive cycle is not the first input of the experiment, the drive cycle part only returns 0 current.

Possible Cause of this Issue:

The driving cycles are given to the solver as interpolant. I think there is an issue with the timing of the interpolant which I am unable to overcome. For example, The US06 Drive cycle data have time range [0:600], When the drive cycle is the first input of the experiment is drive cycle (solution start time = 0), the cycle is solved successfully, but when the same cycle is repeated, (solution time > 600), the interpolant returns 0 A.

@tinosulzer and @Saransh-cpp suggestions on overcoming this issue are highly appreciated.

Fixes # (issue)
#1279

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

This commit simulates drive cycle ('A' or 'V' or 'W') in experiment only if drive cycle of particular type is initial instruction in experiment and there are no further drive cycle related instructions.
# create interpolant
timescale = self._parameter_values.evaluate(model.timescale)
drive_cycle_interpolant = pybamm.Interpolant(
op[0][:, 0], op[0][:, 1], timescale * pybamm.t
Copy link
Member

Choose a reason for hiding this comment

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

The last input here is the time that is evaluated by the interpolant. You could do the following:

drive_cycle_interpolant = pybamm.Interpolant(
                    op[0][:, 0], op[0][:, 1], timescale * pybamm.t - pybamm.InputParameter("start time")
)

and pass the appropriate "start time" to the model inputs when solving the model at each step

@brosaplanella
Copy link
Sponsor Member

Hi @alibh95! What is the status of this PR?

@alibh95
Copy link
Contributor Author

alibh95 commented Nov 4, 2021

Dear @brosaplanella,
Unfortunately I am unable to spare much time these days to work on this PR. However, I would be grateful if any other contributor works on this PR as it would be valuable addition to this project.
Again, I am sorry if any I cause any inconvenience.

@brosaplanella
Copy link
Sponsor Member

No worries! I can try to pick it up in a few days. What's the current status? Is it ready and just needs testing before merging or are there still features to be implemented?

@alibh95
Copy link
Contributor Author

alibh95 commented Nov 4, 2021

This PR is currently incomplete and I haven't tried @tinosulzer's suggestion yet.

@brosaplanella brosaplanella merged commit e30edb5 into pybamm-team:develop Nov 10, 2021
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.

3 participants