| 查看: 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 Propertiesfor(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; } 请问各位,上面的代码有什么错误? |
» 猜你喜欢
有院领导为了换新车,用横向课题经费买了俩车
已经有9人回复
酰胺脱乙酰基
已经有13人回复
博士延得我,科研能力直往上蹿
已经有8人回复
同年申请2项不同项目,第1个项目里不写第2个项目的信息,可以吗
已经有4人回复
有时候真觉得大城市人没有县城人甚至个体户幸福
已经有10人回复
天津大学招2026.09的博士生,欢迎大家推荐交流(博导是本人)
已经有5人回复
CSC & MSCA 博洛尼亚大学能源材料课题组博士/博士后招生|MSCA经费充足、排名优
已经有6人回复
面上项目申报
已经有3人回复
遇见不省心的家人很难过
已经有22人回复














;// Open and read the Gas Transport and Properties
回复此楼