Salome HOME
initial project version
[tools/solverlab.git] / CoreFlows / examples / Python / FiveEqsTwoFluid_1DBoilingChannel.py
1 #!/usr/bin/env python
2 # -*-coding:utf-8 -*
3
4 import CoreFlows as cf
5
6 def FiveEqsTwoFluid_1DBoilingChannel():
7
8         spaceDim = 1;
9     # Prepare for the mesh
10         xinf = 0 ;
11         xsup=4.2;
12         nx=50;
13
14     # set the limit field for each boundary
15
16         inletVoidFraction=0;
17         inletVelocityX=[1]*2;
18         inletTemperature=563;
19         outletPressure=155e5;
20
21     # physical constants
22         heatPower=1e8;
23
24         myProblem = cf.FiveEqsTwoFluid(cf.around155bars600K,spaceDim);
25         nVar =  myProblem.getNumberOfVariables();
26
27     # Prepare for the initial condition
28         VV_Constant =[0]*nVar;
29
30         # constant vector
31         VV_Constant[0] = inletVoidFraction;
32         VV_Constant[1] = outletPressure ;
33         VV_Constant[2] = inletVelocityX[0];
34         VV_Constant[3] = inletVelocityX[1];
35         VV_Constant[4] = inletTemperature ;
36
37
38     #Initial field creation
39         print("Building mesh and initial data " ); 
40         myProblem.setInitialFieldConstant( spaceDim, VV_Constant, xinf, xsup, nx,"inlet","outlet");
41
42     # set the boundary conditions
43         myProblem.setInletBoundaryCondition("inlet",inletVoidFraction,inletTemperature,inletVelocityX)
44         myProblem.setOutletBoundaryCondition("outlet", outletPressure);
45
46     # set physical parameters
47         myProblem.setHeatSource(heatPower);
48
49     # set the numerical method
50         myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
51         myProblem.setEntropicCorrection(True);
52         myProblem.setWellBalancedCorrection(True);  
53     
54     # name of result file
55         fileName = "1DBoilingChannel";
56
57     # simulation parameters 
58         MaxNbOfTimeStep = 3 ;
59         freqSave = 1;
60         cfl = 0.5;
61         maxTime = 500;
62         precision = 1e-6;
63
64         myProblem.setCFL(cfl);
65         myProblem.setPrecision(precision);
66         myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
67         myProblem.setTimeMax(maxTime);
68         myProblem.setFreqSave(freqSave);
69         myProblem.setFileName(fileName);
70         myProblem.setNewtonSolver(precision,20);
71         #myProblem.saveConservativeField(True);
72         if(spaceDim>1):
73                 myProblem.saveVelocity();
74                 pass
75  
76     # evolution
77         myProblem.initialize();
78         print("Running python "+ fileName );
79
80         ok = myProblem.run();
81         if (ok):
82                 print( "Simulation python " + fileName + " is successful !" );
83                 pass
84         else:
85                 print( "Simulation python " + fileName + "  failed ! " );
86                 pass
87
88         print( "------------ End of calculation !!! -----------" );
89
90         myProblem.terminate();
91         return ok
92
93 if __name__ == """__main__""":
94     FiveEqsTwoFluid_1DBoilingChannel()