|
[Sponsors] |
May 23, 2018, 10:34 |
UDF Compiling / Parallel mode
|
#1 |
New Member
Join Date: May 2018
Posts: 8
Rep Power: 8 |
Hi,
I am currently using a DEFINE_MATERIAL udf. I am a beginner as a Fluent user and I would have several questions if you can answer them : - I understand that it is faster to use compilation for UDF material properties, but I've never seen anyone quantifying the speed improvement ? Has anyone how much faster it is ? No general result of course, but an idea ? - What are the methods to compile a UDF or a library ? Following tutorials to compile with microsoft visual studio, I thought that somehow fluent has to be run in parallel with an external compiler by linking the environment variables of Fluent. That's why you use crossed commands from Visual Studio to launch Fluent. However, if the udf and the library have been compiled successfully the first time it will not be necessary to compile them again next time ? How does it work ? - Do you think my UDF in parallel case ? #include "udf.h" #include "math.h" DEFINE_SPECIFIC_HEAT(my_user_cp, T, Tref, h, yi) { real cp real cps real cpl real DT real r real Tm Tref=273.15; cps=2025; cpl=4180; Tm=273.15; DT=0.5; r=10/DT; cp=cps+(cpl-cps)/(1+exp(r*(Tm-T)); *h = cpl*(T-Tref)+(cpl-cps)/r*log(fabs(1+exp(-r*(T-Tm)))/fabs(1+exp(-r*(Tref-Tm)))); return cp; } Thank you in advance ! MV78 |
|
May 23, 2018, 12:43 |
|
#2 |
Senior Member
Join Date: Sep 2017
Posts: 246
Rep Power: 12 |
Hi MV78,
The number of limitations on an interpreted UDF is so large that I would never even consider using interpreted. DEFINE_SPECIFIC_HEAT is one of them -- this is mentioned explicitly in the help files for that macro. There are some useful posts on compiling UDFs -- for example: links to instructions Visual Studio 2017 for udf use - which modules do I need?; troubleshooting errors How to solve UDF compilation problems in Fluent.; the basic steps of compile/load/hook The UDF library you are trying to load (libudf) is not compiled for 3D on the current. Note that with more recent installations, there is no requirement for the horrible clunky nonsense of starting Fluent from a yellow SDK command prompt or changing environment variables by hand. Some comments on your UDF: 1) You need semicolons at the end of each statement -- specifically "real cp;" etc. The compiler should detect this and give you an error. (Try it and see -- that way, you may learn how to understand the compiler error for the next time.) 2) Tref is supplied to you as an input parameter -- it is not available for you to change. (Changing it inside the UDF would have no effect anyway.) The value is very very likely to be 298.15K. I would advise against changing it inside the Fluent model. 3) I have tried your integration of Cp to h, and it definitely rings alarm bells. I'm fairly sure that the first cpl in h should be a cps. I'm very sure that fabs should not creep in during integration. I suspect that the second term needs a minus sign in front of the whole thing. But the point is: you should check this super-carefully -- try the integration numerically in a spreadsheet, try the integration in WolframAlpha, and try it some other way. 4) It should be fine in parallel. Good luck! Ed |
|
May 24, 2018, 04:43 |
|
#3 |
New Member
Join Date: May 2018
Posts: 8
Rep Power: 8 |
Hi obscureed,
Thank you for your detailed answer and your advices ! It really helps. Concerning my UDF, I am sorry I picked the wrong file that still carries the syntax errors in C. I had corrected them. 1) Wrong file sorry 2) Indeed, the temperature reference is defined twice if I let it in the cp model... Thank you. 3) I had verified it of course with excel and it worked. The relative error was around 2%. It is a cpl because when you integrate, cps*(T-Tref) is eliminated with (cpl-cps)*(T-Tref). Thank you for the wolfram alpha reference ! 4) Unfortunately, I encountered a problem when I switched the same case and UDF from serial to parallel. I don't understand why, it is a "the fl process could not be started" problem. Do you see any explanation ? Have a good day, MV78 Last edited by MV78; May 25, 2018 at 04:21. |
|
May 27, 2018, 21:14 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
change
Code:
r=10/DT; Code:
r=10.0/DT; |
|
May 28, 2018, 08:07 |
|
#5 |
New Member
Join Date: May 2018
Posts: 8
Rep Power: 8 |
Hi !
Thank you for your help ! I tried to fix the problem with your solution. It still doesn't work and I got this problem related to Visual Studio when I interprete the UDF even if it shouldn't... The second confusing thing is that it worked two or three times at one moment. And after several trials to check if it was just luck or not it started crashing again. Have a good day, MV78 |
|
May 28, 2018, 20:30 |
|
#6 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
you should compile udf instead if interpret
best regards |
|
May 29, 2018, 05:02 |
|
#7 |
Senior Member
Join Date: Sep 2017
Posts: 246
Rep Power: 12 |
Hi MV78,
As AlexanderZ says, you really need to compile this UDF. For a start, the help files for DEFINE_SPECIFIC_HEAT specifically state that interpreting a UDF of this type will not work (or is not intended to work, and is therefore not worth trying). You might want to show us your updated code, and describe the (latest) problems in more detail. But if it is similar to the previous version but you are getting inconsistent behaviour, then it is time for troubleshooting: check (again) that your model runs consistently without the UDF; check that it runs consistently with a simpler UDF; check it all in serial and in parallel; etc etc. Sorry, no easy answers just now. (You might well be struck by the thought that a piecewise-linear definition of Cp would be just as good and much less trouble, and on this occasion you would probably be correct.) Good luck! Ed |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Unsteady Inlet Velocity UDF in Parallel Batch Mode | vtyler | Fluent UDF and Scheme Programming | 4 | April 1, 2020 05:44 |
Dynamic mesh in parallel udf | rsarma | Fluent UDF and Scheme Programming | 3 | August 2, 2018 07:02 |
problem using property udfs in parallel mode | EllenW | FLUENT | 0 | June 23, 2009 17:18 |
DPM model in parallel batch mode | Prashanth | FLUENT | 2 | March 6, 2009 07:54 |
udf compile in parallel system | tahereh | FLUENT | 1 | December 9, 2008 09:48 |