1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313 | def launch_AlphaPEM_for_EIS_current(current_density, T_des, Pa_des, Pc_des, Sa, Sc, Phi_a_des, Phi_c_des, t_step, i_step,
i_max_pola, delta_pola, i_EIS, ratio_EIS, t_EIS, f_EIS, Aact, Hgdl, Hmem, Hcl, Hgc,
Wgc, Lgc, epsilon_gdl, tau, epsilon_mc, epsilon_c, e, Re, i0_c_ref, kappa_co,
kappa_c, a_slim, b_slim, a_switch, C_scl, max_step, n_gdl, t_purge, type_fuel_cell,
type_current, type_auxiliary, type_control, type_purge, type_display, type_plot):
"""Launch the AlphaPEM simulator for an EIS current density and display the results.
Parameters
----------
current_density : function
Current density evolution over time (operating input). It is a function of time and parameters dictionary.
T_des : float
Desired fuel cell temperature in Kelvin (operating input).
Pa_des : float
Desired anode pressure in Pascal (operating input).
Pc_des : float
Desired cathode pressure in Pascal (operating input).
Sa : float
Stoichiometric ratio of hydrogen (operating input).
Sc : float
Stoichiometric ratio of oxygen (operating input).
Phi_a_des : float
Desired anode relative humidity (operating input).
Phi_c_des : float
Desired cathode relative humidity (operating input).
t_step : tuple
Time parameters for the step_current density function (current parameters).
It is a tuple containing the initial time 't0_step', final time 'tf_step', loading time 'delta_t_load_step'
and dynamic time for display 'delta_t_dyn_step'.
i_step : tuple
Current parameters for the step_current density function (current parameters).
It is a tuple containing the initial and final current density value 'i_ini_step' and 'i_final_step'.
i_max_pola : float
Maximum current density for the polarization curve (current parameter).
delta_pola : tuple
Parameters for the polarization curve (current parameters). It is a tuple containing the loading time
'delta_t_load_pola', the breaking time 'delta_t_break_pola', the current density step 'delta_i_pola', and
the initial breaking time 'delta_t_ini_pola'.
i_EIS : float
Current for which a ratio_EIS perturbation is added (current parameter).
ratio_EIS : float
Value of the perturbation on the current density for building the EIS curve (current parameter).
t_EIS : tuple
EIS parameters (current parameters). It is a tuple containing the initial EIS time after stack equilibrium
't0_EIS', a list of time parameters which gives the beginning of each frequency change 't_new_start_EIS',
the final time 'tf_EIS', a list of time parameters which gives the estimated time for reaching equilibrium
at each frequency 'delta_t_break_EIS', and a list of time parameters which gives the estimated time for
measuring the voltage response at each frequency 'delta_t_measurement_EIS'.
f_EIS : tuple
EIS parameters (current parameters). It is a tuple containing the power of the initial frequency
'f_power_min_EIS': f_min_EIS = 10**f_power_min_EIS, the power of the final frequency 'f_power_max_EIS', the
number of frequencies tested 'nb_f_EIS' and the number of points calculated per specific period
'nb_points_EIS'.
Aact : float
Active area of the cell in m² (accessible physical parameter).
Hgdl : float
Thickness of the gas diffusion layer in m (accessible physical parameter).
Hmem : float
Thickness of the membrane in m (accessible physical parameter).
Hcl : float
Thickness of the catalyst layer in m (accessible physical parameter).
Hgc : float
Thickness of the gas channel in m (accessible physical parameter).
Wgc : float
Width of the gas channel in m (accessible physical parameter).
Lgc : float
Length of the gas channel in m (accessible physical parameter).
epsilon_gdl : float
Anode/cathode GDL porosity (undetermined physical parameter).
tau : float
Pore structure coefficient (undetermined physical parameter).
epsilon_mc : float
Volume fraction of ionomer in the CL (undetermined physical parameter).
epsilon_c : float
Compression ratio of the GDL (undetermined physical parameter).
e : float
Capillary exponent (undetermined physical parameter).
Re : float
Electron conduction resistance of the circuit in ohm.m² (undetermined physical parameter).
i0_c_ref : float
Reference exchange current density at the cathode in A.m-2 (undetermined physical parameter).
kappa_co : float
Crossover correction coefficient in mol.m-1.s-1.Pa-1 (undetermined physical parameter).
kappa_c : float
Overpotential correction exponent (undetermined physical parameter).
a_slim : float
One of the limit liquid saturation coefficients: the slop of slim function
(undetermined physical parameter).
b_slim : float
One of the limit liquid saturation coefficients: the intercept of slim function
(undetermined physical parameter).
a_switch : float
One of the limit liquid saturation coefficients: the slop of s_switch function
(undetermined physical parameter).
C_scl : float
Volumetric space-charge layer capacitance in F.m-3 (undetermined physical parameter).
max_step : float
Maximum time step for the solver (computing parameter).
n_gdl : int
Number of points considered in the GDL (computing parameter).
t_purge : tuple
Time parameters for purging the system (computing parameter).
It is the purge time interval 'purge_time' and the time between two purges 'delta_purge'.
type_fuel_cell : str
Type of fuel cell configuration (computing parameter).
type_current : str
Type of current density function (computing parameter).
type_auxiliary : str
Type of auxiliary system (computing parameter).
type_control : str
Type of control system (computing parameter).
type_purge : str
Type of purge system (computing parameter).
type_display : str
Type of display (computing parameter).
type_plot : str
Type of plot (computing parameter).
"""
# Starting time
start_time = time.time()
# Figures preparation
fig1, ax1, fig2, ax2, fig3, ax3 = figures_preparation(type_current, type_display)
# Initialization
# ... of the plot update number (n) and the initial time interval (time_interval)
initial_variable_values = None
t0_EIS, t_new_start, tf_EIS, delta_t_break_EIS, delta_t_measurement_EIS = t_EIS
f_power_min_EIS, f_power_max_EIS, nb_f_EIS, nb_points_EIS = f_EIS # These are used for EIS max_step
# actualization.
f = np.logspace(f_power_min_EIS, f_power_max_EIS, num=nb_f_EIS) # It is a list of all the frequency tested.
n = len(t_new_start) # It is the plot update number.
time_interval = [0, t0_EIS] # It is the initial time interval.
# A preliminary simulation run is necessary to equilibrate the internal variables of the cell at i_EIS
# prior to initiating the EIS.
Simulator = AlphaPEM(current_density, T_des, Pa_des, Pc_des, Sa, Sc, Phi_a_des, Phi_c_des, t_step, i_step,
i_max_pola, delta_pola, i_EIS, ratio_EIS, t_EIS, f_EIS, Aact, Hgdl, Hmem, Hcl, Hgc, Wgc,
Lgc, epsilon_gdl, tau, epsilon_mc, epsilon_c, e, Re, i0_c_ref, kappa_co, kappa_c, a_slim,
b_slim, a_switch, C_scl, max_step, n_gdl, t_purge, type_fuel_cell, type_current,
type_auxiliary, type_control, type_purge, type_display, type_plot,
initial_variable_values, time_interval)
# time_interval actualization
t0_EIS_temp = t0_EIS # It is the initial time for 1 EIS point.
tf_EIS_temp = t_new_start[0] + delta_t_break_EIS[0] + delta_t_measurement_EIS[0] # It is the final time for
# 1 EIS point.
n_inf = np.where(t_new_start <= t0_EIS_temp)[0][-1] # It is the number of frequency changes which has been
# made.
max_step = 1 / (f[n_inf] * nb_points_EIS) # max_step is actualized according to the current frequency
# for increased calculation
time_interval = [t0_EIS_temp, tf_EIS_temp]
# Recovery of the internal states from the end of the preceding simulation.
initial_variable_values = []
for x in Simulator.solver_variable_names:
initial_variable_values.append(Simulator.variables[x][-1])
# Dynamic simulation
for i in range(n):
Simulator = AlphaPEM(current_density, T_des, Pa_des, Pc_des, Sa, Sc, Phi_a_des, Phi_c_des, t_step, i_step,
i_max_pola, delta_pola, i_EIS, ratio_EIS, t_EIS, f_EIS, Aact, Hgdl, Hmem, Hcl, Hgc,
Wgc, Lgc, epsilon_gdl, tau, epsilon_mc, epsilon_c, e, Re, i0_c_ref, kappa_co,
kappa_c, a_slim, b_slim, a_switch, C_scl, max_step, n_gdl, t_purge, type_fuel_cell,
type_current, type_auxiliary, type_control, type_purge, type_display, type_plot,
initial_variable_values, time_interval)
# time_interval actualization
if i < (n - 1): # The final simulation does not require actualization.
t0_EIS_temp = Simulator.variables['t'][-1] # It is the initial time for 1 EIS point.
tf_EIS_temp = t_new_start[i + 1] + delta_t_break_EIS[i + 1] + delta_t_measurement_EIS[i + 1] # It
# is the final time for 1 EIS point.
n_inf = np.where(t_new_start <= t0_EIS_temp)[0][-1] # It is the number of frequency changes which
# has been made.
max_step = 1 / (f[n_inf] * nb_points_EIS) # max_step is actualized according to the current
# frequency for increased calculation
time_interval = [t0_EIS_temp, tf_EIS_temp] # It is the time interval for 1 EIS point.
# Recovery of the internal states from the end of the preceding simulation.
initial_variable_values = []
for x in Simulator.solver_variable_names:
initial_variable_values.append(Simulator.variables[x][-1])
# Display
if type_display != "no_display":
Simulator.Display(ax1, ax2, ax3)
# Plot saving
plot_saving(type_fuel_cell, type_current, type_display, fig1, fig2, fig3)
# Ending time
algo_time = time.time() - start_time
print('Time of the algorithm in second :', algo_time)
|