slaon的个人博客分享 http://blog.sciencenet.cn/u/slaon

博文

fluent加载能量源项 出现:UDF Error at Node 0: Error code: 126

已有 8142 次阅读 2021-5-7 15:14 |系统分类:科研笔记

今天在用batch模式编译UDF时,出现了错误:

UDF Error at Node 0: Error code: 126


bat文件:

@echo off      
@set PATH=C:/Program Files/ANSYS Inc/v202/fluent/ntbin/win64/;%PATH%
@call udf.bat 
@ cd %cd%      
rd /s /q libudf
@ fluent -wait 2ddp -t2  -i  0Run.jou 
exit     

jou文件:

/file read-case EnergySource.cas.gz

其中,cas文件用到了能量源项UDF,

udf文件中,在一个半椭圆区域内施加能量源项,

需要在cas中定义User Defined Memory,即其中的C_UDMI(c,t,1)

#include "udf.h"
//#include <stdio.h>
double x1,y1,x2,y2,x3,y3,x4,y4;
double AA=0.003; //椭圆长轴长度

double BB=0.001; //椭圆长轴长度

double SS=0.062; //椭圆中心x坐标

double TT=0.010932273; //椭圆中心y坐标

double angle=10; //椭圆长轴与x轴夹角

double emax=5e7; //能量源项强度

DEFINE_SOURCE(energy_source,c,t,dS,eqn)

{
  double theta;
  double temp1,temp2,temp3;
  double source,px,py,pz,zmax;
  double x[ND_ND];
 
  C_CENTROID(x,c,t);
  px=x[0];
  py=x[1];
  theta=angle*3.141592657/180.0;
  temp1=((px-SS)*cos(theta) + (py-TT)*sin(theta))*((px-SS)*cos(theta) + (py-TT)*sin(theta));
  temp2=((px-SS)*sin(theta) - (py-TT)*cos(theta))*((px-SS)*sin(theta) - (py-TT)*cos(theta));
  temp3=temp1/(AA*AA) + temp2/(BB*BB);
  if (temp3 <=1.0)
  {
    source=emax;
    C_UDMI(c,t,1)=source;
  }
  dS[eqn]=0.0;
  return source;
}

在Unreal Commander中双击bat文件运行fluent,并调用jou文件,读取cas文件。

由于cas文件中包含了能量源项,会自动编译。

Checking the existence of compiled "libudf" UDF library for current platform.
If needed will attempt auto-compilation...

      Make sure that UDF source files are in the directory
      that contains your case and data files. If you have
      an existing libudf directory, please remove this
      directory to ensure that latest files are used.
 
Will now auto-compile UDF library "libudf".
Copied C:\Temp\Test\CompressionExpansion\Unsteady\Test/.\EnergySource.c to libudf\\src
Creating user_nt.udf file for 2ddp_host ...
(system "copy "C:\PROGRA~1\ANSYSI~1\v202\fluent"\fluent20.2.0\src\udf\makefile_nt.udf "libudf\\win64\2ddp_host\makefile" ")
已复制         1 个文件。
(chdir "libudf")(chdir "win64\\2ddp_host")# Generating ud_io1.h
EnergySource.c
# Generating udf_names.c because of makefile EnergySource.obj
udf_names.c
# Linking libudf.dll because of makefile user_nt.udf udf_names.obj EnergySource.obj
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

   正在创建库 libudf.lib 和对象 libudf.exp
Creating user_nt.udf file for 2ddp_node ...
(system "copy "C:\PROGRA~1\ANSYSI~1\v202\fluent"\fluent20.2.0\src\udf\makefile_nt.udf "libudf\\win64\2ddp_node\makefile" ")
已复制         1 个文件。
(chdir "libudf")(chdir "win64\\2ddp_node")# Generating ud_io1.h
EnergySource.c
# Generating udf_names.c because of makefile EnergySource.obj
udf_names.c
# Linking libudf.dll because of makefile user_nt.udf udf_names.obj EnergySource.obj
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

   正在创建库 libudf.lib 和对象 libudf.exp

Done.

*******: Opening library "C:\\Temp\\Test\\CompressionExpansion\\Unsteady\\Test\\libudf"...
Error at Node 0: Error code: 126

正常在倒数第二行会有加载信息。

例如下面的红字部分

   正在创建库 libudf.lib 和对象 libudf.exp

Done.

*******: Opening library "C:\\Temp\\Test\\CompressionExpansion\\Unsteady\\Test\\libudf"...Done.
*******: Opening library "C:\\Temp\\Test\\CompressionExpansion\\Unsteady\\Test\\libudf"...
    energy_source
Done.
Building...
     mesh


网上也有其它的类似情况 link

但不适用于我的问题。

我用fluent单独打开,并读取jou文件,

没有问题。

我一度怀疑

  1. fluent版本

  2. 使用bat打开fluent时的udf环境变量

  3. UDF编写有问题,没有做专门的并行处理

  4. 电脑运行时间太长了,需要重启

  5. visual studio 2010的版本太老了,不匹配

  6. 我也想不起还猜测过什么。。。



搞了一上午,结果发现问题出在Unreal Commander

具体原因我也不知道。

但是只要不在Unreal Commander环境下双击运行

就一切正常。

汗颜。。。



https://wap.sciencenet.cn/blog-531760-1285435.html

上一篇:[转载]Matlab 曲线 等长度 均分
下一篇:Unreal Commander使用鼠标右键
收藏 IP: 114.213.245.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-5-1 22:22

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部