forked from toddheitmann/PetroPy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.py
More file actions
executable file
·2810 lines (2297 loc) · 108 KB
/
log.py
File metadata and controls
executable file
·2810 lines (2297 loc) · 108 KB
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
# -*- coding: utf-8 -*-
"""
Log contains parent classes to work with log data.
The Log class is subclassed from lasio LASFile class, which provide a
data structure. The methods are for petrophysical calculations and for
viewing data with the LogViewer class.
"""
import os
import re
import xml.etree.ElementTree as ET
import pandas as pd
import numpy as np
import datetime as dt
from scipy.optimize import nnls
from lasio import LASFile, CurveItem
class Log(LASFile):
"""
Log
Subclass of LASFile to provide an extension for all petrophysical
calculations.
Parameters
----------
file_ref : str
str path to las file
drho_matrix : float (default 2.71)
Matrix density for conversion from density porosity to density.
kwargs : kwargs
Key Word arguements for use with lasio LASFile class.
Example
-------
>>> import petropy as ptr
>>> # define path to las file
>>> p = 'path/to/well.las'
>>> # loads specified las file
>>> log = ptr.Log(p)
"""
def __init__(self, file_ref = None, drho_matrix = 2.71, **kwargs):
if file_ref is not None:
LASFile.__init__(self, file_ref = file_ref,
autodetect_encoding = True, **kwargs)
self.precondition(drho_matrix = drho_matrix)
self.fluid_properties_parameters_from_csv()
self.multimineral_parameters_from_csv()
self.tops = {}
def precondition(self, drho_matrix = 2.71):
"""
Preconditions log curve by aliasing names.
Precondition is used after initializing data and standardizes
names for future calculations.
Parameters
----------
drho_matrix : float, optional
drho_matrix is for converting density porosity to bulk
densty, and is only used when bulk density is missing.
Default value for limestone matrix. If log was run on
sandstone matrix, use 2.65. If log was run on dolomite
matrix, use 2.85.
Note
-----
1. Curve Alias is provided by the curve_alias.xml file
"""
file_dir = os.path.dirname(__file__)
ALIAS_XML_PATH = os.path.join(file_dir, 'data',
'curve_alias.xml')
if not os.path.isfile(ALIAS_XML_PATH):
raise ValueError('Could not find alias xml at: %s' % \
ALIAS_XML_PATH)
with open(ALIAS_XML_PATH, 'r') as f:
root = ET.fromstring(f.read())
for alias in root:
for curve in alias:
if curve.tag in self.keys():
if alias.tag not in self.keys():
curve_item = self.curves[curve.tag]
self.add_curve(alias.tag, self[curve.tag],
unit = curve_item.unit,
value = curve_item.value,
descr = curve_item.descr)
break
if 'RHOB_N' not in self.keys() and 'DPHI_N' in self.keys():
calculated_rho = np.empty(len(self[0]))
non_null_depth_index=np.where(~np.isnan(self['DPHI_N']))[0]
non_null_depths = self['DPHI_N'][non_null_depth_index]
calculated_rho[non_null_depth_index] = \
drho_matrix - (drho_matrix - 1) * non_null_depths
self.add_curve('RHOB_N', calculated_rho, unit = 'g/cc',
value = '',
descr = 'Calculated bulk density from density \
porosity assuming rho matrix = %.2f' % \
drho_matrix)
def tops_from_csv(self, csv_path = None):
"""
Reads tops from a csv file and saves as dictionary.
Here is a sample csv file with default tops_ data.
.. _tops: ../_static/tops.csv
Parameters
----------
csv_path : str (default None)
Path to csv file to read. Must contain header row the the
following properties:
::
uwi : str
Unique Well Identifier
form : str
Name of formation top
depth : float
depth of corresponding formation top
Note
-----
Format for csv:
::
uwi,form,depth
11111111111,WFMPA,7000.50
11111111111,WFMPB,7250.50
11111111111,WFMPC,7500.00
11111111111,WFMPD,7700.25
11111111111,DEAN,8000.00
Example
--------
>>> import petropy as ptr
# define path to las file
p = 'path/to/well.las'
# loads specified las file
>>> log = ptr.Log(p)
# define path to csv tops file
>>> t = 'path/to/tops.csv'
# loads specified tops csv
>>> log.tops_from_csv(t)
"""
if csv_path is None:
local_path = os.path.dirname(__file__)
csv_path = os.path.join(local_path, 'data', 'tops.csv')
top_df = pd.read_csv(csv_path, dtype = {'uwi': str,'form': str,
'depth': float})
well_tops_df =top_df[top_df.uwi == str(self.well['UWI'].value)]
for _, row in well_tops_df.iterrows():
self.tops[row.form] = row.depth
def next_formation_depth(self, formation):
"""
Return top of formation below specified formation.
Parameters
----------
formation : str
name of formation which should be found in preloaded tops
Returns
-------
bottom : float
top of formation below input formation, acting as bottom of
input formation
Example
--------
>>> import petropy as ptr
>>> # reads sample Wolfcamp Log from las file
>>> log = ptr.log_data('WFMP')
>>> # get top of formation WFMPA
>>> wfmpa_top = log.tops['WFMPA']
>>> print(wfmpa_top)
6993.5
>>> # got bottom of formation WFMPA
>>> wfmpa_bottom = log.next_formation_depth('WFMPB')
>>> print(wfmpa_bottom)
7294.0
>>> # Compare depths for bottom of WFMPA
>>> # to top of WFMPB
>>> wfmpb_top = log.tops['WFMPB']
>>> print(wfmpb_top)
7294.0
>>> print(wfmpa_bottom == wfmpb_top)
True
"""
top = self.tops[formation]
bottom = self.df().index.max()
closest_formation = bottom - top
for form in self.tops:
form_depth = self.tops[form]
if form_depth > top and form_depth - top<closest_formation:
bottom = form_depth
closest_formation = bottom - top
return bottom
def fluid_properties_parameters_from_csv(self, csv_path = None):
"""
Reads parameters from a csv for input into fluid properties.
This method reads the file located at the csv_path and turns the
values into dictionaries to be used as inputs into the
fluid_properties method.
This reference_ is a sample csv file with default data for
fluid properties.
.. _reference: ../_static/fluid_properties_parameters.csv
Parameters
----------
csv_path : str (default None)
Note
-----
Path to csv file to read. Must contain header row with the
following properties
mast : float (default 67)
The mean annual surface temperature at the location of
the well in degrees Fahrenheit.
temp_grad : float (default 0.015)
The temperature gradient of the reservoir in °F / ft.
press_grad : float (default 0.5)
The pressure gradient of the reservoir in psi / ft.
rws : float (default 0.1)
The resistivity of water at surface conditions in ohm.m
rwt : float (default 70)
The temperature of the rws measurement in °F.
rmfs : float (default 0.4)
The resistivity of mud fultrate at surface conditions
in ohm.m
rmft : float (default 100)
The temperature of the rmfs measurement in °F.
gas_grav : float (default 0.67)
The specific gravity of the separator gas. Air = 1,
CH4 = 0.577
oil_api : float (default 38)
The api gravity of oil after the separator. If fluid
system is dry gas, use :code:`oil_api = 0`.
p_sep : float (default 100)
The pressure of the separator, assuming a 2 stage
system. Only used when :code:`oil_api` is > 0
(not dry gas).
t_sep : float
The temperature of the separator , assuming a 2 stage
system. Only used with :code:`oil_api > 0`.
yn2 : float (default 0)
Molar fraction of nitrogren in gas.
yco2 : float (default 0)
Molar fration of carbon dioxide in gas.
yh2s : float (default 0)
Molar fraction of hydrogen sulfide in gas.
yh20 : float (default 0)
Molar fraction of water in gas.
rs : float (default 0)
Solution gas oil ratio at reservoir conditions.
If unknwon, use 0 and correlation will be calculated.
lith_grad : float (default 1.03)
Lithostatic gradient in psi / ft.
biot : float (default 0.8)
Biot constant.
pr : float (default 0.25)
Poissons ratio
Examples
--------
>>> import petropy as ptr
>>> # reads sample Wolfcamp Log from las file
>>> log = ptr.log_data('WFMP')
>>> # loads sample parameters provided
>>> log.fluid_properties_parameters_from_csv()
>>> import petropy as ptr
>>> # reads sample Wolfcamp Log from las file
>>> log = ptr.log_data('WFMP')
>>> # define path to csv file with parameters
>>> my_csv_paramters = 'path/to/csv/file.csv'
>>> # loads specified parameters
>>> log.fluid_properties_parameters_from_csv(my_csv_paramters)
See Also
--------
:meth:`petropy.Log.fluid_properties`
Calculates fluid properties using input settings loaded
through this method
"""
if csv_path is None:
local_path = os.path.dirname(__file__)
csv_path = os.path.join(local_path, 'data',
'fluid_properties_parameters.csv')
param_df = pd.read_csv(csv_path)
param_df = param_df.set_index('name')
self.fluid_properties_parameters = \
param_df.to_dict(orient = 'index')
def fluid_properties(self, top = 0, bottom = 100000, mast = 67,
temp_grad = 0.015, press_grad = 0.5, rws = 0.1, rwt = 70,
rmfs = 0.4, rmft = 100, gas_grav = 0.67, oil_api = 38, p_sep = 100,
t_sep = 100, yn2 = 0, yco2 = 0, yh2s = 0, yh20 = 0, rs = 0,
lith_grad = 1.03, biot = 0.8, pr = 0.25):
"""
Calculates fluid properties along wellbore.
The output add the following calculated curves at each depth:
PORE_PRESS : (psi)
Reservoir pore pressure
RES_TEMP : (°F)
Reservoir temperature
NES : (psi)
Reservoir net effective stress
RW : (ohm.m)
Resistivity of water
RMF : (ohm.m)
Resistivity of mud filtrate
RHO_HC : (g / cc)
Density of hydrocarbon
RHO_W : (g / cc)
Density of formation water
RHO_MF : (g / cc)
Density of mud filtrate
NPHI_HC
Neutron log response of hydrocarbon
NPHI_W
Neutron log response of water
NPHI_MF
Neutron log response of mud filtrate
MU_HC : (cP)
Viscosity of hydrocarbon
Z
Compressiblity factor for non-ideal gas.
Only output if oil_api = 0
CG : (1 / psi)
Gas Compressiblity. Only output if oil_api = 0
BG
Gas formation volume factor. Only output if oil_api = 0
BP : (psi)
Bubble point. Only output if oil_api > 0
BO
Oil formation volume factor. Only output if oil_api > 0
Parameters
----------
top : float (default 0)
The top depth to begin fluid properties calculation. If
value is not specified, the calculations will start at
the top of the log.
bottom : float (default 100,000)
The bottom depth to end fluid properties, inclusive. If the
value is not specified, the calcuations will go to the
end of the log.
mast : float (default 67)
The mean annual surface temperature at the location of the
well in degrees Fahrenheit.
temp_grad : float (default 0.015)
The temperature gradient of the reservoir in °F / ft.
press_grad : float (default 0.5)
The pressure gradient of the reservoir in psi / ft.
rws : float (default 0.1)
The resistivity of water at surface conditions in ohm.m.
rwt : float (default 70)
The temperature of the rws measurement in °F.
rmfs : float (default 0.4)
The resistivity of mud fultrate at surface conditions in
ohm.m
rmft : float (default 100)
The temperature of the rmfs measurement in °F
gas_grav : float (default 0.67)
The specific gravity of the separator gas. Air = 1,
CH4 = 0.577
oil_api : float (default 38)
The api gravity of oil after the separator
If fluid system is dry gas, use oil_api = 0.
p_sep : float (default 100)
The pressure of the separator, assuming a 2 stage system
Only used when oil_api is > 0 (not dry gas).
t_sep : float
The temperature of the separator, assuming a 2 stage system
Only used with :code:`oil_api > 0`.
yn2 : float (default 0)
Molar fraction of nitrogren in gas.
yco2 : float (default 0)
Molar fration of carbon dioxide in gas.
yh2s : float (default 0)
Molar fraction of hydrogen sulfide in gas.
yh20 : float (default 0)
Molar fraction of water in gas.
rs : float (default 0)
Solution gas oil ratio at reservoir conditions.
If unknwon, use 0 and correlation will be used.
lith_grad : float (default 1.03)
Lithostatic overburden pressure gradient in psi / ft.
biot : float (default 0.8)
Biot constant.
pr : float (default 0.25)
Poissons ratio
Note
----
Current single phase fluid properties assumes either:
1. Dry Gas at Reservoir Conditions
Methane as hydrocarbon type with options to include N2,
CO2, H2S, or H2O. To assume dry_gas, set
:code:`oil_api = 0`
2. Oil at Reservoir Conditions
Assumes reservoir fluids are either a black or volatile
oil. Separator conditions of gas are used to calculate
bubble point and the reservoir fluid properties of the
reconstituted oil.
References
----------
Ahmed, Tarek H. Reservoir Engineering Handbook. Oxford: Gulf
Professional, 2006.
Lee, John, and Robert A. Wattenbarger. Gas Reservoir
Engineering. Richardson, TX: Henry L. Doherty Memorial
Fund of AIME, Society of Petroleum Engineers, 2008.
Example
-------
>>> import petropy as ptr
>>> from petropy import datasets
>>> # reads sample Wolfcamp Log from las file
>>> log = ptr.log_data('WFMP')
>>> # calculates fluid properties with default settings
>>> log.fluid_properties()
See Also
--------
:meth:`petropy.Log.fluid_properties_parameters_from_csv`
loads properties from preconfigured csv file
:meth:`petropy.Log.multimineral_model`
builds on fluid properties to calculate full petrophysical
model
"""
### fluid property calculations ###
depth_index = np.intersect1d(np.where(self[0] >= top)[0],
np.where(self[0] < bottom)[0])
depths = self[0][depth_index]
form_temp = mast + temp_grad * depths
pore_press = press_grad * depths
### water properties ###
rw = (rwt + 6.77) / (form_temp + 6.77) * rws
rmf = (rmft + 6.77) / (form_temp + 6.77) * rmfs
rw68 = (rwt + 6.77) / (68 + 6.77) * rws
rmf68 = (rmft + 6.77) / (68 + 6.77) * rws
### weight percent total disolved solids ###
xsaltw = 10 ** (-0.5268 * (np.log10(rw68) ) ** 3 - 1.0199 * \
(np.log10(rw68)) ** 2 - 1.6693 * (np.log10(rw68)) - 0.3087)
xsaltmf = 10 ** (-0.5268 * (np.log10(rmf68) ) ** 3 - 1.0199 * \
(np.log10(rmf68)) ** 2 - 1.6693 * (np.log10(rmf68)) - 0.3087)
### bw for reservoir water. ###
### Eq 1.83 - 1.85 Gas Reservoir Engineering ###
dvwt = -1.0001 * 10 ** -2 + 1.33391 * 10 ** -4 * form_temp + \
5.50654 * 10 ** -7 * form_temp ** 2
dvwp = -1.95301 * 10 ** -9 * pore_press * form_temp - \
1.72834 * 10 ** -13 * pore_press ** 2 * form_temp - \
3.58922 * 10 ** -7 * pore_press - \
2.25341 * 10 ** -10 * pore_press ** 2
bw = (1 + dvwt) * (1 + dvwp)
### calculate solution gas in water ratio ###
### Eq. 1.86 - 1.91 Gas Reservoir Engineering ###
rsa = 8.15839 - 6.12265 * 10 ** -2 * form_temp + \
1.91663 * 10 ** -4 * form_temp ** 2 - \
2.1654 * 10 ** -7 * form_temp ** 3
rsb = 1.01021 * 10 ** -2 - 7.44241 * 10 ** -5 * form_temp + \
3.05553 * 10 ** -7 * form_temp ** 2 - \
2.94883 * 10 ** -10 * form_temp ** 3
rsc = -1.0 * 10 ** -7 * (9.02505 - 0.130237 * form_temp + \
8.53425 * 10 ** -4 * form_temp ** 2 - 2.34122 * 10 ** -6 * \
form_temp ** 3 + 2.37049 * 10 ** -9 * form_temp ** 4)
rswp = rsa + rsb * pore_press + rsc * pore_press ** 2
rsw = rswp * 10**(-0.0840655 * xsaltw * form_temp ** -0.285584)
### log responses ###
rho_w = (2.7512 * 10 ** -5 * xsaltw + \
6.9159 * 10 ** -3 * xsaltw + 1.0005) * bw
rho_mf = (2.7512 * 10 ** -5 * xsaltmf + \
6.9159 * 10 ** -3 * xsaltmf + 1.0005) * bw
nphi_w = 1 + 0.4 * (xsaltw / 100)
nphi_mf = 1 + 0.4 * (xsaltmf / 100)
### net efective stress ###
nes = (((lith_grad * depths) - (biot * press_grad * depths) + \
2 * (pr / (1 - pr)) * (lith_grad * depths) - \
(biot * press_grad * depths))) / 3
### gas reservoir ###
if oil_api == 0:
# hydrocarbon garvity only
hc_grav = (gas_grav - 1.1767 * yh2s - 1.5196 * yco2 - \
0.9672 * yn2 - 0.622 * yh20) / \
(1.0 - yn2 - yco2 - yh20 - yh2s)
# pseudocritical properties of hydrocarbon
ppc_h = 756.8 - 131.0 * hc_grav - 3.6 * (hc_grav ** 2)
tpc_h = 169.2 + 349.5 * hc_grav - 74.0 * (hc_grav ** 2)
# pseudocritical properties of mixture
ppc = (1.0 - yh2s - yco2 - yn2 - yh20) * ppc_h + \
1306.0 * yh2s + 1071.0 * yco2 + \
493.1 * yn2 + 3200.1 * yh20
tpc = (1.0 - yh2s - yco2 - yn2 - yh20) * tpc_h + \
672.35 * yh2s + 547.58 * yco2 + \
227.16 * yn2 + 1164.9 * yh20
# Wichert-Aziz correction for H2S and CO2
if yco2 > 0 or yh2s > 0:
epsilon = 120 * ((yco2 + yh2s) ** 0.9 - \
(yco2 + yh2s) ** 1.6) + \
15 * (yh2s ** 0.5 - yh2s ** 4)
tpc_temp = tpc - epsilon
ppc = (ppc_a * tpc_temp) / \
(tpc + (yh2s * (1.0 - yh2s) * epsilon))
tpc = tpc_temp
# Casey correction for nitrogen and water vapor
if yn2 > 0 or yh20 > 0:
tpc_cor = -246.1 * yn2 + 400 * yh20
ppc_cor = -162.0 * yn2 + 1270.0 * yh20
tpc = (tpc - 227.2 * yn2 - 1165.0 * yh20) / \
(1.0 - yn2 - yh20) + tpc_cor
ppc = (ppc - 493.1 * yn2 - 3200.0 * yh20) / \
(1.0 - yn2 - yh20) + ppc_cor
# Reduced pseudocritical properties
tpr = (form_temp + 459.67) / tpc
ppr = pore_press / ppc
### z factor from Dranchuk and Abou-Kassem fit of ###
### Standing and Katz chart ###
a = [0.3265,
-1.07,
-0.5339,
0.01569,
-0.05165,
0.5475,
-0.7361,
0.1844,
0.1056,
0.6134,
0.721]
t2 = a[0] * tpr + a[1] + a[2] / (tpr ** 2) + \
a[3] / (tpr ** 3) + a[4] / (tpr ** 4)
t3 = a[5] * tpr + a[6] + a[7] / tpr
t4 = -a[8] * (a[6] + a[7] / tpr)
t5 = a[9] / (tpr ** 2)
r = 0.27 * ppr / tpr
z = 0.27 * ppr / tpr / r
counter = 0
diff = 1
while counter <= 10 and diff > 10 ** -5:
counter += 1
f = r * (tpr + t2 * r + t3 * r ** 2 + t4 * r ** 5 + \
t5 * r ** 2 * (1 + a[10] * r**2) * \
np.exp(-a[10] * r **2)) - 0.27 * ppr
fp = tpr + 2 * t2 * r + 3 * t3 * r ** 2 + \
6 * t4 * r ** 5 + t5 * r ** 2 * \
np.exp(-a[10] * r ** 2) * \
(3 + a[10] * r ** 2 * (3 - 2 * a[10] * r ** 2))
r = r - f/fp
diff = np.abs(z - (0.27 * ppr / tpr / r)).max()
z = 0.27 * ppr / tpr / r
### gas compressiblity from Dranchuk and Abau-Kassem ###
cpr = tpr * z / ppr / fp
cg = cpr / ppc
### gas expansion factor ###
bg = (0.0282793 * z * (form_temp + 459.67)) / pore_press
### gas density Eq 1.64 GRE ###
rho_hc = 1.495 * 10 ** -3 * (pore_press * (gas_grav)) / \
(z * (form_temp + 459.67))
nphi_hc = 2.17 * rho_hc
### gas viscosity Lee Gonzalez Eakin method ###
### Eqs. 1.63-1.67 GRE ###
k = ((9.379 + 0.01607 * (28.9625 * gas_grav)) * \
(form_temp + 459.67) ** 1.5) / \
(209.2 + 19.26 * (28.9625 * gas_grav) + \
(form_temp + 459.67))
x = 3.448 + 986.4 / \
(form_temp + 459.67) + 0.01009 * (28.9625 * gas_grav)
y = 2.447 - 0.2224 * x
mu_hc = 10 **-4 * k * np.exp(x * rho_hc ** y)
### oil reservoir ###
else:
# Normalize gas gravity to separator pressure of 100 psi
ygs100 = gas_grav * (1 + 5.912 * 0.00001 * oil_api * \
(t_sep - 459.67) * np.log10(p_sep / 114.7))
if oil_api < 30:
if rs == 0 or rs is None:
rs = 0.0362 * ygs100 * pore_press ** 1.0937 * \
np.exp((25.724 * oil_api) / (form_temp + 459.67))
bp = ((56.18 * rs / ygs100) * 10 ** \
(-10.393 * oil_api / (form_temp + 459.67))) ** 0.84246
### gas saturated bubble-point ###
bo = 1 + 4.677 * 10 ** -4 * rs + 1.751 * 10 ** -5 * \
(form_temp - 60) * (oil_api / ygs100) - \
1.811 * 10 ** -8 * rs * \
(form_temp - 60) * (oil_api / ygs100)
else:
if rs == 0 or rs is None:
rs = 0.0178 * ygs100 * pore_press ** 1.187 * \
np.exp((23.931 * oil_api) / (form_temp + 459.67))
bp = ((56.18 * rs / ygs100) * 10 ** \
(-10.393 * oil_api / (form_temp + 459.67))) ** 0.84246
### gas saturated bubble-point ###
bo = 1 + 4.670 * 10 ** -4 * rs + 1.1 * \
10 ** -5 * (form_temp - 60) * (oil_api / ygs100) + \
1.337 * 10 ** -9 * rs * (form_temp - 60) * \
(oil_api / ygs100)
### calculate bo for undersaturated oil ###
pp_gt_bp = np.where(pore_press > bp + 100)[0]
if len(pp_gt_bp) > 0:
bo[pp_gt_bp] = bo[pp_gt_bp] * np.exp(-(0.00001 * \
(-1433 + 5 * rs + 17.2 * form_temp[pp_gt_bp] - \
1180 * ygs100 + 12.61 * oil_api)) * \
np.log(pore_press[pp_gt_bp] / bp[pp_gt_bp]))
### oil properties ###
rho_hc = (((141.5 / (oil_api + 131.5) * 62.428) + \
0.0136 * rs *ygs100) / bo) / 62.428
nphi_hc = 1.003 * rho_hc
### oil viscosity from Beggs-Robinson ###
### RE Handbook Eqs. 2.121 ###
muod = 10 ** (np.exp(6.9824 - 0.04658 * oil_api) *\
form_temp ** -1.163) - 1
mu_hc = (10.715 * (rs + 100) ** -0.515) * \
muod ** (5.44 * (rs + 150) ** -0.338)
### undersaturated oil viscosity from Vasquez and Beggs ###
### Eqs. 2.123 ###
if len(pp_gt_bp) > 0:
mu_hc[pp_gt_bp] = mu_hc[pp_gt_bp] * \
(pore_press[pp_gt_bp] / bp[pp_gt_bp]) ** \
(2.6 * pore_press[pp_gt_bp] ** 1.187 * \
10 ** (-0.000039 * pore_press[pp_gt_bp] - 5))
output_curves = [
{'mnemoic': 'PORE_PRESS', 'data': pore_press, 'unit':'psi',
'descr': 'Calculated Pore Pressure'},
{'mnemoic': 'RES_TEMP', 'data': form_temp, 'unit': 'F',
'descr': 'Calculated Reservoir Temperature'},
{'mnemoic': 'NES', 'data': nes, 'unit': 'psi',
'descr': 'Calculated Net Effective Stress'},
{'mnemoic': 'RW', 'data': rw, 'unit': 'ohmm',
'descr': 'Calculated Resistivity Water'},
{'mnemoic': 'RMF', 'data': rmf, 'unit': 'ohmm',
'descr': 'Calculated Resistivity Mud Filtrate'},
{'mnemoic': 'RHO_HC', 'data': rho_hc, 'unit': 'g/cc',
'descr': 'Calculated Density of Hydrocarbon'},
{'mnemoic': 'RHO_W', 'data': rho_w, 'unit': 'g/cc',
'descr': 'Calculated Density of Water'},
{'mnemoic': 'RHO_MF', 'data': rho_mf, 'unit': 'g/cc',
'descr': 'Calculated Density of Mud Filtrate'},
{'mnemoic': 'NPHI_HC', 'data': nphi_hc, 'unit': 'v/v',
'descr': 'Calculated Neutron Log Response of Hydrocarbon'},
{'mnemoic': 'NPHI_W', 'data': nphi_w, 'unit': 'v/v',
'descr': 'Calculated Neutron Log Response of Water'},
{'mnemoic': 'NPHI_MF', 'data': nphi_mf, 'unit': 'v/v',
'descr':'Calculated Neutron Log Response of Mud Filtrate'},
{'mnemoic': 'MU_HC', 'data': mu_hc, 'unit': 'cP',
'descr': 'Calculated Viscosity of Hydrocarbon'}
]
for curve in output_curves:
if curve['mnemoic'] in self.keys():
self[curve['mnemoic']][depth_index] = curve['data']
else:
data = np.empty(len(self[0]))
data[:] = np.nan
data[depth_index] = curve['data']
curve['data'] = data
self.add_curve(curve['mnemoic'], data = curve['data'],
unit = curve['unit'], descr = curve['descr'])
### gas curves ###
if oil_api == 0:
gas_curves = [
{'mnemoic': 'Z', 'data': z, 'unit': '',
'descr': 'Calcualted Real Gas Z Factor'},
{'mnemoic': 'CG', 'data': cg, 'unit': '1 / psi',
'descr': 'Calculated Gas Compressibility'},
{'mnemoic': 'BG', 'data': bg, 'unit': '',
'descr': 'Calculated Gas Formation Volume Factor'}
]
for curve in gas_curves:
if curve['mnemoic'] in self.keys():
self[curve['mnemoic']][depth_index] = curve['data']
else:
data = np.empty(len(self[0]))
data[:] = np.nan
data[depth_index] = curve['data']
curve['data'] = data
self.add_curve(curve['mnemoic'],
data = curve['data'],
unit = curve['unit'],
descr = curve['descr'])
### oil curves ###
else:
oil_curves = [
{'mnemoic': 'BO', 'data': bo, 'unit': '',
'descr': 'Calculated Oil Formation Volume Factor'},
{'mnemoic': 'BP', 'data': bp, 'unit': 'psi',
'descr': 'Calcualted Bubble Point'}
]
for curve in oil_curves:
if curve['mnemoic'] in self.keys():
self[curve['mnemoic']][depth_index] = curve['data']
else:
data = np.empty(len(self[0]))
data[:] = np.nan
data[depth_index] = curve['data']
curve['data'] = data
self.add_curve(curve['mnemoic'],
data = curve['data'],
unit = curve['unit'],
descr = curve['descr'])
def formation_fluid_properties(self, formations,
parameter = 'default'):
"""
Calculate fluid properties over formations with preloaded
paramters
Parameters
----------
formations : list
list of formations to calculate fluid properties over
parameter : str (default 'default')
name of parameter to use for fluid properties parameter
settings loaded in method
fluid_properties_parameters_from_csv
Example
-------
>>> import petropy as ptr
>>> # reads sample Wolfcamp Log from las file
>>> log = ptr.log_data('WFMP')
>>> # loads sample parameters provided
>>> log.fluid_properties_parameters_from_csv()
>>> # define formations to run
>>> f = ['WFMPA', 'WFMPB', 'WFMPC']
>>> # use WFMP parameters for formations from f
>>> log.formation_fluid_properties(f, parameter = 'WFMP')
See Also
--------
:meth:`petropy.Log.fluid_properties`
calculates fluid properties of log
:meth:`petropy.Log.fluid_properties_parameters_from_csv`
loads fluid properties parameters
:meth:`petropy.Log.tops_from_csv`
loads tops of log from csv
"""
for form in formations:
top = self.tops[form]
bottom = self.next_formation_depth(form)
params = self.fluid_properties_parameters[parameter]
self.fluid_properties(top = top, bottom = bottom, **params)
def multimineral_parameters_from_csv(self, csv_path = None):
"""
Reads parameters from a csv for input into the multimineral
model.
This method reads the file located at the csv_path and turns
the values into dictionaries to be used as inputs into the
multimineral method.
This link_ contains a sample csv file with default
multimineral properties data.
.. _link: ../_static/multimineral_parameters.csv
Parameters
----------
csv_path : str (default None)
Path to csv file to read.
Note
----
CSV file must contain header row with the following properties
for the multimineral_model
gr_matrix : float (default 10)
Gamma Ray response of clean (non-clay) matrix
nphi_matrix : float (default 0)
Neutron response of clean (non-clay) matrix
gr_clay : float (default 450)
Gamma Ray response of pure clay matrix
rho_clay : float (default 2.64)
Density of pure clay matrix
nphi_clay : float (default 0.65)
Neutron reponse of pure clay matrix
pe_clay : float (default 4)
Photoelectric response of pure clay matrix
rma : float (default 180)
Resistivity of clean tight matrix
rt_clay : float (default 80)
Resistivity for inorganic shale matrix
vclay_linear_weight : float (default 1)
Weight of liner clay volume
vclay_clavier_weight : float (defaul 0.5)
Weight of Clavier clay volume
vclay_larionov_weight : float (defaul 0.5)
Weight of Larionov clay volume
vclay_nphi_weight : float (default 1)
Weight of Neutron clay volume
vclay_nphi_rhob_weight : float (default 1)
Weight of Neutron Density clay volume
vclay_cutoff : float (default 0.05)
Cutoff for oranics calculation.
If vclay < vclay_cutoff then toc = 0
rho_om : float (default 1.15)
Density of organic matter
nphi_om : float (default 0.6)
Neutron response of pure organic matter
pe_om : float (default 0.2)
Photoelectric response of pure organic matter
ro : float (default 1.6)
Vitronite reflectance of organic matter
lang_press : float (default 670)
Langmiur pressure for gas adsorption on organics in psi
passey_nphi_weight : float (default 1)
Weight for Passey nphi toc
passey_rhob_weight : float (default 1)
Weight for Passey rhob toc
passey_lom : float (default 10)
Passey level of organic maturity
passey_baseline_res : float (default 40)
Passey inorganic baseline resistivity
passey_baseline_rhob : float (default 2.65)
Passey inorganic baseline density
passey_baseline_nphi : float (default 0)
Passey inorganic baseline neutron
schmoker_weight : float (default 1)
Weight for Schmoker toc
schmoker_slope : float (default 0.7257)
Slope for schmoker density to toc correlation
schmoker_baseline_rhob : float (default 2.6)
Density cutoff for schmoker toc correlation
rho_pyr : float (default 5)
Density of pyrite
nphi_pyr : float (default 0.13)
Neutron response of pure pyrite
pe_pyr : float (default 13)
Photoelectric response of pure pyrite
om_pyrite_slope : float (default 0.2)
Slope correlating pyrite volume to organic matter
include_qtz : str {'YES', 'NO'} (default 'YES')
Toggle to include or exclude qtz.
'YES' to include. 'NO' to exclude.
rho_qtz : float (default 2.65)
Density of quartz
nphi_qtz : float (default -0.04)
Neutron response for pure quartz
pe_qtz : float (default 1.81)
Photoelectric response for pure quartz
include_clc : str {'YES', 'NO'} (default 'YES')
Toggle to include or exclude clc.
'YES' to include. 'NO' to exclude.
rho_clc : float (default 2.71)
Density of calcite
nphi_clc : float (default 0)
Neutron response for pure calcite
pe_clc : float (default 5.08)
Photoelectric response for pure calcite
include_dol : str {'YES', 'NO'} (default 'YES')
Toggle to include or exclude dol.
'YES' to include. 'NO' to exclude.
rho_dol : float (default 2.85)
Density of dolomite
nphi_dol : float (default 0.04)
Neutron response to dolomite
pe_dol : float (default 3.14)
Photoelectric response to dolomite
include_x : str {'YES', 'NO'} (default 'NO')
Toggle to include or exclude exotic mineral, x.
'YES' to include. 'NO' to exclude.
name_x : str (default 'Gypsum')
Name of exotic mineral, x.
name_log_x : str (default 'GYP')
Log name of exotic mineral, x
rho_x : float (default 2.35)
Density of exotic mineral, x
nphi_x : float (default 0.507)
Neutron response of exotic mineral, x
pe_x : float (default 4.04)
Photoelectric respone of exotic mineral, x
pe_fl : float (default 0)
Photoelectric response of reservoir fluid.
m : float (default 2)