Scheme macro with random creation of waterdrops
I am using Fluent 6.3 to calculate a complex 2D biphasic simulation. At the moment, I want to patch water drops on a surface while the simulation is running. This should simulate raindrops on a windshield. That is why I just see the possibility to do that with a macro. I already wrote a command in scheme, but there is always an error when running the simulation. I have big problems in finding the mistake, because of a missing debugger in scheme.
My code is the following:
'((autodrop . "(if (= (truncate (/ (rpgetvar 'flow-time) 0.05)) (+ (truncate (/ (- (rpgetvar 'flow-time) (rpgetvar 'physical-time-step)) 0.05)) 1)) (begin (ti-menu-load-string \"adapt/free-registers yes\") (do ((x 0 (+ x 0.05))) ((>= x 1)) (ti-menu-load-string \"adapt/mark-inout-circle yes no (* 3650 sin((/ (+ 100 (random 590)) 3650))) (- (* 3650 cos((/ (+ 100 (random 590)) 3650))) 3650) 1) (ti-menu-load-string \"solve/patch phase-water () sphere-r~a () mp 1\"))")
I want to add randomly every 0.05s a new drop to the windshield. I do this by marking a circle on the windshield and then patching it with water, but Fluent always runs into an EOF error. The sin() and cos() functions are needed to calculate the x-y-position on the windshield, because it is not flat.
I hope you can help me solving this problem. Maybe there is another possibility to patch without a macro while the simulation is running, too.
Thank you in advance for helping me!
Ok, I improved the whole thing a bit. It seems to work now except the creation of a random value. Normally there should be instead of the 400(bold) a random number between 100 and 690. If you have any idea how to solve that problem, please let me know.
Here's my improved code:
(autodrop . "(define i 1) (define x 0) (if (= (truncate (/ (rpgetvar 'flow-time) 0.00003)) (+ (truncate (/ (- (rpgetvar 'flow-time) (rpgetvar 'physical-time-step)) 0.00003)) 1)) (begin (+ i 1) (+ x 1) (if (= x 25) (exit)) (if (= i 15) ((= i 1) )) (ti-menu-load-string \"adapt/mark-inout-circle yes no (* 3650 (sin (/ 400 3650))) (- (* 3650 (cos (/ 400 3650))) 3650) 1\") (ti-menu-load-string (format #f \"solve/patch phase-water () (~a) mp 1\" i))))")
Thanks for any help.
I'm not much for writing scheme code, but I know this can be done with a UDF via a define_adjust udf (look up begin_f_loop(f,t)). You'll loop over all faces on a boundary, choose a random (or specified) X,Y coordinate, then choose your random value for the diameter(?) of the droplet.
Thanks for your answer.
At the moment, I'm giving my best to write an UDF, but I'm very unexperienced with C and writing UDFs. But here's my try:
Any help would be great!
Is there anyone who can help me? I couldn't make any progress in that problem...
|All times are GMT -4. The time now is 20:11.|