@@ -135,11 +135,25 @@ def __init__(
135
135
pybamm .citations .register ("Andersson2019" )
136
136
137
137
def extract_explicit_sensitivities (self ):
138
+ # if we got here, we havn't set y yet
139
+ self .set_y ()
140
+
141
+ # extract sensitivities from full y solution
138
142
self ._y , self ._sensitivities = \
139
143
self ._extract_explicit_sensitivities (
140
144
self .all_models [0 ], self .y , self .t , self .all_inputs [0 ]
141
145
)
142
146
147
+ # make sure we remove all sensitivities from all_ys
148
+ for index , (model , ys , ts , inputs ) in enumerate (
149
+ zip (self .all_models , self .all_ys , self .all_ts ,
150
+ self .all_inputs )
151
+ ):
152
+ self ._all_ys [index ], _ = \
153
+ self ._extract_explicit_sensitivities (
154
+ model , ys , ts , inputs
155
+ )
156
+
143
157
def _extract_explicit_sensitivities (self , model , y , t_eval , inputs ):
144
158
"""
145
159
given a model and a solution y, extracts the sensitivities
@@ -411,6 +425,10 @@ def set_summary_variables(self, all_summary_variables):
411
425
412
426
def update (self , variables ):
413
427
"""Add ProcessedVariables to the dictionary of variables in the solution"""
428
+ # make sure that sensitivities are extracted if required
429
+ if isinstance (self ._sensitivities , bool ) and self ._sensitivities :
430
+ self .extract_explicit_sensitivities ()
431
+
414
432
# Convert single entry to list
415
433
if isinstance (variables , str ):
416
434
variables = [variables ]
0 commit comments