Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
jgostick committed Oct 20, 2018
2 parents c016c18 + 9ce04ed commit 74a10dd
Show file tree
Hide file tree
Showing 46 changed files with 1,409 additions and 858 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
sudo: false

os:
- linux

language: python

python:
Expand Down
23 changes: 23 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
build: false

environment:
matrix:
- PYTHON_VERSION: 3.6
MINICONDA: C:\Miniconda3

init:
- "ECHO %PYTHON_VERSION% %MINICONDA%"

install:
- "set PATH=%MINICONDA%;%MINICONDA%\\Scripts;%PATH%"
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- conda info -a
- "conda create -q -n test-environment python=%PYTHON_VERSION% numpy==1.14"
- conda install --file conda_requirements.txt
- activate test-environment
- pip install -r test_requirements.txt
- python setup.py install

test_script:
- python ./bin/test pep8 cov
2 changes: 2 additions & 0 deletions bin/test
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import sys
import pytest
import numpy
numpy.warnings.filterwarnings('ignore')

args = ['-v']

Expand Down
3 changes: 1 addition & 2 deletions example_script.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import openpnm as op
ws = op.Workspace()
ws.settings['loglevel'] = 40
proj = ws.new_project()

pn = op.network.Cubic(shape=[10, 10, 10], spacing=1e-4, project=proj)
Expand Down Expand Up @@ -36,7 +35,7 @@
prefactor='pore.A', exponent='pore.n',
regen_mode='deferred')
rxn = op.algorithms.FickianDiffusion(network=pn)
rxn.setup(phase=air)
rxn.setup(phase=air, solver='spsolve')
Ps = pn.find_nearby_pores(pores=50, r=5e-4, flatten=True)
rxn.set_source(propname='pore.2nd_order_rxn', pores=Ps)
rxn.set_value_BC(pores=pn.pores('top'), values=1)
Expand Down
53 changes: 51 additions & 2 deletions openpnm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,60 @@
**OpenPNM**
OpenPNM is a package for performing pore network simulations of transport in
porous materials
porous materials.
It consists of the following submodules:
+----------------+------------------------------------------------------------+
| Submodule | Contents and Description |
+================+============================================================+
| ``core`` | Houses the ``Base`` & ``Subdomain`` classes, & model |
| | related mixins |
+----------------+------------------------------------------------------------+
| ``network`` | ``GenericNetwork`` class plus various network generators |
+----------------+------------------------------------------------------------+
| ``geometry`` | ``GenericGeometry`` class plus some subclasses containing a|
| | predefined set of pore-scale models |
+----------------+------------------------------------------------------------+
| ``phases`` | ``GenericPhase`` class plus some subclasses containing |
| | predefined models for common fluids like Water |
+----------------+------------------------------------------------------------+
| ``physics`` | ``GenericPhysics`` class plus some subclasses containing a |
| | predefined set of pore-scale models |
+----------------+------------------------------------------------------------+
| ``algorithms`` | Algorithms for simulating transport and percolation |
+----------------+------------------------------------------------------------+
| ``materials`` | A collection of predefined projects consisting of a network|
| | with suitable topology and a geometry with necessary models|
+----------------+------------------------------------------------------------+
| ``topotools`` | Tools for querying and manipulating network topology |
+----------------+------------------------------------------------------------+
| ``io`` | Import from and export to various common data formats |
+----------------+------------------------------------------------------------+
| ``utils`` | Helper utilites & classes, including ``Workspace`` and |
| | ``Project`` |
+----------------+------------------------------------------------------------+
| ``models`` | Library of pore-scale models for calculating geometric, |
| | thermodynamic, and physical properties |
+----------------+------------------------------------------------------------+
"""
import os
from pathlib import Path
from git import Repo

__version__ = '2.0.2'

__version__ = '2.0.1'
try:
path = Path(os.path.realpath(__file__), '../../').resolve()
repo = Repo(str(path))
if repo.active_branch.name != 'master':
commit_id = repo.active_branch.commit.hexsha[:6]
__commit__ = ''+str(commit_id)
else:
__commit__ = None
except:
pass

from . import utils
from .utils import Workspace, Project
Expand Down
59 changes: 54 additions & 5 deletions openpnm/algorithms/AdvectionDiffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,68 @@ def _build_A(self, force=False):
Qij = -gh*np.diff(P[conns], axis=1).squeeze()
Qij = np.append(Qij, -Qij)

Peij = Qij/gd
Peij[(Peij < 1e-10) & (Peij >= 0)] = 1e-10
Peij[(Peij > -1e-10) & (Peij <= 0)] = -1e-10
Qij = Peij*gd

if force:
self._pure_A = None
if self._pure_A is None:
if (s_dis == 'upwind'):
if s_dis == 'upwind':
w = gd + np.maximum(0, -Qij)
A = network.create_adjacency_matrix(weights=w)
elif (s_dis == 'hybrid'):
elif s_dis == 'hybrid':
w = np.maximum(0, np.maximum(-Qij, gd-Qij/2))
A = network.create_adjacency_matrix(weights=w)
elif (s_dis == 'powerlaw'):
Peij = np.absolute(Qij/gd)
w = gd*np.maximum(0, (1-0.1*Peij)**5) + np.maximum(0, -Qij)
elif s_dis == 'powerlaw':
w = gd * np.maximum(0, (1 - 0.1*np.abs(Peij))**5) + \
np.maximum(0, -Qij)
A = network.create_adjacency_matrix(weights=w)
elif s_dis == 'exponential':
w = -Qij / (1 - np.exp(Peij))
A = network.create_adjacency_matrix(weights=w)
else:
raise Exception('Unrecognized discretization scheme: ' + s_dis)
A = laplacian(A)
self._pure_A = A
self.A = self._pure_A.copy()

def set_outflow_BC(self, pores, mode='merge'):
r"""
Adds outflow boundary condition to the selected pores.
Outflow condition simply means that the gradient of the solved
quantity does not change, i.e. is 0.
"""
# Hijack the parse_mode function to verify mode/pores argument
mode = self._parse_mode(mode, allowed=['merge', 'overwrite', 'remove'],
single=True)
pores = self._parse_indices(pores)
# Calculating A[i,i] values to ensure the outflow condition
network = self.project.network
phase = self.project.phases()[self.settings['phase']]
throats = network.find_neighbor_throats(pores=pores)
C12 = network['throat.conns'][throats]
P12 = phase[self.settings['pressure']][C12]
gh = phase[self.settings['hydraulic_conductance']][throats]
Q12 = -gh * np.diff(P12, axis=1).squeeze()
Qp = np.zeros(self.Np)
np.add.at(Qp, C12[:, 0], -Q12)
np.add.at(Qp, C12[:, 1], Q12)
# Store boundary values
if ('pore.bc_outflow' not in self.keys()) or (mode == 'overwrite'):
self['pore.bc_outflow'] = np.nan
self['pore.bc_outflow'][pores] = Qp[pores]

def _apply_BCs(self):
# Apply Dirichlet and rate BCs
ReactiveTransport._apply_BCs(self)
if 'pore.bc_outflow' not in self.keys():
return
# Apply outflow BC
diag = self.A.diagonal()
ind = np.isfinite(self['pore.bc_outflow'])
diag[ind] += self['pore.bc_outflow'][ind]
self.A.setdiag(diag)
92 changes: 0 additions & 92 deletions openpnm/algorithms/Dispersion.py

This file was deleted.

Loading

0 comments on commit 74a10dd

Please sign in to comment.