]> SALOME platform Git repositories - tools/solverlab.git/blob - CoreFlows/examples/Python/FiveEqsTwoFluid/FiveEqsTwoFluid_2DInclinedSedimentation.py
Salome HOME
Mesh should be set befor giving input fields
[tools/solverlab.git] / CoreFlows / examples / Python / FiveEqsTwoFluid / FiveEqsTwoFluid_2DInclinedSedimentation.py
1 #!/usr/bin/env python
2 # -*-coding:utf-8 -*
3
4
5 import CoreFlows as cf
6
7 def FiveEqsTwoFluid_2DInclinedSedimentation():
8         spaceDim = 2;
9
10     # Prepare for the mesh
11         xinf = 0 ;
12         xsup=2.0;
13         yinf=0.0;
14         ysup=4.0;
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
23     # set the initial field  
24         initialVoidFraction=0.5;
25         initialVelocityX=[0]*2;
26         initialVelocityY=[1]*2;
27         initialTemperature=573;
28         initialPressure=155e5;
29
30         # physical constants
31         gravite = [0] * spaceDim
32     
33         gravite[1]=-7;
34         gravite[0]=7;
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] = initialVoidFraction;
44         VV_Constant[1] = initialPressure ;
45         VV_Constant[2] = initialVelocityX[0];
46         VV_Constant[3] = initialVelocityY[0];
47         VV_Constant[4] = initialVelocityX[1];
48         VV_Constant[5] = initialVelocityY[1];
49         VV_Constant[6] = initialTemperature ;
50
51     #Initial field creation
52         print("Building initial data " );
53         myProblem.setInitialFieldConstant(spaceDim,VV_Constant,
54                                           xinf,xsup,nx,"wall","wall",
55                                           yinf,ysup,ny,"wall","wall", 
56                                           0.0,0.0,  0,  "", "")
57
58     # the boundary conditions
59         myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
60
61     # set physical parameters
62         myProblem.setGravity(gravite);
63
64         # set the numerical method
65         myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
66         myProblem.setEntropicCorrection(True);
67     
68         # name of result file
69         fileName = "2DInclinedSedimentation";
70
71         # simulation parameters
72         MaxNbOfTimeStep = 3 ;
73         freqSave = 1;
74         cfl = 0.25;
75         maxTime = 5;
76         precision = 1e-6;
77
78         myProblem.setCFL(cfl);
79         myProblem.setPrecision(precision);
80         myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
81         myProblem.setTimeMax(maxTime);
82         myProblem.setFreqSave(freqSave);
83         myProblem.setFileName(fileName);
84         myProblem.setNewtonSolver(precision,20);
85         myProblem.saveConservativeField(True);
86         if(spaceDim>1):
87                 myProblem.saveVelocity();
88                 pass
89
90         # evolution
91         myProblem.initialize();
92         print("Running python "+ fileName );
93
94         ok = myProblem.run();
95         if (ok):
96                 print( "Simulation python " + fileName + " is successful !" );
97                 pass
98         else:
99                 print( "Simulation python " + fileName + "  failed ! " );
100                 pass
101
102         print( "------------ End of calculation !!! -----------" );
103
104         myProblem.terminate();
105         return ok
106
107 if __name__ == """__main__""":
108     FiveEqsTwoFluid_2DInclinedSedimentation()