@@ -278,6 +278,8 @@ def check_and_update_parameter_values(self, values):
278
278
data = values ["C-rate" ][1 ]
279
279
data [:, 1 ] = data [:, 1 ] * capacity
280
280
value = (values ["C-rate" ][0 ] + "_to_Crate" , data )
281
+ elif values ["C-rate" ] == "[input]" :
282
+ value = CrateToCurrent (values ["C-rate" ], capacity , typ = "input" )
281
283
else :
282
284
value = values ["C-rate" ] * capacity
283
285
self ._dict_items ["Current function [A]" ] = value
@@ -288,6 +290,10 @@ def check_and_update_parameter_values(self, values):
288
290
data = values ["Current function [A]" ][1 ]
289
291
data [:, 1 ] = data [:, 1 ] / capacity
290
292
value = (values ["Current function [A]" ][0 ] + "_to_current" , data )
293
+ elif values ["Current function [A]" ] == "[input]" :
294
+ value = CurrentToCrate (
295
+ values ["Current function [A]" ], capacity , typ = "input"
296
+ )
291
297
else :
292
298
value = values ["Current function [A]" ] / capacity
293
299
self ._dict_items ["C-rate" ] = value
@@ -472,6 +478,9 @@ def _process_symbol(self, symbol):
472
478
function = pybamm .Scalar (
473
479
function_name , name = symbol .name
474
480
) * pybamm .ones_like (* new_children )
481
+ elif isinstance (function_name , pybamm .InputParameter ):
482
+ # Replace the function with an input parameter
483
+ function = function_name
475
484
else :
476
485
# otherwise evaluate the function to create a new PyBaMM object
477
486
function = function_name (* new_children )
@@ -547,20 +556,28 @@ def evaluate(self, symbol):
547
556
class CurrentToCrate :
548
557
"Convert a current function to a C-rate function"
549
558
550
- def __init__ (self , function , capacity ):
551
- self .function = function
559
+ def __init__ (self , current , capacity , typ = "function" ):
560
+ self .current = current
552
561
self .capacity = capacity
562
+ self .type = typ
553
563
554
564
def __call__ (self , t ):
555
- return self .function (t ) / self .capacity
565
+ if self .type == "function" :
566
+ return self .current (t ) / self .capacity
567
+ elif self .type == "input" :
568
+ return pybamm .InputParameter ("Current function [A]" ) / self .capacity
556
569
557
570
558
571
class CrateToCurrent :
559
572
"Convert a C-rate function to a current function"
560
573
561
- def __init__ (self , function , capacity ):
562
- self .function = function
574
+ def __init__ (self , Crate , capacity , typ = "function" ):
575
+ self .Crate = Crate
563
576
self .capacity = capacity
577
+ self .type = typ
564
578
565
579
def __call__ (self , t ):
566
- return self .function (t ) * self .capacity
580
+ if self .type == "function" :
581
+ return self .Crate (t ) * self .capacity
582
+ elif self .type == "input" :
583
+ return pybamm .InputParameter ("C-rate" ) * self .capacity
0 commit comments