24小时热门版块排行榜    

查看: 1000  |  回复: 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 的主题更新
信息提示
请填处理意见