pydfnWorks
python wrapper for dfnWorks
flow.py
Go to the documentation of this file.
1 import os
2 import subprocess
3 import sys
4 import glob
5 import shutil
6 from time import time
7 import numpy as np
8 
9 
10 def set_flow_solver(self, flow_solver):
11  """Sets flow solver to be used
12 
13  Parameters
14  ----------
15  self : object
16  DFN Class
17  flow_solver: string
18  Name of flow solver. Currently supported flow sovlers are FEHM and PFLOTRAN
19 
20  Returns
21  ---------
22 
23  Notes
24  --------
25  Default is PFLOTRAN
26 
27 """
28  if flow_solver == "FEHM" or flow_solver == "PFLOTRAN":
29  print("Using flow solver %s" % flow_solver)
30  self.flow_solver = flow_solver
31  else:
32  error = "ERROR: Unknown flow solver requested %s\nCurrently supported flow solvers are FEHM and PFLOTRAN\nExiting dfnWorks\n" % flow_solver
33  sys.stderr.write(error)
34  sys.exit(1)
35 
36 
37 def dfn_flow(self, dump_vtk=True, effective_perm=True):
38  """ Run the dfnFlow portion of the workflow
39 
40  Parameters
41  ----------
42  self : object
43  DFN Class
44  dump_vtk : bool
45  True - Write out vtk files for flow solutions
46  False - Does not write out vtk files for flow solutions
47 
48  Returns
49  ---------
50 
51  Notes
52  --------
53  Information on individual functions is found therein
54  """
55 
56  print('=' * 80)
57  print("dfnFlow Starting")
58  print('=' * 80)
59 
60  tic_flow = time()
61 
62  if self.flow_solver == "PFLOTRAN":
63  print("Using flow solver: %s" % self.flow_solver)
64  tic = time()
65  self.lagrit2pflotran()
66  self.dump_time('Function: lagrit2pflotran', time() - tic)
67 
68  tic = time()
69  self.pflotran()
70  self.dump_time('Function: pflotran', time() - tic)
71 
72  if dump_vtk:
73  tic = time()
74  self.parse_pflotran_vtk_python()
75  self.dump_time('Function: parse_pflotran_vtk', time() - tic)
76  tic = time()
77  self.pflotran_cleanup()
78  self.dump_time('Function: pflotran_cleanup', time() - tic)
79 
80  tic = time()
81  if effective_perm:
82  self.effective_perm()
83  self.dump_time('Function: effective_perm', time() - tic)
84 
85  elif self.flow_solver == "FEHM":
86  print("Using flow solver: %s" % self.flow_solver)
87  tic = time()
88  self.correct_stor_file()
89  self.fehm()
90  self.dump_time('Function: FEHM', time() - tic)
91 
92  delta_time = time() - tic_flow
93  self.dump_time('Process: dfnFlow', delta_time)
94 
95  print('=' * 80)
96  print("dfnFlow Complete")
97  print("Time Required for dfnFlow %0.2f seconds\n" % delta_time)
98  print('=' * 80)
99 
100 
101 def create_dfn_flow_links(self, path='../'):
102  """ Create symlinks to files required to run dfnFlow that are in another directory.
103 
104  Parameters
105  ---------
106  self : object
107  DFN Class
108  path : string
109  Absolute path to primary directory.
110 
111  Returns
112  --------
113  None
114 
115  Notes
116  -------
117  1. Typically, the path is DFN.path, which is set by the command line argument -path
118  2. Currently only supported for PFLOTRAN
119  """
120  files = [
121  'full_mesh.uge', 'full_mesh.inp', 'full_mesh_vol_area.uge',
122  'materialid.dat', 'full_mesh.stor', 'full_mesh_material.zone',
123  'full_mesh.fehmn', 'allboundaries.zone', 'pboundary_bottom.zone',
124  'pboundary_top.zone', 'pboundary_back_s.zone',
125  'pboundary_front_n.zone', 'pboundary_left_w.zone',
126  'pboundary_right_e.zone', 'perm.dat', 'aperture.dat', 'params.txt'
127  ]
128  for f in files:
129  try:
130  os.symlink(path + f, f)
131  except:
132  print("--> Error Creating link for %s" % f)
def create_dfn_flow_links(self, path='../')
Definition: flow.py:101
def set_flow_solver(self, flow_solver)
Definition: flow.py:10
def dfn_flow(self, dump_vtk=True, effective_perm=True)
Definition: flow.py:37