|
楼主 |
发表于 2012-2-3 20:19:46
|
显示全部楼层
回复 16# doctorwgc 的帖子
我可以把矩方法的代码贴出来,供参考。
#include "udf.h"
#include "mem.h"
#include "sg_udms.h"
#inlcude "math.h"
#define pi 3.141593
#define T 300.0
#define kB 1.38e-23
#define rou_air 1.225
#define rou_particle 950.0
double m_0,m_1,m_2;
enum
{
M0,
M1,
M2,
N_REQUIRED_UDS
};
double m_k(double k)
{
return
pow(m_0,( 1.0 / 2.0 ) * pow(k,2.0) - (3.0 / 2.0) * k + 1.0) *
pow(m_1,-pow(k,2.0) + 2.0 * k) * pow(m_2,(1.0 / 2.0) * pow(k,2.0)
- (1.0 / 2.0) * k);
}
/*DEFINE_ADJUST(adjust,domain)
{
if(n_uds < N_REQUIRED_UDS)
Internal_Error("not enough user-defined scalars allocated");
}*/
DEFINE_DIFFUSIVITY(Moment_diffusivity,c,t,i)
{
double D_mol;
double D_tur;
double D_eff;
double v_g;
double d_p;
double f;
double C;
double l = 6.91e-8;
double mu = 1.86e-05;
double A1 = 1.257,A2 = 0.4,A3 = 0.55;
double Sct = 0.7;
m_0 = C_UDSI(c,t,M0);
m_1 = C_UDSI(c,t,M1);
m_2 = C_UDSI(c,t,M2);
v_g = pow(m_1,2.0) / (pow(m_0,3.0 / 3.0) * pow(m_2,1.0 / 2.0));
d_p = pow((6.0 / pi) * v_g,1.0 / 3.0);
C = 1.0 + 2.0 * l * (A1 + A2 * exp(-A3 * d_p / l)) / d_p;
f = 3.0 * pi * mu * d_p / C;
D_mol = kB * T / f;
D_tur = C_MU_T(c,t) / rou_air * Sct;
D_eff = D_mol + D_tur;
return (float)D_eff;
}
DEFINE_SOURCE(M0_source,c,t,dS,eqn)
{
double v_g,sigma_g;
double A,b_0;
double m_mix;
m_0 = C_UDSI(c,t,M0);
m_1 = C_UDSI(c,t,M1);
m_2 = C_UDSI(c,t,M2);
A = pow(3.0 / (4.0 * pi),1.0 / 6.0) * sqrt(6.0 * kB * T / rou_particle);
m_mix = m_0 * m_2 / pow(m_1,2.0);
if(m_mix < 1.0)
m_mix = 1.0;
sigma_g = exp((1.0 / 3.0) * sqrt(log(m_mix)));
b_0 = 0.633 + 0.092 * pow(sigma_g,2.0) - 0.022 * pow(sigma_g,3.0);
return (float)(-A * b_0 * (m_k(2.0 / 3.0) * m_k(-1.0 / 2.0) + 2.0 * m_k(1.0 / 3.0)
* m_k(-1.0 / 6.0) + m_k(1.0 / 6.0) * m_0));
}
DEFINE_SOURCE(M1_source,c,t,dS,eqn)
{
return 0.0;
}
DEFINE_SOURCE(M2_source,c,t,dS,eqn)
{
double v_g,sigma_g;
double A,b_2;
double m_mix;
m_0 = C_UDSI(c,t,M0);
m_1 = C_UDSI(c,t,M1);
m_2 = C_UDSI(c,t,M2);
A = pow(3.0 / (4.0 * pi),1.0 / 6.0) * sqrt(6.0 * kB * T / rou_particle);
m_mix = m_0 * m_2 / pow(m_1,2.0);
if(m_mix < 1.0)
m_mix = 1.0;
sigma_g = exp((1.0 / 3.0) * sqrt(log(m_mix)));
b_2 = 0.39 + 0.5 * sigma_g - 0.214 * pow(sigma_g,2.0) + 0.029 * pow(sigma_g,3.0);
return (float)(2 * A * b_2 * (m_k(5.0 / 3.0) * m_k(1.0 / 2.0) + 2.0 * m_k(4.0 / 3.0)
* m_k(5.0 / 6.0) + m_k(7.0 / 6.0) * m_1));
} |
|