openpnm 1.4.6__zip → 1.5__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.
- OpenPNM-1.5/OpenPNM/Base/__Controller__.py +10 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Base/__Core__.py +32 -19
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Base/__ModelsDict__.py +11 -11
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Base/__Tools__.py +5 -1
- OpenPNM-1.4.6/OpenPNM/Base/__Controller__.py → OpenPNM-1.5/OpenPNM/Base/__Workspace__.py +52 -41
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Base/__init__.py +3 -1
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/__Boundary__.py +2 -1
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/__GenericGeometry__.py +1 -1
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Network/__GenericNetwork__.py +113 -79
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Network/tools.py +7 -7
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Physics/__GenericPhysics__.py +1 -1
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Physics/models/diffusive_conductance.py +11 -5
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Physics/models/hydraulic_conductance.py +8 -8
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Utilities/IO.py +309 -6
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Utilities/misc.py +3 -3
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/__init__.py +11 -11
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM.egg-info/PKG-INFO +1 -1
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM.egg-info/SOURCES.txt +1 -1
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM.egg-info/requires.txt +2 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/PKG-INFO +1 -1
- OpenPNM-1.5/README.rst +142 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/setup.cfg +2 -5
- {OpenPNM-1.4.6 → OpenPNM-1.5}/setup.py +4 -2
- OpenPNM-1.4.6/README.rst +0 -114
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Algorithms/__Drainage__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Algorithms/__FickianDiffusion__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Algorithms/__FourierConduction__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Algorithms/__GenericAlgorithm__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Algorithms/__GenericLinearTransport__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Algorithms/__InvasionPercolation__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Algorithms/__OhmicConduction__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Algorithms/__OrdinaryPercolation__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Algorithms/__StokesFlow__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Algorithms/__Tortuosity__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Algorithms/__init__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/__Cube_and_Cuboid__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/__SGL10__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/__Stick_and_Ball__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/__TestGeometry__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/__Toray090__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/__Voronoi__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/__init__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/__init__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/misc.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/pore_area.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/pore_centroid.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/pore_diameter.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/pore_misc.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/pore_seed.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/pore_surface_area.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/pore_vertices.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/pore_volume.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/throat_area.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/throat_centroid.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/throat_diameter.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/throat_length.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/throat_misc.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/throat_normal.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/throat_offset_vertices.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/throat_perimeter.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/throat_seed.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/throat_shape_factor.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/throat_surface_area.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/throat_vector.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/throat_vertices.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Geometry/models/throat_volume.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Network/__Cubic__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Network/__DelaunayCubic__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Network/__Delaunay__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Network/__Empty__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Network/__MatFile__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Network/__TestNet__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Network/__init__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Network/models/__init__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Network/models/pore_topology.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Phases/__Air__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Phases/__GenericPhase__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Phases/__Mercury__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Phases/__TestPhase__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Phases/__Water__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Phases/__init__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Phases/models/__init__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Phases/models/contact_angle.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Phases/models/density.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Phases/models/diffusivity.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Phases/models/electrical_conductivity.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Phases/models/misc.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Phases/models/molar_density.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Phases/models/molar_mass.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Phases/models/surface_tension.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Phases/models/thermal_conductivity.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Phases/models/vapor_pressure.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Phases/models/viscosity.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Physics/__Standard__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Physics/__TestPhysics__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Physics/__init__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Physics/models/__init__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Physics/models/capillary_pressure.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Physics/models/electrical_conductance.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Physics/models/generic_source_term.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Physics/models/multiphase.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Physics/models/thermal_conductance.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Postprocessing/Plots.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Postprocessing/__init__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Utilities/__init__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Utilities/__topology__.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM/Utilities/vertexops.py +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM.egg-info/dependency_links.txt +0 -0
- {OpenPNM-1.4.6 → OpenPNM-1.5}/OpenPNM.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""
|
|
2
|
+
###############################################################################
|
|
3
|
+
Controller: Overall controller class
|
|
4
|
+
###############################################################################
|
|
5
|
+
"""
|
|
6
|
+
from OpenPNM.Base import Workspace
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Controller(Workspace):
|
|
10
|
+
pass
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Core: Core Data Class
|
|
4
4
|
###############################################################################
|
|
5
5
|
"""
|
|
6
|
-
from OpenPNM.Base import
|
|
6
|
+
from OpenPNM.Base import Workspace
|
|
7
7
|
import string
|
|
8
8
|
import random
|
|
9
9
|
import scipy as sp
|
|
@@ -11,7 +11,7 @@ import scipy.constants
|
|
|
11
11
|
from OpenPNM.Base import logging, Tools
|
|
12
12
|
from OpenPNM.Base import ModelsDict
|
|
13
13
|
logger = logging.getLogger()
|
|
14
|
-
|
|
14
|
+
mgr = Workspace()
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
class Core(dict):
|
|
@@ -107,20 +107,20 @@ class Core(dict):
|
|
|
107
107
|
# TODO: This should probably raise the following exception
|
|
108
108
|
# raise Exception('Cannot write vector of the wrong length')
|
|
109
109
|
|
|
110
|
-
def
|
|
111
|
-
if self in
|
|
112
|
-
return
|
|
110
|
+
def _get_mgr(self):
|
|
111
|
+
if self in mgr.values():
|
|
112
|
+
return mgr
|
|
113
113
|
else:
|
|
114
114
|
return {}
|
|
115
115
|
|
|
116
|
-
def
|
|
117
|
-
if self not in
|
|
118
|
-
|
|
116
|
+
def _set_mgr(self, mgr):
|
|
117
|
+
if self not in mgr.values():
|
|
118
|
+
mgr.update({self.name: self})
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
workspace = property(fget=_get_mgr, fset=_set_mgr)
|
|
121
121
|
|
|
122
122
|
def _set_name(self, name):
|
|
123
|
-
if name in
|
|
123
|
+
if name in mgr.keys():
|
|
124
124
|
raise Exception('An object named '+name+' already exists')
|
|
125
125
|
elif name is None:
|
|
126
126
|
name = ''.join(random.choice(string.ascii_uppercase +
|
|
@@ -130,7 +130,7 @@ class Core(dict):
|
|
|
130
130
|
elif self._name is not None:
|
|
131
131
|
logger.info('Changing the name of '+self.name+' to '+name)
|
|
132
132
|
# Check if name collides with any arrays in the simulation
|
|
133
|
-
if
|
|
133
|
+
if mgr._validate_name(name):
|
|
134
134
|
# Rename any label arrays
|
|
135
135
|
for item in self._simulation():
|
|
136
136
|
if 'pore.'+self.name in item.keys():
|
|
@@ -140,11 +140,11 @@ class Core(dict):
|
|
|
140
140
|
else:
|
|
141
141
|
raise Exception('The provided name is already in use')
|
|
142
142
|
# Remove reference to object under old name, if present
|
|
143
|
-
for item in list(
|
|
143
|
+
for item in list(mgr.items()):
|
|
144
144
|
if item[1] is self:
|
|
145
|
-
|
|
146
|
-
# Add object to
|
|
147
|
-
|
|
145
|
+
mgr.pop(item[0])
|
|
146
|
+
# Add object to workspace under new name
|
|
147
|
+
mgr.update({name: self})
|
|
148
148
|
self._name = name
|
|
149
149
|
|
|
150
150
|
def _get_name(self):
|
|
@@ -425,7 +425,7 @@ class Core(dict):
|
|
|
425
425
|
Returns
|
|
426
426
|
-------
|
|
427
427
|
A list containing the dictionary keys on the object limited by the
|
|
428
|
-
specified
|
|
428
|
+
specified ``mode``.
|
|
429
429
|
|
|
430
430
|
Examples
|
|
431
431
|
--------
|
|
@@ -1294,8 +1294,21 @@ class Core(dict):
|
|
|
1294
1294
|
return_mapping=return_mapping)
|
|
1295
1295
|
return Ts
|
|
1296
1296
|
|
|
1297
|
-
|
|
1298
|
-
|
|
1297
|
+
@property
|
|
1298
|
+
def Tnet(self):
|
|
1299
|
+
r"""
|
|
1300
|
+
A shortcut to retrieve the mapping of the current object's throats onto
|
|
1301
|
+
the network.
|
|
1302
|
+
"""
|
|
1303
|
+
return self.map_throats()
|
|
1304
|
+
|
|
1305
|
+
@property
|
|
1306
|
+
def Pnet(self):
|
|
1307
|
+
r"""
|
|
1308
|
+
A shortcut to retrieve the mapping of the current object's pores onto
|
|
1309
|
+
the network.
|
|
1310
|
+
"""
|
|
1311
|
+
return self.map_pores()
|
|
1299
1312
|
|
|
1300
1313
|
def _parse_locations(self, locations):
|
|
1301
1314
|
r"""
|
|
@@ -1424,7 +1437,7 @@ class Core(dict):
|
|
|
1424
1437
|
if parsed_labels.count(L) > 1]
|
|
1425
1438
|
return parsed_labels
|
|
1426
1439
|
|
|
1427
|
-
def _parse_mode(self, mode, allowed=None, single=
|
|
1440
|
+
def _parse_mode(self, mode, allowed=None, single=False):
|
|
1428
1441
|
r"""
|
|
1429
1442
|
This private method is for checking the \'mode\' used in the calling
|
|
1430
1443
|
method.
|
|
@@ -5,7 +5,7 @@ ModelsDict: Abstract Class for Containing Models
|
|
|
5
5
|
"""
|
|
6
6
|
import inspect
|
|
7
7
|
from collections import OrderedDict
|
|
8
|
-
from OpenPNM.Base import logging,
|
|
8
|
+
from OpenPNM.Base import logging, Workspace
|
|
9
9
|
logger = logging.getLogger()
|
|
10
10
|
|
|
11
11
|
|
|
@@ -81,13 +81,13 @@ class ModelWrapper(dict):
|
|
|
81
81
|
return self['model'](**kwargs)
|
|
82
82
|
|
|
83
83
|
def _find_master(self):
|
|
84
|
-
|
|
84
|
+
mgr = Workspace()
|
|
85
85
|
master = []
|
|
86
|
-
for item in list(
|
|
87
|
-
if
|
|
88
|
-
for model in list(
|
|
89
|
-
if
|
|
90
|
-
master.append(
|
|
86
|
+
for item in list(mgr.keys()):
|
|
87
|
+
if mgr[item].models is not None:
|
|
88
|
+
for model in list(mgr[item].models.keys()):
|
|
89
|
+
if mgr[item].models[model] is self:
|
|
90
|
+
master.append(mgr[item])
|
|
91
91
|
if len(master) > 1:
|
|
92
92
|
raise Exception('More than one master found! This model dictionary '
|
|
93
93
|
'has been associated with multiple objects. To use '
|
|
@@ -360,11 +360,11 @@ class ModelsDict(OrderedDict):
|
|
|
360
360
|
self.move_to_end(item)
|
|
361
361
|
|
|
362
362
|
def _find_master(self):
|
|
363
|
-
|
|
363
|
+
mgr = Workspace()
|
|
364
364
|
master = []
|
|
365
|
-
for item in list(
|
|
366
|
-
if
|
|
367
|
-
master.append(
|
|
365
|
+
for item in list(mgr.keys()):
|
|
366
|
+
if mgr[item].models is self:
|
|
367
|
+
master.append(mgr[item])
|
|
368
368
|
if len(master) > 1:
|
|
369
369
|
raise Exception('More than one master found! This model dictionary '
|
|
370
370
|
'has been associated with multiple objects. To use the '
|
|
@@ -17,6 +17,10 @@ class PrintableList(list):
|
|
|
17
17
|
lines.append(horizontal_rule)
|
|
18
18
|
return '\n'.join(lines)
|
|
19
19
|
|
|
20
|
+
def __repr__(self):
|
|
21
|
+
self.sort()
|
|
22
|
+
return super().__repr__()
|
|
23
|
+
|
|
20
24
|
|
|
21
25
|
class ObjectContainer(dict):
|
|
22
26
|
r"""
|
|
@@ -98,7 +102,7 @@ class SetLocations():
|
|
|
98
102
|
def add(obj, element, locations):
|
|
99
103
|
net = obj._net
|
|
100
104
|
element = obj._parse_element(element, single=True)
|
|
101
|
-
locations =
|
|
105
|
+
locations = net._parse_locations(locations)
|
|
102
106
|
|
|
103
107
|
# Adapt the method depending on type of object received
|
|
104
108
|
if obj._isa('Physics'):
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"""
|
|
2
2
|
###############################################################################
|
|
3
|
-
|
|
3
|
+
Workspace: A class for managing the workspace of all objects
|
|
4
4
|
###############################################################################
|
|
5
5
|
"""
|
|
6
|
-
import
|
|
6
|
+
import dill as _pickle
|
|
7
7
|
import copy as _copy
|
|
8
8
|
import time
|
|
9
9
|
import random
|
|
@@ -13,16 +13,16 @@ from OpenPNM.Base import logging
|
|
|
13
13
|
logger = logging.getLogger()
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
class
|
|
16
|
+
class Workspace(dict):
|
|
17
17
|
# The following __instance__ class variable and subclassed __new__ method
|
|
18
|
-
# makes the
|
|
19
|
-
# of a
|
|
18
|
+
# makes the Workspace class a 'Singleton'. This way, any instantiation
|
|
19
|
+
# of a workspace object anywhere in the code will return the same object.
|
|
20
20
|
__instance__ = None
|
|
21
21
|
|
|
22
22
|
def __new__(cls, *args, **kwargs):
|
|
23
|
-
if
|
|
24
|
-
|
|
25
|
-
return
|
|
23
|
+
if Workspace.__instance__ is None:
|
|
24
|
+
Workspace.__instance__ = dict.__new__(cls)
|
|
25
|
+
return Workspace.__instance__
|
|
26
26
|
|
|
27
27
|
def __init__(self):
|
|
28
28
|
self.comments = 'Using OpenPNM ' + OpenPNM.__version__
|
|
@@ -48,7 +48,7 @@ class Controller(dict):
|
|
|
48
48
|
else:
|
|
49
49
|
lines.append(str.format('ERROR: ',
|
|
50
50
|
geom.name,
|
|
51
|
-
'Object Not in
|
|
51
|
+
'Object Not in Workspace'))
|
|
52
52
|
for phase in net._phases:
|
|
53
53
|
if len(phase._phases) == 0:
|
|
54
54
|
str = '+ {0:<13} {1:<20} ({2})'
|
|
@@ -75,7 +75,7 @@ class Controller(dict):
|
|
|
75
75
|
else:
|
|
76
76
|
lines.append(str.format('ERROR: ',
|
|
77
77
|
phys.name,
|
|
78
|
-
'Object Not in
|
|
78
|
+
'Object Not in Workspace'))
|
|
79
79
|
return '\n'.join(lines)
|
|
80
80
|
|
|
81
81
|
def _setloglevel(self, level):
|
|
@@ -149,7 +149,7 @@ class Controller(dict):
|
|
|
149
149
|
Examples
|
|
150
150
|
--------
|
|
151
151
|
>>> import OpenPNM
|
|
152
|
-
>>>
|
|
152
|
+
>>> mgr = OpenPNM.Base.Workspace()
|
|
153
153
|
>>> pn = OpenPNM.Network.TestNet()
|
|
154
154
|
>>> geom = OpenPNM.Geometry.GenericGeometry(network=pn,
|
|
155
155
|
... pores=pn.Ps,
|
|
@@ -158,10 +158,10 @@ class Controller(dict):
|
|
|
158
158
|
# Label entries are added to the Network where geom is defined
|
|
159
159
|
>>> 'pore.'+geom.name in pn.keys()
|
|
160
160
|
True
|
|
161
|
-
>>>
|
|
161
|
+
>>> mgr.purge_object(geom)
|
|
162
162
|
|
|
163
|
-
# geom is removed from
|
|
164
|
-
>>> geom.name in
|
|
163
|
+
# geom is removed from Workspace object
|
|
164
|
+
>>> geom.name in mgr.keys()
|
|
165
165
|
False
|
|
166
166
|
|
|
167
167
|
# geom's labels are removed from the Network too
|
|
@@ -186,7 +186,7 @@ class Controller(dict):
|
|
|
186
186
|
self[item].geometries.pop(name, None)
|
|
187
187
|
self[item].physics.pop(name, None)
|
|
188
188
|
self[item].phases.pop(name, None)
|
|
189
|
-
# Remove object from
|
|
189
|
+
# Remove object from Workspace dict
|
|
190
190
|
self.pop(name, None)
|
|
191
191
|
|
|
192
192
|
def ghost_object(self, obj):
|
|
@@ -210,14 +210,14 @@ class Controller(dict):
|
|
|
210
210
|
Examples
|
|
211
211
|
--------
|
|
212
212
|
>>> import OpenPNM
|
|
213
|
-
>>>
|
|
213
|
+
>>> mgr = OpenPNM.Base.Workspace()
|
|
214
214
|
>>> pn = OpenPNM.Network.TestNet()
|
|
215
|
-
>>> pn2 =
|
|
215
|
+
>>> pn2 = mgr.ghost_object(pn)
|
|
216
216
|
>>> pn is pn2 # A copy of pn is created
|
|
217
217
|
False
|
|
218
218
|
>>> pn2.keys() == pn.keys() # They have otherwise identical data
|
|
219
219
|
True
|
|
220
|
-
>>> pn2 in
|
|
220
|
+
>>> pn2 in mgr.values() # pn2 is not associated with existing Workspace
|
|
221
221
|
False
|
|
222
222
|
|
|
223
223
|
It can also be used to create ghosts of other object types:
|
|
@@ -225,7 +225,7 @@ class Controller(dict):
|
|
|
225
225
|
>>> geom = OpenPNM.Geometry.TestGeometry(network=pn,
|
|
226
226
|
... pores=pn.Ps,
|
|
227
227
|
... throats=pn.Ts)
|
|
228
|
-
>>> geo2 =
|
|
228
|
+
>>> geo2 = mgr.ghost_object(geom)
|
|
229
229
|
>>> geom is geo2
|
|
230
230
|
False
|
|
231
231
|
|
|
@@ -234,11 +234,11 @@ class Controller(dict):
|
|
|
234
234
|
True
|
|
235
235
|
|
|
236
236
|
# But they are not the same object
|
|
237
|
-
>>> geo2 is
|
|
237
|
+
>>> geo2 is mgr[geo2.name]
|
|
238
238
|
False
|
|
239
239
|
|
|
240
|
-
# The ghost is not registered with the
|
|
241
|
-
>>> geo2 in
|
|
240
|
+
# The ghost is not registered with the Workspace
|
|
241
|
+
>>> geo2 in mgr.values()
|
|
242
242
|
False
|
|
243
243
|
|
|
244
244
|
# The following comparisons look at some 'behind the scenes' information
|
|
@@ -279,7 +279,7 @@ class Controller(dict):
|
|
|
279
279
|
def load_simulation(self, filename):
|
|
280
280
|
r"""
|
|
281
281
|
Loads a Network simulation fromt the specified 'net' file and adds it
|
|
282
|
-
to the
|
|
282
|
+
to the Workspace
|
|
283
283
|
|
|
284
284
|
Parameters
|
|
285
285
|
----------
|
|
@@ -300,11 +300,11 @@ class Controller(dict):
|
|
|
300
300
|
raise Exception('An object with that name is already present')
|
|
301
301
|
# If no exceptions, then transfer objects to self
|
|
302
302
|
for item in temp_dict.values():
|
|
303
|
-
item.
|
|
303
|
+
item.workspace = self
|
|
304
304
|
|
|
305
305
|
def save(self, filename=''):
|
|
306
306
|
r"""
|
|
307
|
-
Save the entire state of the
|
|
307
|
+
Save the entire state of the Workspace to a 'pnm' file.
|
|
308
308
|
|
|
309
309
|
Parameters
|
|
310
310
|
----------
|
|
@@ -318,17 +318,17 @@ class Controller(dict):
|
|
|
318
318
|
.. code-block:: python
|
|
319
319
|
|
|
320
320
|
import OpenPNM
|
|
321
|
-
|
|
322
|
-
|
|
321
|
+
mgr = OpenPNM.Base.Workspace()
|
|
322
|
+
mgr.clear() # Ensure no previous objects are present
|
|
323
323
|
pn = OpenPNM.Network.TestNet()
|
|
324
|
-
|
|
325
|
-
pn.name in
|
|
324
|
+
mgr.save('test.pnm')
|
|
325
|
+
pn.name in mgr.keys()
|
|
326
326
|
#=> True
|
|
327
|
-
|
|
328
|
-
|
|
327
|
+
mgr.clear()
|
|
328
|
+
mgr.keys()
|
|
329
329
|
dict_keys([])
|
|
330
|
-
|
|
331
|
-
pn.name in
|
|
330
|
+
mgr.load('test.pnm')
|
|
331
|
+
pn.name in mgr.keys()
|
|
332
332
|
#=> True
|
|
333
333
|
|
|
334
334
|
"""
|
|
@@ -344,25 +344,36 @@ class Controller(dict):
|
|
|
344
344
|
|
|
345
345
|
def load(self, filename):
|
|
346
346
|
r"""
|
|
347
|
-
Load an entire
|
|
347
|
+
Load an entire Workspace from a 'pnm' file.
|
|
348
348
|
|
|
349
349
|
Parameters
|
|
350
350
|
----------
|
|
351
351
|
filename : string
|
|
352
|
-
The file name of the
|
|
352
|
+
The file name of the Workspace to load.
|
|
353
353
|
|
|
354
354
|
Notes
|
|
355
355
|
-----
|
|
356
|
-
This calls the ``clear`` method of the
|
|
356
|
+
This calls the ``clear`` method of the Workspace object, so it will
|
|
357
357
|
remove all existing objects in the current workspace.
|
|
358
358
|
"""
|
|
359
359
|
filename = filename.rsplit('.pnm', 1)[0]
|
|
360
360
|
if self != {}:
|
|
361
|
-
logger.warn('Loading data onto non-empty
|
|
361
|
+
logger.warn('Loading data onto non-empty workspace object,' +
|
|
362
362
|
' existing data will be lost')
|
|
363
363
|
self.clear()
|
|
364
364
|
|
|
365
365
|
self = _pickle.load(open(filename+'.pnm', 'rb'))
|
|
366
|
+
for item in self._comments.values():
|
|
367
|
+
if 'Using OpenPNM' in item:
|
|
368
|
+
version = item.lstrip('Using OpenPNM ')
|
|
369
|
+
if version < OpenPNM.__version__:
|
|
370
|
+
logger.warning('File was created with an earlier version ' +
|
|
371
|
+
'OpenPNM: \n' +
|
|
372
|
+
'--> File saved with version: ' +
|
|
373
|
+
str(version) +
|
|
374
|
+
'\n' +
|
|
375
|
+
'--> Current version: ' +
|
|
376
|
+
str(OpenPNM.__version__))
|
|
366
377
|
|
|
367
378
|
def export(self, network=None, filename='', fileformat='VTK'):
|
|
368
379
|
logger.warning("This method is deprecated, use \'export_data\'.")
|
|
@@ -379,7 +390,7 @@ class Controller(dict):
|
|
|
379
390
|
network : OpenPNM Network Object
|
|
380
391
|
This Network and all of its phases will be written to the specified
|
|
381
392
|
file. If no Network is given it will check to ensure that only one
|
|
382
|
-
Network exists on the
|
|
393
|
+
Network exists on the Workspace and use that. If there is more
|
|
383
394
|
than one Network an error is thrown.
|
|
384
395
|
filename : string, optional
|
|
385
396
|
The file name to save as. If no name is given then the name of
|
|
@@ -487,7 +498,7 @@ class Controller(dict):
|
|
|
487
498
|
r"""
|
|
488
499
|
Accepts a Network object and creates a complete clone including all
|
|
489
500
|
associated objects. All objects in the cloned simulation are
|
|
490
|
-
registered with the
|
|
501
|
+
registered with the Workspace object and are fully functional.
|
|
491
502
|
|
|
492
503
|
Parameters
|
|
493
504
|
----------
|
|
@@ -517,9 +528,9 @@ class Controller(dict):
|
|
|
517
528
|
Examples
|
|
518
529
|
--------
|
|
519
530
|
>>> import OpenPNM
|
|
520
|
-
>>>
|
|
531
|
+
>>> mgr = OpenPNM.Base.Workspace()
|
|
521
532
|
>>> pn = OpenPNM.Network.TestNet()
|
|
522
|
-
>>> pn2 =
|
|
533
|
+
>>> pn2 = mgr.clone_simulation(pn, name='cloned')
|
|
523
534
|
>>> pn2 is pn
|
|
524
535
|
False
|
|
525
536
|
"""
|
|
@@ -3,7 +3,7 @@ r"""
|
|
|
3
3
|
:mod:`OpenPNM.Base` -- Abstract Base Class, and Core Data Class
|
|
4
4
|
###############################################################################
|
|
5
5
|
|
|
6
|
-
.. autoclass:: OpenPNM.Base.
|
|
6
|
+
.. autoclass:: OpenPNM.Base.Workspace
|
|
7
7
|
:members:
|
|
8
8
|
:undoc-members:
|
|
9
9
|
:show-inheritance:
|
|
@@ -20,11 +20,13 @@ r"""
|
|
|
20
20
|
|
|
21
21
|
"""
|
|
22
22
|
import logging as logging
|
|
23
|
+
from .__Workspace__ import Workspace
|
|
23
24
|
from .__Controller__ import Controller
|
|
24
25
|
from .__ModelsDict__ import ModelsDict
|
|
25
26
|
from . import __Tools__ as Tools
|
|
26
27
|
from .__Core__ import Core
|
|
27
28
|
|
|
29
|
+
|
|
28
30
|
# Set up logging to file - see previous section for more details
|
|
29
31
|
log_format = \
|
|
30
32
|
'%(asctime)s | %(levelname)-8s | %(name)s.%(funcName)s | %(message)s'
|
|
@@ -47,10 +47,11 @@ class Boundary(GenericGeometry):
|
|
|
47
47
|
pore_prop='pore.diameter',
|
|
48
48
|
mode='max')
|
|
49
49
|
self['pore.volume'] = 0.0
|
|
50
|
+
self['pore.seed'] = 1.0
|
|
51
|
+
self['throat.seed'] = 1.0
|
|
50
52
|
self['throat.volume'] = 0.0
|
|
51
53
|
self.models.add(propname='throat.length',
|
|
52
54
|
model=gm.throat_length.straight)
|
|
53
|
-
self['pore.area'] = 1.0
|
|
54
55
|
if shape == 'spheres':
|
|
55
56
|
self.models.add(propname='throat.area',
|
|
56
57
|
model=gm.throat_area.cylinder)
|
|
@@ -57,7 +57,7 @@ class GenericGeometry(Core):
|
|
|
57
57
|
try:
|
|
58
58
|
self.set_locations(pores=pores, throats=throats)
|
|
59
59
|
except:
|
|
60
|
-
self.
|
|
60
|
+
self.workspace.purge_object(self)
|
|
61
61
|
raise Exception('Provided locations are in use, instantiation cancelled')
|
|
62
62
|
|
|
63
63
|
def __getitem__(self, key):
|