@@ -16,6 +16,7 @@ def __init__(self, model, parameter_values, disc, solution):
16
16
17
17
# Assign attributes
18
18
self .model = model
19
+ self .options = model .options
19
20
self .parameter_values = parameter_values
20
21
self .disc = disc
21
22
self .solution = solution
@@ -30,12 +31,15 @@ def __init__(self, model, parameter_values, disc, solution):
30
31
parameter_values ["Current function" ].parameters_eval ["Current [A]" ]
31
32
)
32
33
33
- if current_sign == 1 :
34
- self .operating_condition = "discharge"
35
- elif current_sign == - 1 :
36
- self .operating_condition = "charge"
34
+ if self .options ["problem type" ] == "galvanostatic" :
35
+ if current_sign == 1 :
36
+ self .operating_condition = "discharge"
37
+ elif current_sign == - 1 :
38
+ self .operating_condition = "charge"
39
+ else :
40
+ self .operating_condition = "off"
37
41
else :
38
- self .operating_condition = "off "
42
+ self .operating_condition = "potentiostatic "
39
43
40
44
def process_variables (self ):
41
45
return
@@ -324,10 +328,10 @@ def test_fluxes(self):
324
328
if self .operating_condition == "discharge" :
325
329
np .testing .assert_array_less (0 , self .N_s_n (t [1 :], x_n , r_n [1 :]))
326
330
np .testing .assert_array_less (self .N_s_p (t [1 :], x_p , r_p [1 :]), 0 )
327
- if self .operating_condition == "charge" :
331
+ elif self .operating_condition == "charge" :
328
332
np .testing .assert_array_less (self .N_s_n (t [1 :], x_n , r_n [1 :]), 0 )
329
333
np .testing .assert_array_less (0 , self .N_s_p (t [1 :], x_p , r_p [1 :]))
330
- if self .operating_condition == "off" :
334
+ elif self .operating_condition == "off" :
331
335
np .testing .assert_array_almost_equal (self .N_s_n (t , x_n , r_n ), 0 )
332
336
np .testing .assert_array_almost_equal (self .N_s_p (t , x_p , r_p ), 0 )
333
337
@@ -546,14 +550,16 @@ def __init__(self, model, param, disc, solution, operating_condition):
546
550
self .i_s = variables ["Electrode current density" ]
547
551
self .i_e = variables ["Electrolyte current density" ]
548
552
553
+ self .i_boundary_cc = variables ["Current collector current density" ]
554
+
549
555
def test_interfacial_current_average (self ):
550
556
"""Test that average of the interfacial current density is equal to the true
551
557
value."""
552
558
np .testing .assert_array_almost_equal (
553
- self .j_n_av (self .t ), self .i_cell / self .l_n , decimal = 4
559
+ self .j_n_av (self .t ), self .i_boundary_cc ( self . t ) / self .l_n , decimal = 1
554
560
)
555
561
np .testing .assert_array_almost_equal (
556
- self .j_p_av (self .t ), - self .i_cell / self .l_p , decimal = 4
562
+ self .j_p_av (self .t ), - self .i_boundary_cc ( self . t ) / self .l_p , decimal = 1
557
563
)
558
564
559
565
def test_conservation (self ):
@@ -568,10 +574,12 @@ def test_conservation(self):
568
574
else :
569
575
current_param = pybamm .electrical_parameters .current_with_time
570
576
571
- i_cell = self .param .process_symbol (current_param ).evaluate (t = t )
577
+ # i_cell = self.param.process_symbol(current_param).evaluate(t=t)
572
578
for x in [x_n , x_s , x_p ]:
573
579
np .testing .assert_array_almost_equal (
574
- self .i_s (t , x ) + self .i_e (t , x ), i_cell , decimal = 2
580
+ self .i_s (t , x ) + self .i_e (t , x ),
581
+ [self .i_boundary_cc (t )] * len (x ),
582
+ decimal = 1 ,
575
583
)
576
584
np .testing .assert_array_almost_equal (
577
585
self .i_s (t , x_n ), self .i_s_n (t , x_n ), decimal = 3
@@ -591,10 +599,14 @@ def test_current_density_boundaries(self):
591
599
else :
592
600
current_param = pybamm .electrical_parameters .current_with_time
593
601
594
- i_cell = self .param .process_symbol (current_param ).evaluate (t = t )
595
- np .testing .assert_array_almost_equal (self .i_s_n (t , x_n [0 ]), i_cell , decimal = 2 )
602
+ # i_cell = self.param.process_symbol(current_param).evaluate(t=t)
603
+ np .testing .assert_array_almost_equal (
604
+ self .i_s_n (t , x_n [0 ]), self .i_boundary_cc (t ), decimal = 1
605
+ )
596
606
np .testing .assert_array_almost_equal (self .i_s_n (t , x_n [- 1 ]), 0 , decimal = 4 )
597
- np .testing .assert_array_almost_equal (self .i_s_p (t , x_p [- 1 ]), i_cell , decimal = 3 )
607
+ np .testing .assert_array_almost_equal (
608
+ self .i_s_p (t , x_p [- 1 ]), self .i_boundary_cc (t ), decimal = 1
609
+ )
598
610
np .testing .assert_array_almost_equal (self .i_s_p (t , x_p [0 ]), 0 , decimal = 4 )
599
611
600
612
def test_all (self ):
0 commit comments