24小时热门版块排行榜    

Znn3bq.jpeg
查看: 1012  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 0703化学求调剂 +16 不知名的小卅 2026-04-08 16/800 2026-04-08 21:53 by 旺旺豆包
[考研] 277求调剂 +16 倪建设 2026-04-06 16/800 2026-04-08 21:28 by zhouxiaoyu
[考研] 材料专硕调剂 +14 哈哈哈吼吼吼哈 2026-04-07 15/750 2026-04-08 19:36 by cheerful9622
[考研] 273求调剂 +41 麦小叮当 2026-04-06 48/2400 2026-04-08 15:16 by screening
[考研] 362求调剂 +8 我要考大 2026-04-06 12/600 2026-04-08 00:32 by JourneyLucky
[考研] 326求调剂 +5 9ahye 2026-04-02 6/300 2026-04-07 21:37 by lijunpoly
[考研] 301求调剂 +18 121. 2026-04-04 18/900 2026-04-07 17:49 by 蓝云思雨
[考研] 学硕化学工程与技术,一志愿中国海洋大学320+求调剂 +9 披星河 2026-04-02 9/450 2026-04-07 12:53 by 尽舜尧1
[论文投稿] Decision: Revise for Editor还会送审吗 100+3 CccccccccFD 2026-04-04 5/250 2026-04-07 10:58 by 北京莱茵润色
[考研] 一志愿C9的化学工程(085602) 340分,感觉校内调剂无望,求调剂 +12 万事宜臻 2026-04-04 12/600 2026-04-06 07:46 by 无际的草原
[考研] 327求调剂 +4 拾光任染 2026-04-05 4/200 2026-04-05 20:16 by 南航~万老师
[考研] 298分 070300求调剂 +15 zwen03 2026-04-02 15/750 2026-04-05 12:52 by Hdyxbekcb
[考研] 求调剂 +3 ffyyu 2026-04-02 3/150 2026-04-04 19:03 by 蓝云思雨
[考研] 266求调剂 +8 学员97LZgn 2026-04-03 8/400 2026-04-04 09:02 by 20021109
[考研] 283分材料与化工求调剂 +29 罗KAKA 2026-04-02 29/1450 2026-04-03 23:56 by userper
[考研] 285求调剂 +5 AZMK 2026-04-03 8/400 2026-04-03 18:17 by AZMK
[考研] 工科341分调剂 +3 洛多罗 2026-04-03 3/150 2026-04-03 14:20 by 1753564080
[考研] 315分 085602 求调剂 +15 26考研上岸版26 2026-04-02 15/750 2026-04-03 12:45 by xingguangj
[考研] 土木水利328分求调剂 +6 疾风知劲草666 2026-04-02 6/300 2026-04-03 11:38 by znian
[考研] 298求B区调剂 +4 zzz,,r 2026-04-02 5/250 2026-04-02 12:17 by 土木硕士招生
信息提示
请填处理意见