24小时热门版块排行榜    

查看: 1058  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 欢迎发来filecode的Mz6后的代码验证其规律 +32 医学老男孩 2026-08-13 74/3700 2026-08-16 21:05 by 医学老男孩
[论文投稿] 岩土工程学报什么时候才能终审完呐 25+3 yeager111 2026-08-10 4/200 2026-08-16 20:42 by tfang
[基金申请] 2027广东省杰青 +3 奶牛小黑 2026-08-15 6/300 2026-08-16 20:07 by 奶牛小黑
[基金申请] 咱们一起用铁证分析2026国家社科基金中标与否 +7 启萌科技 2026-08-12 26/1300 2026-08-16 12:35 by 启萌科技
[基金申请] 有时候,自然基金真的不能太认真 (我的申报经验) +10 majunge000 2026-08-11 12/600 2026-08-16 08:18 by xli1984
[精细化工] 招聘 金属平磨液,抛光液研发工程师 +3 小天0311 2026-08-14 3/150 2026-08-16 07:31 by H9PLUS
[基金申请] filecode +8 cratir 2026-08-14 12/600 2026-08-15 18:08 by zyfgau
[基金申请] 小木虫上这么多卖论文的,真有人买论文么?感觉没必要啊 +12 Tide man 2026-08-10 13/650 2026-08-15 16:34 by 氺木
[基金申请] 关于Filecode分析方法 +10 majunge000 2026-08-10 13/650 2026-08-15 12:26 by hanpeng972
[硕博家园] 读博的好处 +4 lnee 2026-08-11 4/200 2026-08-14 10:20 by ahsoarli
[基金申请] filecode +15 documentary 2026-08-10 17/850 2026-08-14 10:08 by kissu88
[基金申请] 静等基金结果 +8 gjjjzhong 2026-08-10 21/1050 2026-08-13 17:56 by 且听虎啸
[基金申请] 重要来源:本周末出结果 +10 瞬息宇宙 2026-08-12 10/500 2026-08-13 15:46 by likettle
[基金申请] 不应该看fileCode +7 且听虎啸 2026-08-12 9/450 2026-08-13 14:27 by flydreamws
[基金申请] Filecode 又变了,巨变 +3 WH3796 2026-08-12 4/200 2026-08-13 14:13 by 小木虫6752397
[基金申请] 分享一下我之前已中青C的计划书的filecode +4 布布和一二 2026-08-11 5/250 2026-08-13 12:56 by cratir
[基金申请] 结合人工智能,周易传统文化,filecode打分制来了,3分以上希望很大。 +3 Tide man 2026-08-12 4/200 2026-08-13 08:35 by ZJTJZ
[基金申请] 2019年青年基金涵评意见,大家看看几个A,几个B? +11 Tide man 2026-08-11 11/550 2026-08-13 07:35 by 撸猫猫
[基金申请] 国自然结果 +4 Vierhys 2026-08-10 8/400 2026-08-10 15:06 by Vierhys
[基金申请] 据悉今年马上要出结果了 +7 瞬息宇宙 2026-08-10 8/400 2026-08-10 12:42 by Vivilian
信息提示
请填处理意见