CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Coded FlowrateInlet

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 6, 2020, 07:39
Post Coded FlowrateInlet
  #1
New Member
 
Marius
Join Date: Aug 2020
Location: Germany
Posts: 11
Rep Power: 6
Muerio is on a distinguished road
Hello everyone,

I'm currently trying to implement a pair of coded BCs in a simpleFoam case.

The pair of BCs should represent an inlet and outlet with a adapting flow rate on the inner faces parallel to the XZ-Plane (see attachment).

As a first proof of concept I ran the case with flowRateInletVelocity BCs. For the upper face, I defined:
Code:
type flowRateInletVelocity;
rhoInlet 1071.2;
value uniform (0 0 0);
massFlowRate 0.0015;
The lower face is the same with a negative massFlowRate. The resulting flowfield can be seen in the attached image.

Now I want to vary the flow rate based on the pressure difference between the two BCs. For this I export the pressure difference using a fieldValueDelta function in the controlDict.

At first I tried to replace the value for the flow rate with a codestream. In the code block I read the last line from the exported fieldValueDelta as the pressure difference and multiplied it with the density resulting in delta_p. From this I calculated my new flow rate flow_rate and tried writing it to the BC using
Code:
scalarField mass_flow_rate(1, flow_rate);
mass_flow_rate.writeEntry("", os);
in the code block.
I noticed that the codestream is only evaluated at the first time step, so the flow_rate would not adapt to the change in pressure difference.

Now I tried using codedFixedValue BCs. Again I read the last line from the fieldValueDelta and store it in deltaP. From there I use my scaling factor hydResistance to calculate the volumetric flow rate for the next time step. The scaling vector was determined in the "proof of concept" run. Divided by the patch area, I get the average velocity for the patch which I then write to all faces on the patch.
Code:
// Calc volFlow from deltaP 
double hydResistance = 1.1e+08;     //in kg / (m^4 * s)
double volFlow = (deltaP * rho) / hydResistance; //Pressure normalized with rho!    // m^2 / s^2 * kg / m^3 /( kg / (m^4 * s)) = m^3 / s

// Avg. velocity on Patch equals volFlow / patchArea
double velocity = volFlow / area_1;                                                 // m^3 / (s * m^2) = m / s

forAll(Cf, faceI) // Write avg. velocity to Patch faces
{
    U [faceI] = vector(0, velocity, 0);
}
Running the case results in very large changes in the pressure difference and ultimately fails when the values get too large.

Code:
# Source1         : pressureDifferencePatch1.region1
# Source2         : pressureDifferencePatch1.region2
# Operation       : subtract
# Time            	p
1                 	1.2744304410e+01
2                 	1.0534881848e+00
3                 	-2.1438541297e+03
4                 	5.3147321704e+04
5                 	3.6129157963e+06
6                 	-2.1841268573e+10
7                 	-3.1164728773e+13
For all cases, the settings for the BCs for the pressure remain the same:
All BCs use zeroGradient except for the main outlet at the top of the geometry, which is a fixedValue of uniform 0.

So now I don't know where to go from here and have a few questions:
  1. Is there a way to use codestream in a flowRateInletVelocity condition so it is evaluated in every iteration?
  2. Is there a mistake in my codedFixedValue condition I haven't noticed?
  3. What could be changed in the codedFixedValue condition to stop the pressure values from going crazy?
  4. Is there another possibility to achieve my goal?

Thank you for your help!
Attached Images
File Type: jpg CFD.jpg (41.4 KB, 3 views)
Muerio is offline   Reply With Quote

Reply

Tags
codedboundarycondition


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
accessing 0 time directory in coded functionObject JM27 OpenFOAM Programming & Development 3 May 26, 2023 17:50
Coded function object in openfoam v5 kit607 OpenFOAM Post-Processing 3 September 29, 2020 16:43
accessing 0 time directory in coded functionObject JM27 OpenFOAM Post-Processing 0 November 21, 2018 09:41
codeInclude in coded function in controlDict, and yPlus LuisAlberto OpenFOAM Programming & Development 4 August 18, 2015 13:48
coded function object and field average matthias OpenFOAM Post-Processing 3 June 30, 2014 05:52


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