-
Notifications
You must be signed in to change notification settings - Fork 10
/
fdata.py
7752 lines (7349 loc) · 338 KB
/
fdata.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""Class for FEHM data"""
"""
Copyright 2013.
Los Alamos National Security, LLC.
This material was produced under U.S. Government contract DE-AC52-06NA25396 for
Los Alamos National Laboratory (LANL), which is operated by Los Alamos National
Security, LLC for the U.S. Department of Energy. The U.S. Government has rights
to use, reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR LOS
ALAMOS NATIONAL SECURITY, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES
ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified to produce
derivative works, such modified software should be clearly marked, so as not to
confuse it with the version available from LANL.
Additionally, this library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2.1 of the License, or (at your option)
any later version. Accordingly, this library is distributed in the hope that it
will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
"""
import numpy as np
from copy import copy, deepcopy
import os,time,platform,shutil
from subprocess import Popen, PIPE
from time import sleep
from collections import Counter
import Tkinter as tk
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
from matplotlib.patches import Rectangle
try: import ctypes; has_ctypes = True
except: has_ctypes = False
try:
from matplotlib import pyplot as plt
#plt.ion()
from mpl_toolkits.mplot3d import axes3d
from matplotlib import cm
from matplotlib.pylab import subplots,close
except ImportError:
'placeholder'
from fgrid import*
from fvars import*
from fpost import*
from fdflt import*
from fhelp import*
dflt = fdflt()
WINDOWS = platform.system()=='Windows'
if not WINDOWS: has_ctypes = False
# list of macros that might be encountered
fdata_sections = ['cont','pres','zonn','zone','cond','time','ctrl','iter','rock','perm',
'boun','flow','strs','text','sol','nfin','hist','node','carb','rlp','grad','nobr',
'flxz','rlpm','hflx','trac','vcon','ppor','vapl','adif','ngas','flxo','head','flxn','air','airwater']
# list of potential CONTOUR output variables
contour_variables=[['strain','stress'],
['co2'],
['vapor','dp','grid','capillary','density','displacement','fhydrate','flux','permeability','porosity','source','velocity','wt','zid'],
['formatted','material','liquid','geo','nodit','concentration','head','pressure','saturation','temperature','xyz','zone']]
# list of potential HISTORY output variables
history_variables=['deg','temperature','mpa','pressure','head','meters','feet','saturation','wco','flow','kgs',
'enthalpy','efl','mjs','density','humidity','viscosity','zflux','concentration','wt','co2s',
'co2sl','co2sg','co2m','co2mt','co2mf','co2md','cfluxz','displacements','disx','disy','disz',
'stress','strsx','strsy','strsz','strsxy','strsxz','strsyz','strain','rel','global']
# dictionary of perm model parameters, indexed by perm model number, ORDER OF LIST MUST EQUAL ORDER OF INPUT
permDicts = dict((
(1,[]),
(21,['nx','ny','nz','frict_coef','cohesion','pore_press_factor','tau_ex_ramp_range',
'yngs_mod_mult_x','yngs_mod_mult_y','yngs_mod_mult_z','perm_mult_x','perm_mult_y','perm_mult_z']),
(22,['frict_coef','cohesion','pore_press_factor','tau_ex_ramp_range','yngs_mod_mult_x','yngs_mod_mult_y',
'yngs_mod_mult_z','perm_mult_x','perm_mult_y','perm_mult_z','por_mult','perm_incremental','tau_ex_init']),
(24,['shear_frac_tough','static_frict_coef','dynamic_frict_coef','frac_num','onset_disp',
'disp_interval','max_perm_change','frac_cohesion','frac_dens']),
(25,['shear_frac_tough',
'static_frict_coef','dynamic_frict_coef','frac_num','onset_disp','disp_interval','max_perm_change',
'frac_cohesion']),
(100,['perm_mult_x','perm_mult_y','perm_mult_z','ramp_range']),
))
# dictionary of plastic model parameters, indexed by plastic model number, ORDER OF LIST MUST EQUAL ORDER OF INPUT
plasticDicts = dict((
(3,['youngs_modulus','poissons_ratio','eta_drucker','zeta_drucker','c_drucker']),
))
# dictionary of perm model units, indexed by perm model number, ORDER OF LIST MUST EQUAL ORDER OF INPUT
permUnits = dict((
(1,[]),
(21,['','','','','MPa','','MPa','','','','','','']),
(22,['','MPa','','MPa','','','','','','','','','MPa']),
(24,['MPa/m','','','','m','m','log(m^2)','MPa','']),
(25,['MPa/m','','','','m','m','log(m^2)','MPa']),
(100,['','','','MPa']),
))
# dictionary of relative permeability model parameters, indexed by model number, ORDER OF LIST MUST EQUAL ORDER OF INPUT
rlpDicts = dict((
(-1,['liq_rel_perm','vap_rel_perm','cap_pres_zero_sat','sat_zero_cap_pres']),
(1,['resid_liq_sat','resid_vap_sat','max_liq_sat','max_vap_sat','cap_pres_zero_sat','sat_zero_cap_pres']),
(2,['resid_liq_sat','resid_vap_sat','cap_pres_zero_sat','sat_zero_cap_pres']),
(3,['resid_liq_sat','resid_vap_sat','inv_air_entry_head','power_exponent',
'low_sat_fit_param','cutoff_sat']),
(16,['resid_water_sat','max_water_sat','water_exp','resid_co2_sat','max_co2_sat','co2_exp',
'co2_water_Pc_exp','co2_water_Pc_max']),
(17,['resid_water_sat','max_water_sat','water_exp','resid_co2liq_sat','max_co2liq_sat','co2liq_exp',
'co2gasliq_exp','resid_co2gas_sat','max_co2gas_sat','co2gas_exp','co2liq_water_Pc_exp','co2liq_water_Pc_max',
'co2liq_co2gas_Pc_exp','co2liq_co2gas_Pc_max']),
))
adsorptionDicts = dict((
(0,['alpha1','alpha2','beta']), # conservative solute
(1,['alpha1','alpha2','beta']), # linear sorption isotherm
(2,['alpha1','alpha2','beta']), # Freundlich sorption isotherm
(3,['alpha1','alpha2','beta']), # Modified Freundlich sorption isotherm
(4,['alpha1','alpha2','beta']), # Langmuir sorption isotherm
))
diffusionDicts = dict((
(0,['diffusion','dispersion_x','dispersion_y','dispersion_z']), # molecular diffusion coefficient is constant
(1,['diffusion','dispersion_x','dispersion_y','dispersion_z']), # Millington Quark diffusion model
(2,['diffusion','dispersion_x','dispersion_y','dispersion_z']), # Conca Wright diffusion model
(3,['diffusion','dispersion_x','dispersion_y','dispersion_z']), # calculated from adif
))
vconDicts = dict((
(1,['T_ref','cond_ref','dcond_dT']), # linear variation of thermal conductivity with temperature
(2,['cond_s1','cond_s0']), # square root variation of thermal conductivity with liquid saturation
(3,['T_ref','cond_ref','exponent']), # intact salt
(4,['T_ref','cond_ref','coeff_phi4','coeff_phi3','coeff_phi2','coeff_phi1','coeff_phi0','exponent']), # crushed salt
))
pporDicts = dict((
(1,['compressibility']), # aquifer compressibility
(-1,['specific_storage']), # specific storage
(-2,['exponent','Px']), # gangi model
(7,['param1','param2','param3','param4']), # unknown - salt
))
model_list = dict((('permmodel',permDicts),
('plasticmodel',plasticDicts),
('rlp',rlpDicts),
('vcon',vconDicts),
('ppor',pporDicts),
('adsorption',adsorptionDicts),
('diffusion',diffusionDicts)))
model_titles = dict((('rlp','RELATIVE PERMEABILITY'),
('permmodel',''),
('plasticmodel',''),
('vcon','VARIABLE THERMAL CONDUCTIVITY'),
('ppor','VARIABLE POROSITY'),
('dispersion',''),
('adsorption',''),
))
# list of macros
fpres = (('pressure',None),('temperature',None),('saturation',None))
fperm = (('kx',None),('ky',None),('kz',None))
fcond = (('cond_x',None),('cond_y',None),('cond_z',None))
fflow = (('rate',None),('energy',None),('impedance',None))
frock = (('density',None),('specific_heat',None),('porosity',None))
fgrad = (('reference_coord',None),('direction',None),('variable',None),('reference_value',None),('gradient',None))
fbiot = (('thermal_expansion',None),('pressure_coupling',None))
felastic = (('youngs_modulus',None),('poissons_ratio',None))
fbodyforce = (('fx',None),('fy',None),('fz',None))
fco2frac = (('water_rich_sat',None),('co2_rich_sat',None),('co2_mass_frac',None),('init_salt_conc',None),('override_flag',None))
fco2flow = (('rate',None),('energy',None),('impedance',None),('bc_flag',None))
fco2diff = (('diffusion',None),('tortuosity',None))
fco2pres = (('pressure',None),('temperature',None),('phase',None))
fstressboun = (('value',None),('direction',None))
fhflx = (('heat_flow',None),('multiplier',None))
ftpor = (('tracer_porosity',None),)
macro_list = dict((('pres',fpres),('perm',fperm),('cond',fcond),('flow',fflow),('rock',frock),
('biot',fbiot),('elastic',felastic),('bodyforce',fbodyforce),('co2frac',fco2frac),('co2flow',fco2flow),
('co2pres',fco2pres),('co2diff',fco2diff),
('stressboun',fstressboun),('grad',fgrad),('hflx',fhflx),('tpor',ftpor)))
# potential nodal properties
node_props = ('kx','ky','kz','cond_x','cond_y','cond_z','density','specific_heat','porosity','thermal_expansion','pressure_coupling',
'youngs_modulus','poissons_ratio')
node_gen = ('rate','energy','impedance')
macro_titles = dict((('pres','INITIAL TEMPERATURE AND PRESSURE'),
('perm','PERMEABILITY'),
('cond','ROCK CONDUCTIVITY'),
('flow','GENERATORS'),
('hflx',''),
('rock','MATERIAL PARAMETERS'),
('grad','INITIAL VARIABLE GRADIENTS'),
('elastic',''),
('biot',''),
('bodyforce',''),
('co2flow',''),
('co2frac',''),
('co2pres',''),
('co2diff',''),
('stressboun',''),
('rlpm','RELATIVE PERMEABILITY'),
('tpor',''),))
macro_descriptor = dict((
('pres','Initial conditions'),
('perm','Permeability'),
('cond','Thermal conductivity properties'),
('flow','Source or sink'),
('rock','Material properties'),
('grad','Initial condition gradients'),
('elastic','Elastic properties'),
('bodyforce','Body force at node'),
('biot','Fluid-stress coupling properties'),
('co2flow','CO2 source of sink'),
('co2frac','CO2 fraction'),
('co2pres','CO2 initial conditions'),
('co2diff','CO2 diffusion properties'),
('stressboun','Stress boundary condition'),
('permmodel','Stress permeability relationship'),
('plasticmodel','Plasticity relationship'),
('rlp','Relative permeablity relationship'),
('hflx','Heat flux boundary condition'),
('tpor','Tracer porosity'),)
)
rlpm_dicts=dict((
('constant',{}),
('linear',(('minimum_saturation',0),('maximum_saturation',1))),
('exponential',(('minimum_saturation',0),('maximum_saturation',1),('exponent',1),('maximum_relperm',1))),
('corey',(('minimum_saturation',0),('maximum_saturation',1))),
('brooks-corey',(('minimum_saturation',0),('maximum_saturation',1),('exponent',1))),
('vg',(('minimum_saturation',0),('maximum_saturation',1),('air_entry_head',1),('exponent',1))),
('linear_cap',(('cap_at_zero_sat',None),('sat_at_zero_cap',None))),
('brooks-corey_cap',(('minimum_saturation',0),('maximum_saturation',1),('exponent',1),('capillary_entry_presure',0.01),
('low_saturation_fitting',None),('cutoff_saturation',None))),
('vg_cap',(('minimum_saturation',0),('maximum_saturation',1),('air_entry_head',1),('exponent',1),
('low_saturation_fitting',None),('cutoff_saturation',None))),
))
rlpm_cap1 = dict((('vg_cap','vg_cap'),('brooks-corey_cap','brooks-corey'),('linear_cap','linear_for')))
rlpm_cap2 = dict((('vg_cap','vg_cap'),('brooks-corey','brooks-corey_cap'),('linear_for','linear_cap')))
rlpm_phases = ['water','air','co2_liquid','co2_gas','vapor']
buildWarnings = []
def _buildWarnings(s):
global buildWarnings
buildWarnings.append(s)
def _title_string(s,n): #prepends headers to sections of FEHM input file
if not n: return
ws = '# '
pad = int(np.floor((n - len(s) - 2)/2))
for i in range(pad): ws+='-'
ws+=s
for i in range(pad): ws+='-'
ws+='\n'
return ws
def _zone_ind(indStr): return abs(int(indStr))-(int(indStr)+abs(int(indStr)))/2
def process_output(filename,input=None,grid=None,hide=False,silent=False,write=True):
"""Runs an FEHM \*.outp file through the diagnostic tool. Writes output files containing simulation balance,
convergence, time stepping information.
:param filename: Path to the \*.outp file.
:type filename: str
:param input: Path to corresponding FEHM input file .
:type input: str
:param grid: Path to corresponding FEHM grid file.
:type grid: str
:param hide: Suppress diagnostic window (default False).
:type hide: bool
:param silent: Suppress output to the screen (default False).
:type silent: bool
:param write: Write output files (default True).
:type write: bool
"""
if input and grid: dat = fdata(filename=input,gridfilename=grid)
else:
dat = fdata()
dat._path.filename=filename
dat.files.root = dat.filename.split('.')[0]
dat.hist.variables=list(flatten(dat.hist.variables))
dat._diagnostic.hide = hide
dat._diagnostic.write = write
dat._diagnostic.silent = silent
dat._diagnostic.refresh_nodes()
dat._diagnostic.stdout = open(filename)
dat._diagnostic.poll = True
dat._diagnostic.read_with_tcl()
return dat._diagnostic
class fzone(object): #FEHM zone object.
"""FEHM Zone object.
"""
__slots__ = ['_index','_type','_points','_file','_name','_parent','_nodelist','_file','_permeability',
'_conductivity','_density','_specific_heat','_porosity','_youngs_modulus','_poissons_ratio',
'_thermal_expansion','_pressure_coupling','_Pi','_Ti','_Si','_fixedT','_fixedP','_updateFlag','_silent']
def __init__(self,index=None,type='',points=[],nodelist=[],file='',name = ''):
self._index=None
self._silent = dflt.silent
if index != None: self._index = index
self._type=''
if type: self._type = type
self._points=[]
if points: self._points=points
self._file = ''
self._name = ''
self._parent = None
if name: self._name = name
self._nodelist=[]
if (self.type == 'nnum' or self.type == 'list') and nodelist:
self._nodelist = nodelist
if file: self._file = file
# material properties
self._permeability = None
self._conductivity = None
self._density = None
self._specific_heat = None
self._porosity = None
self._youngs_modulus = None
self._poissons_ratio = None
self._thermal_expansion = None
self._pressure_coupling = None
self._Pi = None
self._Ti = None
self._Si = None
self._fixedT = None
self._fixedP = None
self._updateFlag = True
def __repr__(self): return 'zn'+str(self.index)
def __getstate__(self):
return dict((k, getattr(self, k)) for k in self.__slots__)
def __setstate__(self, data_dict):
for (name, value) in data_dict.iteritems():
setattr(self, name, value)
def _get_index(self): return self._index
def _set_index(self,value): self._index = value
index = property(_get_index,_set_index) #: (*int*) Integer number denoting the zone.
def _get_type(self): return self._type
def _set_type(self,value):
oldtype = self._type
self._type = value
if self._type != oldtype:
self._points = []
type = property(_get_type,_set_type) #: (*str*) String denoting the zone type. Default is 'rect', alternatives are 'list', 'nnum'
def _get_name(self): return self._name
def _set_name(self,value): self._name = value
name = property(_get_name,_set_name) #: (*str*) Name of the zone. Will appear commented beside the zone definition in the input file. Can be used to index the ``fdata.zone`` attribute.
def _get_file(self): return self._file
def _set_file(self,value): self._file=value
file = property(_get_file,_set_file) #: (*str*) File name if zone data is or is to be contained in a separate file. If file does not exist, it will be created and written to when the FEHM input file is being written out.
def rect(self,p1,p2): #generates a rectangular zone based on corner coordinates
"""Create a rectangular zone corresponding to the bounding box delimited by p1 and p2.
:param p1: coordinate of first corner of the bounding box.
:type p1: ndarray
:param p2: coordinate of the second corner of the bounding box.
:type p2: ndarray
"""
self.type='rect'
if len(p1) == 2:
xmax,xmin = np.max([p1[0],p2[0]]),np.min([p1[0],p2[0]])
ymax,ymin = np.max([p1[1],p2[1]]),np.min([p1[1],p2[1]])
self.points=[[xmin,xmax,xmax,xmin],
[ymax,ymax,ymin,ymin],
#[0., 0., 0., 0., 0., 0., 0., 0.]
]
elif len(p1) == 3:
xmax,xmin = np.max([p1[0],p2[0]]),np.min([p1[0],p2[0]])
ymax,ymin = np.max([p1[1],p2[1]]),np.min([p1[1],p2[1]])
zmax,zmin = np.max([p1[2],p2[2]]),np.min([p1[2],p2[2]])
self.points=[[xmin,xmax,xmax,xmin,xmin,xmax,xmax,xmin],
[ymax,ymax,ymin,ymin,ymax,ymax,ymin,ymin],
[zmax,zmax,zmax,zmax,zmin,zmin,zmin,zmin]]
def fix_temperature(self,T,multiplier=1.e10,file=None):
''' Fixes temperatures at nodes within this zone. Temperatures fixed by adding an HFLX macro with high
heat flow multiplier.
:param T: Temperature to fix.
:type T: fl64
:param multiplier: Multiplier for HFLX macro (default = 1.e10)
:type multiplier: fl64
:param file: Name of auxiliary file to save macro.
:type file: str
'''
if not self._parent:
pyfehm_print('fix_temperature() only available if zone associated with fdata() object',self._silent)
return
self._parent.add(fmacro('hflx',zone=self,param=(('heat_flow',T),('multiplier',multiplier)),file=file))
self._fixedT = T
def fix_pressure(self,P=0, T=30., impedance=1.e6, file = None):
''' Fixes pressures at nodes within this zone. Pressures fixed by adding a FLOW macro with high
impedance.
:param P: Pressure to fix. Default is 0, corresponding to fixing initial pressure.
:type P: fl64
:param T: Temperature to fix (default = 30 degC).
:type T: fl64
:param impedance: Impedance for FLOW macro (default = 1.e6)
:type impedance: fl64
:param file: Name of auxiliary file to save macro.
:type file: str
'''
if not self._parent:
pyfehm_print('fix_pressure() only available if zone associated with fdata() object',self._silent)
return
self._parent.add(fmacro('flow',zone=self,param=(('rate',P),('energy',-T),('impedance',impedance)),file=file))
self._fixedP = [P,T]
def fix_displacement(self,direction,displacement,file=None):
''' Fixes displacement at nodes within this zone. Displacements fixed by adding a STRESSBOUN macro.
:param direction: Direction in which displacement is fixed. Specify as string or integer, e.g., 1 = 'x', 2 = 'y', 3 = 'z'.
:type direction: str, int
:param displacement: Fixed displacement
:type displacement: fl64
:param file: Name of auxiliary file to save macro.
:type file: str
'''
if not self._parent:
pyfehm_print('fix_displacement() only available if zone associated with fdata() object',self._silent)
return
if direction == 'x': direction = 1
elif direction == 'y': direction = 2
elif direction == 'z': direction = 3
elif direction in [1,2,3]: pass
else:
pyfehm_print('direction must be specified as either 1, 2, 3, \'x\', \'y\', \'z\'.',self._silent)
return
self._parent.add(fmacro('stressboun',zone=self,param=(('direction',direction),('value',displacement)),file=file))
def fix_stress(self,direction,stress,file=None):
''' Fixes displacement at nodes within this zone. Displacements fixed by adding a STRESSBOUN macro.
:param direction: Direction in which stress is fixed. Specify as string or integer, e.g., 1 = 'x', 2 = 'y', 3 = 'z'.
:type direction: str, int
:param stress: Fixed stress
:type stress: fl64
:param file: Name of auxiliary file to save macro.
:type file: str
'''
if not self._parent:
pyfehm_print('fix_stress() only available if zone associated with fdata() object',self._silent)
return
if direction == 'x': direction = 1
elif direction == 'y': direction = 2
elif direction == 'z': direction = 3
elif abs(direction) in [1,2,3]: pass
else:
pyfehm_print('direction must be specified as either 1, 2, 3, \'x\', \'y\', \'z\'.',self._silent)
return
self._parent.add(fmacro('stressboun',zone=self,param=(('direction',-abs(direction)),('value',stress)),file=file))
def roller(self,direction=None,file=None):
''' Assigns a roller boundary condition to the zone (zero displacement in normal direction).
:param direction: Normal of roller. Specify as string or integer, e.g., 1 = 'x', 2 = 'y', 3 = 'z'. Defaults to zone normal for 'XMIN', 'ZMAX' etc.
:type direction: str, int
'''
if direction is None:
if self.name in ['XMIN','XMAX']: direction = 1
elif self.name in ['YMIN','YMAX']: direction = 2
elif self.name in ['ZMIN','ZMAX']: direction = 3
else:
pyfehm_print('no direction specified',self._silent)
return
self.fix_displacement(direction=direction,displacement=0,file=file)
def free_surface(self,direction=None,file=None):
''' Assigns a free surface boundary condition to the zone (zero stress in normal direction).
:param direction: Normal of free surface. Specify as string or integer, e.g., 1 = 'x', 2 = 'y', 3 = 'z'. Defaults to zone normal for 'XMIN', 'ZMAX' etc.
:type direction: str, int
'''
if direction is None:
if self.name in ['XMIN','XMAX']: direction = -1
elif self.name in ['YMIN','YMAX']: direction = -2
elif self.name in ['ZMIN','ZMAX']: direction = -3
else:
pyfehm_print('no direction specified',self._silent)
return
self.fix_stress(direction=direction,stress=0,file=file)
def copy_from(self,from_zone=None,grid_new=None,method = 'nearest',grid_old=None):
'''Transfer zone information from one grid to another.
:param from_zone: Zone object to convert.
:type from_zone: fzone
:param method: Method for node to node transfer of zone. Options are 'nearest', 'volume'.
:type method: str
'''
if grid_new: self.grid = grid_new
if grid_old: from_zone.grid = grid_old
if not self.index: self.index = from_zone.index
if not from_zone: pyfehm_print('No zone supplied',self._silent); return
if from_zone.type == 'rect': # if rectangular zone, copy across bounding box
self.type = 'rect'
self.points = from_zone.points
else: # zone comprises a list of nodes
if not from_zone.grid or not from_zone.nodelist:
pyfehm_print('Supplied zone does not contain grid information.',self._silent)
return
from_nodes = from_zone.nodelist
if method == 'nearest':
ndinds = np.unique([self.grid.node_nearest_point(nd.position) for nd in from_nodes])
ndinds = [nd.index for nd in ndinds if nd != None]
elif method == 'volume':
'a'
if not self.type: self.type = from_zone.type
self.nodelist = [self.grid.node[ndind] for ndind in ndinds]
def plot(self,save='',angle=[45,45],color='k',connections=False,equal_axes=True,
xlabel='x / m',ylabel='y / m',zlabel='z / m',title='',font_size='small'): #generates a 3-D plot of the zone.
'''Generates and saves a 3-D plot of the zone.
:param save: Name of saved zone image.
:type save: str
:param angle: View angle of zone. First number is azimuth angle in degrees, second number is tilt. Alternatively, if angle is 'x', 'y', 'z', view is aligned along the corresponding axis.
:type angle: [fl64,fl64], str
:param color: Colour of zone.
:type color: str, [fl64,fl64,fl64]
:param connections: Plot connections. If ``True`` all connections plotted. If between 0 and 1, random proportion plotted. If greater than 1, specified number plotted.
:type connections: bool
:param equal_axes: Force plotting with equal aspect ratios for all axes.
:type equal_axes: bool
:param xlabel: Label on x-axis.
:type xlabel: str
:param ylabel: Label on y-axis.
:type ylabel: str
:param zlabel: Label on z-axis.
:type zlabel: str
:param title: Title of plot.
:type title: str
:param font_size: Size of text on plot.
:type font_size: str, int
*Example:*
``zn.plot(save='myzone.png', angle = [45,45], xlabel = 'x / m', font_size = 'small', color = 'r')``
'''
save = os_path(save)
if isinstance(angle,str):
if angle == 'x': angle = [0,0]
elif angle == 'y': angle = [0,90]
elif angle == 'z': angle = [90,90]
else: return
plotBoundingBox = False
plotZoneBox = False
if self._parent: plotBoundingBox = True
if self.type == 'rect': plotZoneBox = True
# plot bounding box
plt.clf()
fig = plt.figure(figsize=[8.275,11.7])
ax = plt.axes(projection='3d')
ax.set_aspect('equal', 'datalim')
ax.set_xlabel(xlabel,size=font_size)
ax.set_ylabel(ylabel,size=font_size)
ax.set_zlabel(zlabel,size=font_size)
ax.set_title(title,size=font_size)
for t in ax.get_xticklabels():
t.set_fontsize(font_size)
for t in ax.get_yticklabels():
t.set_fontsize(font_size)
for t in ax.get_zticklabels():
t.set_fontsize(font_size)
xmin,xmax = self._parent.grid.xmin, self._parent.grid.xmax
ymin,ymax = self._parent.grid.ymin, self._parent.grid.ymax
zmin,zmax = self._parent.grid.zmin, self._parent.grid.zmax
if equal_axes:
MAX = np.max([xmax-xmin,ymax-ymin,zmax-zmin])/2
C = np.array([xmin+xmax,ymin+ymax,zmin+zmax])/2
for direction in (-1, 1):
for point in np.diag(direction * MAX * np.array([1,1,1])):
ax.plot([point[0]+C[0]], [point[1]+C[1]], [point[2]+C[2]], 'w')
ax.view_init(angle[0],angle[1])
if plotBoundingBox:
# x lines
ax.plot([xmin,xmax],[ymin,ymin],[zmin,zmin],'k--')
ax.plot([xmin,xmax],[ymax,ymax],[zmin,zmin],'k--')
ax.plot([xmin,xmax],[ymax,ymax],[zmax,zmax],'k--')
ax.plot([xmin,xmax],[ymin,ymin],[zmax,zmax],'k--')
# y lines
ax.plot([xmin,xmin],[ymin,ymax],[zmin,zmin],'k--')
ax.plot([xmax,xmax],[ymin,ymax],[zmin,zmin],'k--')
ax.plot([xmax,xmax],[ymin,ymax],[zmax,zmax],'k--')
ax.plot([xmin,xmin],[ymin,ymax],[zmax,zmax],'k--')
# z lines
ax.plot([xmin,xmin],[ymin,ymin],[zmin,zmax],'k--')
ax.plot([xmin,xmin],[ymax,ymax],[zmin,zmax],'k--')
ax.plot([xmax,xmax],[ymax,ymax],[zmin,zmax],'k--')
ax.plot([xmax,xmax],[ymin,ymin],[zmin,zmax],'k--')
# plot node connections
if connections:
conns = []
for node in self.nodelist:
for nb in node.connected_nodes:
if nb in self.nodelist:
p1 = node.position
p2 = nb.position
conns.append((p1,p2))
if not isinstance(connections,bool): # plot all connections
if connections>0 and connections<1: # plot proportion of connections
connections = int(len(conns)*connections)
connections = np.min([connections,len(conns)])
import random
random.shuffle(conns)
conns = conns[:connections]
for p1,p2 in conns:
ax.plot([p1[0],p2[0]],[p1[1],p2[1]],[p1[2],p2[2]],color=color, linestyle = '-', linewidth = 0.5) # plot some connections
# plot nodes
for node in self.nodelist:
ax.plot([node.position[0],],[node.position[1],],[node.position[2],],
markerfacecolor=color,marker='o',markersize=3,markeredgecolor=color)
if plotZoneBox:
xmax,xmin = np.max(self.points[0]),np.min(self.points[0])
ymax,ymin = np.max(self.points[1]),np.min(self.points[1])
zmax,zmin = np.max(self.points[2]),np.min(self.points[2])
# x lines
ax.plot([xmin,xmax],[ymin,ymin],[zmin,zmin],color=color,linestyle='-')
ax.plot([xmin,xmax],[ymax,ymax],[zmin,zmin],color=color,linestyle='-')
ax.plot([xmin,xmax],[ymax,ymax],[zmax,zmax],color=color,linestyle='-')
ax.plot([xmin,xmax],[ymin,ymin],[zmax,zmax],color=color,linestyle='-')
# y lines
ax.plot([xmin,xmin],[ymin,ymax],[zmin,zmin],color=color,linestyle='-')
ax.plot([xmax,xmax],[ymin,ymax],[zmin,zmin],color=color,linestyle='-')
ax.plot([xmax,xmax],[ymin,ymax],[zmax,zmax],color=color,linestyle='-')
ax.plot([xmin,xmin],[ymin,ymax],[zmax,zmax],color=color,linestyle='-')
# z lines
ax.plot([xmin,xmin],[ymin,ymin],[zmin,zmax],color=color,linestyle='-')
ax.plot([xmin,xmin],[ymax,ymax],[zmin,zmax],color=color,linestyle='-')
ax.plot([xmax,xmax],[ymax,ymax],[zmin,zmax],color=color,linestyle='-')
ax.plot([xmax,xmax],[ymin,ymin],[zmin,zmax],color=color,linestyle='-')
extension, save_fname, pdf = save_name(save,variable='zone'+str(self.index),time=1)
plt.savefig(save_fname, dpi=200, facecolor='w', edgecolor='w',orientation='portrait',
format=extension,transparent=True, bbox_inches=None, pad_inches=0.1)
if pdf:
os.system('epstopdf ' + save_fname)
os.remove(save_fname)
def topo(self,save='',cbar=True,equal_axes=True, method = 'nearest', divisions=[30,30], xlims=[],
ylims=[], clims=[], levels=10,clabel='',
xlabel='x / m',ylabel='y / m',zlabel='z / m',title='',font_size='small'): #generates a 2-D topographical plot of the zone.
'''Returns a contour plot of the top surface of the zone.
:param divisions: Resolution to supply mesh data.
:type divisions: [int,int]
:param method: Method of interpolation, options are 'nearest', 'linear'.
:type method: str
:param levels: Contour levels to plot. Can specify specific levels in list form, or a single integer indicating automatic assignment of levels.
:type levels: lst[fl64], int
:param cbar: Add colour bar to plot.
:param type: bool
:param xlims: Plot limits on x-axis.
:type xlims: [fl64, fl64]
:param ylims: Plot limits on y-axis.
:type ylims: [fl64, fl64]
:param clims: Colour limits.
:type clims: [fl64,fl64]
:param save: Name to save plot. Format specified extension (default .png if none give). Supported extensions: .png, .eps, .pdf.
:type save: str
:param xlabel: Label on x-axis.
:type xlabel: str
:param ylabel: Label on y-axis.
:type ylabel: str
:param title: Plot title.
:type title: str
:param font_size: Specify text size, either as an integer or string, e.g., 10, 'small', 'x-large'.
:type font_size: str, int
:param equal_axes: Specify equal scales on axes.
:type equal_axes: bool
*Example:*
``dat.zone[2].topo('zoneDEMtopo.png',method = 'linear')``
'''
save = os_path(save)
if not self.nodelist:
pyfehm_print('ERROR: No node information, aborting...',self._silent)
return
if not title:
title = 'Topographic plot of zone ' +str(self.index)
if self.name: title += ': '+self.name
# assemble data
xs = np.unique([nd.position[0] for nd in self.nodelist])
ys = np.unique([nd.position[1] for nd in self.nodelist])
xmin = np.min(xs); xmax = np.max(xs)
ymin = np.min(ys); ymax = np.max(ys)
xrange = np.linspace(xmin,xmax,divisions[0])
yrange = np.linspace(ymin,ymax,divisions[1])
XI,YI = np.meshgrid(xs,ys)
X,Y = np.meshgrid(xrange,yrange)
ZI = np.ones((len(ys),len(xs)))*self._parent.grid.zmin-1
for nd in self.nodelist:
i = np.where(xs==nd.position[0])[0][0]
j = np.where(ys==nd.position[1])[0][0]
ZI[j,i] = np.max([ZI[j,i],nd.position[2]])
pts = np.transpose(np.reshape((X,Y),(2,X.size)))
ptsI = np.transpose(np.reshape((XI,YI,ZI),(3,XI.size)))
from scipy.interpolate import griddata
vals = griddata(ptsI[:,:2],ptsI[:,2],pts,method=method)
vals = np.reshape(vals,(X.shape[0],X.shape[1]))
# plot topo
plt.clf()
fig = plt.figure(figsize=[8.275,11.7])
ax = plt.axes([0.15,0.15,0.7,0.7])
if xlims: ax.set_xlim(xlims)
if ylims: ax.set_ylim(ylims)
if equal_axes: ax.set_aspect('equal', 'datalim')
CS = plt.contourf(X,Y,vals,levels)
if clims: CS.vmin=clims[0]; CS.vmax=clims[1]
if xlabel: plt.xlabel(xlabel,size=font_size)
if ylabel: plt.ylabel(ylabel,size=font_size)
if title: plt.title(title,size=font_size)
if cbar:
cbar=plt.colorbar(CS)
for t in cbar.ax.get_yticklabels():
t.set_fontsize(font_size)
for t in ax.get_xticklabels():
t.set_fontsize(font_size)
for t in ax.get_yticklabels():
t.set_fontsize(font_size)
ax.set_aspect('equal', 'datalim')
extension, save_fname, pdf = save_name(save,variable='zone_topo'+str(self.index),time=1)
plt.savefig(save_fname, dpi=200, facecolor='w', edgecolor='w',orientation='portrait',
format=extension,transparent=True, bbox_inches=None, pad_inches=0.1)
def _get_info(self):
"""Print details of the zone to the screen."""
ws = 'Zone '+str(self.index)+'\n'
ws+='\nGeometric properties.......\n'
if self.type == 'rect':
ws += ' Type: rectangular box\n'
if self.nodelist: ws += ' Contains '+str(len(self.nodelist))+' nodes\n'
pts = np.array(self.points)
if np.size(pts)==24: pts=pts.reshape(3,8)
else: pts = pts.reshape(2,4)
xmin, xmax = np.min(pts[0,:]), np.max(pts[0,:])
ymin, ymax = np.min(pts[1,:]), np.max(pts[1,:])
if pts.shape[1] == 3:
zmin, zmax = np.min(pts[2,:]), np.max(pts[2,:])
dx,dy,dz = [xmax-xmin,ymax-ymin,zmax-zmin]
ws += ' dimensions: ['+str(dx)+', '+str(dy)+', '+str(dz)+']'
if 100*dz<dx and 100*dz<dy: ws += ' (plane at z = '+str((zmin+zmax)/2)+')'
elif 100*dx<dy and 100*dx<dz: ws += ' (plane at x = '+str((xmin+xmax)/2)+')'
elif 100*dy<dz and 100*dy<dz: ws += ' (plane at y = '+str((ymin+ymax)/2)+')'
elif 100*dz<dx and 100*dy<dx: ws += ' (column at x = '+str((xmin+xmax)/2)+')'
elif 100*dx<dy and 100*dz<dy: ws += ' (column at y = '+str((ymin+ymax)/2)+')'
elif 100*dx<dz and 100*dy<dz: ws += ' (column at z = '+str((zmin+zmax)/2)+')'
ws += '\n'
ws += ' x-range: '+str(xmin)+' - '+str(xmax)+'\n'
ws += ' y-range: '+str(ymin)+' - '+str(ymax)+'\n'
if pts.shape[1] == 3:
ws += ' z-range: '+str(zmin)+' - '+str(zmax)+'\n'
ws += ' mid-point: ['+str((xmin+xmax)/2.)+', '+str((ymin+ymax)/2.)+', '+str((zmin+zmax)/2.)+']\n'
elif pts.shape[1] ==1:
ws += ' mid-point: ['+str((xmin+xmax)/2.)+', '+str((ymin+ymax)/2.)+']\n'
elif self.type == 'list':
#ws = 'Zone '+str(self.index)+'\n'
#ws+='\nGeometric properties.......\n'
ws += ' Type: list\n'
ws += ' Contains '+str(len(self.nodelist))+' nodes\n'
pts=np.array(self.points)
ws += ' x-range: '+str(np.min(pts[:,0]))+' - '+str(np.max(pts[:,0]))+'\n'
ws += ' y-range: '+str(np.min(pts[:,1]))+' - '+str(np.max(pts[:,1]))+'\n'
ws += ' z-range: '+str(np.min(pts[:,2]))+' - '+str(np.max(pts[:,2]))+'\n'
ws += ' mid-point: ['+str(np.mean(pts[:,0]))+', '+str(np.mean(pts[:,1]))+', '+str(np.mean(pts[:,2]))+']\n'
if pts.shape[0]<20:
ws+=' points: ['+str(self.points[0][0])+', '+str(self.points[0][1])+', '+str(self.points[0][2])+']\n'
for pt in self.points[1:]:
ws+=' ['+str(pt[0])+', '+str(pt[1])+', '+str(pt[2])+']\n'
elif self.type == 'nnum':
ws += ' Type: nnum (list of nodes)\n'
ws += ' Contains '+str(len(self.nodelist))+' nodes\n'
elif not self.index:
ws += ' Background zone (denoted 1 0 0), encompassing all nodes.\n'
else: return
ws += '\nMaterial properties........\n'
if self._permeability != None: ws += ' permeability...... '+str(self._permeability)+'\n'
if self._conductivity != None: ws += ' conductivity...... '+str(self._conductivity)+'\n'
if self._density: ws += ' density........... '+str(self._density)+'\n'
if self._specific_heat: ws += ' specific heat..... '+str(self._specific_heat)+'\n'
if self._porosity: ws += ' porosity.......... '+str(self._porosity)+'\n'
if self._youngs_modulus: ws += ' Youngs modulus.... '+str(self._youngs_modulus)+'\n'
if self._poissons_ratio: ws += ' Poissons ratio.... '+str(self._poissons_ratio)+'\n'
if self._thermal_expansion: ws += ' thermal expansion. '+str(self._thermal_expansion)+'\n'
if self._pressure_coupling: ws += ' pressure coupling. '+str(self._pressure_coupling)+'\n'
ws += '\nInitial conditions.........\n'
if self._Pi: ws += ' pressure.......... '+str(self._Pi)+'\n'
if self._Ti: ws += ' temperature....... '+str(self._Ti)+'\n'
if self._Si: ws += ' saturation........ '+str(self._Si)+'\n'
ws += '\nBoundary conditions........\n'
if self._fixedT: ws += ' fixed temperature.... '+str(self._fixedT)+'\n'
if self._fixedP:
ws += ' fixed pressure....... '+str(self._fixedP[0])+'\n'
ws += ' inflow temperature. '+str(self._fixedP[1])+'\n'
print ws
what = property(_get_info) #: Print to screen information about the zone.
def _get_nodes(self):
"""Assemble a list of fnode objects contained in the zone."""
nds = []
if self.type == 'rect':
if not self._parent.grid: self._nodelist = nds; return self._nodelist
xmax,xmin = np.max(self.points[0]),np.min(self.points[0])
ymax,ymin = np.max(self.points[1]),np.min(self.points[1])
if self._parent._grid.dimensions == 3:
zmax,zmin = np.max(self.points[2]),np.min(self.points[2])
else:
zmax,zmin = self._parent._grid.zmax+.01,self._parent._grid.zmin-.01
x,y,z = np.array([nd._position for nd in self._parent._grid._nodelist]).T
inds = np.where((x<=xmax)&(x>=xmin)&(y<=ymax)&(y>=ymin)&(z<=zmax)&(z>=zmin))
self._nodelist = [self._parent._grid._nodelist[i] for i in inds[0]]
if self._index == 0: self._nodelist = self._parent._grid._nodelist
return self._nodelist
def _set_nodes(self,value):
if self.type == 'rect':
pyfehm_print('ERROR: nodelist for zone defined by content of points.',self._silent)
return
self._nodelist = value
nodelist = property(_get_nodes,_set_nodes) #: (*lst[fnode]*) List of nodes contained within the zone.
def _get_node(self): return dict([(nd.index,nd) for nd in self.nodelist])
node = property(_get_node) #: (*dict[fnode]*) Dictionary of nodes contained within the zone, indexed by node number.
def _get_points(self):
"""Assemble spatial data as it would appear in an FEHM input file."""
pts=[]
if self.type in ['nnum','list']:
if not self._parent.grid: self._points = pts; return self._points
row = []
if self.type == 'nnum': row.append(len(self.nodelist))
for nd in self.nodelist:
if isinstance(nd,int): nd = self._parent.grid.node[nd]
if self.type == 'list': pts.append(nd.position)
elif self.type == 'nnum': row.append(nd.index)
if len(row) == 10: pts.append(row); row = []
if row != []: pts.append(row)
self._points = pts
return self._points
def _set_points(self,value):
if self.type in ['list','nnum']:
pyfehm_print('ERROR: points defined by content of nodelist.',self._silent)
return
self._points = value
points = property(_get_points,_set_points)#: (*lst[fl64]*) Spatial data defining the zone.
def _get_permeability(self): return self._permeability
def _set_permeability(self,value):
self._permeability = value
# set commands
if not self._parent: _buildWarnings('Zone not associated with input file, no macro changes made.'); return
if isinstance(value,(int,float)): kx = value; ky = value; kz = value
elif isinstance(value,(list,tuple,np.ndarray)) and len(value)==3: kx,ky,kz = value
if self.index in self._parent.perm.keys():
if self._updateFlag:
self._parent.perm[self.index].param['kx']=kx
self._parent.perm[self.index].param['ky']=ky
self._parent.perm[self.index].param['kz']=kz
else:
self._parent.add(fmacro('perm',zone=self.index,param=(('kx',kx),('ky',ky),('kz',kz))))
if self._parent:
for nd in self.nodelist:
if not (nd.permeability is not None and self.index == 0):
nd._permeability = np.array([kx,ky,kz])
permeability = property(_get_permeability, _set_permeability) #: (*fl64*,*lst*) Permeability properties of zone.
def _get_conductivity(self): return self._conductivity
def _set_conductivity(self,value):
self._conductivity = value
# set commands
if not self._parent: _buildWarnings('Zone not associated with input file, no macro changes made.'); return
if isinstance(value,(int,float)): kx = value; ky = value; kz = value
elif isinstance(value,(list,tuple,np.ndarray)) and len(value)==3: kx,ky,kz = value
if self.index in self._parent.cond.keys():
if self._updateFlag:
self._parent.cond[self.index].param['cond_x']=kx
self._parent.cond[self.index].param['cond_y']=ky
self._parent.cond[self.index].param['cond_z']=kz
else:
self._parent.add(fmacro('cond',zone=self.index,param=(('cond_x',kx),('cond_y',ky),('cond_z',kz))))
if self._parent:
for nd in self.nodelist:
if not (nd.conductivity is not None and self.index == 0):
nd._conductivity = np.array([kx,ky,kz])
conductivity = property(_get_conductivity, _set_conductivity) #: (*fl64*,*lst*) Conductivity properties of zone.
def _set_property(self,value,prop0,props,macro):
self.__setattr__(prop0,value)
if not self._parent:
pyfehm_print('Zone not associated with input file, no macro changes made.',self._silent)
return
# macro creation/modification
ks = self._parent.__getattribute__(macro).keys()
if self.index in ks:
if self._updateFlag:
self._parent.__getattribute__(macro)[self.index].param[prop0[1:]]=value
else:
params = [(prop0[1:],value)]
for prop in props:
params.append((prop[1:],dflt.__getattribute__(prop[1:])))
self._parent.add(fmacro(macro,zone=self.index,param=tuple(params)))
warn_string = 'WARNING: Assigning default '
for prop in props:
warn_string += prop[1:]+' (%6.1f'%dflt.__getattribute__(prop[1:])+'), '
warn_string = warn_string[:-2] + ' to zone '+str(self.index)+'.'
_buildWarnings(warn_string)
for prop in props:
self.__setattr__(prop[1:],dflt.__getattribute__(prop[1:]))
# node association
if self._parent:
for nd in self._nodelist:
if isinstance(nd,int): nd = self._parent.grid.node[nd]
if len(set([zn.index for zn in nd.zonelist])-set([994,995,996,997,998,999]))==0:
nd.__setattr__(prop0,value)
elif len([zn.index for zn in nd.zonelist if zn.index in ks])==0:
nd.__setattr__(prop0,value)
elif self.index == np.max([zn.index for zn in nd.zonelist if zn.index in ks]):
nd.__setattr__(prop0,value)
def _get_density(self): return self._density
def _set_density(self,value):
self._set_property(value,'_density',['_specific_heat','_porosity'],'rock')
density = property(_get_density, _set_density) #: (*fl64*) Density of zone.
def _get_specific_heat(self): return self._specific_heat
def _set_specific_heat(self,value):
self._set_property(value,'_specific_heat',['_density','_porosity'],'rock')
specific_heat = property(_get_specific_heat, _set_specific_heat) #: (*fl64*) Specific heat of zone.
def _get_porosity(self): return self._porosity
def _set_porosity(self,value):
self._set_property(value,'_porosity',['_density','_specific_heat'],'rock')
porosity = property(_get_porosity, _set_porosity) #: (*fl64*) Porosity of zone.
def _get_youngs_modulus(self): return self._youngs_modulus
def _set_youngs_modulus(self,value):
self._set_property(value,'_youngs_modulus',['_poissons_ratio'],'elastic')
youngs_modulus = property(_get_youngs_modulus, _set_youngs_modulus) #: (*fl64*) Young's modulus of zone.
def _get_poissons_ratio(self): return self._poissons_ratio
def _set_poissons_ratio(self,value):
self._set_property(value,'_poissons_ratio',['_youngs_modulus'],'elastic')
poissons_ratio = property(_get_poissons_ratio, _set_poissons_ratio) #: (*fl64*) Poisson's ratio of zone.
def _get_thermal_expansion(self): return self._thermal_expansion
def _set_thermal_expansion(self,value):
self._set_property(value,'_thermal_expansion',['_pressure_coupling'],'biot')
thermal_expansion = property(_get_thermal_expansion, _set_thermal_expansion) #: (*fl64*) Coefficient of thermal expansion of zone.
def _get_pressure_coupling(self): return self._pressure_coupling
def _set_pressure_coupling(self,value):
self._set_property(value,'_pressure_coupling',['_thermal_expansion'],'biot')
pressure_coupling = property(_get_pressure_coupling, _set_pressure_coupling) #: (*fl64*) Pressure coupling term of zone.
def _get_Pi(self): return self._Pi
def _set_Pi(self,value):
self._Pi = value
# set commands
if not self._parent:
pyfehm_print('Zone not associated with input file, no macro changes made.',self._silent)
return
if self.index in self._parent.pres.keys():
if self._updateFlag:
self._parent.pres[self.index].param['pressure']=value
else:
self._parent.add(fmacro('pres',zone=self.index,param=(('pressure',value),('temperature',dflt.Ti),('saturation',1))))
_buildWarnings('WARNING: Assigning default initial temperature (%4.1f'%dflt.Ti+' degC, fully saturated liquid) to zone '+str(self.index)+'.')
self.Ti = dflt.Ti
if self.Ti > tsat(self.Pi)[0]:
self._parent.pres[self.index].param['saturation']=3
self.Si = 0.
else:
self._parent.pres[self.index].param['saturation']=1
self.Si = 1.
if self._parent:
for nd in self.nodelist:
if not (nd.Pi is not None and self.index == 0):
nd._Pi = value
Pi = property(_get_Pi, _set_Pi) #: (*fl64*) Initial pressure in zone.
def _get_Ti(self): return self._Ti
def _set_Ti(self,value):
self._Ti = value
# set commands
if not self._parent:
pyfehm_print('Zone not associated with input file, no macro changes made.',self._silent)
return
if self.index in self._parent.pres.keys():
if self._updateFlag:
self._parent.pres[self.index].param['temperature']=value
else:
self._parent.add(fmacro('pres',zone=self.index,param=(('pressure',dflt.Pi),('temperature',value),('saturation',1))))
_buildWarnings('WARNING: Assigning default initial pressure (%4.1f'%dflt.Pi+' MPa, fully saturated liquid) to zone '+str(self.index)+'.')
self._Pi = dflt.Pi
if self._Ti > tsat(self._Pi)[0]:
self._parent.pres[self.index].param['saturation']=3
self._Si = 0.
else:
self._parent.pres[self.index].param['saturation']=1
self._Si = 1.
if self._parent:
for nd in self.nodelist:
if not (nd.Ti is not None and self.index == 0):