]> SALOME platform Git repositories - tools/solverlab.git/commitdiff
Salome HOME
Updated python diffusion tests
authormichael <michael@localhost.localdomain>
Wed, 24 Nov 2021 15:00:42 +0000 (16:00 +0100)
committermichael <michael@localhost.localdomain>
Wed, 24 Nov 2021 15:00:42 +0000 (16:00 +0100)
CoreFlows/examples/Python/DiffusionEquation/DiffusionEquation_1DHeatedRod.py
CoreFlows/examples/Python/DiffusionEquation/DiffusionEquation_1DHeatedRod_FE.py
CoreFlows/examples/Python/DiffusionEquation/DiffusionEquation_2DSpherical.py
CoreFlows/examples/resources/BoxWithMeshWithTriangularCells.med

index 333936a87a41dc533f78d7c622948b69c2d9f32a..e6bf4045d8310310eb14a43a16f7f31364cdc462 100755 (executable)
@@ -42,7 +42,7 @@ def DiffusionEquation_1DHeatedRod():
 
     # set the numerical method
        myProblem.setTimeScheme( cf.Explicit);
-       # myProblem.setLinearSolver(GMRES,ILU,True);
+       # myProblem.setLinearSolver(GMRES,ILU);
 
     # name of result file
        fileName = "1DRodTemperature";
index 920869d9fadaf9c5efd18f8bc888f44c4ad1eef4..3e7fc305d0bfd8942c552110954a161553640728 100755 (executable)
@@ -44,7 +44,7 @@ def DiffusionEquation_1DHeatedRod():
 
     # set the numerical method
        myProblem.setTimeScheme( cf.Explicit);
-       # myProblem.setLinearSolver(GMRES,ILU,True);
+       # myProblem.setLinearSolver(GMRES,ILU);
 
     # name of result file
        fileName = "1DRodTemperature_FE";
index cd47f4b727058753b5d0bf7a83cbf9364c9acc57..83305377d1d07e4295aaa8528139d53de21c2ad8 100644 (file)
@@ -11,7 +11,7 @@ import solverlab
 #================================================================================================================================
 
 
-def DiffusionEquation_2DSpherical(FECalculation):
+def DiffusionEquation_2DSpherical(FECalculation, fileName):
 
        """ Description : Test solving the diffusion of the temperature T in a solid (default is Uranium). 
                Equation : Thermal diffusion equation  \rho cp dT/dt-\lambda\Delta T=\Phi + \lambda_{sf} (T_{fluid}-T)
@@ -19,34 +19,53 @@ def DiffusionEquation_2DSpherical(FECalculation):
                        The solid may be extra refrigerated by a fluid with transfer coefficient using functions setFluidTemperature and setHeatTransfertCoeff
                        The solid may receive some extra heat power due to nuclear fissions using function setHeatSource
        """
-       
-    # Prepare for the mesh and initial data
-       inputfile="../resources/BoxWithMeshWithTriangularCells";
-       fieldName="Temperature";
+       #Space dimension of the problem
        spaceDim=2
        
     # Mandatory physical values
-       specific_heat=300# specific heat capacity
-       density=10000# density
-       conductivity=5# conductivity
-
-       myProblem = solverlab.DiffusionEquation(spaceDim,FECalculation,density,specific_heat,conductivity);
+       solid_specific_heat=300# specific heat capacity, default value 300
+       solid_density=10000# density, default value 10000
+       solid_conductivity=5# conductivity, default value 5
 
-    # Optional physical values (default value is zero)
-       fluidTemperature=573.;#fluid mean temperature
-       heatTransfertCoeff=1000.;#fluid/solid exchange coefficient
-       constant_heat=1e5;#heat power ddensity
-       myProblem.setFluidTemperature(fluidTemperature);
-       myProblem.setHeatTransfertCoeff(heatTransfertCoeff);
-       myProblem.setHeatSource(constant_heat);
+       myProblem = solverlab.DiffusionEquation(spaceDim,FECalculation,solid_density,solid_specific_heat,solid_conductivity);
 
-    #Initial field load
-       time_iteration=0
-       print("Loading unstructured mesh and initial data" )
+       # Definition of field support parameter
        if( FECalculation):
-               myProblem.setInitialField(inputfile,fieldName,time_iteration, solverlab.NODES)
+               supportOfField=solverlab.NODES
        else:
-               myProblem.setInitialField(inputfile,fieldName,time_iteration, solverlab.CELLS)
+               supportOfField=solverlab.CELLS  
+       
+    # Set the mesh and initial data
+       initial_data_inputfile="../resources/BoxWithMeshWithTriangularCells";
+       initial_data_fieldName="Temperature";
+       print("Loading unstructured mesh and initial data", " in file ", initial_data_inputfile )
+       initial_data_time_iteration=0# default value is 0
+       initial_data_time_sub_iteration=0# default value is 0
+       initial_data_time_meshLevel=0# default value is 0
+       myProblem.setInitialField(initial_data_inputfile, initial_data_fieldName, initial_data_time_iteration, initial_data_time_sub_iteration, initial_data_time_meshLevel, supportOfField)
+
+    #### Optional physical values (default value is zero) : fluid temperature field, heat transfert coefficient, heat power field 
+       # Loading and setting fluid temperature field
+       fluid_temperature_inputfile="../resources/BoxWithMeshWithTriangularCells";
+       fluid_temperature_fieldName="Fluid temperature field";
+       fluid_temperature_time_iteration=0# default value is 0
+       fluid_temperature_time_sub_iteration=0# default value is 0
+       fluid_temperature_meshLevel=0# default value is 0
+       print("Loading field :", fluid_temperature_fieldName, " in file ", fluid_temperature_inputfile)
+       fluidTemperatureField=solverlab.Field(fluid_temperature_inputfile, supportOfField, fluid_temperature_fieldName, fluid_temperature_time_iteration, fluid_temperature_time_sub_iteration, fluid_temperature_meshLevel)
+       myProblem.setFluidTemperatureField(fluidTemperatureField)
+       # Setting heat transfert coefficient
+       heatTransfertCoeff=1000.;#fluid/solid exchange coefficient, default value is 0
+       myProblem.setHeatTransfertCoeff(heatTransfertCoeff);
+       # Loading heat power field
+       heat_power_inputfile="../resources/BoxWithMeshWithTriangularCells";
+       heat_power_fieldName="Heat power field";
+       heat_power_time_iteration=0# default value is 0
+       heat_power_time_sub_iteration=0# default value is 0
+       heat_power_meshLevel=0# default value is 0
+       print("Loading field :", heat_power_fieldName, " in file ", heat_power_inputfile)
+       heatPowerField=solverlab.Field(heat_power_inputfile, supportOfField, heat_power_fieldName, heat_power_time_iteration, heat_power_time_sub_iteration, heat_power_meshLevel)
+       myProblem.setHeatPowerField(heatPowerField)
 
     # the boundary conditions :
        if( FECalculation):
@@ -63,20 +82,16 @@ def DiffusionEquation_2DSpherical(FECalculation):
 
     # set the numerical method
        myProblem.setTimeScheme( solverlab.Explicit);
-       myProblem.setLinearSolver(solverlab.GMRES,solverlab.ILU);
-
-    # name of result file
-       if( FECalculation):
-               fileName = "2DSpherical_FE";
-       else:
-               fileName = "2DSpherical_FV";
+       max_nb_its_lin_solver = 50
+       myProblem.setLinearSolver(solverlab.GMRES, solverlab.ILU, max_nb_its_lin_solver );
 
     # computation parameters
-       MaxNbOfTimeStep = 3 ;
-       freqSave = 1;
-       cfl = 0.95;
-       maxTime = 100000000;
-       precision = 1e-6;
+       MaxNbOfTimeStep = 3 ;# default value is 10
+       freqSave = 1;# default value is 1
+       cfl = 0.95;# default value is 1
+       maxTime = 100000000;# default value is 10
+       precision = 1e-6;# default value is 1e-6
+       result_directory="."# default value = current directory
 
        myProblem.setCFL(cfl);
        myProblem.setPrecision(precision);
@@ -84,20 +99,22 @@ def DiffusionEquation_2DSpherical(FECalculation):
        myProblem.setTimeMax(maxTime);
        myProblem.setFreqSave(freqSave);
        myProblem.setFileName(fileName);
+       myProblem.setResultDirectory(result_directory)
+       myProblem.setSaveFileFormat(solverlab.MED)#default value is solverlab.VTK
 
     # evolution
        myProblem.initialize();
-       print("Running python "+ fileName );
+       print("Running python test "+ fileName );
 
        ok = myProblem.run();
        if (ok):
-               print( "Simulation python " + fileName + " is successful !" );
+               print( "Python simulation " + fileName + " is successful !" );
                pass
        else:
-               print( "Simulation python " + fileName + "  failed ! " );
+               print( "Python simulation " + fileName + "  failed ! " );
                pass
 
-       print( "------------ End of calculation !!! -----------" );
+       print( "------------ End of simulation !!! -----------" );
 
        myProblem.terminate();
        return ok
@@ -105,6 +122,11 @@ def DiffusionEquation_2DSpherical(FECalculation):
 if __name__ == """__main__""":
     if len(sys.argv) >1 :
         FECalculation = bool(int(sys.argv[1]))
-        DiffusionEquation_2DSpherical(FECalculation)
+        # name of result file
+        if( FECalculation):
+               fileName = "2DSpherical_FE";# default value is ""
+        else:
+               fileName = "2DSpherical_FV";# default value is ""
+        DiffusionEquation_2DSpherical(FECalculation, fileName)
     else :
         raise ValueError("DiffusionEquation_2DSpherical : missing one argument")
index de865a0725cc7f544116dffa2f9a2eb3da1c3008..2ae956ab43d262343d00afce2147ec84c8325bee 100755 (executable)
Binary files a/CoreFlows/examples/resources/BoxWithMeshWithTriangularCells.med and b/CoreFlows/examples/resources/BoxWithMeshWithTriangularCells.med differ