From: michael Date: Wed, 24 Nov 2021 15:00:42 +0000 (+0100) Subject: Updated python diffusion tests X-Git-Tag: V9_8_0~33 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fc4fd23dd68ee05f057efdb2c22430ab782135b4;p=tools%2Fsolverlab.git Updated python diffusion tests --- diff --git a/CoreFlows/examples/Python/DiffusionEquation/DiffusionEquation_1DHeatedRod.py b/CoreFlows/examples/Python/DiffusionEquation/DiffusionEquation_1DHeatedRod.py index 333936a..e6bf404 100755 --- a/CoreFlows/examples/Python/DiffusionEquation/DiffusionEquation_1DHeatedRod.py +++ b/CoreFlows/examples/Python/DiffusionEquation/DiffusionEquation_1DHeatedRod.py @@ -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"; diff --git a/CoreFlows/examples/Python/DiffusionEquation/DiffusionEquation_1DHeatedRod_FE.py b/CoreFlows/examples/Python/DiffusionEquation/DiffusionEquation_1DHeatedRod_FE.py index 920869d..3e7fc30 100755 --- a/CoreFlows/examples/Python/DiffusionEquation/DiffusionEquation_1DHeatedRod_FE.py +++ b/CoreFlows/examples/Python/DiffusionEquation/DiffusionEquation_1DHeatedRod_FE.py @@ -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"; diff --git a/CoreFlows/examples/Python/DiffusionEquation/DiffusionEquation_2DSpherical.py b/CoreFlows/examples/Python/DiffusionEquation/DiffusionEquation_2DSpherical.py index cd47f4b..8330537 100644 --- a/CoreFlows/examples/Python/DiffusionEquation/DiffusionEquation_2DSpherical.py +++ b/CoreFlows/examples/Python/DiffusionEquation/DiffusionEquation_2DSpherical.py @@ -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") diff --git a/CoreFlows/examples/resources/BoxWithMeshWithTriangularCells.med b/CoreFlows/examples/resources/BoxWithMeshWithTriangularCells.med index de865a0..2ae956a 100755 Binary files a/CoreFlows/examples/resources/BoxWithMeshWithTriangularCells.med and b/CoreFlows/examples/resources/BoxWithMeshWithTriangularCells.med differ