24小时热门版块排行榜    

查看: 1005  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 材料调剂 +4 爱擦汗的可乐冰 2026-02-28 4/200 2026-03-01 00:38 by 猫猫球alter
[考研] 304求调剂 +3 52hz~~ 2026-02-28 5/250 2026-03-01 00:00 by 52hz~~
[考研] 317一志愿华南理工电气工程求调剂 +5 Soliloquy_Q 2026-02-28 8/400 2026-02-28 23:36 by xyx2012xyx
[考研] 272求调剂 +3 材紫有化 2026-02-28 3/150 2026-02-28 22:52 by ms629
[考研] 化工专硕348,一志愿985求调剂 +4 弗格个 2026-02-28 6/300 2026-02-28 22:00 by wang_dand
[考研] 290求调剂 +5 材料专硕调剂; 2026-02-28 6/300 2026-02-28 21:40 by gaoxiaoniuma
[考研] 295求调剂 +5 19171856320 2026-02-28 5/250 2026-02-28 21:39 by gaoxiaoniuma
[考博] 26申博 +4 想申博! 2026-02-26 4/200 2026-02-28 21:37 by limorning
[考研] 材料学调剂 +5 提神豆沙包 2026-02-28 5/250 2026-02-28 21:34 by gaoxiaoniuma
[考研] 311求调剂 +8 南迦720 2026-02-28 8/400 2026-02-28 21:30 by gaoxiaoniuma
[考研] 材料类求调剂 +6 wana_kiko 2026-02-28 6/300 2026-02-28 21:20 by gaoxiaoniuma
[考研] 284求调剂 +4 天下熯 2026-02-28 4/200 2026-02-28 21:13 by gaoxiaoniuma
[考研] 276求调剂 +3 路lyh123 2026-02-28 4/200 2026-02-28 19:45 by 路lyh123
[考研] 285求调剂 +5 满头大汗的学生 2026-02-28 5/250 2026-02-28 18:10 by 材料专硕调剂;
[考博] 博士自荐 +3 kkluvs 2026-02-28 3/150 2026-02-28 16:59 by StarAura
[高分子] 求环氧树脂研发1名 +3 孙xc 2026-02-25 11/550 2026-02-28 16:57 by ichall
[考研] 寻找调剂 +3 LYidhsjabdj 2026-02-28 3/150 2026-02-28 12:59 by miniwendy
[考研] 304求调剂 +5 曼殊2266 2026-02-28 6/300 2026-02-28 12:44 by 迷糊CCPs
[硕博家园] 博士自荐 +6 科研狗111 2026-02-26 9/450 2026-02-28 12:32 by seaskyy
[硕博家园] 【博士招生】太原理工大学2026化工博士 +4 N1ce_try 2026-02-24 8/400 2026-02-26 08:40 by N1ce_try
信息提示
请填处理意见