API Reference
Core module
taufactor.taufactor module
Main module.
- class taufactor.taufactor.ElectrodeSolver(img, omega=1e-06, device=device(type='cuda'))[source]
Bases:
objectElectrode 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.
- 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
- 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
- class taufactor.taufactor.MultiPhaseSolver(img, cond={1: 1}, bc=(-0.5, 0.5), device=device(type='cuda', index=0))[source]
Bases:
SolverMulti=phase solver for two phase images. Once solve method is called, tau, D_eff and D_rel are available as attributes.
- 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:
SolverPeriodic 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.
- 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:
objectDefault solver for two phase images. Once solve method is called, tau, D_eff and D_rel are available as attributes.
- init_cb(img)[source]
Creates a chequerboard to ensure neighbouring pixels dont update, which can cause instability
- 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
Module contents
Top-level package for TauFactor.