CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   execute command, how to refer to report definitions (https://www.cfd-online.com/Forums/fluent-udf/226774-execute-command-how-refer-report-definitions.html)

franc1 May 7, 2020 11:18

execute command, how to refer to report definitions
 
Hi everybody,
I'm writing an execute command which has to do a specific task each time-step.
It has to interrupt the calculation after a parameter reach a determined value.

So i tried something of this type:
Code:


(if (<VALUE (pick-a-real "/rep/vol...PROBLEM..."))(set! mstop? #t))

The problem is: how can i call my parameter (which is a report definition i defined) on the command? (instead of "PROBLEM" obv)

thank you in advance.

vinerm May 7, 2020 12:26

Report Definition
 
Report Definitions are used only for defining a report and not for computing it. Though in GUI there is an option by doing a right-click on Report-Definitions and selecting Compute, in TUI, you need to define an output-parameter which is equal to report-definition. Then you can access the value using

def para out p-t-c "name of output parameter"

franc1 May 8, 2020 03:39

Thank you Vinerm,

Code:

(if(=170 (def para out p-t-c "energia-totale-op"
))(set! mstop? #t))

this gives me the error:
Error: eval: unbound variable
Error Object: =170

What does it mean?

Thank you in advance

vinerm May 8, 2020 03:51

Space
 
A space is required between operand and operator. Write it as = 170.

And you have to use pick to pick-up numerical value. The output of direct command is just like report.

franc1 May 8, 2020 04:16

Thank you again,

The problem of "unbound variable" isn't occurring anymore, in fact a space was missing as you said.
But how do i use "pick" in my code?
Really sorry for the question, it should be easy but i have no background in scheme programming.
Thank you in advance

vinerm May 8, 2020 05:06

Pick
 
Just the way you did it before with report. (pick-a-real "TUI command" indices), where TUI command is full define param command all the way up to the selection of the output parameter and indices are used to identify the value you want to pick-up. You can try with just one index, say, 3 or 4 and see which one returns the value you are expecting.

franc1 May 8, 2020 06:18

In TUI you mean this way: ( pick-a-real "/define/parameters/output-parameters, stop-op" )
or not?

But then i do not understand the meaning of the "indices". I tried to write in it 1,2,3,4,.. but no values are returned.

Code:

def para out p-t-c "stop-op" (if(< 0 (  pick-a-real "/define/parameters/output-parameters, stop-op" INDICES )) (set! mstop? #t))

vinerm May 8, 2020 06:39

Command
 
pick-a-real command is actually a combination of two commands, pick and string->number. It picks up a string from the output of the journal command and then converts it into number because returned value is always string. So, if you type

define parameters output-parameters print-to-console report-def-0-op

it will return number but other strings as well. You need to pick up only the value of the number. That's what pick-a-real does. Since the whole output is a list of strings (that's what Scheme language is, a subset of List Processing Language), user needs to specify which member of the list he or she requires. Index starts from bottom. So, usually, for dimensional return values, 3 is the index to be used and for non-dimensional ones, 2 is to be used.

The command to compare it and then execute a stop has to be outside pick command. So, the command

(if (> threshold_value (pick-a-real "define parameters output-parameters print-to-console report-def-0-op" 3)) (cx-interrupt))

will stop Fluent if value of output parameter report-def-0-op is smaller than threshold_value.

ksgr January 16, 2021 07:56

Stop transient simulation when a parameter reaches threshold value
 
Hello everyone,

I am trying to stop a transient simulation when the volume averaged temperature of a cell zone reaches a particular value using the following scheme script:
Code:

(if (< 295 (pick-a-real "/rep/vol/volume-avg 32 , temperature n")) (set! mstop? #t))
where, 295 K is the volume-averaged threshold temperature below which if the simulation should stop, 32 is the cell zone id.

The problem is as soon as the simulation starts with the above scheme command, the simulation stops while the volume average temperature of the cell zone is still around 320 K. If anybody could explain what is the problem with the above scheme command or the execution part, your help would be appreciated.

Thanks

AlexanderZ January 18, 2021 00:32

Code:

(set! mstop? #t)
where did you find this command? did you make it by your own?

Actually, you code seems to be correct.
you can execute it through execute commands window, don't see any problem here, frankly speaking

you may try to print the value of avg temperature at the moment, when simulation stops, just to check


All times are GMT -4. The time now is 13:46.