Differential equations

This file represents all the differential equations used for the fuel cell model.

dydt(t, y, operating_inputs, parameters, solver_variable_names, control_variables)

This function gives the system of differential equations to solve.

Parameters:
  • t (float) –

    Time (s).

  • y (ndarray) –

    Numpy list of the solver variables.

  • operating_inputs (dict) –

    Operating inputs of the fuel cell.

  • parameters (dict) –

    Parameters of the fuel cell model.

  • solver_variable_names (list) –

    Names of the solver variables.

  • control_variables (dict) –

    Variables controlled by the user.

Returns:
  • dydt( list ) –

    List containing the derivative of the solver variables.

Source code in model/dif_eq.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
def dydt(t, y, operating_inputs, parameters, solver_variable_names, control_variables):
    """This function gives the system of differential equations to solve.

    Parameters
    ----------
    t : float
        Time (s).
    y : numpy.ndarray
        Numpy list of the solver variables.
    operating_inputs : dict
        Operating inputs of the fuel cell.
    parameters : dict
        Parameters of the fuel cell model.
    solver_variable_names : list
        Names of the solver variables.
    control_variables : dict
        Variables controlled by the user.

    Returns
    -------
    dydt : list
        List containing the derivative of the solver variables.
    """

    # Creation of the dif_eq dictionary. It is an intermediate calculation to simplify the writing of the code.
    dif_eq = {('d' + key + ' / dt'): None for key in solver_variable_names}
    # Creation of the solver_variables dict. It is an intermediate calculation to simplify the writing of the code.
    solver_variables = {}
    for index, key in enumerate(solver_variable_names):
        solver_variables[key] = y[index]

    # Modifications of the operating conditions in real time, if required.
    if parameters["type_control"] != "no_control":
        control_operating_conditions(t, solver_variables, operating_inputs, parameters, control_variables)

    # Intermediate values
    i_fc = operating_inputs['current_density'](t, parameters)
    dif_eq_int_values = calculate_dif_eq_int_values(t, solver_variables, control_variables, operating_inputs, parameters)
    eta_c_intermediate_values = calculate_eta_c_intermediate_values(solver_variables, operating_inputs, parameters)

    # Calculation of the flows
    matter_flows_dico = calculate_flows(t, solver_variables, control_variables, i_fc, operating_inputs, parameters)
    heat_flows_dico = calculate_heat_transfers(solver_variables, i_fc, operating_inputs, parameters, **matter_flows_dico)

    # Calculation of the dynamic evolutions
    #       Inside the MEA
    calculate_dyn_dissoved_water_evolution_inside_MEA(dif_eq, **parameters, **matter_flows_dico)
    calculate_dyn_liquid_water_evolution_inside_MEA(dif_eq, solver_variables, **parameters, **matter_flows_dico)
    calculate_dyn_vapor_evolution_inside_MEA(dif_eq, solver_variables, **parameters, **matter_flows_dico)
    calculate_dyn_H2_O2_N2_evolution_inside_MEA(dif_eq, solver_variables, **parameters, **matter_flows_dico)
    calculate_dyn_voltage_evolution(dif_eq, i_fc, **solver_variables, **operating_inputs, **parameters,
                                    **dif_eq_int_values, **eta_c_intermediate_values)
    calculate_dyn_temperature_evolution_inside_MEA(dif_eq, **parameters, **dif_eq_int_values, **heat_flows_dico)
    #       Inside the gaz channels and the manifolds
    calculate_dyn_gas_evolution_inside_gas_channel(dif_eq, **parameters, **matter_flows_dico)
    calculate_dyn_temperature_evolution_inside_gas_channel(dif_eq, **parameters)
    if parameters['type_auxiliary'] != "no_auxiliary":
        calculate_dyn_manifold_pressure_and_humidity_evolution(dif_eq, **operating_inputs, **parameters, **matter_flows_dico)
    #       Inside the auxiliaries
    if parameters['type_auxiliary'] != "no_auxiliary":
        calculate_dyn_air_compressor_evolution(dif_eq, **solver_variables, **parameters)
        calculate_dyn_humidifier_evolution(dif_eq, **solver_variables, **parameters, **dif_eq_int_values)
        calculate_dyn_throttle_area_controler(dif_eq, solver_variables, **operating_inputs, **parameters,
                                              **matter_flows_dico)

    # dif_eq is converted to dydt because the solver requires an ordered list to work
    dydt = np.array([dif_eq['d' + key + ' / dt'] for key in solver_variable_names])
    return dydt