问题
A sequel to my previous question:
I'm using the ANSYS Fluent program for CFD simulations. This program allows some partial automation of the simulation setup using a so-called Journal File, and I just came to know that this Journal File is written in Scheme. Unfortunately I never even heard of Scheme, I just know it's a Lisp dialect (which I also know nothing of).
I'm trying to automate some boring tasks by using a loop to automatically set a bunch of parameters to my simulation. If I run this command from Fluent's command interface (modulo comments):
; Select item in list
(cx-gui-do cx-set-list-selections "Boundary Conditions*Table1*List2(Zone)" '( 4))
; (Also?) select item in list
(cx-gui-do cx-activate-item "Boundary Conditions*Table1*List2(Zone)")
; Open dialog window for the selected item
(cx-gui-do cx-activate-item "Boundary Conditions*Table1*Table3*Table4*ButtonBox1*PushButton1(Edit)")
; Set the "volume fraction" parameter to 1
(cx-gui-do cx-set-expression-entry "Velocity Inlet*Frame3*Frame6(Multiphase)*Table1*Table16*ExpressionEntry1(Volume Fraction)" '("1" . 0))
; CLick OK button to close window
(cx-gui-do cx-activate-item "Velocity Inlet*PanelButtons*PushButton1(OK)")
it does as expected: It selects an item from a drop down list, opens a dialog window for that item, changes the value of a parameter from 0 to 1, and then closes that window. If I wrap the above in a loop to cycle through the items in the list, and replace the '( 4)
by (list z)
:
(do ((z 4 (+ 1 z)))
((> z 27))
(cx-gui-do cx-set-list-selections "Boundary Conditions*Table1*List2(Zone)" (list z))
(cx-gui-do cx-activate-item "Boundary Conditions*Table1*List2(Zone)")
(cx-gui-do cx-activate-item "Boundary Conditions*Table1*Table3*Table4*ButtonBox1*PushButton1(Edit)")
(cx-gui-do cx-set-expression-entry "Velocity Inlet*Frame3*Frame6(Multiphase)*Table1*Table16*ExpressionEntry1(Volume Fraction)" '("1" . 0))
(cx-gui-do cx-activate-item "Velocity Inlet*PanelButtons*PushButton1(OK)"))
the program selects the item from the list and opens the dialog window (so I suppose the first three cx-gui-do
lines are okay), but it doesn't set the value of "Volume Fraction" to 1 neither does it close the window. Also, at the end of the loop, an #f
is printed to the command window, which I suppose is Scheme telling me something went wrong, but I can't figure out what.
Why does the behaviour of the code change when I put it inside the loop, even though the part that uses the loop variable is (apparently) working? And what is the #f
printed at the end?
来源:https://stackoverflow.com/questions/58907521/running-code-inside-do-in-scheme-fluent-executes-differently-than-outsid