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

UDF: Change boundary condition. Velocity inlet to pressure inlet at time "t"

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree6Likes
  • 6 Post By jpina

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 3, 2015, 13:14
Default UDF: Change boundary condition. Velocity inlet to pressure inlet at time "t"
  #1
Senior Member
 
Jordi Pina
Join Date: Mar 2015
Posts: 157
Rep Power: 7
jpina is on a distinguished road
Hello!

I'm trying to simulate an injection moulding process. An injection process is defined by two phases:

1) Filling phase: The polymer fills the mould. It is a velocity controlled phase were the inlet flow is fixed and the machine sets the necessary pressure in order to maintain this flow.

2) Packaging phase: Once the cavity is 98% full. The machine switches from velocity control to pressure control, where the cavity is "packed out" at a constant pressure.

I would like to know how could I make an inlet be a velocity or flow inlet from time 0 to time "t" and a pressure inlet after time "t". I guess I should develop a UDF but maybe there's some other way?

I appreciate your help!
jpina is offline   Reply With Quote

Old   April 3, 2015, 17:59
Default
  #2
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 14
`e` is on a distinguished road
Velocity inlet and pressure inlet are two distinct inlet conditions. Fluent needs to know to change between these two conditions and a simple DEFINE_PROFILE or UDF wouldn't suffice.

Try running a scheme file every time step (under calculation activities) which makes the switch between velocity to pressure inlet (TUI command) after a certain time (if statement).
`e` is offline   Reply With Quote

Old   April 7, 2015, 14:14
Default
  #3
Senior Member
 
Jordi Pina
Join Date: Mar 2015
Posts: 157
Rep Power: 7
jpina is on a distinguished road
Dear `e`,

I've been trying to do what you suggested me.

I created a macro, which changes the inlet_velocity boundary condition to an inlet_pressure condition.

In the calculation activities I set the following command:

*IF,CURRENT_TIME,GT,3,THEN,macro-2,*ENDIF

However, when solving the problem, Fluent says:

*IF,invalid command [*IF]
CURRENT_TIME,GT,3,THEN,macro-2,*ENDIF

I will appreciate your help.
jpina is offline   Reply With Quote

Old   April 7, 2015, 18:09
Default
  #4
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 14
`e` is on a distinguished road
What is your macro that "changes the inlet_velocity boundary condition to an inlet_pressure condition"? You need to create a scheme file with the relevant TUI commands for changing the inlet velocity boundary to a pressure inlet boundary condition.

Find these TUI commands and then include them in your scheme file with ti-menu-load-string, for example:

Code:
(ti-menu-load-string "tui-command-goes-here")
Perhaps if you're unsure of the steps, start with:
1) run the simulation for a few time steps and then change the inlet condition with the GUI (checks if Fluent won't crash from changing this inlet condition)
2) reset and run the simulation for a few time steps and then changing the inlet condition with the TUI
3) write a scheme file (using ti-menu-load-string) with the commands you used in step 2) and then run this scheme file after a number of time steps (if statement)
`e` is offline   Reply With Quote

Old   April 9, 2015, 10:17
Default
  #5
Senior Member
 
Jordi Pina
Join Date: Mar 2015
Posts: 157
Rep Power: 7
jpina is on a distinguished road
Dear `e`,

I'm afraid I need a little bit of help.

I have succeeded on changing the boundary condition from velocity to pressure:

define/boundary-conditions/zone-type inlet pressure_inlet

However, I don't know how to make a line for setting the pressure. If I make

define/boundary-conditions/pressure-inlet

I can set the pressure when fluent asks for it, but it is now suitable for making a .scm...

Thanks!!!!!!

Last edited by jpina; April 9, 2015 at 11:18.
jpina is offline   Reply With Quote

Old   April 9, 2015, 11:33
Default
  #6
Senior Member
 
Jordi Pina
Join Date: Mar 2015
Posts: 157
Rep Power: 7
jpina is on a distinguished road
I just found the solution, in case anyone needs it, it's:

Define/boundary-conditions pressure-inlet inlet mixture yes no 6000000 no 0 no 300 no yes

Where the answers to the questions without commas must be written.
jpina is offline   Reply With Quote

Old   April 9, 2015, 16:28
Default
  #7
Senior Member
 
Jordi Pina
Join Date: Mar 2015
Posts: 157
Rep Power: 7
jpina is on a distinguished road
I'm facing the following problem... I have created a .scm file with:

*if,CURRENT_TIME,gt,3,then
;Change inlet boundary condition
(ti-menu-load-string "define/boundary-conditions/zone-type inlet_velocity pressure-inlet")
;Set the pressure of the inlet boundary condition
(ti-menu-load-string "define/boundary-conditions pressure-inlet inlet_velocity mixture yes no 6000000 no 0 no 300 no yes")
*endif

However, something seems to happen with the if statement. When I do File-Read-Scheme Fluent says:

Error: eval: unbound variable
Error Object: *if
#f

The same scheme file without the if works.

Does anybody know what is happening?

Thanks!
jpina is offline   Reply With Quote

Old   April 9, 2015, 17:25
Default
  #8
Senior Member
 
Andrew Kokemoor
Join Date: Aug 2013
Posts: 122
Rep Power: 10
Kokemoor is on a distinguished road
The correct syntax for if is
Code:
(if conditional-statement then-statement else-statement)
so you'll need something like
Code:
(if (> current_time 3) (
(ti-menu-load-string "define/boundary-conditions/zone-type inlet_velocity pressure-inlet")
)
(if (> current_time 3) (
(ti-menu-load-string "define/boundary-conditions pressure-inlet inlet_velocity mixture yes no 6000000 no 0 no 300 no yes")
)
I'm sure you could clean this up into one if statement, but I'm not in a position to test anything fancy right now.

If I was, though... this is what I'd try.

Code:
(if (> current_time 3) (map ti-menu-load-string '("define/boundary-conditions/zone-type inlet_velocity pressure-inlet" "define/boundary-conditions pressure-inlet inlet_velocity mixture yes no 6000000 no 0 no 300 no yes")))
Kokemoor is offline   Reply With Quote

Old   April 10, 2015, 02:33
Default
  #9
Senior Member
 
Jordi Pina
Join Date: Mar 2015
Posts: 157
Rep Power: 7
jpina is on a distinguished road
Dear Kokemoor,

first of all thanks for your help.

I'm afraid to ask an obviety but... In which programming language is the code you typed?

I had looked for distinct APDL manuals and none of them showed this 'if statement' structure, for example the manual https://caeai.com/sites/default/files/APDL_0.pdf shows an estructure like:

*IF, VAL1, Oper1, VAL2, AND / OR, VAL3, Oper2, VAL4, THEN

Your code is not C either :S
jpina is offline   Reply With Quote

Old   April 10, 2015, 06:34
Default
  #10
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 14
`e` is on a distinguished road
We've both stated that you're creating a Scheme file: the programming language is Scheme (a dialect of LISP). LISP is the second oldest high-level programming language (second to Fortran), have a read of the Wikipedia article if you're interested. Scheme was created in the 1970s over in MIT (Wikipedia). I'll quote what I've typed in another thread:

Quote:
Originally Posted by `e` View Post
Fluent has no official documentation for Scheme, and in fact the developers were intending to replace Scheme with Python as the official scripting language back in 2004... have a read of this unofficial Fluent Scheme Programming Reference which I believe is the only Scheme-Fluent documentation available.
`e` is offline   Reply With Quote

Old   April 11, 2015, 14:19
Default
  #11
Senior Member
 
Jordi Pina
Join Date: Mar 2015
Posts: 157
Rep Power: 7
jpina is on a distinguished road
Hi everybody!

I've solved my problem, I expose here the definitive solution in case it's someday useful for somebody:

For changing a boundary condition at a time t:

Create a .scm file with the following content:

(if (> (rpgetvar' flow-time) 0.05)
; Set que inlet_velocity boundary to pressure-inlet
(ti-menu-load-string "define/boundary-conditions/zone-type inlet_velocity pressure-inlet")
; Set the pressure value to 6000000
(ti-menu-load-string "define/boundary-conditions pressure-inlet inlet_velocity mixture yes no 6000000 no 0 no 300 no yes")
)

In the Calculation Activities make this scheme file be executed every time_step with:

(load "velocity_to_pressure_inlet.scm")

I hope to be helpful after all the received help
jpina is offline   Reply With Quote

Reply

Tags
change, inlet pressure, inlet velocity, udf

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Star cd es-ice solver error ernarasimman STAR-CD 2 September 12, 2014 00:01
Radiation interface hinca CFX 15 January 26, 2014 17:11
An error has occurred in cfx5solve: volo87 CFX 5 June 14, 2013 17:44
Velocity inlet boundary condition for porous medium Chander CFX 3 March 11, 2012 21:18
can i set the velocity and pressure at the inlet at the same time by UDF minyang.cau FLUENT 0 July 14, 2009 23:14


All times are GMT -4. The time now is 21:14.