7 Returns a string of appropriate units for different variable
12 name of variable. Acceptable values are aperture, permeability, and transmissivity
16 appropriate units for provided variable
19 if variable ==
"aperture":
21 elif variable ==
"permeability":
23 elif variable ==
"transmissivity":
26 error =
"ERROR!!! The variable of choice '{0}' is not known in the function get_units()\nAcceptable names are aperture, permeability, and transmissivity\nExiting.".format(
28 sys.stderr.write(error)
35 Checks if key is in dict
44 True if key is in dictionary, False if not
48 if key
in dict.keys():
56 Loads fracture information from filename.
61 name of fracture radii file
65 maximum radii of fractures
67 family_id : array of ints
68 family id for each fractures
70 number of fractures in the domain
74 print(
"--> Loading Fracture information from {0}".format(filename))
76 data = np.genfromtxt(filename, skip_header=2)
77 family_id = (data[:, 2]).astype(int)
81 if data[i, 0] >= data[i, 1]:
85 return r, family_id, n
90 converts between variables aperture, permeability, and transmissivity
97 variable name of source
99 variable name of output
103 array of converted values
107 permeability/Transmissivty are defined using the cubic law
111 T = (b^3 rho g)/(12 mu)
119 if source ==
"aperture" and target ==
"permeability":
122 if source ==
"aperture" and target ==
"transmissivity":
123 T = (x**3 * rho * g) / (12 * mu)
125 if source ==
"permeability" and target ==
"aperture":
126 b = np.sqrt((12.0 * x))
129 if source ==
"permeability" and target ==
"transmissivity":
130 b = np.sqrt((12.0 * x))
131 T = (b * x * rho * g) / (12 * mu)
134 if source ==
"transmissivity" and target ==
"aperture":
135 b = ((x * 12 * mu) / (rho * g))**(1 / 3)
137 if source ==
"transmissivity" and target ==
"permeability":
138 b = ((x * 12 * mu) / (rho * g))**(1 / 3)
142 error =
"ERROR!!! Unknown names is convert. Either '{0}' or '{1}' is not known\nAcceptable names are aperture, permeability, and transmissivity\nExiting.\n".format(
144 sys.stderr.write(error)
149 """ Creates Fracture Based Log-Normal values that is number_of_fractures long.
150 The values has a mean mu and log-variance sigma.
155 Dictionary of parameters for the Log Normal values. Must contain keys mu and sigma.
157 name of values being generated. Acceptable values are aperture, permeability, and transmissivity
158 number_of_fractures : int
159 number of fractures in the DFN
167 transmissivity values
171 values are generated for the variable provided. The two remaining variables are derived using those values
173 print(
'--> Creating uncorrelated lognormal {0} values.'.format(variable))
175 print(
"--> Mean: {0} {1}".format(params[
"mu"], units))
176 print(
"--> Log Variance: {0}".format(params[
"sigma"]))
178 if variable ==
"aperture":
179 b = np.log(params[
"mu"]) * np.ones(number_of_fractures)
180 perturbation = np.random.normal(0.0, 1.0, number_of_fractures)
181 b = np.exp(b + np.sqrt(params[
"sigma"]) * perturbation)
183 perm =
convert(b, variable,
"permeability")
184 T =
convert(b, variable,
"transmissivity")
186 elif variable ==
"permeability":
187 perm = np.log(params[
"mu"]) * np.ones(number_of_fractures)
188 perturbation = np.random.normal(0.0, 1.0, number_of_fractures)
189 perm = np.exp(perm + np.sqrt(params[
"sigma"]) * perturbation)
191 b =
convert(perm, variable,
"aperture")
192 T =
convert(perm, variable,
"transmissivity")
194 elif variable ==
"transmissivity":
195 T = np.log(params[
"mu"]) * np.ones(number_of_fractures)
196 perturbation = np.random.normal(0.0, 1.0, number_of_fractures)
197 T = np.exp(T + np.sqrt(params[
"sigma"]) * perturbation)
199 b =
convert(T, variable,
"aperture")
200 perm =
convert(T, variable,
"permeability")
203 error =
"ERROR!!! The variable of choice '{0}'' is not known\nAcceptable names are aperture, permeability, and transmissivity\nExiting.\n".format(
205 sys.stderr.write(error)
207 print(
'--> Complete\n')
212 """ Creates hydraulic properties of fractures based on power-law relationship with
213 fracture radius. For example, T = alpha*r^beta
218 Dictionary of parameters for the power-law relationship. Must contain alpha and beta.
220 name of values being generated. Acceptable values are aperture, permeability, and transmissivity
222 array of fracture radii in the domain
231 transmissivity values
235 Values are generated for the variable provided. The two remaining variables are derived using those values
238 '--> Creating Perfectly Correlated {0} values based on fracture radius.'
241 if variable ==
"aperture":
242 print(
"b ={1}*r^{2} {3}".format(variable, params[
"alpha"],
243 params[
"beta"], units))
244 if variable ==
"permeability":
245 print(
"k ={1}*r^{2} {3}".format(variable, params[
"alpha"],
246 params[
"beta"], units))
247 if variable ==
"transmissivity":
248 print(
"T ={1}*r^{2} {3}".format(variable, params[
"alpha"],
249 params[
"beta"], units))
251 if variable ==
"aperture":
252 b = params[
"alpha"] * radii**params[
"beta"]
254 perm =
convert(b, variable,
"permeability")
255 T =
convert(b, variable,
"transmissivity")
257 elif variable ==
"permeability":
258 perm = params[
"alpha"] * radii**params[
"beta"]
260 b =
convert(perm, variable,
"aperture")
261 T =
convert(perm, variable,
"transmissivity")
263 elif variable ==
"transmissivity":
264 T = params[
"alpha"] * radii**params[
"beta"]
265 b =
convert(T, variable,
"aperture")
266 perm =
convert(T, variable,
"permeability")
268 print(
"--> Complete\n")
273 """ Creates hydraulic properties of fractures based on power-law relationship with
274 fracture radius with a noise term. For example, log(T) = log(alpha*r^beta) + sigma * N(0,1)
279 Dictionary of parameters for the power-law relationship. Must contain alpha and beta.
281 name of values being generated. Acceptable values are aperture, permeability, and transmissivity
283 array of fracture radii in the domain
284 number_of_fractures : int
285 number of fractures in the DFN
294 transmissivity values
298 Values are generated for the variable provided. The two remaining variables are derived using those values
300 print(
"--> Creating Semi-Correlated {0} values based on fracture radius.".
302 print(
'--> Coefficient: {0}'.format(params[
"alpha"]))
303 print(
'--> Exponent : {0}'.format(params[
"beta"]))
304 print(
'--> Log Variance: {0}'.format(params[
"sigma"]))
306 if variable ==
"aperture":
307 b = params[
"alpha"] * radii**params[
"beta"]
308 perturbation = np.random.normal(0.0, 1.0, number_of_fractures)
309 b = np.exp(np.log(b) + np.sqrt(params[
"sigma"]) * perturbation)
311 perm =
convert(b, variable,
"permeability")
312 T =
convert(b, variable,
"transmissivity")
314 elif variable ==
"permeability":
316 perm = params[
"alpha"] * radii**params[
"beta"]
317 perturbation = np.random.normal(0.0, 1.0, number_of_fractures)
318 perm = np.exp(np.log(perm) + np.sqrt(params[
"sigma"]) * perturbation)
320 b =
convert(perm, variable,
"aperture")
321 T =
convert(perm, variable,
"transmissivity")
323 elif variable ==
"transmissivity":
325 T = params[
"alpha"] * radii**params[
"beta"]
326 perturbation = np.random.normal(0.0, 1.0, number_of_fractures)
327 T = np.exp(np.log(T) + np.sqrt(params[
"sigma"]) * perturbation)
328 b =
convert(T, variable,
"aperture")
329 perm =
convert(T, variable,
"permeability")
331 print(
'--> Complete\n')
335 def constant(params, variable, number_of_fractures):
336 """ Creates hydraulic properties of fractures with constant values
341 Dictionary of parameters for the power-law relationship. Must contain alpha and beta.
343 name of values being generated. Acceptable values are aperture, permeability, and transmissivity
344 number_of_fractures : int
345 number of fractures in the DFN
354 transmissivity values
362 transmissivity values
366 Values are generated for the variable provided. The two remaining variables are derived using those values
369 print(
"--> Creating constant {0} values.".format(variable))
371 print(
"--> Value: {0} {1}".format(params[
"mu"], units))
373 if variable ==
"aperture":
374 b = params[
"mu"] * np.ones(number_of_fractures)
375 perm =
convert(b, variable,
"permeability")
376 T =
convert(b, variable,
"transmissivity")
378 elif variable ==
"permeability":
380 perm = params[
"mu"] * np.ones(number_of_fractures)
381 b =
convert(perm, variable,
"aperture")
382 T =
convert(perm, variable,
"transmissivity")
384 elif variable ==
"transmissivity":
386 T = params[
"mu"] * np.ones(number_of_fractures)
387 b =
convert(T, variable,
"aperture")
388 perm =
convert(T, variable,
"permeability")
390 print(
'--> Complete\n')
395 """ Writes variable information to files.
400 prefix of aperture.dat and perm.dat file names
401 prefix_aperture.dat and prefix_perm.dat
407 transmissivity values
415 print(
"--> Dumping values to files")
418 if prefix
is not None:
419 aper_filename = prefix +
'_aperture.dat'
420 perm_filename = prefix +
'_perm.dat'
421 trans_filename = prefix +
'_transmissivity.dat'
423 aper_filename =
"aperture.dat"
424 perm_filename =
"perm.dat"
425 trans_filename =
"transmissivity.dat"
428 print(
"--> Writing {0}".format(aper_filename))
429 with open(aper_filename,
'w+')
as fp:
430 fp.write(
'aperture\n')
432 fp.write(
'-{0:d} 0 0 {1:0.5e}\n'.format(i + 7, b[i]))
435 print(
"--> Writing {0}".format(perm_filename))
436 with open(perm_filename,
'w+')
as fp:
437 fp.write(
'permeability\n')
439 fp.write(
'-{0:d} 0 0 {1:0.5e} {1:0.5e} {1:0.5e}\n'.format(
442 print(f
"--> Writing {trans_filename}")
443 with open(trans_filename,
'w+')
as fp:
444 fp.write(
'transmissivty\n')
446 fp.write(
'-{0:d} {1:0.5e}\n'.format(i + 7, T[i]))
454 radii_filename="radii_Final.dat",
456 """ Generates hydraulic property values.
462 relationship : string
463 name of functional relationship for apertures.
464 options are log-normal, correlated, semi-correlated, and
467 dictionary of parameters for functional relationship
469 family id of fractures
478 transmissivity values
480 true / false of fracture families requested. If family_id = None, all entires are true.
481 Only family members entires of b, perm, and T will be non-zero
485 See Hyman et al. 2016 "Fracture size and transmissivity correlations: Implications for transport simulations in sparse
486 three-dimensional discrete fracture networks following a truncated power law distribution of fracture size" Water Resources Research for more details
490 variables = [
"aperture",
"permeability",
"transmissivity"]
491 if variable
not in variables:
492 error =
"ERROR!!! The variable of choice '{0}'' is not known\nAcceptable names are {1}, {2}, {3}\nExiting.\n".format(
493 variable, variables[0], variables[1], variables[2])
494 sys.stderr.write(error)
502 functions = [
"log-normal",
"semi-correlated",
"constant",
"correlated"]
503 if relationship
not in functions:
504 error =
"ERROR!!! The provided relationship '{0}' is unknown\nAcceptable relationship are {1}, {2}, {3}, {4}\nExiting.\n".format(
505 relationship, functions[0], functions[1], functions[2],
507 sys.stderr.write(error)
515 radii, families, number_of_fractures =
load_fractures(radii_filename,
517 if family_id
is not None:
518 print(
"--> Working on Fracture Family {0}".format(family_id))
520 if relationship ==
"log-normal":
521 keys = [
"mu",
"sigma"]
524 error =
"ERROR!!! The required key '{0}' was not found in the params dictionary\nExiting\n".format(
526 sys.stderr.write(error)
528 b, perm, T =
log_normal(params, variable, number_of_fractures)
530 if relationship ==
"correlated":
531 keys = [
"alpha",
"beta"]
534 error =
"ERROR!!! The required key '{0}' was not found in the params dictionary\nExiting\n".format(
536 sys.stderr.write(error)
538 b, perm, T =
correlated(params, variable, radii)
540 if relationship ==
"semi-correlated":
541 keys = [
"alpha",
"beta",
"sigma"]
544 error =
"ERROR!!! The required key '{0}' was not found in the params dictionary\nExiting\n\n".format(
546 sys.stderr.write(error)
551 if relationship ==
"constant":
555 error =
"ERROR!!! The required key '{0}' was not found in the params dictionary\nExiting\n\n".format(
557 sys.stderr.write(error)
559 b, perm, T =
constant(params, variable, number_of_fractures)
561 if family_id ==
None:
565 idx = np.where(families != family_id)
def generate_hydraulic_values(self, variable, relationship, params, radii_filename="radii_Final.dat", family_id=None)
def semi_correlated(params, variable, radii, number_of_fractures)
def correlated(params, variable, radii)
def load_fractures(filename, quiet)
def dump_hydraulic_values(self, b, perm, T, prefix=None)
def log_normal(params, variable, number_of_fractures)
def constant(params, variable, number_of_fractures)
def convert(x, source, target)