9 """Primary driver for dfnTrans.
21 print(
"\ndfnTrans Starting\n")
24 self.copy_dfn_trans_files()
25 self.check_dfn_trans_run_files()
27 delta_time = time() - tic
28 self.dump_time(
'Process: dfnTrans', delta_time)
30 print(
"\ndfnTrans Complete\n")
31 print(
"Time Required for dfnTrans: %0.2f Seconds\n" % delta_time)
36 """Creates symlink to dfnTrans Execuateble and copies input files for dfnTrans into working directory
48 print(
"Attempting to Copy %s\n" % self.dfnTrans_file)
50 shutil.copy(self.dfnTrans_file, os.path.abspath(os.getcwd()))
52 print(
"--> Problem copying %s file" % self.local_dfnTrans_file)
53 print(
"--> Trying to delete and recopy")
54 os.remove(self.local_dfnTrans_file)
55 shutil.copy(self.dfnTrans_file, os.path.abspath(os.getcwd()))
57 print(
"--> ERROR: Problem copying %s file\n" % self.dfnTrans_file)
58 error =
"Unable to replace. Exiting Program\n"
59 sys.stderr.write(error)
76 failure = subprocess.call(os.environ[
'DFNTRANS_EXE'] +
' ' +
77 self.local_dfnTrans_file,
79 self.dump_time(
"Function: DFNTrans ", time() - tic)
81 error =
"--> ERROR: dfnTrans did not complete\n"
82 sys.stderr.write(error)
87 """ Create symlinks to files required to run dfnTrans that are in another directory.
94 Absolute path to primary directory.
102 Typically, the path is DFN.path, which is set by the command line argument -path
106 'params.txt',
'allboundaries.zone',
'full_mesh.stor',
'poly_info.dat',
107 'full_mesh.inp',
'aperture.dat'
109 if self.flow_solver ==
'PFLOTRAN':
110 files.append(
'cellinfo.dat')
111 files.append(
'darcyvel.dat')
112 files.append(
'full_mesh_vol_area.uge')
113 if self.flow_solver ==
'FEHM':
114 files.append(
'tri_frac.fin')
118 os.symlink(path + f, f)
120 print(
"--> Error Creating link for %s\n" % f)
124 """ Ensures that all files required for dfnTrans run are in the current directory
141 "\nChecking that all files required for dfnTrans are in the current directory"
143 print(
"--> Current Working Directory: %s" % cwd)
144 print(
"--> dfnTrans is running from: %s" % self.local_dfnTrans_file)
146 print(
"--> Checking DFNTrans Parameters")
161 "out_filetemp:":
None,
165 "ControlPlane:":
None,
166 "control_out:":
None,
167 "delta_Control:":
None,
174 "init_totalnumber:":
None,
175 "init_oneregion:":
None,
178 "init_nodepart:":
None,
185 "init_random:":
None,
186 "in_randpart:":
None,
187 "init_matrix:":
None,
190 "inm_porosity:":
None,
191 "inm_diffcoeff:":
None,
192 "streamline_routing:":
None,
194 "tdrw_porosity:":
None,
195 "tdrw_diffcoeff:":
None,
198 "flux_weight:":
None,
200 "in-flow-boundary:":
None,
201 "out-flow-boundary:":
None,
203 "aperture_type:":
None,
204 "aperture_file:":
None,
211 files = [
"param:",
"poly:",
"inp:",
"stor:",
"boundary:"]
213 if self.flow_solver ==
"PFLOTRAN":
214 params[
"PFLOTRAN_vel:"] =
None
215 files.append(
"PFLOTRAN_vel:")
217 params[
"PFLOTRAN_cell:"] =
None
218 files.append(
"PFLOTRAN_cell:")
220 params[
"PFLOTRAN_uge:"] =
None
221 files.append(
"PFLOTRAN_uge:")
223 if self.flow_solver ==
"FEHM":
224 params[
"FEHM_fin:"] =
None
225 files.append(
"FEHM_fin:")
229 with open(self.local_dfnTrans_file)
as fp:
231 for line
in fp.readlines():
234 line = line[:line.index(
237 line = line[:line.index(
"//")]
242 if params[key] ==
None:
243 params[key] = line.split()[1]
250 if params[key]
is None:
251 error = f
"ERROR!!!!!\nRequired file {key} was not provided.\nPlease check DFNTrans control file\nExiting Program\n"
252 sys.stderr.write(error)
254 elif not os.path.isfile(params[key]):
255 error =
"ERROR!!!!!\nRequired file %s is not the current directory.\nPlease check required files\nExiting Program\n" % params[
257 sys.stderr.write(error)
261 "--> All files required for dfnTrans have been found in current directory\n\n"
265 "out_grid:",
"out_3dflow:",
"out_init:",
"out_tort:",
"out_curv:",
266 "out_avs:",
"out_traj:",
"out_fract:",
"out_filetemp:",
"out_dir:",
267 "out_path:",
"out_time:",
"timesteps:",
"time_units:",
268 "flux_weight:",
"seed:",
"in-flow-boundary:",
"out-flow-boundary:",
269 "aperture:",
"porosity",
"density:",
"satur:",
270 "streamline_routing:"
272 if params[required] ==
None:
273 error =
"ERROR!!!\n%s not provided. Exiting\n\n" % (required)
274 sys.stderr.write(error)
279 print(
"--> Checking Initial Conditions")
280 initial_conditions = [
281 (
"init_nf:",
"init_partn:"), (
"init_eqd:",
"init_npart:"),
282 (
"init_fluxw:",
"init_totalnumber:"), (
"init_random:",
"in_randpart:"),
283 (
"init_oneregion:",
"in_partn:",
"in_xmin:",
"in_ymin:",
"in_zmin:",
284 "in_xmax:",
"in_ymax:",
"in_zmax:"),
285 (
"init_matrix:",
"inm_coord:",
"inm_nodeID:",
"inm_porosity:"),
286 (
"init_well:",
"init_nodepart:")
289 for ic
in initial_conditions:
291 if params[ic[0]] ==
"yes":
292 ic_selected.append(ic[0])
294 if params[i] ==
None:
295 error =
"Initial condition %s selected but %s not provided\n" % (
297 sys.stderr.write(error)
299 if len(ic_selected) > 1:
300 error =
"ERROR!!! More than one initial condition defined\nExiting\n"
301 sys.stderr.write(error)
302 print(
"Selected Initial Conditions:\n:")
303 for ic
in ic_selected:
307 elif len(ic_selected) == 0:
308 error =
"ERROR!!! No initial condition defined\nExiting\n"
309 sys.stderr.write(error)
312 if params[
"ControlPlane:"] !=
None:
313 for required
in [
"control_out:",
"delta_Control:",
"flowdir:"]:
314 if params[required] ==
None:
315 error =
"Parameter %s required for ControlPlane\n" % required
316 sys.stderr.write(error)
319 if params[
"tdrw:"] ==
"yes":
320 if params[
"time_units:"] !=
"seconds":
321 error =
"ERROR!!!You must use seconds for the time_units to run TDRW"
322 sys.stderr.write(error)
325 for required
in [
"tdrw_porosity:",
"tdrw_diffcoeff:"]:
326 if params[required] ==
None:
327 error =
"Parameter %s required for tdrw\n" % required
328 sys.stderr.write(error)
331 if params[
"aperture:"] ==
"yes":
332 if params[
"aperture_type:"] ==
None:
333 error =
"Parameter aperture_type: required for aperture: yes\n"
334 sys.stderr.write(error)
338 if not os.path.isfile(params[
"aperture_file:"])
or os.stat(
339 params[
"aperture_file:"]).st_size == 0:
340 error =
"aperture_file: %s not found or empty\n" % params[
342 sys.stderr.write(error)
346 if params[
"thickness:"] ==
None:
347 error =
"Parameter thickness: required for aperture: no:\n"
348 sys.stderr.write(error)
351 print(
"--> Checking Initial Conditions Complete")
def create_dfn_trans_links(self, path='../')
def check_dfn_trans_run_files(self)
def copy_dfn_trans_files(self)