2

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?

  • Do you use `'("1" . 0)` exactly like this in both - *manual* and *do-loop* - versions? `"1"` is a string, and `0` is a number. Can you give it a try and change both to be strings `'("1" . "0")` and if doesn't work, also both to be numbers `'(1 . 0)`? – rsm Nov 18 '19 at 03:37
  • @rsm Both raise errors. Setting both to numbers gives `cx-set-expression-entry: wta[2](ExpressionType)`, and setting both to strings gives `cx-set-expression-entry: wta[2](String)`. Funnily (or sadly) enough, I just noticed that the _first_ item in the loop gets its value changed, but the others don't :/ It's looking like the entire code is executed, and then the graphical thingy kicks in and the effect goes to one of them only... (I have to go to bed now, sorry. I'll be back tomorrow) – The Drunken Whaler Nov 18 '19 at 03:56

1 Answers1

1

I am working on a similar project and these strange issues happened to me as well. The only difference is, I am using plain TUI commands not these CFX commands.

Ansys Fluent does not have a clear standard regarding Scheme, so it is often a bit difficult to find reliable documentation or explain issues. I was told by an Ansys Engineer that they use "a mixture of MIT Scheme 3 and 4".

I have to suggestion for you which helped me from time to time.

First of all try to wrap your commands in a (begin .....) statement.

(do ((z 4 (+ 1 z)))
    ((> z 27))
     (begin
      (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)")
     )
)

This often solved these kind of problems for me.

And secondly execute these commands on its own again and pay special attention to where you end up in the menu. You might get stuck in some kind of "submenu" which you have to quit before you do something else. I hope you get my point from the following example, which would work without the "quit"

/display objects create mesh car surfaces-list (car) quit

blackbaddl
  • 62
  • 8
  • Thanks for your answer! I hadn't looked at this for a long time now, but I'll probably need this again soon, then I'll try your suggestion. – The Drunken Whaler Aug 05 '20 at 19:26