Salome HOME
Updated tests for gui
[tools/solverlab.git] / CoreFlows / examples / Python / TransportEquation / TransportEquation_1DHeatedChannel.py
1 #!/usr/bin/env python
2 # -*-coding:utf-8 -*
3
4 import CoreFlows as cf
5
6 def TransportEquation_1DHeatedChannel():
7
8         spaceDim = 1;
9     # Prepare for the mesh
10         xinf = 0 ;
11         xsup=4.2;
12         nx=10;
13
14     # set the limit field for each boundary
15         inletEnthalpy=1.3e6;
16
17     # Set the transport velocity
18         transportVelocity=[5];
19
20         myProblem = cf.TransportEquation(cf.Water,cf.around155bars600K,transportVelocity);
21         nVar = myProblem.getNumberOfVariables();
22
23     # Prepare for the initial condition
24         VV_Constant = [1.3e6]; #initial enthalpy
25
26         #Set rod temperature and heat exchamge coefficient
27         rodTemp=623;#Rod clad temperature 
28         heatTransfertCoeff=1000;#fluid/solid heat exchange coefficient
29         myProblem.setRodTemperature(rodTemp);
30         myProblem.setHeatTransfertCoeff(heatTransfertCoeff);
31
32     #Initial field creation
33         print("Building mesh and initial data " );
34         myProblem.setInitialFieldConstant(spaceDim,VV_Constant,xinf,xsup,nx,"inlet","neumann");
35  
36     # Set the boundary conditions
37         myProblem.setInletBoundaryCondition("inlet", inletEnthalpy);
38         myProblem.setNeumannBoundaryCondition("neumann")
39
40     # Set the numerical method
41         myProblem.setTimeScheme( cf.Explicit);
42
43     # name file save
44         fileName = "1DFluidEnthalpy";
45
46     # parameters calculation
47         MaxNbOfTimeStep = 3 ;
48         freqSave = 5;
49         cfl = 0.95;
50         maxTime = 5;
51         precision = 1e-6;
52
53         myProblem.setCFL(cfl);
54         myProblem.setPrecision(precision);
55         myProblem.setMaxNbOfTimeStep(MaxNbOfTimeStep);
56         myProblem.setTimeMax(maxTime);
57         myProblem.setFreqSave(freqSave);
58         myProblem.setFileName(fileName);
59
60
61      # evolution
62         myProblem.initialize();
63
64         ok = myProblem.run();
65         if (ok):
66                 print( "Simulation python " + fileName + " is successful !" );
67                 pass
68         else:
69                 print( "Simulation python " + fileName + "  failed ! " );
70                 pass
71
72         print( "------------ End of calculation !!! -----------" );
73
74         myProblem.terminate();
75         return ok
76
77 if __name__ == """__main__""":
78     TransportEquation_1DHeatedChannel()