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