openpnm 1.0.0__zip

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. OpenPNM-1.1/MANIFEST.in +2 -0
  2. OpenPNM-1.1/OpenPNM/Algorithms/__FickianDiffusion__.py +67 -0
  3. OpenPNM-1.1/OpenPNM/Algorithms/__FourierConduction__.py +63 -0
  4. OpenPNM-1.1/OpenPNM/Algorithms/__GenericAlgorithm__.py +235 -0
  5. OpenPNM-1.1/OpenPNM/Algorithms/__GenericLinearTransport__.py +641 -0
  6. OpenPNM-1.1/OpenPNM/Algorithms/__InvasionPercolationForImbibition__.py +703 -0
  7. OpenPNM-1.1/OpenPNM/Algorithms/__InvasionPercolationTimed__.py +702 -0
  8. OpenPNM-1.1/OpenPNM/Algorithms/__InvasionPercolation__.py +156 -0
  9. OpenPNM-1.1/OpenPNM/Algorithms/__OhmicConduction__.py +64 -0
  10. OpenPNM-1.1/OpenPNM/Algorithms/__OrdinaryPercolation__.py +402 -0
  11. OpenPNM-1.1/OpenPNM/Algorithms/__StokesFlow__.py +64 -0
  12. OpenPNM-1.1/OpenPNM/Algorithms/__Tortuosity__.py +91 -0
  13. OpenPNM-1.1/OpenPNM/Algorithms/__init__.py +48 -0
  14. OpenPNM-1.1/OpenPNM/Base/__Controller__.py +480 -0
  15. OpenPNM-1.1/OpenPNM/Base/__Core__.py +1522 -0
  16. OpenPNM-1.1/OpenPNM/Base/__ModelsDict__.py +345 -0
  17. OpenPNM-1.1/OpenPNM/Base/__Tools__.py +72 -0
  18. OpenPNM-1.1/OpenPNM/Base/__init__.py +32 -0
  19. OpenPNM-1.1/OpenPNM/Geometry/__Boundary__.py +80 -0
  20. OpenPNM-1.1/OpenPNM/Geometry/__Cube_and_Cuboid__.py +64 -0
  21. OpenPNM-1.1/OpenPNM/Geometry/__GenericGeometry__.py +106 -0
  22. OpenPNM-1.1/OpenPNM/Geometry/__SGL10__.py +67 -0
  23. OpenPNM-1.1/OpenPNM/Geometry/__Stick_and_Ball__.py +68 -0
  24. OpenPNM-1.1/OpenPNM/Geometry/__TestGeometry__.py +51 -0
  25. OpenPNM-1.1/OpenPNM/Geometry/__Toray090__.py +68 -0
  26. OpenPNM-1.1/OpenPNM/Geometry/__Voronoi__.py +98 -0
  27. OpenPNM-1.1/OpenPNM/Geometry/__init__.py +47 -0
  28. OpenPNM-1.1/OpenPNM/Geometry/models/__init__.py +33 -0
  29. OpenPNM-1.1/OpenPNM/Geometry/models/pore_area.py +27 -0
  30. OpenPNM-1.1/OpenPNM/Geometry/models/pore_centroid.py +35 -0
  31. OpenPNM-1.1/OpenPNM/Geometry/models/pore_diameter.py +127 -0
  32. OpenPNM-1.1/OpenPNM/Geometry/models/pore_misc.py +55 -0
  33. OpenPNM-1.1/OpenPNM/Geometry/models/pore_seed.py +212 -0
  34. OpenPNM-1.1/OpenPNM/Geometry/models/pore_surface_area.py +28 -0
  35. OpenPNM-1.1/OpenPNM/Geometry/models/pore_vertices.py +19 -0
  36. OpenPNM-1.1/OpenPNM/Geometry/models/pore_volume.py +133 -0
  37. OpenPNM-1.1/OpenPNM/Geometry/models/throat_area.py +47 -0
  38. OpenPNM-1.1/OpenPNM/Geometry/models/throat_centroid.py +80 -0
  39. OpenPNM-1.1/OpenPNM/Geometry/models/throat_diameter.py +106 -0
  40. OpenPNM-1.1/OpenPNM/Geometry/models/throat_length.py +95 -0
  41. OpenPNM-1.1/OpenPNM/Geometry/models/throat_misc.py +42 -0
  42. OpenPNM-1.1/OpenPNM/Geometry/models/throat_normal.py +31 -0
  43. OpenPNM-1.1/OpenPNM/Geometry/models/throat_offset_vertices.py +191 -0
  44. OpenPNM-1.1/OpenPNM/Geometry/models/throat_perimeter.py +26 -0
  45. OpenPNM-1.1/OpenPNM/Geometry/models/throat_seed.py +12 -0
  46. OpenPNM-1.1/OpenPNM/Geometry/models/throat_shape_factor.py +37 -0
  47. OpenPNM-1.1/OpenPNM/Geometry/models/throat_surface_area.py +44 -0
  48. OpenPNM-1.1/OpenPNM/Geometry/models/throat_vector.py +27 -0
  49. OpenPNM-1.1/OpenPNM/Geometry/models/throat_vertices.py +19 -0
  50. OpenPNM-1.1/OpenPNM/Geometry/models/throat_volume.py +45 -0
  51. OpenPNM-1.1/OpenPNM/Network/__Cubic__.py +316 -0
  52. OpenPNM-1.1/OpenPNM/Network/__DelaunayCubic__.py +127 -0
  53. OpenPNM-1.1/OpenPNM/Network/__Delaunay__.py +600 -0
  54. OpenPNM-1.1/OpenPNM/Network/__GenericNetwork__.py +1184 -0
  55. OpenPNM-1.1/OpenPNM/Network/__MatFile__.py +331 -0
  56. OpenPNM-1.1/OpenPNM/Network/__TestNet__.py +109 -0
  57. OpenPNM-1.1/OpenPNM/Network/__init__.py +40 -0
  58. OpenPNM-1.1/OpenPNM/Network/models/__init__.py +12 -0
  59. OpenPNM-1.1/OpenPNM/Network/models/pore_topology.py +106 -0
  60. OpenPNM-1.1/OpenPNM/Phases/__Air__.py +63 -0
  61. OpenPNM-1.1/OpenPNM/Phases/__GenericPhase__.py +146 -0
  62. OpenPNM-1.1/OpenPNM/Phases/__Mercury__.py +71 -0
  63. OpenPNM-1.1/OpenPNM/Phases/__TestPhase__.py +46 -0
  64. OpenPNM-1.1/OpenPNM/Phases/__Water__.py +56 -0
  65. OpenPNM-1.1/OpenPNM/Phases/__init__.py +38 -0
  66. OpenPNM-1.1/OpenPNM/Phases/models/__init__.py +22 -0
  67. OpenPNM-1.1/OpenPNM/Phases/models/contact_angle.py +34 -0
  68. OpenPNM-1.1/OpenPNM/Phases/models/density.py +81 -0
  69. OpenPNM-1.1/OpenPNM/Phases/models/diffusivity.py +95 -0
  70. OpenPNM-1.1/OpenPNM/Phases/models/electrical_conductivity.py +10 -0
  71. OpenPNM-1.1/OpenPNM/Phases/models/misc.py +125 -0
  72. OpenPNM-1.1/OpenPNM/Phases/models/molar_density.py +69 -0
  73. OpenPNM-1.1/OpenPNM/Phases/models/molar_mass.py +31 -0
  74. OpenPNM-1.1/OpenPNM/Phases/models/surface_tension.py +104 -0
  75. OpenPNM-1.1/OpenPNM/Phases/models/thermal_conductivity.py +98 -0
  76. OpenPNM-1.1/OpenPNM/Phases/models/vapor_pressure.py +69 -0
  77. OpenPNM-1.1/OpenPNM/Phases/models/viscosity.py +103 -0
  78. OpenPNM-1.1/OpenPNM/Physics/__GenericPhysics__.py +111 -0
  79. OpenPNM-1.1/OpenPNM/Physics/__Standard__.py +51 -0
  80. OpenPNM-1.1/OpenPNM/Physics/__TestPhysics__.py +50 -0
  81. OpenPNM-1.1/OpenPNM/Physics/__init__.py +30 -0
  82. OpenPNM-1.1/OpenPNM/Physics/models/__init__.py +18 -0
  83. OpenPNM-1.1/OpenPNM/Physics/models/capillary_pressure.py +122 -0
  84. OpenPNM-1.1/OpenPNM/Physics/models/diffusive_conductance.py +82 -0
  85. OpenPNM-1.1/OpenPNM/Physics/models/electrical_conductance.py +59 -0
  86. OpenPNM-1.1/OpenPNM/Physics/models/generic_source_term.py +564 -0
  87. OpenPNM-1.1/OpenPNM/Physics/models/hydraulic_conductance.py +76 -0
  88. OpenPNM-1.1/OpenPNM/Physics/models/multiphase.py +133 -0
  89. OpenPNM-1.1/OpenPNM/Physics/models/thermal_conductance.py +67 -0
  90. OpenPNM-1.1/OpenPNM/Postprocessing/Graphics.py +251 -0
  91. OpenPNM-1.1/OpenPNM/Postprocessing/Plots.py +369 -0
  92. OpenPNM-1.1/OpenPNM/Postprocessing/__init__.py +10 -0
  93. OpenPNM-1.1/OpenPNM/Utilities/IO.py +277 -0
  94. OpenPNM-1.1/OpenPNM/Utilities/Shortcuts.py +17 -0
  95. OpenPNM-1.1/OpenPNM/Utilities/__init__.py +16 -0
  96. OpenPNM-1.1/OpenPNM/Utilities/misc.py +226 -0
  97. OpenPNM-1.1/OpenPNM/Utilities/transformations.py +1923 -0
  98. OpenPNM-1.1/OpenPNM/Utilities/vertexops.py +824 -0
  99. OpenPNM-1.1/OpenPNM/__init__.py +56 -0
  100. OpenPNM-1.1/OpenPNM.egg-info/PKG-INFO +11 -0
  101. OpenPNM-1.1/OpenPNM.egg-info/SOURCES.txt +107 -0
  102. OpenPNM-1.1/OpenPNM.egg-info/dependency_links.txt +1 -0
  103. OpenPNM-1.1/OpenPNM.egg-info/requires.txt +1 -0
  104. OpenPNM-1.1/OpenPNM.egg-info/top_level.txt +1 -0
  105. OpenPNM-1.1/PKG-INFO +11 -0
  106. OpenPNM-1.1/README.txt +88 -0
  107. OpenPNM-1.1/setup.cfg +7 -0
  108. OpenPNM-1.1/setup.py +39 -0
@@ -0,0 +1,226 @@
1
+ import scipy as _sp
2
+ import time as _time
3
+ from scipy.spatial.distance import cdist as dist
4
+
5
+ def reflect_pts(coords,nplane):
6
+ r'''
7
+ Reflect points across the given plane
8
+
9
+ Parameters
10
+ ----------
11
+ coords : array_like
12
+ An Np x ndims array off [x,y,z] coordinates
13
+
14
+ nplane : array_like
15
+ A vector of length ndims, specifying the normal to the plane. The tail
16
+ of the vector is assume to lie on the plane, and the reflection will
17
+ be applied in the direction of the vector.
18
+
19
+ Returns
20
+ -------
21
+ coords : array_like
22
+ An Np x ndmins vector of reflected point, not including the input points
23
+
24
+ '''
25
+ pass
26
+
27
+ def crop_pts(coords,box):
28
+ r'''
29
+ Drop all points lying outside the box
30
+
31
+ Parameters
32
+ ----------
33
+ coords : array_like
34
+ An Np x ndims array off [x,y,z] coordinates
35
+
36
+ box : array_like
37
+ A 2 x ndims array of diametrically opposed corner coordintes
38
+
39
+ Returns
40
+ -------
41
+ coords : array_like
42
+ Inputs coordinates with outliers removed
43
+
44
+ Notes
45
+ -----
46
+ This needs to be made more general so that an arbitray cuboid with any
47
+ orientation can be supplied, using Np x 8 points
48
+ '''
49
+ coords = coords[_sp.any(coords<box[0],axis=1)]
50
+ coords = coords[_sp.any(coords>box[1],axis=1)]
51
+ return coords
52
+
53
+ def iscoplanar(coords):
54
+ r'''
55
+ Determines if given pores are coplanar with each other
56
+
57
+ Parameters
58
+ ----------
59
+ coords : array_like
60
+ List of pore coords to check for coplanarity. At least 3 pores are
61
+ required.
62
+
63
+ Returns
64
+ -------
65
+ A boolean value of whether given points are colplanar (True) or not (False)
66
+ '''
67
+ coords = _sp.array(coords,ndmin=1)
68
+ if _sp.shape(coords)[0] < 3:
69
+ raise Exception('At least 3 input pores are required')
70
+
71
+ Px = coords[:,0]
72
+ Py = coords[:,1]
73
+ Pz = coords[:,2]
74
+
75
+ #Do easy check first, for common coordinate
76
+ if _sp.shape(_sp.unique(Px))[0] == 1:
77
+ return True
78
+ if _sp.shape(_sp.unique(Py))[0] == 1:
79
+ return True
80
+ if _sp.shape(_sp.unique(Pz))[0] == 1:
81
+ return True
82
+
83
+ #Perform rigorous check using vector algebra
84
+ n = _sp.array((Px - Px[0],Py - Py[0],Pz - Pz[0])).T
85
+ n0 = _sp.array((Px[-1] - Px[0],Py[-1] - Py[0],Pz[-1] - Pz[0])).T
86
+
87
+ n_cross = _sp.cross(n0,n)
88
+ n_dot = _sp.multiply(n0,n_cross)
89
+
90
+ if _sp.sum(_sp.absolute(n_dot)) == 0:
91
+ return True
92
+ else:
93
+ return False
94
+
95
+ def tic():
96
+ r'''
97
+ Homemade version of matlab tic and toc function, tic starts or resets
98
+ the clock, toc reports the time since the last call of tic.
99
+ '''
100
+ global _startTime_for_tictoc
101
+ _startTime_for_tictoc = _time.time()
102
+
103
+ def toc(quiet=False):
104
+ r'''
105
+ Homemade version of matlab tic and toc function, tic starts or resets
106
+ the clock, toc reports the time since the last call of tic.
107
+
108
+ Parameters
109
+ ----------
110
+ quiet : Boolean
111
+ If False (default) then a message is output to the console. If True
112
+ the message is not displayed and the elapsed time is returned.
113
+ '''
114
+ if '_startTime_for_tictoc' in globals():
115
+ t = _time.time() - _startTime_for_tictoc
116
+ if quiet == False:
117
+ print('Elapsed time in seconds: ', t)
118
+ else:
119
+ return t
120
+ else:
121
+ print("Toc: start time not set")
122
+
123
+
124
+ def unique_list(input_list):
125
+ r"""
126
+ For a given list (of points) remove any duplicates
127
+ """
128
+ output_list = []
129
+ if len(input_list) > 0:
130
+ dim = _sp.shape(input_list)[1]
131
+ for i in input_list:
132
+ match=False
133
+ for j in output_list:
134
+ if dim == 3:
135
+ if (i[0]==j[0]) and (i[1]==j[1]) and (i[2]==j[2]):
136
+ match=True
137
+ elif dim == 2:
138
+ if (i[0]==j[0]) and (i[1]==j[1]):
139
+ match=True
140
+ elif dim ==1:
141
+ if (i[0]==j[0]):
142
+ match=True
143
+ if match==False:
144
+ output_list.append(i)
145
+ return output_list
146
+
147
+ def amalgamate_data(objs=[]):
148
+ r"""
149
+ Returns a dictionary containing ALL pore data from all netowrk and/or
150
+ phase objects received as arguments
151
+ """
152
+ if type(objs) is not list:
153
+ objs = list(objs)
154
+ data_amalgamated = {}
155
+ exclusion_list = ['pore.centroid','pore.vertices','throat.centroid','throat.offset_vertices','throat.vertices','throat.normal','throat.perimeter','pore.vert_index','throat.vert_index']
156
+ for item in objs:
157
+ mro = [module.__name__ for module in item.__class__.__mro__]
158
+ if 'GenericNetwork' in mro: #if Network object, combine Geometry and Network keys
159
+ keys = []
160
+ for key in item.keys():
161
+ keys.append(key)
162
+ for geom in item._geometries:
163
+ for key in geom.keys():
164
+ if key not in keys:
165
+ keys.append(key)
166
+ else:
167
+ if 'GenericPhase' in mro:
168
+ keys = []
169
+ for key in item.keys():
170
+ keys.append(key)
171
+ for physics in item._physics:
172
+ for key in physics.keys():
173
+ if key not in keys:
174
+ keys.append(key)
175
+ keys.sort()
176
+ for key in keys:
177
+ if key not in exclusion_list:
178
+ try:
179
+ if _sp.amax(item[key]) < _sp.inf:
180
+ element = key.split('.')[0]
181
+ propname = key.split('.')[1]
182
+ dict_name = element+'.'+item.name+'_'+propname
183
+ if key in ['pore.coords', 'throat.conns', 'pore.all','throat.all']:
184
+ dict_name = key
185
+ data_amalgamated.update({dict_name : item[key]})
186
+ except TypeError:
187
+ pass
188
+ return data_amalgamated
189
+
190
+ def conduit_lengths(network,throats=None,mode='pore'):
191
+ r"""
192
+ Return the respective lengths of the conduit components defined by the throat conns P1 T P2
193
+ mode = 'pore' - uses pore coordinates
194
+ mode = 'centroid' uses pore and throat centroids
195
+ """
196
+ if throats is None:
197
+ throats = network.throats()
198
+ Ps = network['throat.conns']
199
+ pdia = network['pore.diameter']
200
+
201
+ if mode == 'centroid':
202
+ try:
203
+ pcentroids = network['pore.centroid']
204
+ tcentroids = network['throat.centroid']
205
+ if _sp.sum(_sp.isnan(pcentroids)) + _sp.sum(_sp.isnan(tcentroids)) > 0:
206
+ mode = 'pore'
207
+ else:
208
+ plen1 = _sp.sqrt(_sp.sum(_sp.square(pcentroids[Ps[:,0]]-tcentroids),1))-network['throat.length']/2
209
+ plen2 = _sp.sqrt(_sp.sum(_sp.square(pcentroids[Ps[:,1]]-tcentroids),1))-network['throat.length']/2
210
+ except KeyError:
211
+ mode = 'pore'
212
+ if mode == 'pore':
213
+ #Find half-lengths of each pore
214
+ pcoords = network['pore.coords']
215
+ # Find the pore-to-pore distance, minus the throat length
216
+ lengths = _sp.sqrt(_sp.sum(_sp.square(pcoords[Ps[:,0]]-pcoords[Ps[:,1]]),1))-network['throat.length']
217
+ # Calculate the fraction of that distance from the first pore
218
+ try:
219
+ fractions = pdia[Ps[:,0]]/(pdia[Ps[:,0]]+pdia[Ps[:,1]])
220
+ except:
221
+ fractions = 0.5
222
+ plen1 = lengths*fractions
223
+ plen2 = lengths*(1-fractions)
224
+
225
+ return _sp.vstack((plen1,network['throat.length'],plen2)).T[throats]
226
+