Mark Fullerton
Subscriber

This is currently the udf that I am trying to input, which aims to define a reaction between two immiscible liquids (methanol and oil)

#include "udf.h"

#define Pre 2.333e+7 /*Pre exponential factor, 1/sec*/
#define EA 43400 /*Activation energy, J/mol*/
#define R 8.3145 /*Universal gas constant, J/molK*/

#define liquid_primary_index 0 /*defining WCO mixture index*/
#define liquid_wco_index 0 /*wco in mixture index*/
#define liquid_fame_index 1 /*fame in mixture index*/
#define liquid_gly_index 2 /*glycerol in mixture index*/

#define liquid_secondary_index 1 /*defining MeOH mixture index*/
#define meoh_index 0 /*wco in meoh mixture index*/

DEFINE_HET_RXN_RATE(Arrh, c, t, r, mw, yi, rr, rr_t)
{
    Thread** pt = THREAD_SUB_THREADS(t);
    Thread* pri_t = pt[0]; /*Thread for WCO phase*/
    Thread* sec_t = pt[1]; /*Thread for methanol phase*/
    Thread* thi_t = pt[2]; /*Thread for FAME phase*/
    Thread* fou_t = pt[3]; /*Thread for glycerol phase*/

    real T_sec = C_T(c, sec_t); /*Temperature of methanol phase*/
    real T_thi = C_T(c, thi_t); /*Temperature of FAME phase*/
    real MFO = C_YI(c, pri_t, 1); /*Mass fraction of oil*/
    real MFM = C_YI(c, sec_t, 1); /*Mass fraction of MeOH*/
    real MFF = C_YI(c, thi_t, 1); /*Mass fraction of fame*/
    real MFG = C_YI(c, fou_t, 1); /*Mass fraction of glycerol*/
    real RHOO = C_R(c, pri_t); /*Density of oil*/
    real RHOM = C_R(c, sec_t); /*Density of MeOH*/
    real RHOF = C_R(c, thi_t); /*Density of fame*/
    real RHOG = C_R(c, fou_t); /*Density of glycerol*/

    real O_conc = (RHOO * MFO) / mw[liquid_primary_index][liquid_wco_index]; /*concentration of oil*/
    real M_conc = (RHOM * MFM) / mw[liquid_secondary_index][meoh_index]; /*concentration of MeOH*/
    real F_conc = (RHOF * MFF) / mw[liquid_primary_index][liquid_fame_index]; /*concentration of FAME*/
    real G_conc = (RHOG * MFG) / mw[liquid_primary_index][liquid_gly_index]; /*concentration of glycerol*/
    real MOR = M_conc / O_conc; /*Methanol to oil molar ratio*/

    if (MOR > 6)
        *rr = Pre * exp(-EA / (R * T_sec)) * O_conc;
    else
        *rr = Pre * exp(-EA / (R * T_sec)) * O_conc * pow(M_conc, 3);
    
    *rr_t = *rr;
}  

 

Kind regards,

Mark