Salome HOME
initial project version
[tools/solverlab.git] / CoreFlows / examples / Python / SinglePhase_3DHeatDrivenCavity.py
1 #!/usr/bin/env python
2 # -*-coding:utf-8 -*
3
4
5 import CoreFlows as cf
6
7 def SinglePhase_3DHeatDrivenCavity():
8  
9         spaceDim = 3;
10     #Preprocessing: mesh data
11         xinf=0;
12         xsup=1;
13         yinf=0;
14         ysup=1;
15         zinf=0;
16         zsup=1;
17         
18         nx=10;
19         ny=10;
20         nz=10;
21
22     # set the limit field for each boundary
23
24         coldWallVelocityX=0;
25         coldWallVelocityY=0;
26         coldWallVelocityZ=0;
27         coldWallTemperature=563;
28
29         hotWallVelocityX=0;
30         hotWallVelocityY=0;
31         hotWallVelocityZ=0;
32         hotWallTemperature=613;
33         
34     # physical constants
35
36         gravite = [0] * spaceDim
37         gravite[2]=-10;
38         gravite[1]=0;
39         gravite[0]=0;
40         viscosite=[8.85e-5];
41         conductivite=[1000];#Wall heat transfert due to nucleate boiling.
42
43
44         myProblem = cf.SinglePhase(cf.Liquid,cf.around155bars600K,spaceDim);
45         nVar = myProblem.getNumberOfVariables();
46
47         #Initial field creation
48         print("Building initial data " ); 
49         
50     # Prepare for the initial condition
51     
52         VV_Constant = [0] * nVar
53
54         # constant vector
55         VV_Constant[0] = 155e5;
56         VV_Constant[1] = 0 ;
57         VV_Constant[2] = 0;
58         VV_Constant[3] = 0;
59         VV_Constant[4] = 573;
60
61     #Initial field creation
62         print("Setting mesh and initial data" );
63         myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"hotWall","hotWall",yinf,ysup,ny,"hotWall","hotWall",zinf,zsup,nz, "hotWall", "coldWall");
64
65     # Set the boundary conditions
66         myProblem.setWallBoundaryCondition("coldWall", coldWallTemperature, coldWallVelocityX, coldWallVelocityY, coldWallVelocityZ);
67         myProblem.setWallBoundaryCondition("hotWall", hotWallTemperature, hotWallVelocityX, hotWallVelocityY, hotWallVelocityZ);
68
69     # set physical parameters
70         myProblem.setViscosity(viscosite);
71         myProblem.setConductivity(conductivite);
72         myProblem.setGravity(gravite);
73
74     # set the numerical method
75         myProblem.setNumericalScheme(cf.upwind, cf.Implicit);
76         myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
77         myProblem.setEntropicCorrection(False);
78         myProblem.setWellBalancedCorrection(False);   
79     
80     # name file save
81         fileName = "3DHeatDrivenCavity";
82
83     # simulation parameters
84         MaxNbOfTimeStep = 3 ;
85         freqSave = 1;
86         cfl = 10;
87         maxTime = 50;
88         precision = 1e-6;
89
90         myProblem.setCFL(cfl);
91         myProblem.setPrecision(precision);
92         myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
93         myProblem.setTimeMax(maxTime);
94         myProblem.setFreqSave(freqSave);
95         myProblem.setFileName(fileName);
96         myProblem.setNewtonSolver(precision,50);
97         myProblem.saveConservativeField(True);
98         if(spaceDim>1):
99                 myProblem.saveVelocity();
100                 pass
101
102     # evolution
103         myProblem.initialize();
104
105         ok = myProblem.run();
106         if (ok):
107                 print( "Simulation python " + fileName + " is successful !" );
108                 pass
109         else:
110                 print( "Simulation python " + fileName + "  failed ! " );
111                 pass
112
113         print( "------------ End of calculation !!! -----------" );
114
115         myProblem.terminate();
116         return ok
117
118 if __name__ == """__main__""":
119     SinglePhase_3DHeatDrivenCavity()