forked from PMEAL/OpenPNM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_script_two_subdomains.py
51 lines (43 loc) · 1.5 KB
/
example_script_two_subdomains.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
import pytest
import openpnm as op
ws = op.Workspace()
proj = ws.new_project()
pn = op.network.Cubic(shape=[10, 10, 10], spacing=1e-4, project=proj)
Ps = pn['pore.coords'][:, 0] < pn['pore.coords'][:, 0].mean()
Ts = pn.find_neighbor_throats(pores=Ps, mode='xnor')
geo1 = op.geometry.StickAndBall(network=pn, pores=Ps, throats=Ts)
Ps = pn['pore.coords'][:, 0] >= pn['pore.coords'][:, 0].mean()
Ts = pn.find_neighbor_throats(pores=Ps, mode='or')
geo2 = op.geometry.StickAndBall(network=pn, pores=Ps, throats=Ts)
pn['pore.foo'] = 1
# Can't create a subdict below foo
with pytest.raises(Exception):
pn['pore.foo.bar'] = 1
# Can create a subdict directly
pn['pore.baz.bar'] = 2
# Can't create a new item already used as subdict
with pytest.raises(Exception):
pn['pore.baz'] = 2
# Also works on subdomains
geo1['pore.blah'] = 1
with pytest.raises(Exception):
geo1['pore.blah.boo'] = 1
geo1['pore.bee.bop'] = 1
with pytest.raises(Exception):
geo1['pore.bee'] = 1
# Now start looking across objects
with pytest.raises(Exception):
geo1['pore.foo'] = 1 # Already exists on pn
with pytest.raises(Exception):
geo1['pore.foo.bar'] = 1 # pore.foo already exists on pn
with pytest.raises(Exception):
geo1['pore.baz'] = 1 # pore.baz.bar already exists on pn
# Now start looking across objects
geo2['pore.blah'] = 1
geo2['pore.bee.bop'] = 1
with pytest.raises(Exception):
geo1['pore.bee'] = 1
with pytest.raises(Exception):
pn['pore.bee'] = 1
with pytest.raises(Exception):
pn['pore.bee.bop'] = 1