API Reference

Core module

taufactor.taufactor module

Main module.

class taufactor.taufactor.ElectrodeSolver(img, omega=1e-06, device=device(type='cuda'))[source]

Bases: object

Electrode Solver - solves the electrode tortuosity factor system (migration and capacitive current between current collector and solid/electrolyte interface) Once solve method is called, tau, D_eff and D_rel are available as attributes.

check_convergence()[source]
crop(img, c=1)[source]
end_simulation()[source]
init_cb(img)[source]
init_phi(img)[source]

Initialise phi field as zeros

Parameters:

img (torch.array) – input image, with 1s conductive and 0s non-conductive

Returns:

phi

Return type:

torch.array

init_prefactor(img)[source]

Initialise prefactors -> (nn_cond+2j*omega*res*c(dims-nn_cond))**-1

Parameters:

img (cp.array) – input image, with 1s conductive and 0s non-conductive

Returns:

prefactor

Return type:

cp.array

pad(img, vals=[0, 0, 0, 0, 0, 0])[source]
solve(iter_limit=100000, verbose=True, conv_crit=1e-05, conv_crit_2=0.001)[source]

run a solve simulation

Parameters:

iter_limit – max iterations before aborting, will attemtorch double for the same no. iterations

if initialised as singles :param verbose: Whether to print tau. Can be set to ‘per_iter’ for more feedback :param conv_crit: convergence criteria - running standard deviation of tau_e :param conv_crit_2: convergence criteria - maximum difference between tau_e in consecutive omega solves :return: tau

sum_neighbours()[source]
tau_e_from_phi()[source]
class taufactor.taufactor.MultiPhaseSolver(img, cond={1: 1}, bc=(-0.5, 0.5), device=device(type='cuda', index=0))[source]

Bases: Solver

Multi=phase solver for two phase images. Once solve method is called, tau, D_eff and D_rel are available as attributes.

check_convergence(verbose, conv_crit, start, iter_limit)[source]
check_vertical_flux(conv_crit)[source]
init_conc(img)[source]

Sets an initial linear field across the volume

init_nn(img)[source]

Saves the number of conductive neighbours for flux calculation

solve(iter_limit=5000, verbose=True, conv_crit=0.02)[source]

run a solve simulation

Parameters:

iter_limit – max iterations before aborting, will attemtorch double for the same no. iterations

if initialised as singles :param verbose: Whether to print tau. Can be set to ‘per_iter’ for more feedback :param conv_crit: convergence criteria, minimum percent difference between max and min flux through a given layer :return: tau

class taufactor.taufactor.PeriodicSolver(img, bc=(-0.5, 0.5), D_0=1, device=device(type='cuda', index=0))[source]

Bases: Solver

Periodic Solver (works for non-periodic structures, but has higher RAM requirements) Once solve method is called, tau, D_eff and D_rel are available as attributes.

check_vertical_flux(conv_crit)[source]
init_nn(img)[source]

Saves the number of conductive neighbours for flux calculation

solve(iter_limit=5000, verbose=True, conv_crit=0.02, D_0=1)[source]

run a solve simulation

Parameters:

iter_limit – max iterations before aborting, will attemtorch double for the same no. iterations

if initialised as singles :param verbose: Whether to print tau. Can be set to ‘per_iter’ for more feedback :param conv_crit: convergence criteria, minimum percent difference between max and min flux through a given layer :return: tau

class taufactor.taufactor.Solver(img, bc=(-0.5, 0.5), D_0=1, device=device(type='cuda'))[source]

Bases: object

Default solver for two phase images. Once solve method is called, tau, D_eff and D_rel are available as attributes.

check_convergence(verbose, conv_crit, start, iter_limit)[source]
check_rolling_mean(conv_crit)[source]
check_vertical_flux(conv_crit)[source]
crop(img, c=1)[source]

removes a layer from the volume edges

end_simulation(iter_limit, verbose, start)[source]
init_cb(img)[source]

Creates a chequerboard to ensure neighbouring pixels dont update, which can cause instability

init_conc(img)[source]

Sets an initial linear field across the volume

init_nn(img)[source]

Saves the number of conductive neighbours for flux calculation

pad(img, vals=[0, 0, 0, 0, 0, 0])[source]

Pads a volume with values

solve(iter_limit=5000, verbose=True, conv_crit=0.02)[source]

run a solve simulation

Parameters:

iter_limit – max iterations before aborting, will attemtorch double for the same no. iterations

if initialised as singles :param verbose: Whether to print tau. Can be set to ‘per_iter’ for more feedback :param conv_crit: convergence criteria, minimum percent difference between max and min flux through a given layer :return: tau

Submodules

taufactor.metrics module

taufactor.metrics.surface_area(img, phases, periodic=False)[source]

Calculate interfacial surface area between two phases or the total surface area of one phase :param img: :param phases: list of phases to calculate SA, if lenght 1 calculate total SA, if length 2 calculate inerfacial SA :param periodic: list of bools indicating if the image is periodic in each dimension :return: the surface area in faces per unit volume

taufactor.metrics.triple_phase_boundary(img)[source]

Calculate triple phase boundary density i.e. fraction of voxel verticies that touch at least 3 phases

Args:

img (numpy array): image to calculate metric on

Returns:

float: triple phase boundary density

taufactor.metrics.volume_fraction(img, phases={})[source]

Calculates volume fractions of phases in an image :param img: segmented input image with n phases :param phases: a dictionary of phases to be calculated with keys as labels and phase values as values, default empty :return: list of volume fractions if no labels, dictionary of label: volume fraction pairs if labelled

taufactor.utils module

taufactor.utils.flux_direction(im, outpath=None)[source]

Plots the flux direction of the image and provides code for transposing the image to change the flux direction :param im: segmented input image with n phases :return: None

Module contents

Top-level package for TauFactor.