Exemplo n.º 1
0
 def _changeUnit(self, event):
     newUnit = self.dateUnit.GetValue()
     print newUnit
     oldUnit = self.Unit
     boxes = [ self.startCtrl, self.dt0Ctrl, self.simulationTimeCtrl, self.minTimeStep, self.maxTimeStep ]
     for box in boxes:
         box.SetValue(str(inSecondsConverter(str(box.GetValue()) + ' ' + oldUnit, False)))
         box.SetValue(str(inUnitConverter(box.GetValue(), newUnit)))
     self.Unit = newUnit
Exemplo n.º 2
0
 def _changeUnit(self, event):
     newUnit = self.dateUnit.GetValue()
     print newUnit
     oldUnit = self.Unit
     boxes = [
         self.startCtrl, self.dt0Ctrl, self.simulationTimeCtrl,
         self.minTimeStep, self.maxTimeStep
     ]
     for box in boxes:
         box.SetValue(
             str(
                 inSecondsConverter(
                     str(box.GetValue()) + ' ' + oldUnit, False)))
         box.SetValue(str(inUnitConverter(box.GetValue(), newUnit)))
     self.Unit = newUnit
Exemplo n.º 3
0
    def _onOk(self, params):
        # coupling algotithm
        radio1 = filter(lambda r: r.GetValue(), self.radios1)[0]
        name = radio1.GetLabelText()
        params.getParam(parameters.Iterate_Default_Algorithm).setValue(
            ITERATE_ALGORITHMS_BY_LABEL[name])

        unit = ' ' + self.dateUnit.GetValue()
        # NI time parameters
        self.params.getParam(parameters.Elmer_Time_Stepping_Method).setValue(
            self.TimeSteppingMethod.GetValue())
        self.params.getParam(parameters.Elmer_BDF_Order).setValue(
            self.BDFOrderCtrl.GetValue())
        self.params.getParam(parameters.Elmer_Iterate_InitialTime).setValue(
            float(
                inSecondsConverter(
                    str(self.startCtrl.GetValue()) + unit, False)))
        self.params.getParam(
            parameters.Elmer_Iterate_InitialTimeStep).setValue(
                float(
                    inSecondsConverter(
                        str(self.dt0Ctrl.GetValue()) + unit, False)))
        self.params.getParam(parameters.Elmer_Iterate_SimulationTime).setValue(
            float(
                inSecondsConverter(
                    str(self.simulationTimeCtrl.GetValue()) + unit, False)))
        self.params.getParam(parameters.Elmer_Min_Time_Step).setValue(
            float(
                inSecondsConverter(
                    str(self.minTimeStep.GetValue()) + unit, False)))
        self.params.getParam(parameters.Elmer_Max_Time_Step).setValue(
            float(
                inSecondsConverter(
                    str(self.maxTimeStep.GetValue()) + unit, False)))
        self.params.getParam(parameters.TimeUnit).setValue(self.Unit)
        #
        # CC algorithms
        #
        if self.cc:

            self.params.getParam(parameters.Iterate_Algorithm).setValue("CC")

            picardMaxOfIterations = params.getParam(
                parameters.Iterate_PicardMaxOfIterations)
            value = self.maxPicardCtrl.GetValue()
            picardMaxOfIterations.setValue(str(value))

            picardTargetNumber = params.getParam(
                parameters.Iterate_PicardTargetNumber)
            value = self.targetCtrl.GetValue()
            picardTargetNumber.setValue(str(value))

            epsPicard = params.getParam(parameters.Iterate_CouplingPrecision)
            value = self.epsPicardCtrl.GetValue()
            epsPicard.setValue(str(value))

            dtmin = params.getParam(parameters.Iterate_MinTimeStep)
            value = self.minTimeStep.GetValue()
            dtmin.setValue(int(inSecondsConverter(str(value) + unit, False)))

            dtmax = params.getParam(parameters.Iterate_MaxTimeStep)
            value = self.maxTimeStep.GetValue()
            dtmax.setValue(int(inSecondsConverter(str(value) + unit, False)))

            omegaMin = params.getParam(parameters.Iterate_RelaxationMinFactor)
            value = self.omegaMinCtrl.GetValue()
            omegaMin.setValue(str(value))

            omegaMax = params.getParam(parameters.Iterate_RelaxationMaxFactor)
            value = self.omegaMaxCtrl.GetValue()
            omegaMax.setValue(str(value))
        else:
            self.params.getParam(parameters.Iterate_Algorithm).setValue("NI")

#        print '\n\n\nt0 = ', self.params.getParam(parameters.Elmer_Iterate_InitialTime).getValue()
#        print 'dt0 = ', self.params.getParam(parameters.Elmer_Iterate_InitialTimeStep).getValue()
#        print 'tmax = ', self.params.getParam(parameters.Elmer_Iterate_SimulationTime).getValue()
#        print 'dtmin = ', self.params.getParam(parameters.Elmer_Min_Time_Step).getValue()
#        print 'dtmax = ', self.params.getParam(parameters.Elmer_Max_Time_Step).getValue()
#        print 'maintenant le CC:'
#        print 'dtmin = ', self.params.getParam(parameters.Iterate_MinTimeStep).getValue()
#        print 'dtmax = ', self.params.getParam(parameters.Iterate_MaxTimeStep).getValue()

        return True
Exemplo n.º 4
0
    def _onOk(self, params):
# coupling algotithm        
        radio1 = filter(lambda r: r.GetValue(), self.radios1)[0]
        name = radio1.GetLabelText()
        params.getParam(parameters.Iterate_Default_Algorithm).setValue(ITERATE_ALGORITHMS_BY_LABEL[name])

        unit = ' ' + self.dateUnit.GetValue()
# NI time parameters
        self.params.getParam(parameters.Elmer_Time_Stepping_Method).setValue(self.TimeSteppingMethod.GetValue())
        self.params.getParam(parameters.Elmer_BDF_Order).setValue(self.BDFOrderCtrl.GetValue())
        self.params.getParam(parameters.Elmer_Iterate_InitialTime).setValue(float(inSecondsConverter(str(self.startCtrl.GetValue()) + unit, False)))
        self.params.getParam(parameters.Elmer_Iterate_InitialTimeStep).setValue(float(inSecondsConverter(str(self.dt0Ctrl.GetValue()) + unit, False)))
        self.params.getParam(parameters.Elmer_Iterate_SimulationTime).setValue(float(inSecondsConverter(str(self.simulationTimeCtrl.GetValue()) + unit, False)))
        self.params.getParam(parameters.Elmer_Min_Time_Step).setValue(float(inSecondsConverter(str(self.minTimeStep.GetValue()) + unit, False)))
        self.params.getParam(parameters.Elmer_Max_Time_Step).setValue(float(inSecondsConverter(str(self.maxTimeStep.GetValue()) + unit, False)))
        self.params.getParam(parameters.TimeUnit).setValue(self.Unit) 
#
# CC algorithms
#        
        if self.cc:
            
            self.params.getParam(parameters.Iterate_Algorithm).setValue("CC")
            
            picardMaxOfIterations = params.getParam( parameters.Iterate_PicardMaxOfIterations )
            value = self.maxPicardCtrl.GetValue()
            picardMaxOfIterations.setValue(str(value))

            picardTargetNumber = params.getParam( parameters.Iterate_PicardTargetNumber )
            value = self.targetCtrl.GetValue()
            picardTargetNumber.setValue(str(value))

            epsPicard = params.getParam( parameters.Iterate_CouplingPrecision )
            value = self.epsPicardCtrl.GetValue()
            epsPicard.setValue(str(value))
 
            dtmin = params.getParam( parameters.Iterate_MinTimeStep )
            value = self.minTimeStep.GetValue()
            dtmin.setValue( int(inSecondsConverter(str(value) + unit, False)) )

            dtmax = params.getParam( parameters.Iterate_MaxTimeStep )
            value = self.maxTimeStep.GetValue()
            dtmax.setValue(int(inSecondsConverter(str(value) + unit, False)) )
 
            omegaMin = params.getParam( parameters.Iterate_RelaxationMinFactor )
            value = self.omegaMinCtrl.GetValue()
            omegaMin.setValue(str(value))

            omegaMax = params.getParam( parameters.Iterate_RelaxationMaxFactor )
            value = self.omegaMaxCtrl.GetValue()
            omegaMax.setValue(str(value))
        else:
            self.params.getParam(parameters.Iterate_Algorithm).setValue("NI")
            
#        print '\n\n\nt0 = ', self.params.getParam(parameters.Elmer_Iterate_InitialTime).getValue()
#        print 'dt0 = ', self.params.getParam(parameters.Elmer_Iterate_InitialTimeStep).getValue()
#        print 'tmax = ', self.params.getParam(parameters.Elmer_Iterate_SimulationTime).getValue()
#        print 'dtmin = ', self.params.getParam(parameters.Elmer_Min_Time_Step).getValue()
#        print 'dtmax = ', self.params.getParam(parameters.Elmer_Max_Time_Step).getValue()
#        print 'maintenant le CC:'
#        print 'dtmin = ', self.params.getParam(parameters.Iterate_MinTimeStep).getValue()
#        print 'dtmax = ', self.params.getParam(parameters.Iterate_MaxTimeStep).getValue()

        return True
Exemplo n.º 5
0
def _postProcessing(paramsDict, scriptFile):
    
    materials = paramsDict.getParamValue(parameters.CUSTOM_MATERIAL_DB).getMaterials()
    diffusivity = materials[materials.keys()[0]]["EffectiveDiffusion"]
    
    ExpOutToPlot = paramsDict.getParam(parameters.GlobalOutputs_list).getValue()
    
    if ExpOutToPlot != [] and paramsDict.getParam(parameters.GlobalDates_list).getValue() != []:
        # Converting dates in seconds
        dates = []
        for i in range(len(paramsDict.getParam(parameters.GlobalDates_list).getValue())):
            dates.append(inSecondsConverter(paramsDict.getParam(parameters.GlobalDates_list).getValue()[i]))
        
        
    
    
        scriptFile.write("\ndates = %d"%(dates))
        scriptFile.write("\nNb_meters = 5.")
    
    

        scriptFile.write("if module.getOutput(%s)[-1][0] > {1}:				# Here is checked if results are saved\
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\\n\
	#     Post processing : every plots - Second Method     ~\\n\
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\\n\
	XListe   = module.getOutput(%s)[0][1].getColumn(1)\\n\
	ploting = %d"%(ExpOutToPlot[0], dates[0], ExpOutToPlot))
	
    #scriptFile.write("""
	#h = []
	#h_ind = 0
	#for name in ploting:
	
		# creating lib of the results concerning "name" variable
		
		#name_unk	 = module.getOutput(name)

		#name_back    = []
		#time         = []

		# On recherche les colonnes correspondant aux annees ou l'on veut connaitre la repartition du pH
		#k = 0
		#j = 1
		#while k < len(dates) and j == 1:							# tant qu'il reste des dates (k) et que les precedentes ont ete trouvees (j=1)
			#i = 0
			#j = 0

			#while i < len(name_unk) and j == 0:						# j = 1 signifie que l'on a trouve une date superieure a date[k]

				#if name_unk[i][0] >= dates[k]:
					#name_back.append(name_unk[i][1].getColumn(-1))
					#j=1
					#time.append(name_unk[i][0])
					#i += 1
				#else:
					#i+=1
			
			#k += 1

		
		# ploting the curves together
	


		# units changes
		#if name.lower() == 'porosity': 
			#coef = 100
		#elif name.lower() == 'ph':
			#coef = 1
		#else:
			#coef = 1


		#XListe2 = []
		#maximum  = 0
		#minimum = name_back[0][0]*coef
		#for i in range(len(name_back[0])):
		
		#	if (name.lower() != 'porosity' or i > 1) and XListe[i] <= Nb_meters :				# We delete the porosity terms equal to 0
				#XListe2.append(XListe[i])
	
				#for j in range(len(name_back)):
					#name_back[j][i] = name_back[j][i]*coef
					#if name_back[j][i]>maximum:
					#	maximum = name_back[j][i]
					#if name_back[j][i]<minimum:
					#	minimum = name_back[j][i]
					#if name.lower() != 'porosity':
					#	name_back[j][i-2] = name_back[j][i]

		

		



		#h.append(Gnuplot.Gnuplot(debug=1))
		

		
		#h[h_ind].title(name + ' profiles in case ' + str(module.problem.getName()) + '\\\\nporosity = ' + str(int(module.regions[0].getMaterial().getPorosity().getValue()*100)) + '% | diffusivity = ' + str(round({0}*10**12)/10**12))
		#h[h_ind]('set style data lines')

		# Label and scale of output axis
#		ecart = max(name_back[-1])-min(name_back[-1])
		#ecart = maximum - minimum
		#maximum = maximum + ecart/10
		#minimum = minimum - ecart/10
		#h[h_ind]('set xrange['+ str(minimum) + ':'+ str(maximum) + ']')
		#h[h_ind]('set xtics 0,' + str((maximum-minimum)/4) + "rotate by -20")
		#h[h_ind]('set xlabel "' + str(name) + '"')
		#h[h_ind]('set format x "%.3e"')
		
		#h[h_ind]('set yrange[0:'+ str(Nb_meters) +']')
		#h[h_ind]('set ytics 0,' + str(Nb_meters/4))
		#h[h_ind]('set ylabel "m"')
		#h[h_ind]('set format y "%10.1f"')
		
		
		# Plot
		#h[h_ind].plot(Gnuplot.Data(name_back[0][0:len(XListe2)], XListe2, title=str(int(round(time[0]/3.15576e+7))) +' years' ))
		
		#for j in range(1,len(name_back)):
		#		h[h_ind].replot(Gnuplot.Data(name_back[j][0:len(XListe2)], XListe2, title=str(int(round(time[j]/3.15576e+7))) +' years' ))
		
		# Saving the graphics
		#h[h_ind]('set term postscript portrait')
		#h[h_ind]('set output "'+ module.problem.getName() + '_' + name + '.ps"')
		#h[h_ind]('set size 0.7, 0.7')
		#h[h_ind].plot(Gnuplot.Data(name_back[0][0:len(XListe2)], XListe2, title=str(int(round(time[0]/3.15576e+7))) +' years' ))
		
		#for j in range(1,len(name_back)):
				#h[h_ind].replot(Gnuplot.Data(name_back[j][0:len(XListe2)], XListe2, title=str(int(round(time[j]/3.15576e+7))) +' years' ))

		#h_ind += 1
				
	
	
#else:					# If no results are saved
	#print 'Warning : selected dates are larger than simulation time limit'

#import wx
#wx.MessageDialog(self.parent, "You have to select an output\\nto complete that action."\\
#            , "Warning", wx.OK | wx.ICON_WARNING).ShowModal()

#import time
#time.sleep(3)
	
#""".format(diffusivity))
    
    scriptFile.write("""\nmodule.end()""")
Exemplo n.º 6
0
def _postProcessing(paramsDict, scriptFile):

    materials = paramsDict.getParamValue(
        parameters.CUSTOM_MATERIAL_DB).getMaterials()
    diffusivity = materials[materials.keys()[0]]["EffectiveDiffusion"]

    ExpOutToPlot = paramsDict.getParam(
        parameters.GlobalOutputs_list).getValue()

    if ExpOutToPlot != [] and paramsDict.getParam(
            parameters.GlobalDates_list).getValue() != []:
        # Converting dates in seconds
        dates = []
        for i in range(
                len(
                    paramsDict.getParam(
                        parameters.GlobalDates_list).getValue())):
            dates.append(
                inSecondsConverter(
                    paramsDict.getParam(
                        parameters.GlobalDates_list).getValue()[i]))

        scriptFile.write("\ndates = %d" % (dates))
        scriptFile.write("\nNb_meters = 5.")

        scriptFile.write(
            "if module.getOutput(%s)[-1][0] > {1}:				# Here is checked if results are saved\
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\\n\
	#     Post processing : every plots - Second Method     ~\\n\
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\\n\
	XListe   = module.getOutput(%s)[0][1].getColumn(1)\\n\
	ploting = %d" % (ExpOutToPlot[0], dates[0], ExpOutToPlot))

    #scriptFile.write("""
#h = []
#h_ind = 0
#for name in ploting:

# creating lib of the results concerning "name" variable

#name_unk	 = module.getOutput(name)

#name_back    = []
#time         = []

# On recherche les colonnes correspondant aux annees ou l'on veut connaitre la repartition du pH
#k = 0
#j = 1
#while k < len(dates) and j == 1:							# tant qu'il reste des dates (k) et que les precedentes ont ete trouvees (j=1)
#i = 0
#j = 0

#while i < len(name_unk) and j == 0:						# j = 1 signifie que l'on a trouve une date superieure a date[k]

#if name_unk[i][0] >= dates[k]:
#name_back.append(name_unk[i][1].getColumn(-1))
#j=1
#time.append(name_unk[i][0])
#i += 1
#else:
#i+=1

#k += 1

# ploting the curves together

# units changes
#if name.lower() == 'porosity':
#coef = 100
#elif name.lower() == 'ph':
#coef = 1
#else:
#coef = 1

#XListe2 = []
#maximum  = 0
#minimum = name_back[0][0]*coef
#for i in range(len(name_back[0])):

#	if (name.lower() != 'porosity' or i > 1) and XListe[i] <= Nb_meters :				# We delete the porosity terms equal to 0
#XListe2.append(XListe[i])

#for j in range(len(name_back)):
#name_back[j][i] = name_back[j][i]*coef
#if name_back[j][i]>maximum:
#	maximum = name_back[j][i]
#if name_back[j][i]<minimum:
#	minimum = name_back[j][i]
#if name.lower() != 'porosity':
#	name_back[j][i-2] = name_back[j][i]

#h.append(Gnuplot.Gnuplot(debug=1))

#h[h_ind].title(name + ' profiles in case ' + str(module.problem.getName()) + '\\\\nporosity = ' + str(int(module.regions[0].getMaterial().getPorosity().getValue()*100)) + '% | diffusivity = ' + str(round({0}*10**12)/10**12))
#h[h_ind]('set style data lines')

# Label and scale of output axis
#		ecart = max(name_back[-1])-min(name_back[-1])
#ecart = maximum - minimum
#maximum = maximum + ecart/10
#minimum = minimum - ecart/10
#h[h_ind]('set xrange['+ str(minimum) + ':'+ str(maximum) + ']')
#h[h_ind]('set xtics 0,' + str((maximum-minimum)/4) + "rotate by -20")
#h[h_ind]('set xlabel "' + str(name) + '"')
#h[h_ind]('set format x "%.3e"')

#h[h_ind]('set yrange[0:'+ str(Nb_meters) +']')
#h[h_ind]('set ytics 0,' + str(Nb_meters/4))
#h[h_ind]('set ylabel "m"')
#h[h_ind]('set format y "%10.1f"')

# Plot
#h[h_ind].plot(Gnuplot.Data(name_back[0][0:len(XListe2)], XListe2, title=str(int(round(time[0]/3.15576e+7))) +' years' ))

#for j in range(1,len(name_back)):
#		h[h_ind].replot(Gnuplot.Data(name_back[j][0:len(XListe2)], XListe2, title=str(int(round(time[j]/3.15576e+7))) +' years' ))

# Saving the graphics
#h[h_ind]('set term postscript portrait')
#h[h_ind]('set output "'+ module.problem.getName() + '_' + name + '.ps"')
#h[h_ind]('set size 0.7, 0.7')
#h[h_ind].plot(Gnuplot.Data(name_back[0][0:len(XListe2)], XListe2, title=str(int(round(time[0]/3.15576e+7))) +' years' ))

#for j in range(1,len(name_back)):
#h[h_ind].replot(Gnuplot.Data(name_back[j][0:len(XListe2)], XListe2, title=str(int(round(time[j]/3.15576e+7))) +' years' ))

#h_ind += 1

#else:					# If no results are saved
#print 'Warning : selected dates are larger than simulation time limit'

#import wx
#wx.MessageDialog(self.parent, "You have to select an output\\nto complete that action."\\
#            , "Warning", wx.OK | wx.ICON_WARNING).ShowModal()

#import time
#time.sleep(3)

#""".format(diffusivity))

    scriptFile.write("""\nmodule.end()""")