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/)
-   -   How to save /adjoint/observable/evaluate result to scheme variable? (https://www.cfd-online.com/Forums/fluent-udf/213249-how-save-adjoint-observable-evaluate-result-scheme-variable.html)

ProBioticum December 19, 2018 14:40

How to save /adjoint/observable/evaluate result to scheme variable?
 
I have an observable ld(lift drag ratio) which I'm calculating through scheme script by which is calling command /adjoint/observable/evaluate.

The result is printed to TUI console.
Code:

Observable name: ld
Observable Value (undefined): 2.6054044

But I need to get that same calculation result into some variable in scheme script so the next statement could read that variable and operate with it.

For example the scheme script should look like this:

Code:

1. apply command  /adjoint/observable/evaluate
2. save that ld value to scheme variable
3. do something next with that variable

How can I save that calculation result into scheme variable?

AlexanderZ December 20, 2018 00:44

try to use following command
Code:

(rpgetvar 'monitor/lift)
what output do you have?

best regards

ProBioticum January 6, 2019 06:57

Code:

(rpgetvar 'monitor/lift)
Gives result

Code:

()

AlexanderZ January 7, 2019 02:44

you may get lift/drag coef value using following command
Code:

(car (cdr (car (rpgetvar 'adjoint/multiobjective-data ))))
create your own rpvar variable
Code:

        (define (make-new-rpvar name default type)
        (if (not (rp-var-object name))
        (rp-var-define name default type #f)))
(make-new-rpvar 'my_lift/drag 0.0 'real)

set your variable equal to computated ld ratio

Code:

(rpsetvar 'my_lift/drag (car (cdr (car (rpgetvar 'adjoint/multiobjective-data )))))
check
Code:

(rpgetvar 'my_lift/drag)
now you can use it in scheme as well as in UDF

best regards

ProBioticum May 10, 2019 18:07

Thank you for your contribution. The solution you proposed worked for the observable `ld`. How would I get values of other observables (lift, drag, le_moment)?

riccardo.frezza October 8, 2019 09:55

Hi, I'm new in using the scheme language and I need to get the "pressure-drop" observable into a variable in scheme script. Did you find a different solution? With (rpgetvar 'adjoint/multiobjective-data) it shows me the pressure-drop observable value. Adjoint/multiobjective-data isn't a TUI command. Where can I find those commands?


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