# Varying Pressure Outlet with Field Function

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

 September 28, 2017, 14:14 Varying Pressure Outlet with Field Function #1 Member   Tate Join Date: Feb 2015 Posts: 31 Rep Power: 11 I'm modelling a pump with cavitation. The amount of cavitation is defined by the inlet pressure, but my inlet boundary condition is a mass flow inlet. Therefore, changing the value of the pressure outlet boundary condition indirectly defines the inlet pressure. I'm trying to define the outlet pressure boundary condition with a field function to vary the outlet pressure to hit a target inlet pressure. The inlet pressure target varies with time. I think an if statement that checks the inlet pressure is the way to do it, but I'm struggling with actual implementation. I have also thought about using a user code, but I'm hoping that a field function will work as it seems easier. Does anyone have any insight or advice on how to define this pressure outlet boundary condition?

 October 9, 2017, 16:45 #2 Senior Member   Matt Join Date: Aug 2014 Posts: 947 Rep Power: 17 Field functions should do the trick. The if-then statements probably aren't needed unless your inlet-outlet relationship is not C0 or C1 continuous. (i.e. a piece wise function). If you can explain a little more about this relationship I will try to be a little more specific.

October 9, 2017, 17:08
#3
Member

Tate
Join Date: Feb 2015
Posts: 31
Rep Power: 11
Thanks for the response. I've tried to find a solution with a macro as well as with field functions.

I was mistaken in my first post. In my simulation, the rotor rotation rate and the inlet mass flow rate change with time, but I need to maintain a constant inlet total pressure. So the outlet pressure will need to vary depending on how far the inlet pressure is from the target.

I've uploaded a txt file containing a java macro I wrote to loop through the following: perform an iteration, check inlet pressure and then adjust outlet pressure. In this case my target inlet pressure is 22820 Pa and the report P00 is a mass flow average of total pressure on the inlet, and P08 is a mass flow average of total pressure on the outlet.

I've also attempted using field functions. I made two field mean monitors to describe the average total pressure on the inlet and outlet, respectively. I then defined the following field function as the outlet pressure boundary condition:

(\$InletFieldMeanMonitor <= 22320) ? \$OutletFieldMeanMonitor+100 : ((\$InletFieldMeanMonitor >= 23320) ? \$OutletFieldMeanMonitor-100 : \$OutletFieldMeanMonitor)

This attempts to keep the inlet total pressure in a 1 kPa band around 22820 Pa. However, the simulation fails to run as the field function cannot be computed.
Attached Files
 change_outlet_pressure.txt (2.9 KB, 52 views)

October 10, 2017, 11:16
#5
Member

Tate
Join Date: Feb 2015
Posts: 31
Rep Power: 11
Quote:
 Originally Posted by MBdonCFD Ok... Correct me if I am wrong (and maybe some images of your domain/regions would be helpful) but you have an inlet total pressure that is constant and a mass flow rate that varies with time. The varying mass flow results in a varying back pressure that you are trying to link to your inlet pressure. Does that sound about right?
That is correct. I've attached an image of my domain.

Quote:
 Originally Posted by MBdonCFD If that is the case, put all this behind you and set up your inlet as a stagnation inlet. This will keep total pressure at your inlet constant. Then, depending on the physics of your problem, either setup a mass flow inlet or pressure outlet at the outlet of your domain. The mass flow inlet should use a field function that gives your mass flow vs time but returns a negative value (i.e. a negative inlet is an outlet). The other option, which is a little more robust but a little more cumbersome, is to use a pressure outlet with the target mass flow option turned on. This will essentially vary outlet pressure, within some bounds you specify, to match the mass flow target.
That sounds like exactly what I want to do. I guess I didn't realize I could prescribe a negative mass flow at an outlet. I'm changing the inlet mass flow with a time table, so I'll just change all those values to negative. I'll also try the pressure outlet with mass flow target. Thank you.

Quote:
 Originally Posted by MBdonCFD Also, I would caution you against setting up reports at a region boundary. Not sure if that's what you were doing, but that is generally bad practice. If you need flow data at those specific locations then you should extend or extrude your inlet/outlet away even further.
I was doing that, but setting up field means monitors. Is it bad practice because there is potential for unrealistic flow discontinuities at the boundaries?
Attached Images
 Pump_Geometry.jpg (30.7 KB, 30 views)

 October 11, 2017, 09:42 #6 Senior Member   Matt Join Date: Aug 2014 Posts: 947 Rep Power: 17 Not so much flow discontinuities, but mis-represented flow. You want to be far enough a way from the boundary conditions that whatever you are looking at is being influenced by your geometry rather than what you have prescribed at your boundary... if that makes any sense.

 October 11, 2017, 09:50 #7 Senior Member   Matt Join Date: Aug 2014 Posts: 947 Rep Power: 17 Just glancing at your domain shot, you might want to move your inlet further upstream (large diameter end). Since you are using a stagnation inlet you will need to provide time for the flow to develop.

 October 31, 2017, 18:39 #8 Member   Tate Join Date: Feb 2015 Posts: 31 Rep Power: 11 Thanks so much for the help. Your suggestion to use a stagnation inlet and a mass flow inlet for the outlet seems to be working well. I am running into another problem though. I can't seem to figure out how to change the rotation rate with time. Both rotating reference frames and rotating motions seem to only take a constant value for rotation. Any idea how to work around this?

November 1, 2017, 08:04
#9
Senior Member

Matt
Join Date: Aug 2014
Posts: 947
Rep Power: 17
Quote:
 Originally Posted by t8fanning Thanks so much for the help. Your suggestion to use a stagnation inlet and a mass flow inlet for the outlet seems to be working well. I am running into another problem though. I can't seem to figure out how to change the rotation rate with time. Both rotating reference frames and rotating motions seem to only take a constant value for rotation. Any idea how to work around this?
I will look into it. Can you provide a little info on how it changes? Is it a ramp, a step function, sinusoidal, random?

 November 1, 2017, 08:44 #10 Senior Member   Matt Join Date: Aug 2014 Posts: 947 Rep Power: 17 Looking at the help files, I think you are going to want to use user-defined vertex motion. This allows you to specify a location for a vertex at each time step. I am not familiar with it, so I will not be much help. You can read up on it yourself... User Guide > Star-CCM+ > Simulating Physics > Modeling Space, Time and Motion > Modeling Motion > Working with User-Defined Vertex Motion

November 1, 2017, 10:25
#11
Member

Tate
Join Date: Feb 2015
Posts: 31
Rep Power: 11
I'll look into user defined vertex motion. Thanks.

I've attached an image of the time vs rotational speed curve I'm trying to match.

I've digitized the curve and put it in a table with increments of 0.01 s. I imported the table into my simulation and wrote a field function that I think will work:

interpolateTable(@Table("10879 Flow and Speed v2"), "Time", SPLINE, "N2", \$Time)

This came from "Working with Table Values Through Field Functions" in the user help files.

I'm still testing it, so I'm not sure if it works yet.
Attached Images
 image001.jpg (65.2 KB, 16 views)

 November 1, 2017, 10:32 #12 Senior Member   Matt Join Date: Aug 2014 Posts: 947 Rep Power: 17 If your table is defined in 0.01 s increments, does that mean your time step is also 0.01 s?

 November 1, 2017, 10:33 #13 Member   Tate Join Date: Feb 2015 Posts: 31 Rep Power: 11 No. My time step is 0.0001 s, but as I understand it, the field function should be interpolating between each table value for a rotational rate at each time step.

 November 1, 2017, 10:37 #14 Senior Member   Matt Join Date: Aug 2014 Posts: 947 Rep Power: 17 Ok... Just wanted to make sure. Typically 1 degree per time step is a good choice and it looks like you are even a little better than that. Good luck.

 November 1, 2017, 10:39 #15 Member   Tate Join Date: Feb 2015 Posts: 31 Rep Power: 11 Thanks. I usually aim for 0.5° per time step just to be sure, but this mesh is pretty large so I tried for a bit closer to 1°.