Skip to content

Commit

Permalink
Merge pull request #709 from PMEAL/Fixing_Numpy_compatibility
Browse files Browse the repository at this point in the history
Fixing Numpy boolean compatibility
  • Loading branch information
jgostick authored Jul 1, 2017
2 parents 3221899 + 2a9eeb8 commit e57ebb3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
5 changes: 4 additions & 1 deletion OpenPNM/Algorithms/__Drainage__.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,10 @@ def _calc_fractional_filling(self, element, pressure):
temp_Pc = phys.models[key]['Pc'] # Store old Pc
phys.models[key]['Pc'] = pressure
# Regenerate Physics model and capture output locally
Snwp[phys.Pnet] = phys.models[key].run()
locs = phys._map(element=element,
locations=phys._get_indices(element),
target=self._net)
Snwp[locs] = phys.models[key].run()
# Re-populate the residual element with the non-wetting phase
if sp.any(self[element+'.residual']):
Snwp[self[element+'.residual']] = 1.0
Expand Down
10 changes: 8 additions & 2 deletions OpenPNM/Algorithms/__GenericLinearTransport__.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,10 +641,16 @@ def _do_inner_iteration_stage(self, guess, **kwargs):
mode='update')
prop1 = 'pore.source_nonlinear_s1_' + source_name
mask1 = ~sp.isnan(self[prop1])
s1[~sp.isnan(self[prop1])] = s1[mask1] + self[prop1][mask1]
s1_temp_1 = s1[:self.Np][mask1]
s1_temp_2 = self[prop1][mask1]
mask_temp_1 = self.Ps[~sp.isnan(self[prop1])]
s1[mask_temp_1] = s1_temp_1 + s1_temp_2
prop2 = 'pore.source_nonlinear_s2_' + source_name
mask2 = ~sp.isnan(self[prop2])
s2[~sp.isnan(self[prop2])] = s2[mask2] + self[prop2][mask2]
s2_temp_1 = s2[:self.Np][mask2]
s2_temp_2 = self[prop2][mask2]
mask_temp_2 = self.Ps[~sp.isnan(self[prop2])]
s2[mask_temp_2] = s2_temp_1 + s2_temp_2
self.s1 = s1
self.s2 = s2
# Modifying A and b
Expand Down
2 changes: 1 addition & 1 deletion OpenPNM/Network/__Cubic__.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def _label_surfaces(self):
if 'pore.'+label not in self.keys():
self['pore.'+label] = False
if 'pore.boundary' in self.keys():
internal = -self['pore.boundary']
internal = ~self['pore.boundary']
else:
internal = self['pore.all']
self['pore.internal'] = internal
Expand Down
5 changes: 2 additions & 3 deletions OpenPNM/Physics/models/multiphase.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def late_throat_filling(network, phase, physics,
criteria such as the 'throat.inv_Pc' array on a *Drainage* algorithm.
"""
Swp = sp.ones(physics.Nt,)
Swp = sp.ones([physics.Nt, ])
if Pc > 0:
Swp = Swp_star*(physics[throat_entry_pressure]/Pc)**eta
values = (1-Swp)*(physics[throat_entry_pressure] <= Pc)
Expand Down Expand Up @@ -157,7 +157,6 @@ def late_pore_filling(physics, phase, network,
criteria such as the 'pore.inv_Pc' array on a *Drainage* algorithm.
"""

# If pc_star has not yet been calculated, do so
if pc_star not in physics.keys():
pores = phase.Ps
Expand All @@ -166,7 +165,7 @@ def late_pore_filling(physics, phase, network,
temp = sp.array([sp.amin(prop[row]) for row in neighborTs])
physics[pc_star] = temp[physics.Pnet]

Swp = sp.ones(physics.Np,)
Swp = sp.ones([physics.Np, ])
if Pc > 0:
Swp = Swp_star*(physics[pc_star]/Pc)**eta
else:
Expand Down
4 changes: 3 additions & 1 deletion OpenPNM/Utilities/IO.py
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,9 @@ def load(cls, path,
network.extend(throat_conns=new_conns, labels='new_conns')
for item in network.props('pore'):
item = item.split('.')[1]
network['throat.'+item] = _sp.nan
arr = _sp.ones_like(network['pore.'+item])[0]
arr = _sp.tile(A=arr, reps=[network.Nt, 1])*_sp.nan
network['throat.'+item] = _sp.squeeze(arr)
network['throat.'+item][network.throats('new_conns')] = \
network['pore.'+item][Ts]
network.trim(pores=Ts)
Expand Down

0 comments on commit e57ebb3

Please sign in to comment.