CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM

lift and drag coefficient

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

Like Tree3Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   October 15, 2010, 06:42
Default lift and drag coefficient
  #1
New Member
 
Girolamo
Join Date: Oct 2010
Location: Napoli
Posts: 14
Rep Power: 6
lift86 is on a distinguished road
Hello, I am new to open foam, I'm trying the tutorial 2d airfoil (simplefoam incompressible). I can not see the values of lift and drag coefficients. I have to put in the contol dict lines you suggested, but I get nothing. How can I do? thanks

functions
{
forces
{
type forces;
functionObjectLibs ( "libforces.so" ); // lib to load
outputControl timeStep;
outputInterval 1;
patches
(
wall // change to your patch name
);
// name of fields
pName p;
UName U;
log true; // dump to file
rhoInf 1025;
CofR ( 0 0 0 );
}
forcesCoeffs
{
type forceCoeffs;
functionObjectLibs ( "libforces.so" ); // lib to load
outputControl timeStep;
outputInterval 1;
patches
(
wall // change to your patch name
);
// name of fields
pName p;
UName U;
log true; // dump to file
rhoInf 1025;
CofR ( 0 0 0 );
liftDir ( 0 1 0 );
dragDir ( 1 0 0 );
pitchAxis ( 0 0 0 );
magUInf 7.30;
lRef 0.305;
Aref 0.001525;
}
}
lift86 is offline   Reply With Quote

Old   October 18, 2010, 07:47
Default
  #2
New Member
 
Alejandro
Join Date: Aug 2010
Posts: 6
Rep Power: 6
velezisaza is on a distinguished road
The script looks fine, are you placing it in the controlDict? I also had some troubles running it in openfoam 1.7. In 1.6 however it works perfectly. Try it!

If you want moment coefficient you have to change the pitch axis to 0 0 1
Rajib likes this.
velezisaza is offline   Reply With Quote

Old   October 21, 2010, 04:02
Default
  #3
Senior Member
 
Vesselin Krastev
Join Date: Jan 2010
Location: University of Tor Vergata, Rome
Posts: 361
Rep Power: 10
vkrastev is on a distinguished road
Have you changed "wall" with the name of the patch (or patches) composing the airfoil?
vkrastev is offline   Reply With Quote

Old   October 21, 2010, 05:06
Default
  #4
New Member
 
Girolamo
Join Date: Oct 2010
Location: Napoli
Posts: 14
Rep Power: 6
lift86 is on a distinguished road
I use open foam nn 1.7.1 but nothing happens, even if the procedure is correct. In your opinion, should I download the library "libforces?
lift86 is offline   Reply With Quote

Old   October 22, 2010, 08:46
Default
  #5
New Member
 
Alejandro
Join Date: Aug 2010
Posts: 6
Rep Power: 6
velezisaza is on a distinguished road
Check if you have the libforces.so library, its shoulf be in OpenFoam1.7.1/lib/linux64GccDPOpt/libforces.so

My problem with openfoam 1.7.1 is that it says that it cannot locate p and U, so it deactivates "forces". But the same script in 1.6 works perfectly fine. Vesselin, have you tried it yourself in 1.7.0 or 1.7.1?
velezisaza is offline   Reply With Quote

Old   October 22, 2010, 09:50
Default
  #6
Senior Member
 
Vesselin Krastev
Join Date: Jan 2010
Location: University of Tor Vergata, Rome
Posts: 361
Rep Power: 10
vkrastev is on a distinguished road
Quote:
Originally Posted by velezisaza View Post
Check if you have the libforces.so library, its shoulf be in OpenFoam1.7.1/lib/linux64GccDPOpt/libforces.so

My problem with openfoam 1.7.1 is that it says that it cannot locate p and U, so it deactivates "forces". But the same script in 1.6 works perfectly fine. Vesselin, have you tried it yourself in 1.7.0 or 1.7.1?
Unfortunately I do not have much experience with the 1.7.x versions, but I have noticed that there are several different particulars between those versions and the 1.6 one: for instance, the interFoam solver of the latest versions uses a different definition of the pressure, and so on...However, the script I use to calculate the force coefficients (in the 1.6 version) is slightly different from the one posted above: don't know if it makes some difference, but maybe you could try it in the 1.7.x one

Regards

V.

ps-the name of the function is not significant: it simply determines the name of the directory in which the forceCoeffs data will be stored

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application simpleFoam;

startFrom latestTime;

startTime 0;

stopAt endTime;

endTime 5000;

deltaT 1;

writeControl runTime;

writeInterval 500;

purgeWrite 0;

writeFormat ascii;

writePrecision 6;

writeCompression uncompressed;

timeFormat general;

timePrecision 6;

runTimeModifiable yes;

functions
{
totalDrag
{
// rhoInf - reference density
// CofR - Centre of rotation
// dragDir - Direction of drag coefficient
// liftDir - Direction of lift coefficient
// pitchAxis - Pitching moment axis
// magUinf - free stream velocity magnitude
// lRef - reference length
// Aref - reference area
type forceCoeffs;
functionObjectLibs ("libforces.so");
patches ( body );
rhoName rhoInf;
rhoInf 1.184;
CofR (0 0 0);
liftDir (0 1 0);
dragDir (1 0 0);
pitchAxis (0 0 1);
magUInf 40;
lRef 0.288;
Aref 0.0561;

outputControl timeStep;
outputInterval 50;
}
mm.abdollahzadeh likes this.
vkrastev is offline   Reply With Quote

Old   October 25, 2010, 05:56
Default
  #7
New Member
 
Girolamo
Join Date: Oct 2010
Location: Napoli
Posts: 14
Rep Power: 6
lift86 is on a distinguished road
Hello. I am studying the case of a cylinder.
these are the files that I put:

{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application simpleFoam;

startFrom latestTime;

startTime 0;

stopAt endTime;

endTime 500;

deltaT 1;

writeControl timeStep;

writeInterval 50;

purgeWrite 0;

writeFormat ascii;

writePrecision 6;

writeCompression uncompressed;

timeFormat general;

timePrecision 6;

runTimeModifiable yes;


functions
{
forces
{
type forces;
functionObjectLibs ( "libforces.so" ); // lib to load
outputControl timeStep;
outputInterval 1;
patches
(
wall // change to your patch name
);
// name of fields
pName p;
UName U;
log true; // dump to file
rhoInf 1025;
CofR ( 0 0 0 );
}
forcesCoeffs
{
type forceCoeffs;
functionObjectLibs ( "libforces.so" ); // lib to load
outputControl timeStep;
outputInterval 1;
patches
(
wall // change to your patch name
);
// name of fields
pName p;
UName U;
log true; // dump to file
rhoInf 1025;
CofR ( 0 0 0 );
liftDir ( 0 1 0 );
dragDir ( 1 0 0 );
pitchAxis ( 0 0 0 );
magUInf 7.30;
lRef 0.305;
Aref 0.001525;
}
}

// Definition of terms:
// rhoInf - reference density
// CofR - Centre of rotation
// dragDir - Direction of drag coefficient
// liftDir - Direction of lift coefficient
// pitchAxis - Pitching moment axis
// magUinf - free stream velocity magnitude
// lRef - reference length
// Aref - reference area


FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 2 -2 0 0 0 0];

internalField uniform 101325;

boundaryField
{
inlet
{
type freestreamPressure;
}

outlet
{
type freestreamPressure;
}

wall
{
type zeroGradient;
}

frontAndBack
{
type empty;
}
}


FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 1 -1 0 0 0 0];

internalField uniform (30 0 0);

boundaryField
{
inlet
{
type freestream;
freestreamValue uniform (30 0 0);
}

outlet
{
type freestream;
freestreamValue uniform (30 0 0);
}

wall
{
type fixedValue;
value uniform (0 0 0);
}

frontAndBack
{
type empty;
}
}
how do I get the CD and Cp Cl??
lift86 is offline   Reply With Quote

Old   October 25, 2010, 06:12
Default
  #8
New Member
 
Girolamo
Join Date: Oct 2010
Location: Napoli
Posts: 14
Rep Power: 6
lift86 is on a distinguished road
i have also this error in the terminal(when i start the iteraction):

--> FOAM Warning :
From function void forces::read(const dictionary& dict)
in file forces/forces.C at line 277
Could not find U, p or rho in database.
De-activating forces.
lift86 is offline   Reply With Quote

Old   October 26, 2010, 07:40
Default
  #9
New Member
 
Alejandro
Join Date: Aug 2010
Posts: 6
Rep Power: 6
velezisaza is on a distinguished road
I had the same error but now its working fine. As Vesselin used, I removed the pName and uName inputs, and added the rhoName rhoInf.

It works perfect now with 1.7.1

Girolarno, I hope it works for you as well
velezisaza is offline   Reply With Quote

Old   October 26, 2010, 08:12
Default
  #10
New Member
 
Girolamo
Join Date: Oct 2010
Location: Napoli
Posts: 14
Rep Power: 6
lift86 is on a distinguished road
Thank you so much you were very kind ...... but you may be able to plot the pressure coefficient on the wall? How do you do for plotting?
lift86 is offline   Reply With Quote

Old   October 26, 2010, 09:49
Default
  #11
New Member
 
Alejandro
Join Date: Aug 2010
Posts: 6
Rep Power: 6
velezisaza is on a distinguished road
Pressure coefficient is another story. For that you use the sampling utility. You need the following file in your system directory: sampleDict.

/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

FoamFile
{
version 2.0;
format ascii;
class dictionary;
location system;
object sampleDict;
}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

// Set output format : choice of
// xmgr
// jplot
// gnuplot
// raw
setFormat raw;

// Surface output format. Choice of
// null : suppress output
// foamFile : separate points, faces and values file
// dx : DX scalar or vector format
// vtk : VTK ascii format
// raw : x y z value format for use with e.g. gnuplot 'splot'.
//
// Note:
// other formats such as obj, stl, etc can also be written (by proxy)
// but without any values!
surfaceFormat raw;

// interpolationScheme. choice of
// cell : use cell-centre value only; constant over cells (default)
// cellPoint : use cell-centre and vertex values
// cellPointFace : use cell-centre, vertex and face values.
// 1] vertex values determined from neighbouring cell-centre values
// 2] face values determined using the current face interpolation scheme
// for the field (linear, gamma, etc.)
interpolationScheme cellPoint;

// Fields to sample.
fields
(
p
);


// Set sampling definition: choice of
// uniform evenly distributed points on line
// face one point per face intersection
// midPoint one point per cell, inbetween two face intersections
// midPointAndFace combination of face and midPoint
//
// curve specified points, not nessecary on line, uses
// tracking
// cloud specified points, uses findCell
//
// axis: how to write point coordinate. Choice of
// - x/y/z: x/y/z coordinate only
// - xyz: three columns
// (probably does not make sense for anything but raw)
// - distance: distance from start of sampling line (if uses line) or
// distance from first specified sampling point
//
// type specific:
// uniform, face, midPoint, midPointAndFace : start and end coordinate
// uniform: extra number of sampling points
// curve, cloud: list of coordinates
sets
(

);


// Surface sampling definition: choice of
// plane : values on plane defined by point, normal.
// patch : values on patch.
//
// 1] patches are not triangulated by default
// 2] planes are always triangulated
// 3] iso-surfaces are always triangulated
surfaces
(
airfoil
{
type patch; // always triangulated
patchName Airfoil;
}
slat
{
type patch;
patchName Slat;
}
);


// ************************************************** ********************* //


I got this from a tutorial, I don't remember which one, and its also explained in the user guide.
After running your simulation you run the sample utility. After that you can use matlab or excel to calculate the Cp.

Good luck!
velezisaza is offline   Reply With Quote

Old   December 18, 2010, 17:22
Default
  #12
Member
 
Maryam Mousazadeh
Join Date: Oct 2010
Posts: 47
Rep Power: 6
anijdon is on a distinguished road
Hello Alejandro,
excuse me, I have an basically question because I'm not sure.
Is it enough that add mentioned lines to controlDict for calculating drag/lift coefficient in a steady state simulation? or we should copy other specific directories in our own case and use specific command during simulate?
in this way can we use sampleDict to plot these coefficients?
thanks
anijdon is offline   Reply With Quote

Old   December 19, 2010, 05:21
Default
  #13
New Member
 
Alejandro
Join Date: Aug 2010
Posts: 6
Rep Power: 6
velezisaza is on a distinguished road
Hi,

To calculate the drag and lift coefficient, the lines inside the controlDict are enough. After running the simulation you should have a directory in your case directory called forceCoeffs or whatever name you give to your function in your controlDict. after that, what I did was import the data in matlab and then plot it, but that depends on you.

This is are the lines I added. I also include the field average in case you need it at a later stage.
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application simpleFoam;

startFrom startTime;

startTime 10000;

stopAt endTime;

endTime 20000;

deltaT 1;

writeControl runTime;

writeInterval 2000;

purgeWrite 0;

writeFormat ascii;

writePrecision 6;

writeCompression uncompressed;

timeFormat general;

timePrecision 6;

runTimeModifiable yes;


functions
{
forceCoeffs_combi
{
type forceCoeffs;
functionObjectLibs ("libforces.so");
outputControl timeStep;
enabled true;
outputInterval 1;
patches
(
Slat
Airfoil
);
rhoName rhoInf;
log true;
rhoInf 1.225;
CofR (0 0 0);
liftDir (-0.309 0.95106 0);
dragDir (0.95106 0.309 0);
pitchAxis (0 0 1);
magUInf 51;
lRef 0.3;
Aref 0.0081;
}

forceCoeffs_airfoil
{
type forces;
functionObjectLibs ("libforces.so");
outputControl timeStep;
enabled false;
outputInterval 1;
patches
(
Airfoil
);
log true;
rhoInf 1.225;
CofR (0 0 0);
liftDir (-0.309 0.95106 0);
dragDir (0.95106 0.309 0);
pitchAxis (0 0 1);
magUInf 51;
lRef 0.3;
Aref 0.0075;
}

forceCoeffs_slat
{
type forces;
functionObjectLibs ("libforces.so");
outputControl timeStep;
enabled false;
outputInterval 1;
patches
(
Slat
);
pName p;
UName U;
log true;
rhoInf 1.225;
CofR (0 0 0);
liftDir (-0.309 0.95106 0);
dragDir (0.95106 0.309 0);
pitchAxis (0 0 1);
magUInf 51;
lRef 0.3;
Aref 0.0001566;
}

fieldAverage1
{
type fieldAverage;
functionObjectLibs ("libfieldFunctionObjects.so");
enabled true;
outputControl timeStep;
outputInterval 2000;
fields
(
U
{
mean on;
prime2Mean on;
base time;
}

p
{
mean on;
prime2Mean on;
base time;
}
);
}

}

// ************************************************** *********************** //
velezisaza is offline   Reply With Quote

Old   December 19, 2010, 11:38
Default
  #14
Member
 
Maryam Mousazadeh
Join Date: Oct 2010
Posts: 47
Rep Power: 6
anijdon is on a distinguished road
Hello,
I thank you for your helping, but I don't know what's the usage of field average and why we should obtain it?
thanks
anijdon is offline   Reply With Quote

Old   December 21, 2010, 05:20
Default forces.dat information
  #15
Member
 
inginer's Avatar
 
Ovidiu Michiu
Join Date: Apr 2010
Location: Ingolstadt, Germany
Posts: 52
Rep Power: 7
inginer is on a distinguished road
Hello,

i have a 2d airfoil and i used simpleFoam to run the case; i have the coefficient lift, drag and momentum. also, i have the forces calculated.
my question is: when i open the forces.dat (were are the forces) file i have on the first line time, forces(pressure, viscous) momentum(pressure, viscous)
and the second line i have 13 colones of numbers, corresponding to time, forces and momentum. but, why do i have 12(+1 the time) and not 9(+1 the time)?

best,
Ovidiu
inginer is offline   Reply With Quote

Old   December 22, 2010, 09:34
Default
  #16
Senior Member
 
David Boger
Join Date: Mar 2009
Location: Penn State Applied Research Laboratory
Posts: 146
Rep Power: 8
boger is on a distinguished road
Based on the first line, the 12 columns are the pressure and viscous component of the force, and the pressure and viscous component of the moment. Since each of these 4 items is a vector, you have 12 columns. Plus time.
__________________
David A. Boger
boger is offline   Reply With Quote

Old   January 7, 2011, 11:49
Default
  #17
Member
 
The True
Join Date: Dec 2010
Posts: 80
Rep Power: 6
Eren10 is on a distinguished road
I have put the required function in the controlDict file, but after running there happens nothing. I was just testing an airfoil with icoFoam app. I even copied the functions from an tutorial.

functions
{
forces
{
type forceCoeffs;
functionObjectLibs ( "libforces.so" );
outputControl timeStep;
outputInterval 1;
patches
(
AirFoil // this consists of the lower and the upper camber, defined as a wall in the BC
);
pName p;
UName U;
log true;
rhoInf 1;
CofR ( 0 0 0 );
liftDir (0 1 0);
dragDir (1 0 0);
pitchAxis ( 0 0 1 );
magUInf 25;
lRef 1;
Aref 1;
}
}
Eren10 is offline   Reply With Quote

Old   January 7, 2011, 11:54
Default
  #18
Senior Member
 
David Boger
Join Date: Mar 2009
Location: Penn State Applied Research Laboratory
Posts: 146
Rep Power: 8
boger is on a distinguished road
What if you use parentheses rather than braces for the list of functions and a semicolon at the end?

Code:
functions
(
  forces
  {
   ...
  }
);
__________________
David A. Boger
boger is offline   Reply With Quote

Old   January 7, 2011, 12:00
Default
  #19
Member
 
The True
Join Date: Dec 2010
Posts: 80
Rep Power: 6
Eren10 is on a distinguished road
no still doesn't do anything.
Eren10 is offline   Reply With Quote

Old   January 7, 2011, 12:06
Default
  #20
Senior Member
 
David Boger
Join Date: Mar 2009
Location: Penn State Applied Research Laboratory
Posts: 146
Rep Power: 8
boger is on a distinguished road
I just pasted your entry (with the modifications I already mentioned) into my controlDict and I got the desired output in forces/0/forceCoeffs.dat.
__________________
David A. Boger
boger is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
lift & drag coefficient on airfoil n. natik FLUENT 8 March 31, 2015 19:02
Fluent Good Lift coefficient BAD drag coefficient Rif Main CFD Forum 4 March 9, 2010 11:52
Drag coefficient & Lift coefficient?? mehrdadeng CFX 15 December 9, 2009 22:49
Automotive test case vinz OpenFOAM Running, Solving & CFD 98 October 27, 2008 09:43
drag and lift coefficient No CD-adapco 5 July 13, 2004 10:21


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