Salome HOME
update CoreFlows
[tools/solverlab.git] / CoreFlows / examples / Python / DriftModel / DriftModel_2DInclinedChannelGravityTriangles.py
1 #!/usr/bin/env python
2 # -*-coding:utf-8 -*
3
4 import CoreFlows as cf
5
6 def DriftModel_2DInclinedBoilingChannel():
7         spaceDim = 2;
8
9     # Prepare for the mesh
10         print( "Loading unstructured mesh " );
11         inputfile="../resources/CanalTrianglesStructures.med";  
12         xinf = 0 ;
13         xsup=1.0;
14         yinf=0.0;
15         ysup=4.0;
16         nx=10;
17         ny=40; 
18
19     # set the limit field for each boundary
20         wallVelocityX=0;
21         wallVelocityY=0;
22         wallTemperature=563;
23         inletConcentration=0;
24         inletVelocityX=0;
25         inletVelocityY=1;
26         inletTemperature=563;
27         outletPressure=155e5;
28
29     # physical constants
30         gravite = [0] * spaceDim
31     
32         gravite[1]=-8.5;
33         gravite[0]=5;
34
35         heatPower=0e8;
36
37         myProblem = cf.DriftModel(cf.around155bars600K,spaceDim);
38         nVar =myProblem.getNumberOfVariables();
39
40     # Prepare for the initial condition
41         VV_Constant =[0]*nVar
42
43         # constant vector
44         VV_Constant[0] = inletConcentration;
45         VV_Constant[1] = outletPressure ;
46         VV_Constant[2] = inletVelocityX;
47         VV_Constant[3] = inletVelocityY;
48         VV_Constant[4] = inletTemperature ;
49
50     #Initial field creation
51         print("Building mesh and initial data " );
52         myProblem.setInitialFieldConstant(spaceDim,VV_Constant,
53                                           xinf,xsup,nx,"wall","wall",
54                                           yinf,ysup,ny,"inlet","outlet", 
55                                           0.0,0.0,  0,  "", "")
56
57     # the boundary conditions
58         myProblem.setOutletBoundaryCondition("outlet", outletPressure,[xsup,ysup]);
59         myProblem.setInletBoundaryCondition("inlet", inletTemperature, inletConcentration, inletVelocityX, inletVelocityY);
60         myProblem.setWallBoundaryCondition("wall", wallTemperature, wallVelocityX, wallVelocityY);
61
62     # set physical parameters
63         myProblem.setHeatSource(heatPower);
64         myProblem.setGravity(gravite);
65
66         # set the numerical method
67         myProblem.setNumericalScheme(cf.staggered, cf.Implicit);
68         myProblem.setWellBalancedCorrection(True);    
69         myProblem.setNonLinearFormulation(cf.VFFC) 
70     
71         # name of result file
72         fileName = "2DInclinedChannelGravityTriangles";
73
74         # simulation parameters
75         MaxNbOfTimeStep = 3 ;
76         freqSave = 1;
77         cfl = 0.5;
78         maxTime = 500;
79         precision = 1e-6;
80
81         myProblem.setCFL(cfl);
82         myProblem.setPrecision(precision);
83         myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
84         myProblem.setTimeMax(maxTime);
85         myProblem.setFreqSave(freqSave);
86         myProblem.setFileName(fileName);
87         myProblem.usePrimitiveVarsInNewton(True)
88
89         # evolution
90         myProblem.initialize();
91
92         ok = myProblem.run();
93         if (ok):
94                 print( "Simulation python " + fileName + " is successful !" );
95                 pass
96         else:
97                 print( "Simulation python " + fileName + "  failed ! " );
98                 pass
99
100         print( "------------ End of calculation !!! -----------" );
101
102         myProblem.terminate();
103         return ok
104
105 if __name__ == """__main__""":
106     DriftModel_2DInclinedBoilingChannel()