7 def SinglePhase_2DPoiseuilleFlow():
10 print("Building the mesh" );
11 # Prepare the mesh data
19 my_mesh=cm.Mesh(xinf,xsup,nx,yinf,ysup,ny)
20 # set the boundary names for each boundary
22 my_mesh.setGroupAtPlan(xsup,0,eps,"wall")
23 my_mesh.setGroupAtPlan(xinf,0,eps,"wall")
24 my_mesh.setGroupAtPlan(ysup,1,eps,"neumann")
25 my_mesh.setGroupAtPlan(yinf,1,eps,"neumann")
29 viscosite=[viscosity];
31 a = -8*viscosity*Vy_max / ((ysup-yinf)*(ysup-yinf) ) #pressure slope
33 initialTemperature = 573
34 outletPressure = 155e5
36 initial_field=cm.Field("Initial field", cm.CELLS, my_mesh, 4)
37 for i in range( 0 , my_mesh.getNumberOfCells() ):
41 initial_field[i,0] = outletPressure + a*(y - ysup )
42 initial_field[i,1] = 0 #x component of the velocity
43 initial_field[i,2] = a/(2*viscosity)*( (x-(xsup+xinf)/2)*(x-(xsup+xinf)/2) - (xsup-xinf)*(xsup-xinf)/4) #y component of the velocity
44 initial_field[i,3] = initialTemperature
47 # set the limit field for each boundary
52 myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
53 nVar =myProblem.getNumberOfVariables();
55 #Initial field creation
56 print("Setting initial data" );
57 myProblem.setInitialField(initial_field)
59 # the boundary conditions
60 myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
61 myProblem.setNeumannBoundaryCondition("neumann");
63 # set physical parameters
64 myProblem.setViscosity(viscosite);
66 # set the numerical method
67 myProblem.setNumericalScheme(cf.upwind, cf.Implicit);
68 #myProblem.setLinearSolver(cf.GMRES,cf.LU,True);
71 fileName = "2DPoiseuilleFlow";
73 # parameters calculation
74 MaxNbOfTimeStep = 10000 ;
80 myProblem.setCFL(cfl);
81 myProblem.setPrecision(precision);
82 myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
83 myProblem.setTimeMax(maxTime);
84 myProblem.setNewtonSolver(float('inf'),20);
85 myProblem.setFreqSave(freqSave);
86 myProblem.setFileName(fileName);
87 myProblem.saveConservativeField(True);
89 myProblem.saveVelocity();
93 myProblem.initialize();
97 print( "Simulation python " + fileName + " is successful !" );
100 print( "Simulation python " + fileName + " failed ! " );
103 print( "------------ End of calculation !!! -----------" );
105 myProblem.terminate();
108 if __name__ == """__main__""":
109 SinglePhase_2DPoiseuilleFlow()