UDF - Execute command : Trigger data sampling and time statistics
Dear all,
I would like to trigger the data sampling and time statistics as soon as a pre-defined accuracy is reached for a quantity of interest in a UDF. I guess it should be possible to do it by setting up an rp variable of boolean type and an execute command that starts the sampling as soon as rp variable becomes true and the value of rp variable can be set by UDF. However i am not really familiar to rp variable and execute command. Is it possible to define the rp variable inside the UDF itself ? Can anyone help me ? I would truly appreciate your help ! Thanks in advance! |
RP-Variable
Defining and setting an rp-variable is straightforward. Use the following command
(make-new-rpvar 'nameofrpvar value type) e.g., to define a variable lcoeff with initial value 0.81, use (make-new-rpvar 'lcoeff 0.81 'real) To fetch its value (rpgetvar 'lcoeff) To set it to new value (rpsetvar 'lcoeff 0.9) In place of 0.81 or 0.9, you can also use other commands that return a real value. You can use conditional statement in Execute-Commands to check if the value of variable you defined is below or above a specified limit. If that matches, then sampling should be enabled. Other option is to use a boolean instead of real value. |
Thank you for your answer !
And is it possible to set the rp variable value inside the UDF and not by means of the text interface ? I know how to access the value (e.g RP_Get_Boolean) but not how to modify it... Thanks in advance! |
you may modify values of rpvariables from UDF
it is convenient to have separated UDF variable which you will use for any modifications and apply its' value to rpvar you need. For instance, you have created rpvariable with name my_rpvar, value False and type boolean Code:
(make-new-rpvar 'my_rpvar #f 'boolean) Code:
#include "udf.h" More information you can find in Ansys Fluent Customization manual |
Thank you again for your great answer AlexanderZ!
A very last question if you still got time, i have tried to trigger the data sampling with the option "execute command". For that purpose, i have previously defined a rp-variable called "variable" which should help to trigger the data sampling when it becomes equal to 5: (if (= rpgetvar 'variable 5)\n (/solve/set/data-sampling/yes 1 yes yes)); However it doesn't work, the following error message appears : Error: eval: unbound variable Error Object: /solve/set/data-sampling/yes Do you have an idea of why and how to fix it ? Thank you in advance again! |
first of all I recommends you to use name which Fluent doesn't use definitely (which could not be a case for just "variable")
use my_variable instead you may try Code:
(if (= (rpgetvar 'my_variable) 5) (/solve/set/data-sampling/yes 1 yes yes) ()) Code:
(if (= (rpgetvar 'variable) 5) (ti-menu-load-string (format #f "/solve/set/data-sampling/yes 1 yes yes")) ()) |
Thanks !! Second option was the good call!!
By chance, is there also a command to reset the data sampling once it has already been triggered ? |
Statistics reset
To reset the sampled statistics, you can use the following command
solve init init-flow-stat |
Quote:
I want to write some text command after each iteration when fluent running , is this possible? If yes how could i do it through UDF? Regards, |
All times are GMT -4. The time now is 10:09. |