我正在使用 CFD 模型研究臭氧水相互作用
臭氧在水中的传质和溶解臭氧分解过程被视为两个用户定义的函数(UDF),用C语言编程,然后将这两个UDF加载到Ansys Fluent求解器中。在编译代码时,我收到使用的错误 UDF 代码:
#include "udf.h"
#define vr 0.0025
#define dg 0.003
#define kl 0.0005
#define cn 6.0
DEFINE_VR_RATE(vol_reac_rate, c, t, r, mw, yi, rr, rr_t)
{
real *rr
real yi[0] = C_YI(cell,thread,0)
*rr = vr*C_VOF(c,t)*C_R(c,t)*yi[0]/mw[0];
return *rr;
}
/*define ozone decay volume reaction rate */
DEFINE_MASS_TRANSFER (liq_gas_transfer, cell, thread, from_index,from_species_index, to_index, to_species_index)
{
real m_lg;
Thread *gas, *liq;
gas = THREAD_SUB_THREAD(thread, from_species_index);
liq = THREAD_SUB_THREAD(thread, to_species_index);
m_lg = kl*cn/dg *C_VOF(cell,gas); /*unit:[s^-1] */
return (m_lg);
} /*define ozone mass transfer rate */
我得到的错误:
mass_transfer_udf.c
..\..\src\mass_transfer_udf.c(10): error C2082: redefinition of formal parameter 'rr'
..\..\src\mass_transfer_udf.c(10): error C2146: syntax error: missing ';' before identifier 'real'
..\..\src\mass_transfer_udf.c(10): error C2275: 'real': illegal use of this type as an expression
C:\PROGRA~1\ANSYSI~1\ANSYSS~1\v221\fluent\fluent22.1.0\src\main\global.h(198): note: see declaration of 'real'
..\..\src\mass_transfer_udf.c(10): error C2146: syntax error: missing ';' before identifier 'yi'
..\..\src\mass_transfer_udf.c(10): error C2065: 'thread': undeclared identifier
..\..\src\mass_transfer_udf.c(10): error C2223: left of '->storageArray' must point to struct/union
..\..\src\mass_transfer_udf.c(10): error C2065: 'cell': undeclared identifier
..\..\src\mass_transfer_udf.c(14): warning C4098: 'vol_reac_rate': 'void' function returning a value
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX86\x64\cl.EXE"' : return code '0x2'
Stop.Error Object: #f
如何解决这些错误。我对 C 语言真的很陌生。