# Diff of /trunk/finley/test/python/coalgas.py

revision 3486 by gross, Sun Mar 27 22:27:45 2011 UTC revision 3487 by gross, Mon Mar 28 03:44:22 2011 UTC
# Line 439  class DualPorosity(object): Line 439  class DualPorosity(object):
439        self.rho_w = rho_w        self.rho_w = rho_w
440        self.rho_g = rho_g            self.rho_g = rho_g
441        self.wells=wells        self.wells=wells
442          self.t =0
443
444          self.__iter_max=1
445          self.__rtol=1.e-4
446          self.__verbose=False
447       def setIterationControl(self, iter_max=None, rtol=None, verbose=None):
448         """
449         sets parameters to control iteration process
450         """
451         if iter_max !=None: self.__iter_max=iter_max
452         if rtol !=None: self.__rtol = rtol
453         if verbose !=None: self.__verbose=verbose
454
455           def update(self, dt):
456             self.u, self.u_old = self.u.copy(), self.u
457             n=0
458             rerr=1.
459             while n < self.__iter_max and rerr > self.__rtol:
460                u=self.solvePDE(dt)
461            norm_u=Lsup(u)
462            norm_e=Lsup(u-self.u)
463            if norm_u > 0:
464                rerr=norm_e/norm_u
465            else:
466                rerr=norm_e
467            if self.__verbose: print "iteration step %d: relative change = %e"%(n, rerr)
468            n+=1
469            self.u=u
470             print "iteration completed."
471             self.t+=dt
472
473
474  class PorosityOneHalfModel(DualPorosity):  class PorosityOneHalfModel(DualPorosity):
# Line 532  class PorosityOneHalfModel(DualPorosity) Line 559  class PorosityOneHalfModel(DualPorosity)
559          else:          else:
560            self.u[2]=C_mg            self.u[2]=C_mg
561
562        def solvePDE(self):        def solvePDE(self, dt):
563
564       p_f, S_fg, C_mg=self.getState()       p_f, S_fg, C_mg=self.getState()
565       p_f_old, S_fg_old, C_mg_old=self.getOldState()       p_f_old, S_fg_old, C_mg_old=self.getOldState()
566
567             S_fw=1-S_fg
568
569             k_fw=self.k_w(S_fw)
570             k_fg=self.k_g(S_fg)
571             mu_fw=self.mu_w(p_f)
572             mu_fg=self.mu_g(p_f)
573
574
575       phi_f   =self.phi_f.getValue(S_fg)       phi_f   =self.phi_f.getValue(S_fg)
576       dphi_fdp=self.phi_f.getValueDifferential(S_fg)       dphi_fdp=self.phi_f.getValueDifferential(S_fg)
# Line 548  class PorosityOneHalfModel(DualPorosity) Line 582  class PorosityOneHalfModel(DualPorosity)
582       rho_fg = self.rho_g.getValue(p_f)       rho_fg = self.rho_g.getValue(p_f)
583       drho_fgdp  = self.rho_g.getValueDifferential(p_f)       drho_fgdp  = self.rho_g.getValueDifferential(p_f)
584
585       L_g       = self.getValue(p_f)       L_g       = self.L_g.getValue(p_f)
586       dL_gdp =  self.rho_w.getValueDifferential(p_f)       dL_gdp =  self.rho_w.getValueDifferential(p_f)
587
588
589       A_fw = rho_fw * k_fw/mu_fw       A_fw = rho_fw * k_fw/mu_fw
590       A_fg = rho_fg * k_fg/mu_fg       A_fg = rho_fg * k_fg/mu_fg
591

Legend:
 Removed from v.3486 changed lines Added in v.3487