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/)
-   -   Scheme Programming: problem writing "set!" for multiple variables (https://www.cfd-online.com/Forums/fluent-udf/173282-scheme-programming-problem-writing-set-multiple-variables.html)

nsaeidi June 16, 2016 12:05

Scheme Programming: problem writing "set!" for multiple variables
 
1 Attachment(s)
Hello all,

I am using Scheme to control Flow Rate Weighting with time for my outlets with outflow boundary condition. I have managed to write the code for controlling only one outlet. Now I want to extend my code as it can control more than one outlet. My code is attached as a txt file!
I can read it successfully but when I run it, I receive this error in text user interface:
Error: set!: not a symbol
Error Object: (flow-wt-1 flow-wt-2)

Can anybody tell me what am I doing wrong?

nsaeidi June 16, 2016 14:58

If anybody interested I sorted out my problem. Here is the code:

(define flow-wt-1 0.0)
(define flow-wt-2 0.0)
(define run1
( lambda(flow-time)
(set! flow-time (/ flow-time 10))
(if (< flow-time 181)
(set! flow-wt-1 '1.0)
(set! flow-wt-1 '0.0))
(ti-menu-load-string (format #f "def bc outflow 6 ~a" flow-wt-1))
(ti-menu-load-string (format #f "def bc outflow 7 ~a" flow-wt-1))
)
)
(define run2
( lambda(flow-time)
(set! flow-time (/ flow-time 10))
(if (> flow-time 180)
(set! flow-wt-2 '1.0)
(set! flow-wt-2 '0.0))
(ti-menu-load-string (format #f "def bc outflow 8 ~a" flow-wt-2))
)
)

It needs to be called in the Execute Commands by defining two commands at each time steps:
(run1 ( rpgetvar 'flow-time)) and (run2 ( rpgetvar 'flow-time))


All times are GMT -4. The time now is 02:55.