CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

How to use Fluent Scheme to change the boundary condition defined by UDF

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By vinerm
  • 1 Post By heke402

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 4, 2020, 14:24
Default How to use Fluent Scheme to change the boundary condition defined by UDF
  #1
New Member
 
Ge
Join Date: Feb 2020
Posts: 8
Rep Power: 6
heke402 is on a distinguished road
Hi all,

I know there are some discussion on how to use Fluent Scheme to change boundary condition and I followed their instructions and made it work. Now the only question I have is if I define the boundary condition using UDF (DEFINE_PROFILE()) then what the format of the scheme should be? The scheme file I wrote is as the following

(define (changeboundary)
(cond

((and (>= (rpgetvar 'flow-time) 0.001) (<= (rpgetvar 'flow-time) 0.002))

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

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

(ti-menu-load-string "define/boundary-conditions mass-flow-inlet 10 mass_flow y"))
)
)

where "mass_flow" is my UDF name. I tried several times by executing the scheme file at each time step but it looks like Fluent did not recognize the UDF I used to define the boundary.
heke402 is offline   Reply With Quote

Old   February 4, 2020, 17:36
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Code:
(ti-menu-load-string "define/boundary-conditions mass-flow-inlet 10 \"mass_flow\" y"))
it is possible that in your code between 10 and mass_flow should be other setting, check through TUI
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   February 5, 2020, 04:39
Default Include full TUI command
  #3
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
TUI commands are sequential, i.e., you cannot miss anything in between. Full TUI commands changes from case to case, depending upon which models are enabled. A RANS based model with flow, without any other model enabled would require

def bc mfi 10 y y y y "functionname::libraryname" n 0 n y n n y 3.7 5

This command assumes that the library is already loaded. If it is not, then you have to load the library using

def user comp load "libraryName"
arashjkh likes this.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 5, 2020, 10:22
Default
  #4
New Member
 
Ge
Join Date: Feb 2020
Posts: 8
Rep Power: 6
heke402 is on a distinguished road
Hi AlexanderZ,

Thanks for the help! I checked through TUI and my issue has been solved.
heke402 is offline   Reply With Quote

Old   February 5, 2020, 10:25
Default
  #5
New Member
 
Ge
Join Date: Feb 2020
Posts: 8
Rep Power: 6
heke402 is on a distinguished road
Hi vinerm,

Thank you so much for the help! I have solved this issue by using the correct TUI command as you mentioned.
heke402 is offline   Reply With Quote

Old   February 5, 2020, 12:30
Default
  #6
New Member
 
Ge
Join Date: Feb 2020
Posts: 8
Rep Power: 6
heke402 is on a distinguished road
Dear AlexanderZ,

I have one more question. By looking up the TUI and answering all the questions, I found for my case the correct TUI commands should be

ti-menu-load-string "define/boundary-conditions mass-flow-inlet 10 yes yes yes yes "udf" "mass_flow::libudf" no 0 no yes"

However, when I typed "udf" in the console window to answer the question, there is no problem about it and Fluent can recognize what I typed. But when I wrote the TUI command into a scm file and execute the file at each time step during simulation, I always got an error as "Error: eval: unbound variable; Error Object :udf". I use ANSYS 16.0 and I am confused why Fluent can recognize "udf" in console window but can not do it in scm file. Could you please help me solve this issue, thank you in advance for your help!
arashjkh likes this.
heke402 is offline   Reply With Quote

Old   February 5, 2020, 12:35
Default
  #7
New Member
 
Ge
Join Date: Feb 2020
Posts: 8
Rep Power: 6
heke402 is on a distinguished road
Dear vinerm,

I have one more question. By looking up the TUI and answering all the questions, I found for my case the correct TUI commands should be

ti-menu-load-string "define/boundary-conditions mass-flow-inlet 10 yes yes yes yes "udf" "mass_flow::libudf" no 0 no yes"

However, when I typed "udf" in the console window to answer the question, there is no problem about it and Fluent can recognize what I typed. But when I wrote the TUI command into a scm file and execute the file at each time step during simulation, I always got an error as "Error: eval: unbound variable; Error Object :udf". I use ANSYS 16.0 and I am confused why Fluent can recognize "udf" in console window but can not do it in scm file. Could you please help me solve this issue, thank you in advance for your help!
heke402 is offline   Reply With Quote

Old   February 6, 2020, 00:42
Default
  #8
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
use \" not "
__________________
best regards


******************************
press LIKE if this message was helpful

Last edited by AlexanderZ; February 6, 2020 at 04:20.
AlexanderZ is offline   Reply With Quote

Old   February 6, 2020, 04:04
Default Escape character
  #9
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
It depends whether you are using TUI within a ti-menu-load-string command or not. Since there is already double-quote opening the command, you have to escape the second one. So, command has to be

(ti-menu... "udf" "mass_flow::libudf" ...)

i.e., just use escape character before double quotes.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 6, 2020, 04:12
Default HTML issue
  #10
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
Apparently, cfd-online is escaping is not displaying \ character before double-quotes. Use \ before every double quote and it will work.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 6, 2020, 10:50
Default
  #11
New Member
 
Ge
Join Date: Feb 2020
Posts: 8
Rep Power: 6
heke402 is on a distinguished road
Hi vinerm and AlexanderZ,

Thank you so much for your help! After adding escape character before double quotes, the problem has been solved.
heke402 is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fluent change boundary condition type using Scheme syntax in journal file lytemar Fluent UDF and Scheme Programming 4 April 28, 2022 03:13
Centrifugal fan j0hnny CFX 13 October 1, 2019 14:55
Basic Nozzle-Expander Design karmavatar CFX 20 March 20, 2016 09:44
Problem in setting Boundary Condition Madhatter92 CFX 12 January 12, 2016 05:39
asking for Boundary condition in FLUENT Destry FLUENT 0 July 27, 2010 01:55


All times are GMT -4. The time now is 17:09.