|
[Sponsors] |
![]() |
![]() |
#1 |
Member
Cpt. Convergence
Join Date: Feb 2020
Posts: 98
Rep Power: 8 ![]() |
I am trying to compile a User Defined Real Gas Model (UDRGM). I have followed the template presented in: https://www.afs.enea.it/project/nept...ug/node337.htm but when I compile the same exact code through the normal UDF interface, no file is generated (if the build is successful, then the compiled library will be placed in the appropriate architecture folder: for example, win64/2d) and I receive this error at the console:
FLUENT_IDEAL.c ..\..\src\FLUENT_IDEAL.c(129): warning C4028: formal parameter 4 different from declaration ..\..\src\FLUENT_IDEAL.c(129): warning C4028: formal parameter 5 different from declaration ..\..\src\FLUENT_IDEAL.c(129): warning C4113: 'double (*)(double,double,double *)' differs in parameter lists from 'double (*)(cell_t,Thread *,cxboolean,double,double,double *)' ..\..\src\FLUENT_IDEAL.c(129): warning C4113: 'double (*)(double,double,double,double *)' differs in parameter lists from 'double (*)(cell_t,Thread *,double,double,double,double *)' # Generating udf_names.c because of makefile FLUENT_IDEAL.obj udf_names.c # Linking libudf.dll because of makefile user_nt.udf udf_names.obj FLUENT_IDEAL.obj Microsoft (R) Incremental Linker Version 14.16.27035.0 Copyright (C) Microsoft Corporation. All rights reserved. Creating library libudf.lib and object libudf.exp Done. Which aparently indicates that there is an error with the parameters 4 and 5, which are entropy and specific heat according to this notation: UDF_EXPORT RGAS_Functions RealGasFunctionList = { /* Code line 129 */ IDEAL_Setup, /* 1 - initialize */ IDEAL_density, /* 2 - density */ IDEAL_enthalpy, /* 3 - enthalpy */ IDEAL_entropy, /* 4 - entropy */ IDEAL_specific_heat, /* 5 - specific_heat */ IDEAL_mw, /* 6 - molecular_weight */ IDEAL_speed_of_sound, /* 7 - speed_of_sound */ IDEAL_viscosity, /* 8 - viscosity */ IDEAL_thermal_conductivity, /* 9 - thermal_conductivity */ IDEAL_rho_t, /* 10 - drho/dT |const p */ IDEAL_rho_p, /* 11 - drho/dp |const T */ IDEAL_enthalpy_t, /* 12 - dh/dT |const p */ IDEAL_enthalpy_p /* 13 - dh/dp |const T */ }; I have checked the notation and seems to be fine (I copied the code from ANSYS website). Maybe I am compiling it in the wrong way, am I supposed to use the same interface as the one used to compile regular UDFs? I have attached the code that I am using. I really would appreciate if anyone could take a look at it or comment me what could be going on. Thank you in advance! |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
|
In the code that you have attached as a file and the code that you have pasted in the post, there appears to be a difference. The attached code has IDEAL in its name while the posted one is REAL. If you modified the code to REAL, did you change it in the functions as well since the end part is only a declaration.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
![]() |
![]() |
![]() |
![]() |
#3 |
Member
Cpt. Convergence
Join Date: Feb 2020
Posts: 98
Rep Power: 8 ![]() |
Sorry for that
![]() |
|
![]() |
![]() |
![]() |
![]() |
#4 |
Senior Member
|
In that case, the code is alright but the version of Fluent you are using is wrong (actually higher than the version for which this code is valid). Secondly, it appears that you are using Windows. Visual Studio is not very good at pointing errors or warnings. And all these are warnings as you can observe from the message. It has successfully compiled the library and .dll file should be available within the library. However, you will get run-time error if you use the compiled library.
Therefore, since you are using rather higher version of Fluent and the code is from version 12, consider updating the code. Development keeps on updating the parameters required by the functions from version to version. It does not happen for all functions nor is it done unnecessarily, however, as a part of improvement. _density function in the code is using three arguments while it requires four now.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
![]() |
![]() |
![]() |
![]() |
#5 |
Member
Cpt. Convergence
Join Date: Feb 2020
Posts: 98
Rep Power: 8 ![]() |
I checked the user's guide from the version 2019R2 which is the one that I am using and I got the same error. The code is here, it didn't change with respect the previous versions:
https://ansyshelp.ansys.com/account/...d%20real%20gas This person had the same exact problem as me and ANSYS Support didn't help him: https://studentcommunity.ansys.com/t...int-exception/ I am completely stucked at this stage, making this code functional is my last step.... god so close and so far at the same time... |
|
![]() |
![]() |
![]() |
![]() |
#6 |
Senior Member
|
The code that you shared earlier will work with version 12.x and even 13.x. Not sure about versions after that but it will certainly not work with v16.x and higher. As far as 19.x is concerned, the functions are quite different. Now _density requires 6 parameters. If you are using the code from 19.x, then ensure that the Fluent version is also 19.x.
As far as your older code is concerned, I was able to compile it properly in v16.2 with only one modification. IDEAL_DENSITY(cxboolean vapor_phase, ...) Even the actual code, without modification compiles alright, in Windows as well as in Linux. However, as you noticed in the student community post, it will give runtime error, same as I mentioned earlier. In essence, just ensure that the function arguments used are compatible with their declarations in Fluent.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
![]() |
![]() |
![]() |
![]() |
#7 |
Member
Cpt. Convergence
Join Date: Feb 2020
Posts: 98
Rep Power: 8 ![]() |
You were right, now the functions have 6 inputs (cell_t cell, Thread *thread, double T, double Rho, double P, double yi[]) and I got rid of 2 errors but I still having the 2 errors at the end of the code:
FLUENT_IDEAL.c ..\..\src\FLUENT_IDEAL.c(114): warning C4028: formal parameter 4 different from declaration ..\..\src\FLUENT_IDEAL.c(114): warning C4028: formal parameter 5 different from declaration # Generating udf_names.c because of makefile FLUENT_IDEAL.obj udf_names.c # Linking libudf.dll because of makefile user_nt.udf udf_names.obj FLUENT_IDEAL.obj Microsoft (R) Incremental Linker Version 14.16.27035.0 Copyright (C) Microsoft Corporation. All rights reserved. Creating library libudf.lib and object libudf.exp Done. Apparently ANSYS is not updating the example functions... Could you paste here your UDF_EXPORT RGAS_Functions RealGasFunctionList at the end of your code please? Maybe the one I am using is not the right one ![]() |
|
![]() |
![]() |
![]() |
![]() |
#8 |
Senior Member
|
What you get is a warning and not an error. I didn't write any code. Just took yours and added the argument as mentioned in my previous post.
Which version of Fluent are you using? That will decide the function.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
![]() |
![]() |
![]() |
![]() |
#9 |
Member
Cpt. Convergence
Join Date: Feb 2020
Posts: 98
Rep Power: 8 ![]() |
I am using Fluent 2019R2. After running the function I have some files called libudf.lib and object libudf.exp which technically contain the information of my model with the warnings. But when I try to load a material, in "User-Defined Database" Fluent asks me for a .scm library file.
Regards. |
|
![]() |
![]() |
![]() |
![]() |
#10 |
Senior Member
|
Windows requires .dll and not .lib or .exp. As far as .scm is concerned, it has got nothing to do with C based UDF. .scm is an extension for Scheme file. It is quite possible that whatever you are trying to do requires some Scheme based script. If you share complete details of what you are trying to do, then you can expect better help.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
![]() |
![]() |
![]() |
![]() |
#11 |
Member
Cpt. Convergence
Join Date: Feb 2020
Posts: 98
Rep Power: 8 ![]() |
What I am trying to do is to create a brand new user-defined real gas model (UDRGM). I have all the required UDFs for calculating the gas properties already programmed and tested separately. Therefore the only thing left is to integrate them within the same UDRGM, which is what I am trying to do using the Ideal-gas model as template. I think that after adding the 6 new parameters, Fluent could compile the UDRGM but I am not sure how to call/cast the gas model that I just compiled and put it as material. And how can I load the generated .dll as material for the simulation?
|
|
![]() |
![]() |
![]() |
![]() |
#12 |
Senior Member
|
I understand now why you might have received error regarding.scm file. I suppose you tried loading the library using Load icon.
UDRGM cannot be loaded using standard procedure. You need to use command define/user-defined/real-gas-models/user-defined-real-gas-model
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
![]() |
![]() |
![]() |
![]() |
#13 |
Member
Cpt. Convergence
Join Date: Feb 2020
Posts: 98
Rep Power: 8 ![]() |
Thank you so much, I didn't know it. I tried to load the library using the command line but Fluent just closes abruptly. I have attached a Capture before it closes, I couldn't copy and paste the console because Fluent doesn't allow me to do so. Therefore the error/warning stills being at the function. I will see if I can find the Fluent 2019R3 guide to see if they have updated the example.
|
|
![]() |
![]() |
![]() |
![]() |
#14 |
Member
Cpt. Convergence
Join Date: Feb 2020
Posts: 98
Rep Power: 8 ![]() |
So the updated code and the way to compile it properly is here:
https://ansyshelp.ansys.com/account/...d%20real%20gas I had to move until version 2020R1 to fing the right one.... Thank you for your help!! |
|
![]() |
![]() |
![]() |
![]() |
#15 |
Senior Member
|
Is there a difference across 2020R1 and 2019R3? With a few modifications, I am able to load the library in 19.2.
You have type definition missing in for few pointers in the functions. It is mentioned as const * while it is missing whether it is of type real, int, or char. Another aspect, though not related to compiling and loading, is definition for enthalpy and entropy. Those must be defined as integrals of CpT.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
![]() |
![]() |
![]() |
![]() |
#16 |
Member
Cpt. Convergence
Join Date: Feb 2020
Posts: 98
Rep Power: 8 ![]() |
Maybe there is no difference within the Fluent code but there are small differences between the codes available in the 2019R1 and 2020R1 user guides because I couldn't compile the template code available in 2019R1. This are the links:
2019R1: https://ansyshelp.ansys.com/account/...d%20real%20gas 2020R1 : https://ansyshelp.ansys.com/account/...d%20real%20gas There must be something different that I cannot identify (maybe it is just some spaces that appear from copy and paste), I just copied the template for having a functional in order to adapt it to mine and my model is finally working in Fluent! Regarding enthalpy and entropy, the UDRGM only asks for a scalar (double) because every single property is calculated from (cell_t cell, Thread *thread, double Temp, double Rho, double Pabs, double yi[]). I have in my model the enthalpy as a function of Temp and Pressure, therefore with the aforementioned passed-in variables is enough for my case, I have already tested it and I've got the same exact values that I calculated in Matlab ![]() |
|
![]() |
![]() |
![]() |
![]() |
#17 |
Senior Member
|
It is not advised to copy the code from the older help guides or help screen because most of the times invisible characters appear in the files. You can display those using advanced text editors. I have observed it with multiple users. It is better with online help but was really bad with offline user guides.
Since specific heat is a function of all these variables, so, its integral is also expected to be. However, if the integral of product of specific heat and temperature do not match with the equation being used, results will be incorrect. All the variables returned to Fluent are scalar. An equation will not convert it into vector or tensor. Nor would Fluent check for the accuracy. It will work with whatever user provides and predict the outcome on those basis. So, the error would be logical not syntactical. And if it is all working for you, then it is really good.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
![]() |
![]() |
![]() |
![]() |
#18 |
Member
Cpt. Convergence
Join Date: Feb 2020
Posts: 98
Rep Power: 8 ![]() |
Hi,
I am comming back to this post because I have some warnings in my UDRGM and this is the message that I am having in the console: Creating user_nt.udf file for 2ddp ... (system "copy "C:\PROGRA~1\ANSYSI~1\v190\fluent"\fluent19.0.0\sr c\udf\makefile_nt.udf "libudf\win64\2ddp\makefile" ") 1 archivo(s) copiado(s). (chdir "libudf")(chdir "win64\2ddp")# Generating ud_io1.h UDRGM.c ..\..\src\UDRGM.c(1329): warning C4090: 'function': different 'const' qualifiers ..\..\src\UDRGM.c(1329): warning C4028: formal parameter 3 different from declaration ..\..\src\UDRGM.c(1329): warning C4113: 'double (*)(cell_t,Thread *,cxboolean,double,double,double *)' differs in parameter lists from 'double (*)(cxboolean,double,double,double *)' ..\..\src\UDRGM.c(1329): warning C4113: 'double (*)(cell_t,Thread *,double,double,double,double *)' differs in parameter lists from 'double (*)(double,double,double,double *)' ..\..\src\UDRGM.c(1329): warning C4113: 'double (*)(cell_t,Thread *,double,double,double *)' differs in parameter lists from 'double (*)(double *)' ..\..\src\UDRGM.c(1329): warning C4113: 'double (*)(cell_t,Thread *,cxboolean,double,double,double *)' differs in parameter lists from 'double (*)(double,double,double,double *)' # Generating udf_names.c because of makefile UDRGM.obj udf_names.c # Linking libudf.dll because of makefile user_nt.udf udf_names.obj UDRGM.obj Microsoft (R) Incremental Linker Version 14.25.28610.4 Copyright (C) Microsoft Corporation. All rights reserved. Creating library libudf.lib and object libudf.exp Since it refers to the same line which is at the very end (where all the functions are collected) I cannot identify where the error is comming from. I know that it is a warning but when I try to initialize the flow, Fluent starts calculating something and it remains there frozen. I am suspecting that the issue could come from the compiler because this function used to work and recently I switched the computer where I normally work and now I am using Visual Studio. I call Fluent from the "x86_x64 Cross Tools Command Prompt for VS 2019" for compiling the functions (I didnīt have to do this before because the compiler was already integrated somehow). I have attached the UDRGM that I am using, if someone could try if it can be compiled, that would reduce the error "hunt". Thank you in advance! |
|
![]() |
![]() |
![]() |
![]() |
#19 |
Senior Member
|
This is a compile time warning but leading to run-time error. The reason is wrong definition of REAL_mw.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
![]() |
![]() |
![]() |
![]() |
#20 |
Member
Cpt. Convergence
Join Date: Feb 2020
Posts: 98
Rep Power: 8 ![]() |
Hello Vinerm,
Firstly how do you know it is the definition of REAL_mw? I cannot undertand how you reached such conclusion. In fact, I added some output messages at my key variables and when I load the UDRGM, for some reason it loops 4 times over the REAL_mw function (see the attached image) before doing any calculation and then the solver crashes when I try to run a single iteration. Secondly, this is my REAL_mw function, it depends on another function (REAL_compressibility) that I am assuming that works well because it is used also in the REAL_density function and I am not having any issue with it. I cannot find any syntax or definition errors on it. I am using ANSYS 19.0. double REAL_mw(cell_t cell, Thread *thread, double Temp, double Pabs, double yi[]) { double Z = REAL_compressibility(cell, thread, Temp, Pabs, yi); double mw = MW0/Z; /*-------------------------------------------------------------------*/ /* Console Display (For Debugging) */ /*-------------------------------------------------------------------*/ Message("PStat: %f (atm) TStat: %f (K) Mw: %f (Kg/mol) \n",Pabs/101325,Temp,mw); /*-------------------------------------------------------------------*/ return mw; /* (Kg/mol) */ } |
|
![]() |
![]() |
![]() |
Tags |
udrgm |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
FLUENT 19.2 User Defined Real Gas Model udf problem | MKPP | FLUENT | 1 | June 23, 2019 21:39 |
Continuing User Defined Real Gas Model issues | aeroman | FLUENT | 6 | April 8, 2016 03:34 |
Parallel User Defined Real Gas Model | aeroman | FLUENT | 4 | July 1, 2015 06:09 |
using METIS functions in fortran | dokeun | Main CFD Forum | 7 | January 29, 2013 04:06 |
error message | cuteapathy | CFX | 14 | March 20, 2012 06:45 |