Salome HOME
initial project version
[tools/solverlab.git] / CoreFlows / examples / Python / SinglePhase_3DVortexTube_NoCone_NoViscosity.py
1 #!/usr/bin/env python
2 # -*-coding:utf-8 -*
3
4
5 import CoreFlows as cf
6
7 def SinglePhase_3DVortexTube_WithoutCone():
8         spaceDim = 3;
9
10         print( "Loading mesh of vortex tube without cone" );
11         inputfile="../resources/VortexTubeWithoutCone.med";     
12  
13     # set the limit field for each boundary
14         outletPressure =  1e5;
15         inletPressure  = 10e5;
16         inletTemperature  = 300;
17         
18     # physical constants
19         #viscosite=[0.025];
20
21         myProblem = cf.SinglePhase(cf.Gas,cf.around1bar300K,spaceDim);
22         nVar = myProblem.getNumberOfVariables();
23
24         #Initial field creation
25         print("Building initial data " ); 
26         
27     # Prepare for the initial condition
28     
29         VV_Constant = [0] * nVar
30
31         # constant vector
32         VV_Constant[0] = 1e5;
33         VV_Constant[1] = 0 ;
34         VV_Constant[2] = 0;
35         VV_Constant[3] = 0;
36         VV_Constant[4] = 300;
37
38     #Initial field creation
39         print("Setting mesh and initial data" );
40         myProblem.setInitialFieldConstant(inputfile,VV_Constant);
41
42     # Set the boundary conditions
43         myProblem.setInletPressureBoundaryCondition("Inlet flow", inletPressure, inletTemperature,0,100,0)
44         myProblem.setOutletBoundaryCondition("Hot outlet", outletPressure)
45         myProblem.setOutletBoundaryCondition("Cold outlet", outletPressure)
46         myProblem.setWallBoundaryCondition("Wall", inletTemperature)
47
48     # set physical parameters
49         #myProblem.setViscosity(viscosite);
50
51     # set the numerical method
52         myProblem.setNumericalScheme(cf.upwind, cf.Explicit);
53         myProblem.setNonLinearFormulation(cf.reducedRoe);
54         myProblem.setEntropicCorrection(True)
55         #myProblem.setLinearSolver(cf.GMRES,cf.ILU,True);
56    
57     # name file save
58         fileName = "3DVortexTubeWithoutCone";
59
60     # simulation parameters
61         MaxNbOfTimeStep = 10000 ;
62         freqSave = 100;
63         cfl = 1./3;
64         maxTime = 50;
65         precision = 1e-6;
66
67         myProblem.setCFL(cfl);
68         myProblem.setPrecision(precision);
69         myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
70         myProblem.setTimeMax(maxTime);
71         myProblem.setFreqSave(freqSave);
72         myProblem.setFileName(fileName);
73         #myProblem.setNewtonSolver(precision,20);
74         #yProblem.saveConservativeField(True);
75         if(spaceDim>1):
76                 myProblem.saveVelocity();
77                 pass
78
79     # evolution
80         myProblem.initialize();
81
82         ok = myProblem.run();
83         if (ok):
84                 print( "Simulation python " + fileName + " is successful !" );
85                 pass
86         else:
87                 print( "Simulation python " + fileName + "  failed ! " );
88                 pass
89
90         print( "------------ End of calculation !!! -----------" );
91
92         myProblem.terminate();
93         return ok
94
95 if __name__ == """__main__""":
96     SinglePhase_3DVortexTube_WithoutCone()