|
[Sponsors] |
September 4, 2022, 06:37 |
|
#41 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
Managed to get this scheme code going, no errors when compiled with Fluent, but when run got this error message after every time step! What could have gone wrong?
" ... (Two_BC_type_Changes) Error: eval: unbound variable Error Object: two_bc_type_changes " (define (Two_BC_type_Changes) (define time-sequence #(0 (30*8.333e-5) (310*8.333e-5))) ;begins opennings then close for compress and ignition finall opening with specific times (define type-sequence #(2 1 2)) (define flag 0) (define bctype 0) (define time (rpgetvar ‘flow-time)) (define dt (rpgetvar ‘physical-time-step)) (set! flag 0) (set! bctype 0) (do ((i 0 (+ i 1))) ((= i (vector-length time-sequence))) (if (>= time (- (vector-ref time-sequence i) (* 8.333e-5 dt))) (if (<= time (+ (vector-ref time-sequence i) (* 8.333e-5 dt))) (set! flag 1) (set! bctype (vector-ref type-sequence i)) ))) (if (= 1 bctype) (if (= flag 1) (set! flag 2))) (if (= flag 1) (begin (ti-menu-load-string (format #f “define bou zone type 24 wall”)) (ti-menu-load-string (format #f “define bou zone type 23 wall”)) (ti-menu-load-string (format #f “define bou zone type 11 wall”)) (ti-menu-load-string (format #f “define bou zone type 12 wall”)) ) ) (if (= flag 2) (cond (and (> (rpgetvar ‘flow-time) 0.0) (< (rpgetvar ‘flow-time) (30*8.333e-5))) ;suction open big timer (begin (ti-menu-load-string (format #f “define bou zone type 24 pressure-inlet”))) ;suction open big BC status (and (> (rpgetvar ‘flow-time) 0.0) (< (rpgetvar ‘flow-time) (30*8.333e-5))) ;suction open timer (begin (ti-menu-load-string (format #f “define boundary-conditions pressure-inlet 24 yes no 1.1e5 no 1 no 300 no yes”))) ;suction open big pressure on (and (> (rpgetvar ‘flow-time) 0.0050) (< (rpgetvar ‘flow-time) (30*8.333e-5))) ;suction open small timer (begin (ti-menu-load-string (format #f “define bou zone type 23 pressure-inlet”))) ;suction open small BC status (and (> (rpgetvar ‘flow-time) 0.0050) (< (rpgetvar ‘flow-time) (30*8.333e-5))) ;suction open small timer (begin (ti-menu-load-string (format #f “define boundary-conditions pressure-inlet 23 yes no 1.1e5 no 1 no 300 no yes”))) ;suction open small pressure on (and (> (rpgetvar ‘flow-time) (490*0.000104)) (<= (rpgetvar ‘flow-time) (720*8.333e-5))) ;outlet open big timer (begin (ti-menu-load-string (format #f “define bou zone type 11 pressure-outlet”))) ;outlet open big BC status (and (> (rpgetvar ‘flow-time) (490*0.000104)) (<= (rpgetvar ‘flow-time) (720*8.333e-5))) ;outlet open small timer (begin (ti-menu-load-string (format #f “define bou zone type 12 pressure-outlet”))) ;outlet open big BC status ) ) (newline) (if (= flag 1) (display “Exhaust BC now wall”)) (if (= flag 2) (Display “Exhaust BC now pressure inlet”)) ) |
|
September 4, 2022, 07:30 |
|
#42 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
Latest scheme error when run with fluent.
At every time step I get this message. Error: eval: unbound variable Error: Object: flow-time |
|
September 5, 2022, 03:56 |
|
#43 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
Then I tried to simplify this and get rid of the flags and loops, by using the following scheme code, but keep getting this error??
--- Error: eval: unbound variable Error Object: �flow-time --- (define (change_BC_cond_only) (cond (>=(rpgetvar ‘flow-time) 0) (ti-menu-load-string “define/boundary-conditions/zone-type 24 pressure-inlet”)) (>=(rpgetvar ‘flow-time) 0) (ti-menu-load-string (format #f “define boundary-conditions pressure-inlet 24 yes no 1.2e5 no 1 no 360 no yes”)) (>=(rpgetvar ‘flow-time) 0.00312) (ti-menu-load-string “define/boundary-conditions/zone-type 24 wall”)) (<=(rpgetvar ‘flow-time) 0.03224) (ti-menu-load-string “define/boundary-conditions/zone-type 11 wall”)) (else (>=(rpgetvar ‘flow-time) 0.03224) (ti-menu-load-string “define/boundary-conditions/zone-type 11 pressure-outlet”))) ) |
|
September 6, 2022, 03:35 |
|
#44 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
problem is in brackets, as it was in other versions of code (above)
stick to scheme language syntax example Code:
(cond ((positive? -5) (error "doesn't get here")) ((zero? -5) (error "doesn't get here, either")) ((positive? 5) 'here)) Code:
here
__________________
best regards ****************************** press LIKE if this message was helpful |
|
September 6, 2022, 04:18 |
|
#45 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
Thanks Alex. I though it was the brackets, I will try this again. Meanwhile I run this code with one BC change relying on flag 1 and flag 2, rather than the complxity of the cond statement. The problem is the limitation of the two flags, it will be good if this can be modified with for example three or four flags (flag 1, flag 2, flag 3, flag 4..) The top part of the program loops over the flags. Still though no BC change was observed, but at least no errors.
(define (outlet_BC_type_Changes) (define time-sequence #(0 0.05616)) ;begins opennings then close for compress and ignition finall opening with specific times (define type-sequence #(1 2)) (define flag 0) (define bctype 0) (define time (rpgetvar ‘flow-time)) (define dt (rpgetvar ‘physical-time-step)) (set! flag 0) (set! bctype 0) (do ((i 0 (+ i 1))) ((= i (vector-length time-sequence))) (if (>= time (- (vector-ref time-sequence i) (* 8.333e-5 dt))) (if (<= time (+ (vector-ref time-sequence i) (* 8.333e-5 dt))) (set! flag 1) (set! bctype (vector-ref type-sequence i)) ))) (if (= 1 bctype) (if (= flag 1) (set! flag 2))) (if (= flag 1) (begin (ti-menu-load-string (format #f “define bou zone type 11 wall”)) (ti-menu-load-string (format #f “define bou zone type 12 wall”)) ) ) (if (= flag 2) (begin (ti-menu-load-string (format #f “define bou zone type 11 pressure-outlet”)) ;suction open big BC status (ti-menu-load-string (format #f “define bou zone type 12 pressure-outlet”)) ;outlet open big BC status ) ) ) |
|
September 6, 2022, 04:48 |
|
#46 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
Just wrote this and got this error message, brackets!
Error: eof inside list Error Object: () (define (Two_BC_type_Changes) (define time-sequence #(0 0.00312 0.05616)) (define type-sequence #(2 1 2)) (define flag 0) (define bctype 0) (define time (rpgetvar ‘flow-time)) (define dt (rpgetvar ‘physical-time-step)) (set! flag 0) (set! bctype 0) (do ((i 0 (+ i 1))) ((= i (vector-length time-sequence))) (if (>= time (- (vector-ref time-sequence i) (* 8.333e-5 dt))) (if (<= time (+ (vector-ref time-sequence i) (* 8.333e-5 dt))) (set! flag 1) (set! bctype (vector-ref type-sequence i)) ))) (if (= 1 bctype) (if (= flag 1) (set! flag 2))) (if (= flag 1) (begin (ti-menu-load-string (format #f “define bou zone type 24 wall”)) (ti-menu-load-string (format #f “define bou zone type 23 wall”)) (ti-menu-load-string (format #f “define bou zone type 6 wall”)) (ti-menu-load-string (format #f “define bou zone type 11 wall”)) ) ) (if (= flag 2) (cond ((> (rpgetvar ‘flow-time) 0.0) (ti-menu-load-string (format #f “define bou zone type 24 pressure-inlet”)) ((> (rpgetvar ‘flow-time) 0.0) (ti-menu-load-string (format #f “define boundary-conditions pressure-inlet 24 yes no 1.1e5 no 1 no 300 no yes”)) ((> (rpgetvar ‘flow-time) 0.0) (ti-menu-load-string (format #f “define bou zone type 23 pressure-inlet”)) ((> (rpgetvar ‘flow-time) 0.0) (ti-menu-load-string (format #f “define boundary-conditions pressure-inlet 23 yes no 1.1e5 no 1 no 300 no yes”)) ((> (rpgetvar ‘flow-time) 0.05616) (ti-menu-load-string (format #f “define bou zone type 11 pressure-outlet”)) ((> (rpgetvar ‘flow-time) 0.05616) (ti-menu-load-string (format #f “define bou zone type 12 pressure-outlet”)) ) ) ) Last edited by visitor; September 6, 2022 at 07:37. |
|
September 6, 2022, 20:23 |
|
#47 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
I recommend you to use notepad++, its quite comfortable, it will help you to check your brackets
__________________
best regards ****************************** press LIKE if this message was helpful |
|
September 7, 2022, 02:50 |
|
#48 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
Thanks Alex. I will look at this tool, but looking at the first 22 lines of scheme code, what should change to make the code work with a third or even fourth flag. Right now it just works for two flags, flag 1 and flag 2. Thanks again
|
|
September 7, 2022, 08:45 |
|
#49 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
Thanks Alex, downloaded Notepad++, yes it is helpful, had an extra bracket at the end.! Still if there is a way in increasing flags from 2 to 3 or even 4, it will be neater I think, no need for 'if' 'and' 'cond' ...
|
|
September 7, 2022, 16:16 |
|
#50 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
This is what I am aiming for now to simplify the code and just change BCs based on flag 1, flag 2 and flag 3. I have not run this yet, though did check this with notepad++, and no bracket errors showed, still doesn't seem right.
(define (Two_BC_type_Changes) (define time-sequence #(0 0.00312 0.05616)) (define type-sequence #(2 1 3)) (define flag 0) (define bctype 0) (define time (rpgetvar ‘flow-time)) (define dt (rpgetvar ‘physical-time-step)) (set! flag 0) (set! bctype 0) (do ((i 0 (+ i 1))) ((= i (vector-length time-sequence))) (if (>= time (- (vector-ref time-sequence i) (* 8.333e-5 dt))) (if (<= time (+ (vector-ref time-sequence i) (* 8.333e-5 dt))) (set! flag 1) (set! bctype (vector-ref type-sequence i)) ))) (if (= 1 bctype) (if (= flag 1) (set! flag 2))) (if (= flag 1) (begin (ti-menu-load-string (format #f “define bou zone type 24 wall”)) (ti-menu-load-string (format #f “define bou zone type 23 wall”)) (ti-menu-load-string (format #f “define bou zone type 6 wall”)) (ti-menu-load-string (format #f “define bou zone type 11 wall”)) ) ) (if (= flag 2) (cond (ti-menu-load-string (format #f “define bou zone type 24 pressure-inlet”) (ti-menu-load-string (format #f “define boundary-conditions pressure-inlet 24 yes no 1.1e5 no 1 no 300 no yes”) (ti-menu-load-string (format #f “define bou zone type 23 pressure-inlet”) (ti-menu-load-string (format #f “define boundary-conditions pressure-inlet 23 yes no 1.1e5 no 1 no 300 no yes”) ) ) (if (= flag 3) (cond (ti-menu-load-string (format #f “define bou zone type 11 pressure-outlet”) (ti-menu-load-string (format #f “define bou zone type 12 pressure-outlet”) ) ) |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF switching with a conditional statement | visitor | FLUENT | 15 | July 5, 2019 13:28 |
Ansys Fluent 17.0 Expression | u_k | FLUENT | 8 | May 13, 2019 07:15 |
Surface tension force expression at the wall in fluent | IndrajitW | FLUENT | 0 | April 15, 2013 09:37 |
Conditional statement over the entire mesh | xisto | OpenFOAM Programming & Development | 6 | November 24, 2010 13:13 |
CFX Expression Statement | Ivan | CFX | 3 | June 5, 2006 12:42 |