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

DAE solver for non-smooth currents #759

Closed
valentinsulzer opened this issue Dec 11, 2019 · 4 comments · Fixed by #808
Closed

DAE solver for non-smooth currents #759

valentinsulzer opened this issue Dec 11, 2019 · 4 comments · Fixed by #808

Comments

@valentinsulzer
Copy link
Member

valentinsulzer commented Dec 11, 2019

Fix (at least one of the) DAE solvers to work when the input current is not smooth.

Hacky approach is to do step-by-step and match up discontinuities with steps, or try stepping the differential and algebraic equations separately

@valentinsulzer valentinsulzer added this to To do in Version 2 - User workshop via automation Dec 12, 2019
@martinjrobins
Copy link
Contributor

could we augment model.events to take 2 types of events: "termination" and "discontinuity". The solver would then make sure to integrate up to just before a discontinuity, and restart integration just after the discontinuity.

@valentinsulzer
Copy link
Member Author

Good idea, so would the discontinuities be a list of variables for which to look out for discontinuities? Or do we analyse the input current (a parameter) before solving to identify discontinuities and then tell the model/solver about them before solving?

@martinjrobins
Copy link
Contributor

I'm thinking that the user would manually specify where the discontinuities occur in time, based on the parameters of the model. Therefore discontinuities would be an expression that evaluates to the time when the discontinuity takes place.

So, given a model that has parameter a and which exhibits a discontinuity at 2*a, the user would set model.events = [(pybamm.DISCONTINUITY, 2*a)]

Then it would be easy for the solver to get the list of where discontinuities occur in time, and make sure that the integration is restarted at each discontinuous time-point

@martinjrobins
Copy link
Contributor

Each event now needs 3 pieces of info, its name, expression and type (DISCONTINUITY or TERMINATION). I think this needs a separate class to encapsulate this (and provide some documentation). Implemented this as Event, so that to create some events you might do something like this:

        model.events = [
            pybamm.Event("var1 = 1.5", pybamm.min(var1 - 1.5)),
            pybamm.Event("var2 = 2.5", pybamm.min(var2 - 2.5)),
            pybamm.Event("nonsmooth rate",
                         pybamm.Scalar(2.5),
                         pybamm.EventType.DISCONTINUITY
                         )
        ]

martinjrobins added a commit that referenced this issue Feb 4, 2020
martinjrobins added a commit that referenced this issue Feb 4, 2020
martinjrobins added a commit that referenced this issue Feb 6, 2020
martinjrobins added a commit that referenced this issue Feb 6, 2020
martinjrobins added a commit that referenced this issue Feb 6, 2020
martinjrobins added a commit that referenced this issue Feb 6, 2020
martinjrobins added a commit that referenced this issue Feb 7, 2020
martinjrobins added a commit that referenced this issue Feb 7, 2020
martinjrobins added a commit that referenced this issue Feb 7, 2020
Version 2 - User workshop automation moved this from In progress to Done Feb 9, 2020
martinjrobins added a commit that referenced this issue Feb 11, 2020
martinjrobins added a commit that referenced this issue Feb 11, 2020
martinjrobins added a commit that referenced this issue Feb 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants