From fd0b511de038918c8e52e059a3cec19e25df16b3 Mon Sep 17 00:00:00 2001 From: michael Date: Sun, 29 Nov 2020 00:12:52 +0100 Subject: [PATCH] Added simulation of NACA airfoil --- CoreFlows/examples/Python/CMakeLists.txt | 1 + .../SinglePhase/SinglePhase_2DAirfoil.py | 99 +++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 CoreFlows/examples/Python/SinglePhase/SinglePhase_2DAirfoil.py diff --git a/CoreFlows/examples/Python/CMakeLists.txt b/CoreFlows/examples/Python/CMakeLists.txt index 7fe76f6..f24f688 100755 --- a/CoreFlows/examples/Python/CMakeLists.txt +++ b/CoreFlows/examples/Python/CMakeLists.txt @@ -125,6 +125,7 @@ CreatePythonTest(SinglePhase/SinglePhase_2DLidDrivenCavity_unstructured.py) CreatePythonTest(SinglePhase/SinglePhase_2DPoiseuilleFlow.py) CreatePythonTest(SinglePhase/SinglePhase_2DPoiseuilleFlow_restart.py) CreatePythonTest(SinglePhase/SinglePhase_2DPoiseuilleFlow_outputFields.py) +CreatePythonTest(SinglePhase/SinglePhase_2DAirfoil.py) CreatePythonTest(SinglePhase/SinglePhase_2DSphericalExplosion_unstructured.py) CreatePythonTest(SinglePhase/SinglePhase_2DSphericalExplosion_HEXAGON.py) CreatePythonTest(SinglePhase/SinglePhase_2DHeatedChannelInclined.py) diff --git a/CoreFlows/examples/Python/SinglePhase/SinglePhase_2DAirfoil.py b/CoreFlows/examples/Python/SinglePhase/SinglePhase_2DAirfoil.py new file mode 100644 index 0000000..3ad0def --- /dev/null +++ b/CoreFlows/examples/Python/SinglePhase/SinglePhase_2DAirfoil.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python3 +# -*-coding:utf-8 -* + +import CoreFlows as cf +import cdmath as cm + +def SinglePhase_2DAirfoil(): + spaceDim = 2; + + # Prepare the mesh data + print("Loading the mesh" ); + filename="./resources/naca10.med" + my_mesh=cm.Mesh(filename) + + # Boundary data + inletVelocityX = 175; + inletVelocityY = 0.; + inletTemperature = 300 + outletPressure = 1e5 + wallVelocityX = 0; + wallVelocityY = 0; + wallTemperature = 300; + + # physical constants + gravite = [0] * spaceDim + gravite[0]= 0; + gravite[1]= -10; + viscosity = 15e-6 + viscosite = [viscosity]; + + myProblem = cf.SinglePhase(cf.Gas,cf.around1bar300K,spaceDim); + nVar =myProblem.getNumberOfVariables(); + + # Prepare for the initial condition + VV_Constant =[0]*nVar + + VV_Constant[0] = outletPressure ; + VV_Constant[1] = inletVelocityX; + VV_Constant[2] = inletVelocityY; + VV_Constant[3] = inletTemperature ; + + #Initial field creation + print("Setting initial data" ); + myProblem.setInitialFieldConstant(my_mesh,VV_Constant) + + # the boundary conditions + myProblem.setOutletBoundaryCondition("Inlet", outletPressure); + myProblem.setInletBoundaryCondition( "Outlet", inletTemperature, inletVelocityX, inletVelocityY); + myProblem.setWallBoundaryCondition("Top", wallTemperature, wallVelocityX, wallVelocityY); + myProblem.setWallBoundaryCondition("Bottom", wallTemperature, wallVelocityX, wallVelocityY); + myProblem.setWallBoundaryCondition("Airfoil_boundary", wallTemperature, wallVelocityX, wallVelocityY); + + # set physical parameters + myProblem.setViscosity(viscosite); + myProblem.setGravity(gravite); + + # set the numerical method + myProblem.setNumericalScheme(cf.upwind, cf.Implicit); + myProblem.setLinearSolver(cf.GMRES,cf.ILU,True); + + # name file save + fileName = "2DAirfoil"; + + # parameters calculation + MaxNbOfTimeStep = 10000 ; + freqSave = 100; + cfl = 50; + maxTime = 5000; + precision = 1e-4; + + myProblem.setCFL(cfl); + myProblem.setPrecision(precision); + myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep); + myProblem.setTimeMax(maxTime); + myProblem.setNewtonSolver(precision,50); + myProblem.setFreqSave(freqSave); + myProblem.setFileName(fileName); + if(spaceDim>1): + myProblem.saveVelocity(); + pass + + # evolution + myProblem.initialize(); + + ok = myProblem.run(); + if (ok): + print( "Simulation " + fileName + " is successful !" ); + pass + else: + print( "Simulation " + fileName + " failed ! " ); + pass + + print( "------------ End of Simulation !!! -----------" ); + + myProblem.terminate(); + return ok + +if __name__ == """__main__""": + SinglePhase_2DAirfoil() -- 2.39.2