13 __author__ = 
'Satish Karra' 
   14 __email__ = 
'satkarra@lanl.gov' 
   18     ''' Return dictionary of domain x,y,z by calling parse_params_file 
   27             Dictionary of domain sizes in x, y, z 
   31         parse_params_file() is in mesh_dfn_helper.py 
   33     _, _, _, _, domain = parse_params_file(quiet=
True)
 
   38     ''' Walk through PFLOTRAN input file and find inflow boundary, inflow and outflow pressure, and direction of flow 
   42         pflotran_input_file : string 
   43             Name of PFLOTRAN input file 
   47         inflow_pressure : double 
   48             Inflow Pressure boundary condition 
   49         outflow_pressure : float 
   50             Outflow pressure boundary condition 
   52             Name of inflow boundary .ex file  
   54             Primary direction of flow x, y, or z 
   58     Currently only works for Dirichlet Boundary Conditions 
   61     with open(pflotran_input_file) 
as fp:
 
   64         for line 
in fp.readlines():
 
   65             if "BOUNDARY_CONDITION OUTFLOW" in line:
 
   69                     outflow = line.split()[-1]
 
   71             if "BOUNDARY_CONDITION INFLOW" in line:
 
   75                     inflow = line.split()[-1]
 
   78     with open(pflotran_input_file) 
as fp:
 
   79         inflow_name_found = 
False 
   80         outflow_name_found = 
False 
   84         for line 
in fp.readlines():
 
   85             if "REGION " + inflow 
in line:
 
   86                 inflow_name_found = 
True 
   89                     inflow_file = line.split()[-1]
 
   90                     inflow_name_found = 
False 
   91             if "FLOW_CONDITION " + inflow 
in line:
 
   94                 if "PRESSURE " in line:
 
   95                     if "dirichlet" not in line:
 
   96                         tmp = line.split()[-1]
 
   98                         inflow_pressure = float(tmp[0]) * 10**float(tmp[1])
 
  101             if "REGION " + outflow 
in line:
 
  102                 outflow_name_found = 
True 
  103             if outflow_name_found:
 
  105                     outflow_file = line.split()[-1]
 
  106                     outflow_name_found = 
False 
  107             if "FLOW_CONDITION " + outflow 
in line:
 
  110                 if "PRESSURE " in line:
 
  111                     if "dirichlet" not in line:
 
  112                         tmp = line.split()[-1]
 
  114                         outflow_pressure = float(tmp[0]) * 10**float(tmp[1])
 
  115                         outflow_found = 
False 
  117     if inflow_file == 
'pboundary_left_w.ex' or inflow_file == 
'pboundary_right_e.ex':
 
  119     if inflow_file == 
'pboundary_front_n.ex' or inflow_file == 
'pboundary_back_s.ex':
 
  121     if inflow_file == 
'pboundary_top.ex' or inflow_file == 
'pboundary_bottom.ex':
 
  124     print(
"Inflow file: %s" % inflow_file)
 
  125     print(
"Inflow Pressure %e" % inflow_pressure)
 
  126     print(
"Outflow Pressure %e" % outflow_pressure)
 
  127     print(
"Primary Flow Direction : %s" % direction)
 
  129     return inflow_pressure, outflow_pressure, inflow_file, direction
 
  133     '''Calculates the flow rate across the inflow boundary 
  137         darcy_vel_file : string 
  138             Name of concatenated Darcy velocity file 
  139         boundary_file : string 
  140              ex file for the inflow boundary 
  145             Mass flow rate across the inflow boundary 
  147             Volumetric flow rate across the inflow boundary 
  157     dat_boundary = np.genfromtxt(boundary_file, skip_header=1)
 
  158     dat = np.genfromtxt(darcy_vel_file)
 
  159     for cell 
in dat_boundary[:, 0]:
 
  160         if (np.any(dat[:, 0] == int(cell))):
 
  161             ids = np.where(dat[:, 0] == int(cell))[0]
 
  163                 cell_up = int(dat[idx, 0])
 
  164                 cell_down = int(dat[idx, 1])
 
  165                 mass_flux = dat[idx, 2]  
 
  166                 density = dat[idx, 3]  
 
  168                 if (cell_up == int(cell)):
 
  169                     mass_rate = mass_flux * area * \
 
  171                     volume_rate = mass_flux * area + volume_rate  
 
  173                     mass_rate = - mass_flux * area * \
 
  175                     volume_rate = -mass_flux * area + volume_rate  
 
  177         if (np.any(dat[:, 1] == int(cell))):
 
  178             ids = np.where(dat[:, 1] == int(cell))[0]
 
  180                 cell_up = int(dat[idx, 0])
 
  181                 cell_down = int(dat[idx, 1])
 
  182                 mass_flux = dat[idx, 2]  
 
  183                 density = dat[idx, 3]  
 
  185                 if (cell_up == int(cell)):
 
  186                     mass_rate = mass_flux * area * \
 
  188                     volume_rate = mass_flux * area + volume_rate  
 
  190                     mass_rate = - mass_flux * area * \
 
  192                     volume_rate = -mass_flux * area + volume_rate  
 
  194     return mass_rate, volume_rate
 
  198                         direction, inflow_pressure, outflow_pressure):
 
  199     '''Compute the effective permeability of the DFN and write it to screen and to the file local_jobname_effective_perm.dat 
  203         local_jobname  : string 
  206             Mass flow rate through inflow boundary 
  208             Volumetric flow rate through inflow boundary 
  210             Primary direction of flow (x, y, or z) 
  212             Dictionary of domain sizes in x, y, z 
  213         inflow_pressure : float 
  214             Inflow boundary pressure 
  215         outflow_pressure : float 
  216             Outflow boundary pressure 
  224     Information is written into (local_jobname)_effective_perm.txt 
  227     Lm3 = domain[
'x'] * domain[
'y'] * domain[
'z']  
 
  230         surface = domain[
'y'] * domain[
'z']
 
  233         surface = domain[
'x'] * domain[
'z']
 
  236         surface = domain[
'x'] * domain[
'y']
 
  240     spery = 3600. * 24. * 365.25  
 
  242     pgrad = (inflow_pressure - outflow_pressure) / L
 
  244     print(
"\n\nEffective Permeabilty Properties\n")
 
  245     fp = open(local_jobname + 
'_effective_perm.txt', 
"w")
 
  246     print(
'The mass flow rate [kg/s]: ' + str(mass_rate))
 
  247     fp.write(
'The mass flow rate [kg/s]: %e\n' % (mass_rate))
 
  248     print(
'The volume flow rate [m3/s]: ' + str(volume_rate))
 
  249     fp.write(
'The volume flow rate [m3/s]: %s\n' % (volume_rate))
 
  250     q = volume_rate / surface  
 
  253         print(
'The darcy flow rate over %f x %f m2 area [m3/m2/s]: %e' %
 
  254               (domain[
'y'], domain[
'z'], q))
 
  255         fp.write(
'The darcy flow rate over %f x %f m2 area [m3/m2/s]: %e\n' %
 
  256                  (domain[
'y'], domain[
'z'], q))
 
  257         print(
'The darcy flow rate over %f x %f m2 area [m3/m2/y]: %e' %
 
  258               (domain[
'y'], domain[
'z'], spery * q))
 
  259         fp.write(
'The darcy flow rate over %f x %f m2 area [m3/m2/y]: %e\n' %
 
  260                  (domain[
'y'], domain[
'z'], spery * q))
 
  263         print(
'The darcy flow rate over %f x %f m2 area [m3/m2/s]: %e' %
 
  264               (domain[
'x'], domain[
'z'], q))
 
  265         fp.write(
'The darcy flow rate over %f x %f m2 area [m3/m2/s]: %e\n' %
 
  266                  (domain[
'x'], domain[
'z'], q))
 
  267         print(
'The darcy flow rate over %f x %f m2 area [m3/m2/y]: %e' %
 
  268               (domain[
'x'], domain[
'z'], spery * q))
 
  269         fp.write(
'The darcy flow rate over %f x %f m2 area [m3/m2/y]: %e\n' %
 
  270                  (domain[
'x'], domain[
'z'], spery * q))
 
  273         print(
'The darcy flow rate over %f x %f m2 area [m3/m2/s]: %e' %
 
  274               (domain[
'x'], domain[
'y'], q))
 
  275         fp.write(
'The darcy flow rate over %f x %f m2 area [m3/m2/s]: %e\n' %
 
  276                  (domain[
'x'], domain[
'y'], q))
 
  277         print(
'The darcy flow rate over %f x %f m2 area [m3/m2/y]: %e' %
 
  278               (domain[
'x'], domain[
'y'], spery * q))
 
  279         fp.write(
'The darcy flow rate over %f x %f m2 area [m3/m2/y]: %e\n' %
 
  280                  (domain[
'x'], domain[
'y'], spery * q))
 
  281     print(
'The effective permeability of the domain [m2]: ' +
 
  283     fp.write(
'The effective permeability of the domain [m2]: %e\n' %
 
  289     '''Computes the effective permeability of a DFN in the primary direction of flow using a steady-state PFLOTRAN solution.  
  302     1. Information is written to screen and to the file self.local_jobname_effective_perm.txt 
  303     2. Currently, only PFLOTRAN solutions are supported 
  304     3. Assumes density of water  
  307     print(
"\n--> Computing Effective Permeability of Block")
 
  308     if not self.flow_solver == 
"PFLOTRAN":
 
  310             "Incorrect flow solver selected. Cannot compute effective permeability" 
  314     darcy_vel_file = 
'darcyvel.dat' 
  315     pflotran_input_file = self.local_dfnFlow_file
 
  320     mass_rate, volume_rate = 
flow_rate(darcy_vel_file, boundary_file)
 
  322                         direction, inflow_pressure, outflow_pressure)
 
  323     print(
"\n--> Complete\n\n")
 
def flow_rate(darcy_vel_file, boundary_file)
 
def dump_effective_perm(local_jobname, mass_rate, volume_rate, domain, direction, inflow_pressure, outflow_pressure)
 
def parse_pflotran_input(pflotran_input_file)