Skip to content

Commit 17c226d

Browse files
authored
Merge pull request #75 from tldr-group/Joss-paper-revisions
Joss paper revisions
2 parents b391adb + 96a195e commit 17c226d

15 files changed

+366
-36
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ wheels/
2424
*.egg-info/
2525
.installed.cfg
2626
*.egg
27+
*.tiff
2728

2829
# PyInstaller
2930
# Usually these files are written by a python script from a template

.readthedocs.yml

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
# .readthedocs.yml
1+
# .readthedocs.yaml
22
# Read the Docs configuration file
33
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
44

55
# Required
66
version: 2
77

8+
# Set the version of Python and other tools you might need
9+
build:
10+
os: ubuntu-22.04
11+
tools:
12+
python: "3.11"
13+
14+
815
# Build documentation in the docs/ directory with Sphinx
916
sphinx:
10-
configuration: docs/conf.py
17+
configuration: docs/conf.py
1118

12-
# Optionally set the version of Python and requirements required to build your docs
19+
# Optionally declare the Python requirements required to build your docs
1320
python:
14-
version: 3.8
15-
install:
16-
- requirements: docs/requirements.txt
21+
install:
22+
- requirements: docs/requirements.txt

docs/index.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ Welcome to TauFactor's documentation!
22
======================================
33

44
.. toctree::
5-
:maxdepth: 2
5+
:maxdepth: 3
66
:caption: Contents:
77

88
readme
99
installation
1010
usage
11+
taufactor
1112
contributing
1213
authors
1314
history

docs/taufactor.rst

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
API Reference
2+
=================
3+
4+
5+
Core module
6+
-----------------
7+
8+
taufactor.taufactor module
9+
~~~~~~~~~~~~~~~~~
10+
11+
12+
.. automodule:: taufactor.taufactor
13+
:members:
14+
:undoc-members:
15+
:show-inheritance:
16+
17+
18+
Submodules
19+
-----------------
20+
21+
taufactor.metrics module
22+
~~~~~~~~~~~~~~~~~
23+
24+
25+
.. automodule:: taufactor.metrics
26+
:members:
27+
:undoc-members:
28+
:show-inheritance:
29+
30+
taufactor.utils module
31+
~~~~~~~~~~~~~~~~~
32+
33+
34+
.. automodule:: taufactor.utils
35+
:members:
36+
:undoc-members:
37+
:show-inheritance:
38+
39+
Module contents
40+
------------------
41+
42+
.. automodule:: taufactor
43+
:members:
44+
:undoc-members:
45+
:show-inheritance:

docs/usage.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Using Taufactor
22

3-
This documentation covers the full usage of TauFactor
3+
This documentation covers the common usage of TauFactor. For a more detailed description see the [module API documentation](./taufactor.rst).
44

55
## Core solver
66

example.ipynb

+223
Large diffs are not rendered by default.

paper.bib

+11
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ @misc{fidgit
5959
}
6060

6161
@article{gostick2019porespy,
62+
doi = {10.1051/0004-6361/201629272},
6263
title={PoreSpy: A python toolkit for quantitative analysis of porous media images},
6364
author={Gostick, Jeff T and Khan, Zohaib A and Tranter, Thomas G and Kok, Matthew DR and Agnaou, Mehrez and Sadeghi, Mohammadamin and Jervis, Rhodri},
6465
journal={Journal of Open Source Software},
@@ -79,6 +80,7 @@ @article{ferguson2018puma
7980
}
8081

8182
@article{le2021openimpala,
83+
doi={10.1016/j.softx.2021.100729},
8284
title={Openimpala: Open source image based parallisable linear algebra solver},
8385
author={Le Houx, James and Kramer, Denis},
8486
journal={SoftwareX},
@@ -89,6 +91,7 @@ @article{le2021openimpala
8991
}
9092

9193
@article{cooper2016taufactor,
94+
doi={10.1016/j.softx.2016.09.002},
9295
title={TauFactor: An open-source application for calculating tortuosity factors from tomographic data},
9396
author={Cooper, Samuel J and Bertei, Antonio and Shearing, Paul R and Kilner, JA and Brandon, Nigel P},
9497
journal={SoftwareX},
@@ -99,6 +102,7 @@ @article{cooper2016taufactor
99102
}
100103

101104
@article{hart1999measurement,
105+
doi={10.1016/s1386-5056(98)00163-4},
102106
title={Measurement and classification of retinal vascular tortuosity},
103107
author={Hart, William E and Goldbaum, Michael and C{\^o}t{\'e}, Brad and Kube, Paul and Nelson, Mark R},
104108
journal={International journal of medical informatics},
@@ -110,6 +114,7 @@ @article{hart1999measurement
110114
}
111115

112116
@article{carey2016estimating,
117+
doi={10.1111/gwat.12406},
113118
title={Estimating tortuosity coefficients based on hydraulic conductivity},
114119
author={Carey, Grant R and McBean, Edward A and Feenstra, Stan},
115120
journal={Groundwater},
@@ -121,6 +126,7 @@ @article{carey2016estimating
121126
}
122127

123128
@article{landesfeind2018tortuosity,
129+
doi={10.1149/2.0231803jes},
124130
title={Tortuosity of battery electrodes: validation of impedance-derived values and critical comparison with 3D tomography},
125131
author={Landesfeind, Johannes and Ebner, Martin and Eldiven, Askin and Wood, Vanessa and Gasteiger, Hubert A},
126132
journal={Journal of The Electrochemical Society},
@@ -132,6 +138,7 @@ @article{landesfeind2018tortuosity
132138
}
133139

134140
@article{dahari2023fusion,
141+
doi={10.1002/aenm.202370009},
135142
title={Fusion of Complementary 2D and 3D Mesostructural Datasets Using Generative Adversarial Networks (Adv. Energy Mater. 2/2023)},
136143
author={Dahari, Amir and Kench, Steve and Squires, Isaac and Cooper, Samuel J},
137144
journal={Advanced Energy Materials},
@@ -142,6 +149,7 @@ @article{dahari2023fusion
142149
publisher={Wiley Online Library}
143150
}
144151
@article{kench2022microlib,
152+
doi={10.1038/s41597-022-01744-1},
145153
title={MicroLib: A library of 3D microstructures generated from 2D micrographs using SliceGAN},
146154
author={Kench, Steve and Squires, Isaac and Dahari, Amir and Cooper, Samuel J},
147155
journal={Scientific Data},
@@ -162,6 +170,7 @@ @article{withers2021x
162170
publisher={Nature Publishing Group UK London}
163171
}
164172
@article{nguyen2020electrode,
173+
doi={10.1038/s41524-020-00386-4},
165174
title={The electrode tortuosity factor: why the conventional tortuosity factor is not well suited for quantifying transport in porous Li-ion battery electrodes and what to use instead},
166175
author={Nguyen, Tuan-Tu and Demorti{\`e}re, Arnaud and Fleutot, Benoit and Delobel, Bruno and Delacourt, Charles and Cooper, Samuel J},
167176
journal={npj Computational Materials},
@@ -182,6 +191,7 @@ @incollection{pytorch
182191
url = {http://papers.neurips.cc/paper/9015-pytorch-an-imperative-style-high-performance-deep-learning-library.pdf}
183192
}
184193
@article{cooper2017simulated,
194+
doi={10.1016/j.electacta.2017.07.152},
185195
title={Simulated impedance of diffusion in porous media},
186196
author={Cooper, Samuel J and Bertei, Antonio and Finegan, Donal P and Brandon, Nigel P},
187197
journal={Electrochimica Acta},
@@ -191,6 +201,7 @@ @article{cooper2017simulated
191201
publisher={Elsevier}
192202
}
193203
@article{tjaden2016origin,
204+
doi={10.1016/j.coche.2016.02.006},
194205
title={On the origin and application of the Bruggeman correlation for analysing transport phenomena in electrochemical systems},
195206
author={Tjaden, Bernhard and Cooper, Samuel J and Brett, Daniel JL and Kramer, Denis and Shearing, Paul R},
196207
journal={Current opinion in chemical engineering},

paper.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@ authors:
1818
affiliation: 1
1919
- name: Samuel Cooper
2020
corresponding: true # (This is how to denote the corresponding author)
21+
orcid: 0000-0003-4055-6903
2122
affiliation: 1
2223
affiliations:
23-
- name: Imperial College London, UK
24+
- name: Imperial College London, United Kingdom
2425
index: 1
2526
date: 9 March 2023
2627
bibliography: paper.bib
2728
---
2829
# Summary
2930

30-
TauFactor 2 is an open-source, GPU accelerated microstructural analysis tool for extracting metrics from voxel based data, including transport properties such as the touristy factor. Tortuosity factor, $\tau$, is a material parameter that defines the reduction in transport arising from the arrangement of the phases in a multiphase medium (see \autoref{example}). As shown in \autoref{eq:tort}, the effective transport co-efficient of a material, $D_{\text{eff}}$, can be calculated from the phases intrinsic transport coefficient, $D$, volume fraction, $\epsilon$, and $\tau$ [@cooper2016taufactor] (note, this value of $\tau$ should not be squared [@tjaden2016origin]).
31+
TauFactor 2 is an open-source, GPU accelerated microstructural analysis tool for extracting metrics from voxel based data, including transport properties such as the touristy factor. Tortuosity factor, $\tau$, is a material parameter that defines the reduction in transport arising from the arrangement of the phases in a multiphase medium (see \autoref{example}). As shown in \autoref{eq:tort}, the effective transport coefficient of a material, $D_{\text{eff}}$, can be calculated from the phases intrinsic transport coefficient, $D$, volume fraction, $\epsilon$, and $\tau$ [@cooper2016taufactor] (note, this value of $\tau$ should not be squared [@tjaden2016origin]).
3132

3233
\begin{equation}\label{eq:tort}
3334
D_{\text{eff}} = D\dfrac{\epsilon}{\tau}
@@ -58,6 +59,10 @@ To compare the performance of TauFactor 2 to other available software, a test vo
5859

5960
![Speed comparison for the four solvers when applied to the test volume. The mean time across all 3 directions is plotted. The values of the overconverged $\tau$ in each direction are: 1.1513, 1.3905, 4.2431. \label{speeds}](tauspeeds.pdf)
6061

62+
# Authorship Contributions
63+
64+
SK wrote the base, periodic and multiphase solvers with input from IS. IS wrote the electrode solver, metric calculations and documentation, and also performed speed tests for other software packages. The project was supervised by SC, and based on his original MATLAB tool. All authors contributed to the writing and editing of the manuscript.
65+
6166
# Acknowledgements
6267

6368
This work was supported by funding from the EPSRC Faraday Institution Multi-Scale Modelling project

requirements_dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ Click==7.0
1111
pytest==4.6.5
1212
matplotlib>3.6
1313
pytest-runner==5.2
14-
numpy==1.24.2
14+
numpy>=1.24.2
1515
tifffile==2023.2.3
1616
myst-parser==0.18.1

setup.py

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
'Programming Language :: Python :: 3.6',
3737
'Programming Language :: Python :: 3.7',
3838
'Programming Language :: Python :: 3.8',
39+
'Programming Language :: Python :: 3.9',
40+
'Programming Language :: Python :: 3.10',
3941
],
4042
description="TauFactor is an application for calculating tortuosity factors from tomographic data",
4143
install_requires=requirements,

tau_speeds.png

710 Bytes
Loading

taufactor/metrics.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def surface_area(img, phases, periodic=False):
5555

5656
SA_map = torch.zeros_like(img)
5757
if not isinstance(phases, list):
58-
phases = [phases]
58+
raise TypeError('phases should be a list')
5959
for i in range(dim):
6060
for j in [1, -1]:
6161
i_rolled = torch.roll(img, j, i)
@@ -86,6 +86,13 @@ def surface_area(img, phases, periodic=False):
8686
return sa
8787

8888
def triple_phase_boundary(img):
89+
"""Calculate triple phase boundary density i.e. fraction of voxel verticies that touch at least 3 phases
90+
91+
Args:
92+
img (numpy array): image to calculate metric on
93+
Returns:
94+
float: triple phase boundary density
95+
"""
8996
phases = torch.unique(torch.tensor(img))
9097
if len(phases)!=3:
9198
raise ValueError('Image must have exactly 3 phases')

taufactor/taufactor.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ def __init__(self, img, bc=(-0.5, 0.5), D_0=1, device=torch.device('cuda')):
2121
for multiple solves.
2222
2323
:param img: input img with 1s conductive and 0s non-conductive
24-
:param precision: cp.single or cp.double
2524
:param bc: Upper and lower boundary conditions. Leave as default.
2625
:param D_0: reference material diffusivity
2726
:param device: pytorch device, can be cuda or cpu
@@ -166,12 +165,16 @@ def check_convergence(self, verbose, conv_crit, start, iter_limit):
166165
# print progress
167166
self.semi_converged, self.new_fl, err = self.check_vertical_flux(
168167
conv_crit)
169-
self.D_rel = ((self.new_fl) * self.L_A /
170-
abs(self.top_bc - self.bot_bc)).cpu()
171-
self.tau = self.VF / \
172-
self.D_rel if self.D_rel != 0 else torch.tensor(torch.inf)
173168
if self.semi_converged == 'zero_flux':
169+
self.D_rel = 0
170+
self.tau = np.inf
174171
return True
172+
else:
173+
self.D_rel = ((self.new_fl) * self.L_A /
174+
abs(self.top_bc - self.bot_bc)).cpu()
175+
self.tau = self.VF / \
176+
self.D_rel if self.D_rel != 0 else torch.tensor(torch.inf)
177+
175178

176179
if verbose == 'per_iter':
177180
print(
@@ -196,10 +199,10 @@ def check_vertical_flux(self, conv_crit):
196199
vert_flux[self.conc[:, 1:-1, 1:-1, 1:-1] == 0] = 0
197200
fl = torch.sum(vert_flux, (0, 2, 3))[1:-1]
198201
err = (fl.max() - fl.min())*2/(fl.max() + fl.min())
199-
if err < conv_crit or torch.isnan(err).item():
200-
return True, torch.mean(fl), err
201202
if fl.min() == 0:
202203
return 'zero_flux', torch.mean(fl), err
204+
if err < conv_crit or torch.isnan(err).item():
205+
return True, torch.mean(fl), err
203206
return False, torch.mean(fl), err
204207

205208
def check_rolling_mean(self, conv_crit):
@@ -233,7 +236,6 @@ def __init__(self, img, bc=(-0.5, 0.5), D_0=1, device=torch.device('cuda:0')):
233236
for multiple solves.
234237
235238
:param img: input img with 1s conductive and 0s non-conductive
236-
:param precision: cp.single or cp.double
237239
:param bc: Upper and lower boundary conditions. Leave as default.
238240
:param D_0: reference material diffusivity
239241
@@ -313,7 +315,6 @@ def __init__(self, img, cond={1: 1}, bc=(-0.5, 0.5), device=torch.device('cuda:0
313315
:param img: input img with n conductive phases labelled as integers, and 0s for non-conductive
314316
:param cond: dict with n phase labels as keys, and their corresponding conductivities as values e.g
315317
for a 2 phase material, {1:0.543, 2: 0.420}, with 1s and 2s in the input img
316-
:param precision: cp.single or cp.double
317318
:param bc: Upper and lower boundary conditions. Leave as default.
318319
"""
319320

@@ -495,7 +496,6 @@ def check_vertical_flux(self, conv_crit):
495496
:-2, 1:-1, 1:-1]) * self.pre_factors[1][:, :-2, 1:-1, 1:-1]
496497
vert_flux[self.nn == torch.inf] = 0
497498
fl = torch.sum(vert_flux, (0, 2, 3))[2:-2]
498-
print(fl.argmin(), fl.argmax())
499499
err = (fl.max() - fl.min())*2/(fl.max() + fl.min())
500500
if err < conv_crit or torch.isnan(err).item():
501501
return True, torch.mean(fl), err

0 commit comments

Comments
 (0)