-
-
Notifications
You must be signed in to change notification settings - Fork 616
Added an option for multiple initial conditions in IDAKLU solver #4981
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
base: develop
Are you sure you want to change the base?
Changes from all commits
23e50f9
fe86f2b
8b07bbd
1b3e547
b09df51
320197e
2c4833c
e86adc1
32242e1
d261930
72ef8a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -650,6 +650,7 @@ def solve( | |
nproc=None, | ||
calculate_sensitivities=False, | ||
t_interp=None, | ||
initial_conditions=None, | ||
): | ||
""" | ||
Execute the solver setup and calculate the solution of the model at | ||
|
@@ -680,7 +681,12 @@ def solve( | |
t_interp : None, list or ndarray, optional | ||
The times (in seconds) at which to interpolate the solution. Defaults to None. | ||
Only valid for solvers that support intra-solve interpolation (`IDAKLUSolver`). | ||
|
||
initial_conditions : dict, numpy.ndarray, or list, optional | ||
Override the model’s default `y0`. Can be: | ||
- a dict mapping variable names → values | ||
- a 1D array of length `n_states` | ||
- a list of such overrides (one per parallel solve) | ||
Only valid for IDAKLU solver. | ||
Returns | ||
------- | ||
:class:`pybamm.Solution` or list of :class:`pybamm.Solution` objects. | ||
|
@@ -852,6 +858,7 @@ def solve( | |
t_eval[start_index:end_index], | ||
model_inputs_list, | ||
t_interp, | ||
initial_conditions, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this arg work for the jax solver? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not now , I'll add support for jax in a seperate PR in future otherwise this would become too long for now |
||
) | ||
else: | ||
ninputs = len(model_inputs_list) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,7 +198,9 @@ def supports_parallel_solve(self): | |
def requires_explicit_sensitivities(self): | ||
return False | ||
|
||
def _integrate(self, model, t_eval, inputs=None, t_interp=None): | ||
def _integrate( | ||
self, model, t_eval, inputs=None, t_interp=None, intial_conditions=None | ||
): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you are not planning on supporting the jax solver, you need to raise an error if |
||
""" | ||
Solve a model defined by dydt with initial conditions y0. | ||
|
||
|
@@ -218,6 +220,10 @@ def _integrate(self, model, t_eval, inputs=None, t_interp=None): | |
various diagnostic messages. | ||
|
||
""" | ||
if intial_conditions is not None: # pragma: no cover | ||
raise NotImplementedError( | ||
"Setting initial conditions is not yet implemented for the JAX IDAKLU solver" | ||
) | ||
if isinstance(inputs, dict): | ||
inputs = [inputs] | ||
timer = pybamm.Timer() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put somewhere here that this is only for the idaklu solver
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and jax perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah right,added that