CFD中文网

    CFD中文网

    • 登录
    • 搜索
    • 最新

    请教大家一个有关反应速率的udf急。

    Fluent
    2
    2
    1697
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • L
      lyyyy 最后由 编辑

      各位大神有会编写反映化学反应速率的用户自定义函数的嘛 求帮忙

      1 条回复 最后回复 回复 引用
      • I
        ibelief 最后由 编辑

        #include "udf.h"
        DEFINE_EC_RATE(user_ec_rate, f, fthread, r, V, current, didV, Eeq)
        {
        double alpha_a = r->alpha_a, alpha_c = r->alpha_c;
        double io = r->io
        double T = F_T(f,fthread);
        double arg1, arg2;
        cxboolean tafelmethod = r->tafelmethod;
        int i;
        double eta;
        if (tafelmethod)
        {
        alpha_a = 2.303 * UNIVERSAL_GAS_CONSTANT * 298.15 /(alpha_a * FARADAY_CONSTANT);
        alpha_c = 2.303 * UNIVERSAL_GAS_CONSTANT * 298.15 /(alpha_c * FARADAY_CONSTANT);
        }
        Eeq = r->Eeq;
        eta = V - Eeq;
        for(i = 0; i<r->n_reactants; i++)
        if( ABS( r->exp_reactant[i] ) > SMALL_S )
        {
        int ni = r->reactant[i];
        io = pow((F_YI(f,fthread,ni)/MAX(r->yi_ref[ni],SMALL) + 1.0e-20), r->exp_reactant[i]);
        }
        for(i = 0; i<r->n_products; i++)
        if( ABS( r->exp_product[i] ) > SMALL_S )
        {
        int ni = r->product[i];
        io = pow((F_YI(f,fthread,ni)/MAX(r->yi_ref[ni],SMALL) + 1.0e-20), r->exp_product[i]);
        }
        arg1 = FARADAY_CONSTANT / (UNIVERSAL_GAS_CONSTANT
        T);
        arg2 = arg1
        eta;
        current = io( exp( arg2
        alpha_a ) - exp( -arg2
        alpha_c ) );
        didV = io( arg1alpha_aexp( arg2alpha_a ) + arg1alpha_cexp( -arg2alpha_c ) );
        /* If multiple electrochemical reactions are used, you can define rate for each reaction
        using the following if-statement /
        /

        if (STREQ(r->name, "reaction-1"))
        {
        ...
        }
        else if (STREQ(r->name, "reaction-2"))
        {
        ...
        }
        */
        }

        努力收敛

        1 条回复 最后回复 回复 引用
        • First post
          Last post