|
[Sponsors] |
Can I define density in terms of liquid fraction in UDF? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
August 11, 2019, 03:10 |
Can I define density in terms of liquid fraction in UDF?
|
#1 |
Senior Member
Join Date: Jan 2011
Posts: 339
Rep Power: 16 |
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 |
|
August 11, 2019, 20:20 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
it looks like some average value
how are you going to apply average value and resolve fluid and gas phases simultaneously? best regards |
|
August 12, 2019, 05:42 |
|
#3 |
Senior Member
Join Date: Jan 2011
Posts: 339
Rep Power: 16 |
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 |
|
August 13, 2019, 01:15 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
press build, not load
best regards |
|
August 13, 2019, 02:34 |
|
#5 |
Senior Member
Join Date: Jan 2011
Posts: 339
Rep Power: 16 |
||
August 13, 2019, 04:12 |
|
#6 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
if you've build the code without errors -> you will never get log error, that you have
best regards |
|
August 13, 2019, 04:22 |
|
#7 | |
Senior Member
Join Date: Jan 2011
Posts: 339
Rep Power: 16 |
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. |
||
August 13, 2019, 07:22 |
|
#8 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
you should in install Visual Studio and run fluent from VS console
best regards |
|
August 13, 2019, 07:28 |
|
#9 |
Senior Member
Join Date: Jan 2011
Posts: 339
Rep Power: 16 |
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; } |
|
August 14, 2019, 05:59 |
|
#10 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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); real LIQF = C_T(cell, thread); best regards |
|
August 14, 2019, 06:08 |
|
#11 | |
Senior Member
Join Date: Jan 2011
Posts: 339
Rep Power: 16 |
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; } Last edited by mariam.sara; August 14, 2019 at 13:24. |
||
August 16, 2019, 01:26 |
|
#12 | |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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" #define cps 1800.0 #define cpl 2400.0 #define lat 160000.0 DEFINE_SPECIFIC_HEAT(cell_cp, T, Tref, h, yi) { float cpm,dt; Tref = 308; dt=exp(-T*(T-Tref)*(T-Tref)/4.0)/sqrt(4.0*3.14); cpm =cps+(cpl-cps)*yi[1]+lat*dt; *h = cpm*(T-Tref); return cpm; } put here final code, when you'll run it successfully best regards |
||
August 19, 2019, 08:53 |
|
#13 | |
Senior Member
Join Date: Jan 2011
Posts: 339
Rep Power: 16 |
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:
|
||
August 20, 2019, 01:45 |
|
#14 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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 |
|
August 21, 2019, 12:23 |
|
#15 | |
Senior Member
Join Date: Jan 2011
Posts: 339
Rep Power: 16 |
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:
|
||
August 22, 2019, 01:21 |
|
#16 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
unfortunately, have no idea about it
best regards |
|
August 22, 2019, 05:28 |
|
#17 |
Senior Member
Join Date: Jan 2011
Posts: 339
Rep Power: 16 |
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?
|
|
August 22, 2019, 07:59 |
|
#18 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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 |
|
August 22, 2019, 08:03 |
|
#19 |
Senior Member
Join Date: Jan 2011
Posts: 339
Rep Power: 16 |
So I need if statement to add the conditions of f(t)? May you just write me the conditions to avoid any mistakes?
|
|
August 22, 2019, 08:16 |
|
#20 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
you comparison conditions from picture are very strange
Tm-deltaT/2 is everywhere check it best regards |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
liquid volume fraction decrease(Eulerian + Degassing BC) | Dereje | Fluent Multiphase | 0 | June 19, 2019 03:26 |
UDF error for Heat Generation | mame | Fluent UDF and Scheme Programming | 4 | March 3, 2016 05:22 |
UDF C_P(c,t) Define density initialization error | yuanmengyuan1989 | Fluent UDF and Scheme Programming | 0 | May 29, 2014 23:12 |
Installing OF 1.6 on Mac OS X | gschaider | OpenFOAM Installation | 129 | June 19, 2010 10:23 |
Missing math.h header | Travis | FLUENT | 4 | January 15, 2009 12:48 |