#pointtoplot = 5 #if list_of_species_toplot !=[]: #module.setInteractivePlot(" module ",list_of_species_toplot,pointtoplot,plotfrequency=30) #module.setInteractiveSpatialPlot([ExpectedOutput('Concentration','Cl',format='table',unit='molal', name='Cl')]) module.run() outTr = module.getOutput("Tr") coordinates = outTr[-1][1].getColumn(0) #print "coordinates", outTr[-1][1].getColumn(0) #print "values", outTr[-1][1].getColumn(-1) numericalSolution = outTr[-1][1].getColumn(-1) analFunction = AnalyticalFunction1D_Tr(outTr[-1][1].getColumn(0)[0:100], C0, 0.0, finalTime, darcy, De + alpha*darcy) analyticalSolution = analFunction.eval() #print analyticalSolution epsilonT = 3.E-2 normTr = normMaxListComparison(numericalSolution[1:15],analyticalSolution[1:15]) #for i in range(1,20): # print i,numericalSolution[i],analyticalSolution[i] #print " norm max ",normTr #print "~~~~~~~~~~~~~~~" #print " Calcite outputs~" #print "~~~~~~~~~~~~~~~~" #outCalcite = module.getOutput("Calcite")[-1][1].getColumn(-1) # #for ind in range (1,20): # print coordinates[ind],outCalcite[ind] # ok = 1 if normTr < epsilonT: print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" print "~ End of the stable sample case ~"
# # Simulation # test.run() # effectiveYoungModulus = test.usE previousEffectiveYoungModulus = [ 1.0436943432360708e-06, 1.0378803775150806e-06, 1.032145715051025e-06, 1.026443038371557e-06, 1.020814421590689e-06, 1.0152107651586925e-06, 1.009658274134666e-06, 1.0041710184809715e-06, 9.98735799030556e-07, 9.933460069422324e-07 ] #previousEffectiveYoungModulus = [1.9151575673985819e-10, 1.8438484993684937e-10, 1.7751043780249623e-10, 1.7086673198657501e-10, 1.6445544059962237e-10, 1.5828989514689877e-10, 1.5232182513198601e-10, 1.4657358054062875e-10, 1.4102192195982855e-10, 1.356688773554728e-10] #[1.9481265572812479e-09, 1.8737673256049104e-09, 1.8039067622339525e-09, 1.7363927593889167e-09, 1.6712422327984073e-09, 1.608588521815435e-09, 1.5479406983083178e-09, 1.4895254491923164e-09, 1.4331087812704512e-09, 1.3787097254768541e-09] norm = normMaxListComparison( previousEffectiveYoungModulus, effectiveYoungModulus[0:len(previousEffectiveYoungModulus)]) effectiveYoungModulus[0:len(previousEffectiveYoungModulus)] print "effectiveYoungModulus ", effectiveYoungModulus[0:len( previousEffectiveYoungModulus)] # print " norm ", norm error = 5.e-5 if norm > error: print "Be careful: error, the Young modulus isn\'t stable" mess = " Problem for the Young modulus evaluation test" raise Warning, " Problem for the Young modulus evaluation test" pass else: print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" print "Good agreement, the result for the evaluation of the effective Young modulus are stable"
R = 1. #Retardation factor for the tracer longDis = 6.67e-4 AnalT = [] from math import exp den = 1./(2.*sqrt(longDis*darcy*time/(porosity*R))) C1 = darcy*time/(porosity*R) x = 0. dx = 0.0008 for dx in dxListe: x+=dx value = erfc((x-C1)*den) value1 = exp(x/longDis)*erfc((x+C1)*den) value = 0.5*C0*(value+value1) AnalT.append(value) tracerNorm = normMaxListComparison(TY.getColumn(2)[0:20],AnalT[0:20]) print 'tracer norm = ',tracerNorm # # R = 1 + Kd*2500*(1-porosity)/porosity (pho = 1 here) # R = 1. + 2 #Retardation factor longDis = 6.67e-4 AnalK = [] from math import exp den = 1./(2.*sqrt(longDis*darcy*time/(porosity*R))) C1 = darcy*time/(porosity*R) x = 0.0002 dx = 0.0004 for dx in dxListe: value = erfc((x-C1)*den)
f_name = "CsdeX_ana.tab" table_Cs_analytic.readFromFile(f_name,nbcolumns = 2,columnsNames = 'no',name = 'no') Cs_analytic = table_Cs_analytic.getColumn(1) print 'Cs_analytic',Cs_analytic[0:50] Cs_numeric = table_Cs_numeric.getColumn(2) print 'Cs_numeric',Cs_numeric[0:50] list1 = [] print 'len(Cs_numeric)',len(Cs_numeric) print 'len(Cs_analytic)',len(Cs_analytic) for i in range(len(Cs_analytic)): list1.append(Cs_analytic[i]) Cs_analytic = list1[0:50] Cs_numeric = Cs_numeric[0:50] CsNorm = normMaxListComparison(Cs_numeric,Cs_analytic) print 'Cs norm = ',CsNorm epsilon_Cs = 10.E-2 if CsNorm > epsilon_Cs: OKConc = 0 message = "Error on the Cs concentration higher than 10% and equal to: "+str(CsNorm) raise Warning, message else : OKConc = 1 print "Good agreement between numerical and analytical results for the Cs concentration, error equal to ", CsNorm print ' ' print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" print " End of the Cesium case ~" print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
for i in range(1,30): dx.append(dx[0]+dx[i-1]) analFunction = analyticalFunction(finalTime, 0.02, dx, 3.e-10) print '================================================= ' print ' comparison to the analytic solution' print '================================================= ' table_Na_numeric = NadeX list_Na_analytic = analFunction.evalNa() list_Na_numeric = table_Na_numeric.getColumn(2) print " ana: ",list_Na_analytic[0:20] print " num: ",list_Na_numeric[0:20] norme_Na = normMaxListComparison(list_Na_numeric[0:30],list_Na_analytic[0:30]) print 'norme_Na = ',norme_Na epsilon_Na = 10.E-2 if norme_Na > epsilon_Na: OKConc = 0 print 'Be carefull: error on the Na concentration higher than 10% and equal to ',norme_Na*100,"%" else : OKConc = 1 print 'Good agreement between numerical and analytical results for the Na concentration, error equal to ',norme_Na*100,"%" print ' ' #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Comparison to analytical pH #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ table_pH_numeric = pHdeX
for i in range(1,30): dx.append(dx[0]+dx[i-1]) analFunction = analyticalFunction(finalTime, 0.02, dx, 3.e-10) table_Na_numeric = NadeX list_Na_numeric = table_Na_numeric.getColumn(2) # on tronque la liste de la solution analytique si elle est trop longue list_Na_analytic = analFunction.evalNa() print " ana: ",list_Na_analytic[0:20] print " num: ",list_Na_numeric[0:20] norme_Na = normMaxListComparison(list_Na_numeric[0:30],list_Na_analytic[0:30]) print 'norme_Na = ',norme_Na epsilon_Na = 10.E-2 if norme_Na > epsilon_Na: OKConc = 0 print 'Be carefull: error on the Na concentration higher than 10% and equal to ', norme_Na else : OKConc = 1 print 'Good agreement between numerical and analytical results for the Na concentration, error equal to ', norme_Na print ' ' print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" print " Comparison to analytical pH ~" print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" table_pH_numeric = pHdeX
refSolution = [\ 6.8114e-05,\ 1.6401e-04,\ 3.1388e-04,\ 4.8294e-04,\ 3.1468e-04,\ 2.3243e-04,\ 2.0708e-04, 2.0124e-04, 2.0018e-04, 2.0002e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-4] K_num = ex11.getOutput('K_output') print K_num absc = K_num[-1][-1].getColumn(0)[0:] knum = K_num[-1][-1].getColumn(3)[0:] print "K =",knum errorNorm = normMaxListComparison(K_num[-1][1].getColumn(3)[1:11],refSolution[0:10]) #for i in range(0,40): # print " %15.10e %15.10e %15.10e "%(absc[i],knum[i],refSolution[i]) # # The front is sharp, so the error control (0.2) is relatively large # print 'error norm = ',errorNorm if errorNorm < 0.2 : print "~~~~~~~~~~~~~~~\nThe results are stable\n~~~~~~~~~~~~~~~\n" else: raise Exception, "~~~~~~~~~~~~~~~\nThe results have significantely changed, check the case\n~~~~~~~~~~~~~~~\n" ex11.end()
den = 1.0 / (2.0 * sqrt(longDis * time / (porosity * R))) C1 = darcy * time / (porosity * R) x = 0.0004 for dx in dxListe: value = erfc((x - C1) * den) value1 = exp(x * darcy / longDis) * erfc((x + C1) * den) value = 0.5 * C0 * (value + value1) AnalT.append(value) x += dx TCompare = [] for i in range(40): if i % 2 != 0: TCompare.append(TY.getColumn(-1)[i]) tracerNorm = normMaxListComparison(TCompare, AnalT[0:20]) print " AnalT =", AnalT[0:30] print "tracer norm = ", tracerNorm # # R = 1 + Kd*2500*(1-porosity)/porosity (pho = 1 here) # R = 3.0 # Retardation factor = 1 + dq/dc = cec*(fraction of exchangeable ion )/aqueous AnalK = [] den = 1.0 / (2.0 * sqrt(longDis * time / (porosity * R))) C1 = darcy * time / (porosity * R) x = 0.0004 for dx in dxListe: value = erfc((x - C1) * den) value1 = exp(x * darcy / longDis) * erfc((x + C1) * den) value = 0.5 * C0 * (value + value1) AnalK.append(value)
# Comparison to reference solution issued from phreeqC # refSolution = [\ 6.8114e-05,\ 1.6401e-04,\ 3.1388e-04,\ 4.8294e-04,\ 3.1468e-04,\ 2.3243e-04,\ 2.0708e-04, 2.0124e-04, 2.0018e-04, 2.0002e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0000e-04, 2.0004e-0] K_num = module.getOutput('K_output') print "K =",K_num[-1][-1].getColumn(2)[0:] errorNorm = normMaxListComparison(K_num[-1][1].getColumn(2)[1:30],refSolution[1:30]) # # The front is sharp, so the error control (0.05) is relatively large # print 'error norm = ',errorNorm if errorNorm < 0.15 : print "~~~~~~~~~~~~~~~\nThe results are stable\n~~~~~~~~~~~~~~~\n" else: raise Exception, "~~~~~~~~~~~~~~~\nThe results have significantely changed, check the case\n~~~~~~~~~~~~~~~\n" #print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" #print " End of the guitest case ~" #print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" module.end()