24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 1011  |  回复: 0

snipers2004

金虫 (初入文坛)

[求助] udf读取txt文件的数据错误求助

气体的物性参数太多了,需用udf导入相应的txt文件,如“氩气输运系数.txt”。但是我编写了一个程序,却无法将数据导入。
#include "udf.h"
#define pi    3.14159265358979
#define mu0   (4*pi*1.0e-7)                                    //真空磁导率

#define DataMax 298                                         //共导入298个数据
#define Tmin 300                                                 //允许的最小温度
#define Tmax 30000                                        //允许的最大温度

real Press[298],TT[298],vis[298],thc[298],elc[298],den[298],sph[298];

DEFINE_EXECUTE_ON_LOADING(on_loading, libname)
{
        int i,j;
        FILE *fPRO;
       
        fPRO=fopen("氩气输运系数.txt","r";// Open and read the Gas Transport and Properties
        for(i=0;i<298;i++)
        {
                fscanf(fPRO,"%le %le %le %le %le\n",&vis,&thc,&elc,&den,&sph);
//fscanf(fPRO,"%e %e %e %e %e",&vis,&thc,&elc,&den,&sph);
//fscanf(fPRO,"%e %e %e %e %e",&(vis),&(thc),&(elc),&(den),&(sph));
                //fscanf(fPRO,"%le %le %le %le %le",&(vis),&(thc),&(elc),&(den),&(sph));
                //Message("%le %le %le %le %le\n",vis,thc,elc,den,sph);
        }
        fclose(fPRO);
}

real sigma(cell_t c,Thread *t)
{
        int ip;
        real ele_con;

        if (C_T(c,t)<Tmin)
                C_T(c,t)=Tmin;
        else if (C_T(c,t)>Tmax)
                C_T(c,t)=Tmax;
        ip=floor((C_T(c,t)-200)/100);
        ele_con=elc[ip]+(C_T(c,t)-100*ip-200)/100*(elc[ip+1]-elc[ip]);
        C_UDMI(c,t,0)=ele_con;
        return ele_con;
}

DEFINE_PROPERTY(density,c,t)/*密度*/
{   
        int i1;
        real rho;
        real temp1=C_T(c,t);
        i1=floor((temp1-200)/100);
        rho=den[i1]+(temp1-100*i1-200)/100*(den[i1+1]-den[i1]);
        C_UDMI(c,t,1)=rho;
        return rho;
}

DEFINE_PROPERTY(viscosity,c,t)/*粘滞率*/
{   
        int i2;
        real mu;
        real temp2=C_T(c,t);
        i2=floor((temp2-200)/100);
        mu=vis[i2]+(temp2-100*i2-200)/100*(vis[i2+1]-vis[i2]);
        C_UDMI(c,t,5)=mu;
        return mu;
}

DEFINE_PROPERTY(thercond,c,t)/*热导率*/
{   
        int i3;
        real kp;
        real temp3=C_T(c,t);
        i3=floor((temp3-200)/100);
        kp=thc[i3]+(temp3-100*i3-200)/100*(thc[i3+1]-thc[i3]);
        C_UDMI(c,t,8)=kp;
        return kp;
}

请问各位,上面的代码有什么错误?
回复此楼

» 猜你喜欢

Impossible is nothing
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 snipers2004 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 301求调剂 +3 细胞相关蛋白 2026-04-03 3/150 2026-04-05 21:07 by 学员8dgXkO
[考研] 348求调剂 +3 车厘子zzz 2026-04-05 3/150 2026-04-05 20:30 by 啵啵啵0119
[考研] 301求调剂 +12 121. 2026-04-04 12/600 2026-04-05 09:00 by 来看流星雨10
[考研] 材料调剂 +12 一样YWY 2026-04-04 12/600 2026-04-05 08:24 by 544594351
[考研] 295求调剂 +4 A你好研究生 2026-04-04 5/250 2026-04-04 22:46 by yu221
[考研] 一志愿安徽某211 0703化学总分339求调剂 +6 晚风不晚 2026-04-04 6/300 2026-04-04 20:11 by dongzh2009
[考研] 11408 一志愿西电,277分求调剂 +4 zhouzhen654 2026-04-03 4/200 2026-04-04 18:10 by 猪会飞
[考研] 一志愿沪985,326分求调剂 +3 刘墨墨 2026-04-03 3/150 2026-04-04 11:16 by 悲伤的芋头
[考研] 350一志愿北京航空航天大学08500材料科学与工程求调剂 +5 kjnasfss 2026-04-03 5/250 2026-04-03 22:29 by 无际的草原
[考研] 机械专硕297 +3 Afksy 2026-04-03 3/150 2026-04-03 14:24 by 1753564080
[考研] 289-求调剂 +4 这里是_ 2026-04-03 4/200 2026-04-03 14:23 by 1753564080
[考研] 318求调剂 +3 笃行致远. 2026-03-31 4/200 2026-04-02 15:56 by Jaylen.
[考研] 081200-11408-276学硕求调剂 +3 崔wj 2026-04-02 3/150 2026-04-02 15:06 by cal0306
[考研] 286分调剂 +20 Faune 2026-03-30 22/1100 2026-04-02 13:24 by clyblh
[考研] 0856初试324分求调剂 +6 想上学求调 2026-04-01 6/300 2026-04-02 11:42 by 星空星月
[考研] 一志愿北交大材料工程总分358 +3 cs0106 2026-04-02 5/250 2026-04-02 11:37 by olim
[考研] 285求调剂 +11 AZMK 2026-04-01 11/550 2026-04-01 22:40 by peike
[考研] 358求调剂 +3 王向阳花 2026-03-31 3/150 2026-04-01 09:56 by zzchen2000
[考研] 339求调剂 +5 zjjkt 2026-03-31 5/250 2026-04-01 09:18 by JourneyLucky
[考研] 复试调剂 +7 双马尾痞老板2 2026-03-31 7/350 2026-03-31 19:49 by Dyhoer
信息提示
请填处理意见