# Best Approach for Force vs Velocity

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

 July 20, 2021, 21:52 Best Approach for Force vs Velocity #1 New Member   Lee Join Date: Jul 2021 Posts: 3 Rep Power: 3 Hello Openfoam forum members! I am seeking some advice on the best method for deriving a Force vs Velocity curve in Openfoamv8 for an automobile. I have adapted the simpleFoam motorbike example to suit the geometry & volume of my vehicle. And, I have copied this case and run it at different inlet velocities which yields an increase in cd or forces (I don't really understand why Cd changes with velocity, but I can ask that later) roughly proportional to v^2 which makes sense. I expect there is a more efficient method for doing this analysis where I can start one run that vary the simpleFoam steady state inlet conditions over multiple steps, but I am struggling to find a good example where someone has done something similar, could you point me to a good example? I get the impression I could do a transient solution of this problem, and ramp the velocity, but that seems like overkill for my problem. Thank You!

 July 23, 2021, 06:16 #2 Senior Member   Tom Fahner Join Date: Mar 2009 Location: Breda, Netherlands Posts: 603 Rep Power: 30 Hi, For the single simpleFoam run you could specify your inlet with the uniformFixedValue boundary condition, which is constant in space, but can vary as a (patch)Function1. For instance you could use a table that specifies the velocity as a function of time/iteration like: Code: ```inlet { type uniformFixedValue; uniformValue table ( (0 (1 0 0)) (3000 (1 0 0)) (3001 (2 0 0)) (4000 (2 0 0)) (4001 (3 0 0)) (5000 (3 0 0)) ); }``` This assumes you will need 3000 iterations to converge with an inlet velocity of 1 m/s in the x-direction and then switches to 2 m/s, keeping that steady for 1000 iterations (where we assume convergence to the new velocity) and then to 3 m/s. You should check if the forces/residuals converge within these 1000 iterations. Probably you also want to use inlet conditions for k and epsilon/omega (or whatever turbulence quantities you have) that scale with the velocity, e.g. Code: ```k: turbulentIntensityKineticEnergyInlet epsilon: turbulentMixingLengthDissipationRateInlet omega: turbulentMixingLengthFrequencyInlet``` Just look for examples of the italic text in the online documentation CFDinfant likes this.

 July 23, 2021, 08:55 #3 New Member   Lee Join Date: Jul 2021 Posts: 3 Rep Power: 3 Thank you! That makes a lot of sense, I will try it out today!

 July 25, 2021, 21:20 Update Tried #4 New Member   Lee Join Date: Jul 2021 Posts: 3 Rep Power: 3 Your explanation made sense, and from the examples I find online, I would think it would work, but upon making that modification, cleaning and attempting to run I get this error Code: ```FOAM FATAL IO ERROR: wrong token type - expected Scalar, found on line 14 the punctuation token '(' file: /home/openfoam/OpenFoam/openfoam-8/run/cube_multispeed/0/k/boundaryField/inlet/uniformValue at line 14.``` Where line 14 is the beginning of this uniformFixedValue table we are creating. Do I need to make changes elsewhere in my code so that it is expecting a table rather than a scalar value? I have tried adjusting the controldict iterations to match the table, but to no success. Thank you again. If uploading my files would be helpful let me know. Currently it is just a simple cube I was using to do some basic F=Cd*A*v^2 correlation with.

July 26, 2021, 07:03
#5
Senior Member

Tom Fahner
Join Date: Mar 2009
Location: Breda, Netherlands
Posts: 603
Rep Power: 30
Hi,

The error you post is in regards to the k file, which is indeed a scalar and not a vector (like U is):

Quote:
 Code: `file: /home/openfoam/OpenFoam/openfoam-8/run/cube_multispeed/0/k/boundaryField/inlet/uniformValue at line 14.`
So for k you could also use this uniformFixedValue but than with a table for scalars:

Code:
```inlet
{
type    uniformFixedValue;
uniformValue    table
(
(0 0.1)
(3000 0.1)
(3001 0.4)
(4000 0.4)
(4001 0.9)
(5000 0.9)
);
}```
Note that those values are just made-up by me and you should modify them for your case.

Or like I said in my first reply use the turbulent inlet conditions based on intensity and mixingLength instead of tables.

Hope this helps.
Cheers,
Tom

 Tags force, simplefoam, vehicle aerodynamics, velocity