Skip to content

Commit 09484e7

Browse files
authored
Release of v3.1.1 #patch
2 parents 43d3631 + 3638ce5 commit 09484e7

File tree

4 files changed

+175
-174
lines changed

4 files changed

+175
-174
lines changed

.github/workflows/bump-version-dev.yml

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,18 @@ on:
77

88
jobs:
99
build:
10+
if: (! contains(github.event.head_commit.message, '[no bump]'))
11+
1012
name: Bump version
1113
runs-on: ubuntu-latest
1214

1315
steps:
14-
- uses: actions/checkout@v2
15-
with:
16-
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
17-
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
16+
- uses: actions/checkout@v3
1817

1918
- name: Set up Python
2019
uses: actions/setup-python@v2
2120
with:
22-
python-version: 3.8
21+
python-version: 3.9
2322

2423
- name: Set env variables
2524
run: |
@@ -41,14 +40,20 @@ jobs:
4140
bump_version build $VERSION_FILE
4241
# Note that we don't want to create a new tag for "builds"
4342
44-
- name: Commit files
45-
run: |
46-
REPOSITORY=${INPUT_REPOSITORY:-$GITHUB_REPOSITORY}
47-
remote_repo="https://${GITHUB_ACTOR}:${{ secrets.PUSH_ACTION_TOKEN }}@github.com/${REPOSITORY}.git"
43+
# - name: Commit files
44+
# run: |
45+
# REPOSITORY=${INPUT_REPOSITORY:-$GITHUB_REPOSITORY}
46+
# remote_repo="https://${GITHUB_ACTOR}:${{ secrets.PUSH_ACTION_TOKEN }}@github.com/${REPOSITORY}.git"
4847

49-
git config --local user.email "action@github.com"
50-
git config --local user.name "GitHub Action"
48+
# git config --local user.email "action@github.com"
49+
# git config --local user.name "GitHub Action"
5150

52-
# Commit version bump to dev ([no ci] to avoid infinite loop)
53-
git commit -m "Bump version number [no ci]" -a
54-
git push "${remote_repo}" dev
51+
# # Commit version bump to dev ([no ci] to avoid infinite loop)
52+
# git commit -m "Bump version number (build) [no ci]" -a
53+
# git push "${remote_repo}" dev
54+
55+
- name: Commit files
56+
uses: stefanzweifel/git-auto-commit-action@v4
57+
with:
58+
commit_message: Bump version number (build part)
59+
commit_author: Author <actions@github.com>

openpnm/algorithms/_reactive_transport.py

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
import sys
21
import logging
2+
import sys
3+
34
import numpy as np
45
from numpy.linalg import norm
56
from scipy.optimize.nonlin import TerminationCondition
6-
from openpnm.algorithms import Transport
7-
from openpnm.utils import TypedList, Docorator
87
from tqdm.auto import tqdm
98

9+
from openpnm.algorithms import Transport
10+
from openpnm.utils import Docorator, TypedList
1011

11-
__all__ = ['ReactiveTransport']
12+
__all__ = ["ReactiveTransport"]
1213

1314

1415
docstr = Docorator()
1516
logger = logging.getLogger(__name__)
1617

1718

18-
@docstr.get_sections(base='ReactiveTransportSettings', sections=['Parameters'])
19+
@docstr.get_sections(base="ReactiveTransportSettings", sections=["Parameters"])
1920
@docstr.dedent
2021
class ReactiveTransportSettings:
2122
r"""
@@ -45,7 +46,7 @@ class ReactiveTransportSettings:
4546
x_rtol = 1e-6
4647

4748

48-
@docstr.get_sections(base='ReactiveTransport', sections=['Parameters'])
49+
@docstr.get_sections(base="ReactiveTransport", sections=["Parameters"])
4950
@docstr.dedent
5051
class ReactiveTransport(Transport):
5152
r"""
@@ -62,11 +63,11 @@ class ReactiveTransport(Transport):
6263
6364
"""
6465

65-
def __init__(self, name='react_trans_?', **kwargs):
66+
def __init__(self, name="react_trans_?", **kwargs):
6667
super().__init__(name=name, **kwargs)
6768
self.settings._update(ReactiveTransportSettings())
6869

69-
def set_source(self, pores, propname, mode='add'):
70+
def set_source(self, pores, propname, mode="add"):
7071
r"""
7172
Applies a given source term to the specified pores
7273
@@ -105,21 +106,21 @@ def set_source(self, pores, propname, mode='add'):
105106
propname = self._parse_prop(propname, "pore")
106107
# Check if any BC is already set in the same locations
107108
locs_BC = np.zeros(self.Np, dtype=bool)
108-
for item in self['pore.bc'].keys():
109-
locs_BC = np.isfinite(self[f'pore.bc.{item}'])
109+
for item in self["pore.bc"].keys():
110+
locs_BC = np.isfinite(self[f"pore.bc.{item}"])
110111
if np.any(locs_BC[pores]):
111112
raise Exception("BCs present in given pores, can't assign source term")
112-
prop = 'pore.source.' + propname.split('.', 1)[1]
113-
if mode == 'add':
113+
prop = "pore.source." + propname.split(".", 1)[1]
114+
if mode == "add":
114115
if prop not in self.keys():
115116
self[prop] = False
116117
self[prop][pores] = True
117-
elif mode == 'remove':
118+
elif mode == "remove":
118119
self[prop][pores] = False
119-
elif mode == 'clear':
120+
elif mode == "clear":
120121
self[prop] = False
121122
else:
122-
raise Exception(f'Unsupported mode {mode}')
123+
raise Exception(f"Unsupported mode {mode}")
123124

124125
def _apply_sources(self):
125126
"""
@@ -134,9 +135,9 @@ def _apply_sources(self):
134135
"""
135136
try:
136137
phase = self.project[self.settings.phase]
137-
for item in self['pore.source'].keys():
138+
for item in self["pore.source"].keys():
138139
# Fetch linearized values of the source term
139-
Ps = self['pore.source.' + item]
140+
Ps = self["pore.source." + item]
140141
S1, S2 = [phase[f"pore.{item}.{Si}"] for Si in ["S1", "S2"]]
141142
# Modify A and b: diag(A) += -S1, b += S2
142143
diag = self.A.diagonal()
@@ -173,20 +174,22 @@ def _run_special(self, solver, x0, verbose=None):
173174
Initial guess of the unknown variable
174175
175176
"""
176-
w = self.settings['relaxation_factor']
177-
maxiter = self.settings['newton_maxiter']
178-
f_rtol = self.settings['f_rtol']
179-
x_rtol = self.settings['x_rtol']
177+
w = self.settings["relaxation_factor"]
178+
maxiter = self.settings["newton_maxiter"]
179+
f_rtol = self.settings["f_rtol"]
180+
x_rtol = self.settings["x_rtol"]
180181
xold = self.x
181182
dx = self.x - xold
182-
condition = TerminationCondition(f_tol=np.inf, f_rtol=f_rtol, x_rtol=x_rtol, norm=norm)
183+
condition = TerminationCondition(
184+
f_tol=np.inf, f_rtol=f_rtol, x_rtol=x_rtol, norm=norm
185+
)
183186

184187
tqdm_settings = {
185188
"total": 100,
186189
"desc": f"{self.name} : Newton iterations",
187190
"disable": not verbose,
188191
"file": sys.stdout,
189-
"leave": False
192+
"leave": False,
190193
}
191194

192195
with tqdm(**tqdm_settings) as pbar:
@@ -198,12 +201,12 @@ def _run_special(self, solver, x0, verbose=None):
198201
if is_converged:
199202
pbar.update(100 - pbar.n)
200203
self.soln.is_converged = is_converged
201-
logger.info(f'Solution converged, residual norm: {norm(res):.4e}')
204+
logger.info(f"Solution converged, residual norm: {norm(res):.4e}")
202205
return
203206
super()._run_special(solver=solver, x0=xold, w=w)
204207
dx = self.x - xold
205208
xold = self.x
206-
logger.info(f'Iteration #{i:<4d} | Residual norm: {norm(res):.4e}')
209+
logger.info(f"Iteration #{i:<4d} | Residual norm: {norm(res):.4e}")
207210
self.soln.num_iter = i + 1
208211

209212
self.soln.is_converged = False
@@ -217,7 +220,7 @@ def _get_progress(self, res):
217220
self._f0_norm = norm(res)
218221
f_rtol = self.settings.f_rtol
219222
norm_reduction = norm(res) / self._f0_norm / f_rtol
220-
progress = (1 - max(np.log10(norm_reduction), 0) / np.log10(1/f_rtol)) * 100
223+
progress = (1 - max(np.log10(norm_reduction), 0) / np.log10(1 / f_rtol)) * 100
221224
return max(0, progress)
222225

223226
def _update_A_and_b(self):
@@ -240,12 +243,12 @@ def _get_residual(self, x=None):
240243
x = self.x
241244
return self.A * x - self.b
242245

243-
def set_BC(self, pores=None, bctype=[], bcvalues=[], mode='add'):
246+
def set_BC(self, pores=None, bctype=[], bcvalues=[], mode="add"):
244247
msg = "Source term already present in given pores, can't assign BCs"
245248
# Ensure that given pores do not have source terms already set
246249
try:
247-
for item in self['pore.source'].keys():
248-
if np.any(self['pore.source.'+item][pores]):
250+
for item in self["pore.source"].keys():
251+
if np.any(self["pore.source." + item][pores]):
249252
raise Exception(msg)
250253
except KeyError:
251254
pass

0 commit comments

Comments
 (0)