Can I define density in terms of liquid fraction in UDF?
1 Attachment(s)
Can I write a UDF for defining density as a function of solid & liquid densities (which they are known) and liquid fraction (as variable) as illustrated in picture?
Mariam |
it looks like some average value
how are you going to apply average value and resolve fluid and gas phases simultaneously? best regards |
Dear Alexander,
many thanks for the answer. I did the UDFs successfully and interpreted it then it loaded within FLUENT now I want to use compile option but the following error appeared to me I used win10 64 bit what the problem? can you assist me? Error: The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64).\n\nThe system cannot find the file specified. \n\nC:\Users\AWm\AppData\Local\Temp\valid1.tmp\val id1_files\dp0\FFF\Fluent\libudf\win64\3ddp_host\li budf.dll Quote:
|
press build, not load
best regards |
Quote:
|
if you've build the code without errors -> you will never get log error, that you have
best regards |
Quote:
Copied D:\workkh\specific.C to libudf\src ************************************************** ************************** ************************************************** ************************** ** WARNING: Automatically switched to run in parallel -t1 mode. ** ** Detected non-parallelized UDF usage, enabling parallel usage. ** ** If you encounter any issues, please re-run with -t0 flag. ** ************************************************** ************************** ************************************************** **************************udf_names.c and user_nt.udf files in 3ddp_host are upto date. (system "copy "C:\PROGRA~1\ANSYSI~1\v193\fluent"\fluent19.3.0\sr c\udf\makefile_nt.udf "libudf\win64\3ddp_host\makefile" ") 1 file(s) copied. (chdir "libudf")(chdir "win64\3ddp_host")'nmake' is not recognized as an internal or external command, operable program or batch file. |
you should in install Visual Studio and run fluent from VS console
best regards |
I installed VS many thanks and the problem fixed. But I face another? I tried to define specific heat as a UDF but it not appear to me while I am trying to use the option user define for it and the following error now appear:
Error: No user-defined functions of type udf-type-specific-heat have been loaded. Error Object: #f Here is my UDF for specific heat what the problem: #include "udf.h" DEFINE_PROPERTY(cell_specific_heat, cell, thread) { real cpm,cps,cpl,Tm,dt,lat; real temp = C_T(cell, thread); real LIQF = C_T(cell, thread); cps=1800.0; cpl=2400.0; Tm=308.0; lat=160000.0; dt=exp(-temp*(temp-Tm)*(temp-Tm)/4.0)/sqrt(4.0*3.14); cpm =cps+(cpl-cps)*LIQF+lat*dt; return cpm; } |
specific heat is defined through other macro called DEFINE_SPECIFIC_HEAT(name,T,Tref,h,yi)
more information you can find in Ansys Fluent Customization manual in your code Code:
real temp = C_T(cell, thread); best regards |
Quote:
I used the macro of define specific heat but there is still error as below: chdir "D:\workkh\valid1_files\dp0\FFF\Fluent\libudf3")(c hdir "win64\3ddp_node")# Generating ud_io1.h abcd.c ..\..\src\abcd.c(7) : error C2143: syntax error : missing ')' before 'constant' ..\..\src\abcd.c(7) : error C2143: syntax error : missing '{' before 'constant' ..\..\src\abcd.c(7) : error C2059: syntax error : 'constant' ..\..\src\abcd.c(7) : error C2059: syntax error : ')' here is the UDF I wrote: #include "udf.h" #define cps 1800.0 #define cpl 2400.0 #define Tref 308.0 #define lat 160000.0 DEFINE_SPECIFIC_HEAT(cell_cp, T, Tref, h, yi) { float cpm,dt; dt=exp(-T*(T-Tref)*(T-Tref)/4.0)/sqrt(4.0*3.14); cpm =cps+(cpl-cps)*LIQF+lat*dt; h = cpm*(T-Tref); return cpm; } |
there are several problems:
1. Tref is defined in macro already, you don't need to redefine it 2. h has type *real, so you should use *h = .... 3. The most important one, LIQF is not defined probably you want to use liquid mass fraction in that case you may try to use yi, which is Quote:
But I don't remember which value you should use, play with it You final code may looks like this, lets assume, that liquid fraction is yi[1]: Code:
#include "udf.h" put here final code, when you'll run it successfully best regards |
1 Attachment(s)
I used solidification and melting model hence there are only two phases solid and liquid? Hence I think your opinion related with liquid fraction is true in species model. Now I uploaded the UDF for specific heat successfully but an error happened and the program closed with unknown reason as soon as I initial the solution? I took quick capture screen picture for the error as the attached picture? knowing that the case is running normally without using the UDF? here is the UDF below is there an error on it:
#include "udf.h" /* #define cps 1800.0 #define cpl 2400.0 #define lat 160000.0 */ DEFINE_SPECIFIC_HEAT(specificheat, T, Tref, h, yi) { real cpm,dt; Tref=308; real cps = 1800.0; real cpl = 2400.0; real lat = 160000.0; Thread *t; cell_t c; dt=exp(-T*(T-Tref)*(T-Tref)/4.0)/sqrt(4.0*3.14); cpm =cps+(cpl-cps)*C_LIQF(c,t)+lat*dt; *h = cpm*(T-Tref); return cpm; } Quote:
|
are you kidding me?
you cant you C_LIQF(c,t) inside DEFINE_SPECIFIC_HEAT, becasue c/t (which are cell/thread) are not defined, find other way best regards |
I referred for this reply from you? You mentioned that I can used y[0],yi[1] for the mass/liquid fraction? I used melting and solidification model not specices model, hence I have just two phases solid & liquid if I write the equation of Cp as you defined it previously as below :
cpm =cps+(cpl-cps)*yi[1]+lat*dt; how can I ensure FLUENT will consider yi[1] as the liquid fraction? Quote:
|
unfortunately, have no idea about it
best regards |
1 Attachment(s)
OK I want to try to define the liquid fraction at Cp relation using the definition at the attached picture (where f(T) is LIQF). As it appeared LIQF is a function of temp so can I give this definition inside specific heat UDF?
|
you do have temperature in this macro
DEFINE_SPECIFIC_HEAT(cell_cp, T, Tref, h, yi) so you can define f(T) easily best regards |
So I need if statement to add the conditions of f(t)? May you just write me the conditions to avoid any mistakes?
|
you comparison conditions from picture are very strange
Tm-deltaT/2 is everywhere check it best regards |
All times are GMT -4. The time now is 09:46. |