Coefficient of Drag of Cars using free CFD tools

 For the past few weeks, I had struggled with free CFD tools to calculate the Coefficient of Drag of a few cars that have well known measured CD. Tesla Model 3, Shulich I solar car, Pac Car 2. I also did a CFD simulation of the Solar Car 2 and my Transparent SUV.

Installation

FreeCAD, Paraview, gmsh, cfmesh for Windows 10. These are the best so far in 2022. I tried a few years ago the online openfoam based such as Simwork, they are limited so as to be impractical if you want to run for free.

Once you have installed FreeCAD, install the addon, plot, CFDoF and FEM. The easiest version is for windows. OSX is more difficult but basic FreeCAD will work. Installin openfoam is just too difficult. I failed to install the docker and another native OSX installers.

When installing CFDoF, no need to install openfoam using other methods other than that shown in the Edit\Preferences\CFDoF. If they failed to install, look at the link and search for the latest version and download separately. The openfoam recommended was from openfoam.org, not from openfoam.com. Paraview and gmsh can be installed separately and then set their executables in the preference setting. Very hard to write down the exact procedure because the software kept on being updated and their links chaned.

When installing Paraview, load the plugin Surface LIC, which is useful but not enabled by default.

Errors

Most of the errors are in the mesh size. The tutorial from Joko Engineering demonstrate one error which was resolved by reducing the maximum mesh size.

The mesh size should be less than 0.5% of the dimension of the object to be calculated.

Operational errors which can occur is mistaking the boundary conditions. Use the methods mentioned in the tutorials. They are the best.

I tried to not use symmetry but some of my models are not symmetrical anyway and took too long to calculate. Days. Better use the symmetry constraint. It worked well. I used the twice cut written tutorial shown in the UAV tutorial. Just use compound, no need to use union or other boolean operations except for the cutting.

Use mesh refinement because it will speed up our calculations tremendously. I used 0.1 refineness for the surface only. instead of the default 0.75. I also use 3 boundaries which are refinements that gradually increases to match the tunnel mesh size, defined by the maximum mesh size.

Use cfmesh. It is more than 10 times faster than gmsh. Use the default 0 for maximum mesh size and then it will change it to a another size.Because I found that 0.5%, I multiply this 0.5% dimension by ten, and then set the maximum mesh size to this number. It worked. My 4.5 m model, failed to solve using even 30 mm maximum mesh size without any refinement. Using both surface refinement set to 3 boundary layers and 0.1, it allowed a maximum mesh size of 200 and the calculations were very quick, finished in less than 1 hour for 40 iterations.

The results for 40 iterations usingg 0.0005 s, using inlet velocity of 34 m per second, the results are the same as more than 8000 usingg a mixture of 0.0005 and 0.0001. For this model, the residuals cannot become lower than the lowest at around 40 iteratioins which was why I set the controlDict for the deltaT and  endTime to have 40 iterations only for the lowest pressure residuals.

Tips

I use Notepad++ to edit the controlDict and fvSolution to control the behaviour of the solver even while it is running. The solver is able to reread these files i n the system directory of the output files of CFDoF, which you can set. The default is set to our user directories.

To reduce the time we can adjust the precision in the fvSolution file by half, e.g. e-8 to e-4. I found that the impact on time is minimal compared to the mesh refinement.

Tunnel size is advised to be 3 times the dimension of the model. I tried just 2 times, and I got results. Looking at the Surface LIC, the curves can reach more than these dimensions. Another method to determine the impact of tunnel size is to observe the surfaces with 16 colours only so that we can see the boundaries of each colour clearly. The best way to determine the size of the tunnel is by making sure that the walls at at ambient condition, and this depends on the speed of inlet flow and shape of the model. If we fail to comply with this requirement, it will mean that there will be errors.

Number of iterations and slight change in residuals do not affect results at all. 40 iterations have the same result as 8000. Even when the residual values are lower, the drag caculation results were the same, between 40 and 60. so, the moment we see the residuals drop to the minimum, we can stop the iterations by changing the endTime to a value lower than that current time. Just save the file stored in Notepad++. Openfoam will reload the system files onnce they are changed.


Comments

Popular posts from this blog

A Short Guide To Metric Nuts and Bolts

CAN Bus Wiring Diagram, a Basics Tutorial

Best Free CFD Tutorial: FreeCAD Openfoam CFD Workbench