]> SALOME platform Git repositories - tools/solverlab.git/blob - CoreFlows/examples/Python/FiveEqsTwoFluid/FiveEqsTwoFluid_2DInclinedBoilingChannel.py
Salome HOME
Mesh should be set befor giving input fields
[tools/solverlab.git] / CoreFlows / examples / Python / FiveEqsTwoFluid / FiveEqsTwoFluid_2DInclinedBoilingChannel.py
1 #!/usr/bin/env python
2 # -*-coding:utf-8 -*
3
4
5 import CoreFlows as cf
6
7 def FiveEqsTwoFluid_2DInclinedBoilingChannel():
8         spaceDim = 2;
9
10     # Prepare for the mesh
11         xinf = 0 ;
12         xsup=2;
13         yinf=0.0;
14         ysup=4;
15         nx=20;
16         ny=40; 
17
18     # set the limit field for each boundary
19         wallVelocityX=[0];
20         wallVelocityY=[0];
21         wallTemperature=573;
22         inletVoidFraction=0;
23         inletVelocityX=[0]*2;
24         inletVelocityY=[1]*2;
25         inletTemperature=573;
26         outletPressure=155e5;
27
28     # physical constants
29         gravite = [0] * spaceDim
30     
31         gravite[1]=-7;
32         gravite[0]=7;
33
34         heatPower=5e7;
35
36         myProblem = cf.FiveEqsTwoFluid(cf.around155bars600K,spaceDim);
37         nVar =myProblem.getNumberOfVariables();
38
39     # Prepare for the initial condition
40         VV_Constant =[0]*nVar
41
42         # constant vector
43         VV_Constant[0] = inletVoidFraction;
44         VV_Constant[1] = outletPressure ;
45         VV_Constant[2] = inletVelocityX[0];
46         VV_Constant[3] = inletVelocityY[0];
47         VV_Constant[4] = inletVelocityX[1];
48         VV_Constant[5] = inletVelocityY[1];
49         VV_Constant[6] = inletTemperature ;
50
51     #Initial field creation
52         print("Building mesh and initial data " );
53         myProblem.setInitialFieldConstant(spaceDim,VV_Constant,
54                                           xinf,xsup,nx,"wall","wall",
55                                           yinf,ysup,ny,"inlet","outlet", 
56                                           0.0,0.0,  0,  "", "")
57
58     # the boundary conditions
59         myProblem.setOutletBoundaryCondition("outlet", outletPressure);
60         myProblem.setInletBoundaryCondition("inlet", inletVoidFraction, inletTemperature, inletVelocityX, inletVelocityY);
61         myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
62
63     # set physical parameters
64         myProblem.setHeatSource(heatPower);
65         myProblem.setGravity(gravite);
66
67         # set the numerical method
68         myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
69         myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
70         myProblem.setEntropicCorrection(True);
71         #myProblem.setWellBalancedCorrection(True);    
72     
73         # name of result file
74         fileName = "2DInclinedBoilingChannel";
75
76         # simulation parameters
77         MaxNbOfTimeStep = 3 ;
78         freqSave = 1;
79         cfl = 0.25;
80         maxTime = 5;
81         precision = 1e-6;
82
83         myProblem.setCFL(cfl);
84         myProblem.setPrecision(precision);
85         myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
86         myProblem.setTimeMax(maxTime);
87         myProblem.setFreqSave(freqSave);
88         myProblem.setFileName(fileName);
89         myProblem.setNewtonSolver(precision,20);
90         #myProblem.saveConservativeField(True);
91         if(spaceDim>1):
92                 myProblem.saveVelocity();
93                 pass
94
95         # evolution
96         myProblem.initialize();
97         print("Running python "+ fileName );
98
99         ok = myProblem.run();
100         if (ok):
101                 print( "Simulation python " + fileName + " is successful !" );
102                 pass
103         else:
104                 print( "Simulation python " + fileName + "  failed ! " );
105                 pass
106
107         print( "------------ End of calculation !!! -----------" );
108
109         myProblem.terminate();
110         return ok
111
112 if __name__ == """__main__""":
113     FiveEqsTwoFluid_2DInclinedBoilingChannel()