API Reference
Core module
taufactor.taufactor module
Main module.
- class taufactor.taufactor.AnisotropicSolver(img, spacing, bc=(-0.5, 0.5), D_0=1, device=device(type='cuda', index=0))[source]
Bases:
SolverAnisotropic Solver e.g. for FIB-SEM datsets where spacing in cutting direction it different from pixel resolution
- solve(iter_limit=5000, verbose=True, conv_crit=0.02, plot_interval=10)[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.BaseSolver(img, bc=(-0.5, 0.5), device=device(type='cuda'))[source]
Bases:
object
- 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:
BaseSolverMulti=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'))[source]
Bases:
SolverSolver with periodic boundary conditions in y and z direction. Only differences to the standard solver are the
neighbour matrix accounting for conductive neighbours on the other side and
the function to apply boundary conditions
Once solve method is called, tau, D_eff and D_rel are available as attributes.
- class taufactor.taufactor.Solver(img, bc=(-0.5, 0.5), D_0=1, device=device(type='cuda'))[source]
Bases:
BaseSolverDefault 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, plot_interval=10)[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.extract_through_feature(array, grayscale_value, axis, periodic=[False, False, False], connectivity=1, debug=False)[source]
- taufactor.metrics.find_spanning_labels(labelled_array, axis)[source]
Find labels that appear on both ends along given axis
- Returns:
set: Labels that appear on both ends of the first axis.
- taufactor.metrics.gaussian_kernel_3d_numpy(size=3, sigma=1.0)[source]
Creates a 3D Gaussian kernel using NumPy
- taufactor.metrics.gaussian_kernel_3d_torch(device, size=3, sigma=1.0)[source]
Creates a 3D Gaussian kernel using PyTorch
- taufactor.metrics.label_periodic(field, grayscale_value, neighbour_structure, periodic, debug=False)[source]
- taufactor.metrics.specific_surface_area(img, spacing=(1, 1, 1), phases={}, method='gradient', device=device(type='cuda'), smoothing=True, verbose=False)[source]
Calculate the specific surface area of all (specified) phases :param img: labelled microstructure where each integer value represents a phase :param spacing: voxel size in each dimension [dx,dy,dz] :param phases: dictionary of phases {‘name’: label, …}. If empty do all by default. :param method: string to indicate preferred method (face_counting, marching_cubes or gradient) :return: the surface area 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.