2.10. User-Accessible Functions

As noted in Properties, you can directly incorporate your own formulations and data for the properties of the fuel cell membrane using the pemfc_user.c source code file.

The following listing represents a description of the contents of the pemfc_user.c source code file:

real Get_P_sat(real T, cell_t c, Thread *t)

Returns the value of the water vapor saturation pressure as a function of temperature (Equation 1–47) or other user-specified values.

real Water_Activity(real P, real T, cell_t c, Thread *t)

Returns the value of water activity (Equation 1–26).

real Osmotic_Drag_Coefficient(cell_t c, Thread *t)

Returns the value of the osmotic drag coefficient (Equation 1–46).

real Membrane_Conductivity(real lam, cell_t c, Thread *t)

Returns the value of the protonic conductivity in MEA (Equation 1–41).

real Water_Content_Diffusivity(real lam, real T, real mem_mol_density,cell_tc,Thread*t)

Returns the value of the water content diffusivity in the MEA (Equation 1–43).

real Gas_Diffusivity(cell_t c, Thread *t, int j_spe)

Returns the value of the gaseous species diffusivities in the channels, gas diffusion layers, micro porous layers, and catalysts (Equation 1–38).

real MCD_Gas_Diffusivity(cell_t c, Thread *t, int i)

Returns the tortuosity-corrected value of the gas species diffusion coefficients computed with the multicomponent diffusion option (Equation 1–40).

real Compute_Js(real s, Thread *t)

Computes the Leverett function; namely, the - relation (Equation 1–33).

Real Capillary_P_Diffusivity(real sat, real K_abs, cell_t c, Thread *t)

Returns the in Equation 1–27.

real Water_Content(cell_t c, Thread *t)

Computes the water content .

real Anode_AV_Ratio(cell_t c, Thread *t)

Returns the value of the specific active surface area ( in Equation 1–5) for the anode catalyst.

real Cathode_AV_Ratio(cell_t c, Thread *t)

Returns the value of the specific active surface area ( in Equation 1–6) for the cathode catalyst.

real Anode_J_TransCoef(cell_t c, Thread *t)

Returns the value of the anode reaction reference current density used in Equation 1–5.

real Cathode_J_TransCoef(cell_t c, Thread *t)

Returns the value of the cathode reaction reference current density used in Equation 1–6.

real Open_Cell_Voltage(cell_t c, Thread *t)

Returns the value of the half-cell potential used in Equation 1–11 and Equation 1–12.

real Leakage_Current(cell_t c, Thread *t)

Returns the value of the total leakage current ( in Equation 1–48 through Equation 1–50).

real resistance_in_channel (real sat)

Returns momentum resistance as a function of liquid saturation in gas channels.

void Set_UDS_Names(char uds[n_uds_required][STRING_SIZE])

Used to rename user-defined scalars (UDSs). Note that the units of the user defined scalars cannot be changed.

void Set_UDS_Names(char uds[n_uds_required][STRING_SIZE])
 {
      strncpy(uds[0], "Electric Potential", STRING_SIZE-1);
      strncpy(uds[1], "Protonic Potential", STRING_SIZE-1);
      strncpy(uds[2], "Cap. Pressure", STRING_SIZE-1);
      strncpy(uds[3], "Water Content", STRING_SIZE-1);
      strncpy(uds[4], "Liq. Saturation in Channels",  STRING_SIZE-1);
 } 

If you want to change the names of UDSs, change the second argument of the strncpy functions, recompile and link the module as with any modification to pemfc_user.c. Note that STRING_SIZE is fixed in pemfc.h and should not be changed.


Important:  When you load older PEM Fuel Cell cases into ANSYS Fluent, and you are monitoring a UDS using volume or surface monitors, make sure you re-visit the corresponding monitors dialog box (for example, the Volume Monitor or the Surface Monitor dialog box) to make sure that the correct UDS name is used for the appropriate monitor.


void Set_UDM_Names(char udm[n_udm_required][STRING_SIZE])

Used to rename user defined memory (UDMs). Note that the units of user defined memory cannot be changed.

void Set_UDM_Names(char udm[n_udm_required][STRING_SIZE])
 {
     strncpy(udm[0], "X Current Flux Density",  STRING_SIZE-1);
     strncpy(udm[1], "Y Current Flux Density",  STRING_SIZE-1);
     strncpy(udm[2], "Z Current Flux Density",  STRING_SIZE-1);
     strncpy(udm[3], "Current Flux Density Magnitude", STRING_SIZE-1);
     strncpy(udm[4], "Ohmic Heat Source", STRING_SIZE-1);
     strncpy(udm[5], "Reaction Heat Source",  STRING_SIZE-1);
     strncpy(udm[6], "Overpotential", STRING_SIZE-1);
     strncpy(udm[7], "Evaporation to Vapor", STRING_SIZE-1);
     strncpy(udm[8], "Osmotic Drag Coefficient", STRING_SIZE-1);
     strncpy(udm[9], "Water Activity", STRING_SIZE-1);
     strncpy(udm[10], "Equilibrium Water Content",  STRING_SIZE-1);
     strncpy(udm[11], "Absorption from Vapor", STRING_SIZE-1);
     strncpy(udm[12], "Absorption from Liquid", STRING_SIZE-1);
     strncpy(udm[13], "Transfer Current",  STRING_SIZE-1);
     strncpy(udm[14], "Liquid Saturation",  STRING_SIZE-1);
     strncpy(udm[15], "GDL Liquid Removal",  STRING_SIZE-1);
     strncpy(udm[16], "Osmotic Drag Source (PEM)", STRING_SIZE-1);
     strncpy(udm[17], "Cap. Pressure", STRING_SIZE-1);
     strncpy(udm[18], "Pressure Gradient Source", STRING_SIZE-1);
 } 

If you want to change the names of UDMs, change the second argument of the strncpy functions, recompile and link the module as with any modification to pemfc_user.c. Note that STRING_SIZE is fixed in pemfc.h and should not be changed.


Important:  When you load older PEM Fuel Cell cases into ANSYS Fluent, and you are monitoring a UDM using volume or surface monitors, make sure you re-visit the corresponding monitors dialog box (for example, the Volume Monitor or the Surface Monitor dialog box) to make sure that the correct UDM name is used for the appropriate monitor.


real electric_contact_resistance(face_t f, Thread *t, int ns)

Returns the value for the electrical contact resistance.

real Transfer_Current(real i_ref, real gamma, int species_i, real alpha_a, real alpha_c, real *dRade, real *dRcde, Thread *t, cell_t c, real cathode_volume)

Computes the transfer current (), corresponding to in Equation 1–5 and in Equation 1–6.

Inputs for this function include:

i_ref effective transfer current coefficient, computed by Cathode_J_TransCoef(c,t) or Anode_J_TransCoef(c,t)
gamma cathode or anode concentration exponent
species_i species index used in fuel cells (for example i_o2, i_h2, i_h2o)
alpha_a product of anode exchange coefficient and
alpha_c product of cathode exchange coefficient and
t current thread
c current cell
cathode_volume total volume of cathode catalyst layer

Outputs for this function include:

source anode or cathode volumetric transfer current ( in Equation 1–5 or in Equation 1–6)
*dRade partial derivative of with respect to activation loss
*dRcde partial derivative of with respect to activation loss
Thermal_ctk_pemfc(face_t f, Thread *t)

Used to change the constant value of Thermal Contact Resistance set in the Porous Jump dialog box to a locally variable value.

Phase_Change_const(cell_t c, Thread *t)

Used to change the constant value of used to compute the gas-liquid phase change rate.

For more information, see the following sections:


Release 18.2 - © ANSYS, Inc. All rights reserved.