Read Scheme File

Max4Max4 Member Posts: 49

Hi,

I have write a Scheme file (see below) to change the boundary condition of inlet and outlet depending on time.

  (iif (> (rpgetvar' flow-time) 0.033) (
  (ti-menu-load-string "define/boundary-conditions/zone-type 5 wall")
  (ti-menu-load-string "define/boundary-conditions/zone-type 6 pressure-outlet ")
  (ti-menu-load-string "define/boundary-conditions pressure-outlet 6 yes no 0 no yes yes no no")

  (iif (> (rpgetvar' flow-time) 0.066) (
  (ti-menu-load-string "define/boundary-conditions/zone-type 5 mass-flow-inlet ")
  (ti-menu-load-string "define/boundary-conditions mass-flow-inlet 5 yes yes no 0.01 no 0 no yes")
  (ti-menu-load-string "define/boundary-conditions/zone-type 6 wall")

The problem is, when I try to read this file, I obtain the following error:

   Error: eof inside list

   Error Object: (if (> current_time 0.066) ((ti-menu-load-string "define/boundary-conditions/zone-type 6 wall")))

I have checked the folder name, direction, file name and there isn´t any problem with this.

Should I define the current time ? If ys, how? The condition if (> current_time 0.033) is true at the same time as if (> current_time 0.066) . Is it a problem ?

 

Regards,

Maxime

Comments

  • KremellaKremella Posts: 3,122Admin
    edited November 2018

    Hello,

    You do not have to define these. They are macros already present in Fluent. Also, try rpgetvar 'flowtime and not rpgetvar' flowtime. However, I do not think there is a different between using this or current_time (someone please correct me if I am wrong).

    Try to use the loop such that only one if statement is true. Based on your algorithm, two if statements can be true if t > 0.066. If I understand if condition, you need to have your algorithm such that only one statement is applicable for any given time.

    I hope this helps.

    Best Regards,

    Karthik

     

  • Max4Max4 Posts: 273Member
    edited November 2018

    Hello,

    Thank you for your answer. I have just found this about the If-Statement for Scheme file:

    image

    image

    My Scheme is as follow:

    (if (> (rpgetvar 'flow-time) 0.033)
    (ti-menu-load-string "define/boundary-conditions/zone-type 5 wall")
    (ti-menu-load-string "define/boundary-conditions/zone-type 6 pressure-outlet ")
    (ti-menu-load-string "define/boundary-conditions pressure-outlet 6 yes no 0 no yes yes no no")
    )

    When I read this file I have this error, because I have 3 arguments instead of 2. It works when I just use the below scheme:

    (if (> (rpgetvar 'flow-time) 0.033)
    (ti-menu-load-string "define/boundary-conditions/zone-type 5 wall")

    May I use two If statements for the condition t > 0.033 ?

    Error: if syntax: Too many arguments

    Regards,

    Maxime

  • KremellaKremella Posts: 3,122Admin
    edited November 2018

    Hi,

    Can you try the following?

    (if (.....)

       (begin

          (ti-menu-.....(.....))

          (ti-menu-......(.....))

          (ti-menu-......(....))

      )

    )

    Please let me know how this works.

    Thanks.

    Best,

    Karthik

  • Max4Max4 Posts: 273Member
    edited November 2018

    I´ve done as you proposed (see below) and the reading of the .scm works. Thank you.

    (if (> (rpgetvar 'flow-time) 0.033)
     (
       (ti-menu-load-string "define/boundary-conditions/zone-type 5 wall")
       (ti-menu-load-string "define/boundary-conditions/zone-type 6 pressure-outlet ")
       (ti-menu-load-string "define/boundary-conditions pressure-outlet 6 yes no 0 no yes yes no no")
    &nbsp
    )

    I read this for loading the .scm in order to use it, but I can´t find it.

    image

     

    Regards,

    Maxime

  • Max4Max4 Posts: 273Member
    edited November 2018

    Moreover, I find this in order to avoid the two true If-Statement :

    image

     

    Maxime

  • DrAmineDrAmine GermanyPosts: 7,890Forum Coordinator
    edited November 2018

    No you need to read the scheme file as /file read-journal or just create procedures out of the scheme files and then just read the scheme file one and execute the procedure by just (procedure-name).

  • Max4Max4 Posts: 273Member
    edited November 2018

    I have read the .scm with the TUI-Commands: /file read-journal xxx.scm and then I load it in Calculation Activities -> Execute Commands -> (load " xxx.scm") for each Time-Step.

    Thank you all for your answers.

    Regards,

    Maxime

  • DrAmineDrAmine GermanyPosts: 7,890Forum Coordinator
    edited November 2018

    Please set then this topic as solved and mark the answer which helped to resolve the question. Thanks.

  • Max4Max4 Posts: 273Member
    edited November 2018

    Below, the Scheme file which I use to solve my problem with the If-Statement. If 'flow-time is 0.067 (delta t=0.001s in my case), then it calls only actions below ((> (rpgetvar 'flow-time) 0.066) and not actions from the following condition ((> (rpgetvar 'flow-time) 0.033).

    (cond
        ((> (rpgetvar 'flow-time) 0.066)
             (ti-menu-load-string "define/boundary-conditions/zone-type 5 velocity-inlet ")
             (ti-menu-load-string "define/boundary-conditions velocity-inlet 5 no no yes yes no 1 no 0")
             (ti-menu-load-string "define/boundary-conditions/zone-type 6 wall")
        )
        ((> (rpgetvar 'flow-time) 0.033)
             (ti-menu-load-string "define/boundary-conditions/zone-type 5 wall")
             (ti-menu-load-string "define/boundary-conditions/zone-type 6 pressure-outlet ")
             (ti-menu-load-string "define/boundary-conditions pressure-outlet 6 yes no 0 no yes yes no no")
        )
    )

    Then I read this file from the TUI-Commands (/file read-journal xxx.scm) and load it in the Execute Commands for each-time-step ( load "xxx.scm" ).

     

    Regards,

    Maxime

  • VanesaVanesa Posts: 13Member
    edited March 15

    Hello,

    I am trying to simulate time varying boundary condition where after some time one of my wall should be changed as mass flow inlet with a certain amount of mass flow rate value. I went through the discussions on this forum and many other internet resources and even fluent documentation. Implementing UDF or using scheme file are the options one can use to define this time varying boundary condition was my conclusion. UDF needs strong programming skills and scheme documentation is rarely available.

    I want to try scheme file for my simulation. I want to know how can we input other details of my changing boundary condition in the scheme file. Suppose my scheme file is:


    (cond

       ((> (rpgetvar 'flow-time) 2.0)

            (ti-menu-load-string "define/boundary-conditions/zone-type 6 wall")

            (ti-menu-load-string "define/boundary-conditions wall 6 no no yes yes no 1 no 0")

            (ti-menu-load-string "define/boundary-conditions/zone-type 6 mass flow-inlet")

       )

    )

    So now for this wall I want it to change to mass flow inlet after 2 secs in my simulation and I want to specify its details within this scheme file befoe the run (flow direction specification method/value of mass flow rate, etc.).

    How can I do it?

    Please help.

    Thank you.

  • RobRob UKPosts: 11,730Forum Coordinator

    I'd also have a look at the Case Modification options, you may find you can trigger the mass flow bc at 2s using those.

    Re the commands, click into the TUI panel and hit Enter. Typing in a menu label and hitting enter takes you to the sub menu, using q (Q) takes you back up a level.

  • salaisargunanspsalaisargunansp Posts: 1Member

    Hi.

    I want to make cyclic pressure outlet and wall with certian time interval using scheme file. Please help to me make.

    I made the code but i wont work.


    (define (changeboundary)

    (define time-sequence #(1 5 10 20))

    (define type-sequence #(0 2 0 1))

    (define flag 0)

    (define bctype 0)

    (define time (rpgetvar 'flow-time))

    (define dt (rpgetvar 'physical-time-step))

    (set! flag 0)


    (do ((i 0 (+ i 1)))

    ((= i (vector-length time-sequence)))

    (if (>= time (- (vector-ref time-sequence i) (* 0.5 dt)))

    (if (<= time (+ (vector-ref time-sequence i) (* 0.5 dt)))

    (set! flag 1)

    (set! bctype (vector-ref type-sequence i))

    )))


    (if (= 1 bctype)

    (if(= flag 1)

    (set! flag 2)))


    (if (= flag 1)

    (ti-menu-load-string "define/boundary-conditions/zone-type 13 pressure-outlet"))


    (if (= flag 2)

    (ti-menu-load-string "define/boundary-conditions/zone-type 13 wall"))


    (newline)

    (if (= flag 1) (display "Boundary is changed into pressure-outlet"))

    (if (= flag 2) (display "Boundary is changed into wall"))

    )



    please check and give your suggestions

Sign In or Register to comment.