kirchhoff modules

kirchhoff.circuit_init

class kirchhoff.circuit_init.Circuit(G: networkx.classes.graph.Graph = <factory>, info: str = 'unknown')[source]

Bases: object

A class of linear circuits (for lumped parameter modelling).

scales (dictionary):

A dictionary holding the unit system.

graph (dictionary):

A dictionary holding circuit initial conditions.

nodes (pd.DataFrame):

A container for node data.

edges (pd.DataFrame):

A container for edge data.

draw_weight_scaling (float):

Standard wights for drawing.

calc_root_incidence()[source]

Find the incidence for a system with binary-type periphehal nodes.

Returns:

list:

A list of nodes adjacent to the source.

list:

A list of nodes adjacent to the sink.

clipp_graph()[source]

Prune the internal graph and generate a new internal variable represting the pruned based on an interanl threshold value.

default_init()[source]

Initialize the default setting of a circuit, by taking a networkx graph and setting containers

get_edges_data(*args)[source]

Get internal nodal DataFrame columns by keywords.

Args:

args (list):

A list of keywords to check for in the internal DataFrames.

Returns:

pd.DataFrame: A cliced DataFrame.

Raises:

Exception: description

get_incidence_matrices()[source]

Get the incidence matrices from the internal graph objects.

Returns:

ndarray:

A internal circuit graph’s incidence matrix.

ndarray.T:

A internal circuit graph’s incidence matrix, transposed.

get_nodes_data(*args)[source]

Get internal nodal DataFrame columns by keywords.

Args:

args (list):

A list of keywords to check for in the internal DataFrames.

Returns:

pd.DataFrame: A cliced DataFrame.

Raises:

Exception: description

get_pos()[source]

Getting positions of the vertices from the internal graphs.

Returns:

dictionary:

A dictionary holding nodes and their positions in euclidean space.

plot_circuit(*args, **kwargs)[source]

Use Plotly.GraphObjects to create interactive plots that have optionally the graph atributes displayed.

Args:

args (list):

A list of keywords for the internal edge and nodal DataFrames which are to be displayed.

kwargs (dictionary):

A dictionary for plotly keywords customizing the plots’ layout.

Returns:

GraphObject.Figure: A plotly figure displaying the circuit.

set_graph_containers()[source]

Set internal graph containers.

set_graph_pars(new_parameters)[source]

Set a circuit boundary conditions.

Args:

new_parameters (dictionary):

A new set of conditions to bet set.

set_network_attributes()[source]

Set the internal DataFrames with the current graph state.

set_pos(pos_data={})[source]

Set the postions of the internal graph.

Args:

pos_data (dictionary):

A dictionary of nodal positions.

set_scale_pars(new_parameters)[source]

Set a new internal unit system.

Args:

new_parameters (dictionary):

A new set of units to bet set.

test_conductance_consistency()[source]

Test whether boundaries conditions for edge consuctancies on the internal graph variable are consistenly set.

test_source_consistency()[source]

Test whether boundaries conditions for sources on the internal graph variable are consistenly set.

kirchhoff.circuit_init.initialize_circuit_from_crystal(crystal_type='default', periods=1)[source]

Initialize a kirchhoff circuit from a custom crystal type.

Args:

input_graph (nx.Graph):

A simple networkx graph.

Returns:

circuit:

A kirchhoff graph.

kirchhoff.circuit_init.initialize_circuit_from_random(random_type='default', periods=10, sidelength=1)[source]

Initialize a kirchhoff circuit from a random graph (voronoi tesselation of random points).

Args:

input_graph (nx.Graph):

A simple networkx graph.

Returns:

circuit:

A kirchhoff graph.

kirchhoff.circuit_flow

class kirchhoff.circuit_flow.FlowCircuit(G: networkx.classes.graph.Graph = <factory>, info: str = 'unknown', source_mode: dict = <factory>, plexus_mode: dict = <factory>)[source]

Bases: kirchhoff.circuit_init.Circuit

A derived class for flow circuits.

source_mode (dictionary):

A dictionary of custom source-sink boundaries.

plexus_mode (dictionary):

A dictionary of custom plexus initializations.

get_edges_data(*args)[source]

Get internal nodal DataFrame columns by keywords.

Args:

args (list):

A list of keywords to check for in the internal DataFrames.

Returns:

pd.DataFrame: A cliced DataFrame.

get_nodes_data(*args)[source]

Get internal nodal DataFrame columns by keywords.

Args:

args (list):

A list of keywords to check for in the internal DataFrames.

Returns:

pd.DataFrame: A cliced DataFrame.

init_plexus_custom()[source]

Set customized initial plexus.

init_plexus_default()[source]

Set random initial plexus.

init_source_custom()[source]

Set custom sinks and sources boundaries.

init_source_default()[source]

Set one topologically central source, sinks otherwise.

init_source_dipole_border()[source]

Set sources on one side of the graph, sinks on the opposing side.

init_source_dipole_point()[source]

Set a single source-sink pair.

init_source_dipole_wall()[source]

Set sources on one side of the graph, sinks on the opposing side.

init_source_root_central_geometric()[source]

Set one geometrically central source, sinks otherwise.

init_source_root_long()[source]

Set one-sided source (left), sinks otherwise.

init_source_root_multi()[source]

Set multiple random sources, sinks otherwise.

init_source_root_short()[source]

Set one-sided source (right), sinks otherwise.

plot_circuit(*args, **kwargs)[source]

Use Plotly.GraphObjects to create interactive plots that have optionally the graph atributes displayed.

Args:

args (list):

A list of keywords for the internal edge and nodal DataFrames which are to be displayed.

kwargs (dictionary):

A dictionary for plotly keywords customizing the plots’ layout.

Returns:

plotly.graph_objects.Figure: A plotly figure displaying the circuit.

set_plexus_landscape(modePLX='default', **kwargs)[source]

Set the intial conductivity landscape of the plexus.

Args:

mode (string): The specific plexus mode. kwargs (dictonary): Plexus attribute specifiers, optional.

set_poles_relationship(sources, sinks)[source]

Set boundaries with distinguished pole vertices.

set_root_leaves_relationship(root)[source]

Set boundaries with distinguished root vertex.

set_source_attributes(j, node, idx)[source]

Set nodal flow attributes.

set_source_landscape(modeSRC='default', **kwargs)[source]

Set the internal bounday state of sinks and sources.

Args:

mode (string): The specific source mode. kwargs (dictonary): Source attribute specifiers, optional.

set_terminals_potentials(p0)[source]

Set nodal potentials.

kirchhoff.circuit_flow.initialize_flow_circuit_from_crystal(crystal_type='default', periods=1)[source]

Initialize a flow circuit from a spatially embedded, crystal networkx graph.

Args:

crystal_type (string):

The type of crystal skeleton (default, simple, chain, bcc, fcc, diamond, laves, square, hexagonal, trigonal_planar).

periods (int):

Repetition number of the lattice’s unit cell.

Returns:

flow_circuit: A flow_circuit object.

kirchhoff.circuit_flow.initialize_flow_circuit_from_random(random_type='default', periods=10, sidelength=1)[source]

Initialize a flow circuit from a random, spatially embedded networkx graph.

Args:

random_type (string):

The type of random lattice to be constructed(voronoi_planar, voronoi_volume).

periods (int):

Number of random points.

sidelength (float):

The box size into which random points in space are generated.

Returns:

flow_circuit: A flow_circuit object.

kirchhoff.circuit_flow.setup_default_flow_circuit(skeleton=None)[source]

Initialize a flow circuit from a given networkx graph.

Args:

skeleton (nx.Graph): A networkx graph.

Returns:

flow_circuit: A flow_circuit object.

kirchhoff.circuit_flow.setup_flow_circuit(skeleton=None, sourceMode=None, plexusMode=None, **kwargs)[source]

Initialize a flow circuit from a given networkx graph and dictioinary of boundary conditions.

Args:

skeleton (nx.Graph):

A networkx graph.

source (string):

A key for source_mode (default, root_geometric, root_short, root_long, dipole_border, dipole_point, root_multi, custom).

plexus (string):

A key for plexus_mode.(default, custom)

Returns:

flow_circuit: A flow_circuit object.

kirchhoff.circuit_flux

class kirchhoff.circuit_flux.FluxCircuit(G: networkx.classes.graph.Graph = <factory>, info: str = 'unknown', source_mode: dict = <factory>, plexus_mode: dict = <factory>)[source]

Bases: kirchhoff.circuit_flow.FlowCircuit

A derived class for flux circuits.

solute_mode (dictionary):

A dictionary of custom solute outflux/influx boundaries.

absorption_mode (dictionary):

A dictionary of custom absorption rate initializations.

geom_mode (dictionary):

A dictionary of custom plexus geometrical initializations.

get_edges_data(**kwargs)[source]

Get internal nodal DataFrame columns by keywords.

Args:

args (list):

A list of keywords to check for in the internal DataFrames.

Returns:

pd.DataFrame: A cliced DataFrame.

Raises:

Exception: description

get_nodes_data()[source]

Get internal nodal DataFrame columns by keywords.

Args:

args (list):

A list of keywords to check for in the internal DataFrames.

Returns:

pd.DataFrame: A cliced DataFrame.

Raises:

Exception: description

init_absorption_custom()[source]

Set a custom absorption rate landscape.

init_absorption_default()[source]

Set a constant absorption rate landscape.

init_absorption_random()[source]

Set a random absorption rate landscape.

init_geom_custom(flux)[source]

Set a custom length for all connections.

init_geom_default()[source]

Set a constant length for all connections.

init_geom_random()[source]

Set a random length for all connections.

init_solute_custom()[source]

Set custom solute out/influx boundaries.

init_solute_default()[source]

Set solute out/influx accordingly to the sinks-sources boundaries.

set_absorption_landscape(mode='default', **kwargs)[source]

Set the internal bounday state of sinks and sources.

Args:

mode (string):

The specific absorption mode.

kwargs (dictonary):

Absorption attribute specifiers, optional.

set_geom_landscape(mode='default', **kwargs)[source]

Set the internal bounday state of sinks and sources.

Args:

mode (string):

The specific geometric initialization mode.

kwargs (dictonary):

Geometric initialization specifiers, optional.

set_solute(idx, nodes, vals)[source]

Set nodal solute in/outflux attributes.

Args:

idx (int): The dataframe vertex indicator. nodes (int): The corresponding networkx graph node. vals (float): Solute value to be set.

set_solute_landscape(mode='default', **kwargs)[source]

Set the internal bounday state of sinks and sources.

Args:

mode (string):

The specific solute mode.

kwargs (dictonary):

Solute attribute specifiers, optional.

kirchhoff.circuit_flux.initialize_flux_circuit_from_crystal(crystal_type='default', periods=1)[source]

Initialize a flux circuit from a spatially embedded, crystal networkx graph.

Args:

crystal_type (string):

The type of crystal skeleton (default, simple, chain, bcc, fcc, diamond, laves, square, hexagonal, trigonal_planar).

periods (int):

Repetition number of the lattice’s unit cell.

Returns:

flux_circuit: A flux_circuit object.

kirchhoff.circuit_flux.initialize_flux_circuit_from_random(random_type='default', periods=10, sidelength=1)[source]

Initialize a flux circuit from a random, spatially embedded networkx graph.

Args:

random_type (string):

The type of random lattice to be constructed(voronoi_planar, voronoi_volume).

periods (int):

Number of random points.

sidelength (float):

The box size into which random points in space are generated.

Returns:

flux_circuit: A flux_circuit object.

kirchhoff.circuit_flux.setup_default_flux_circuit(skeleton=None, diffusion=None, absorption=None)[source]

Initialize a flux circuit from a given networkx graph.

Args:

skeleton (nx.Graph):

A networkx graph.

diffusion (float):

Diffusion constant.

absorption (float):

Absorption rate.

Returns:

flux_circuit: A flow_circuit object.

kirchhoff.circuit_dual

class kirchhoff.circuit_dual.DualCircuit(layer: list = <factory>, e_adj: list = <factory>, e_adj_idx: list = <factory>, n_adj: list = <factory>)[source]

Bases: object

A base class for flow circuits.

layer (list):

List of the graphs contained in the multilayer circuit.

e_adj (list):

A list off edge affiliation between the different layers, edge view.

e_adj_idx (list):

A list off edge affiliation between the different layers, label view.

n_adj (list): An internal nodal varaible.

distance_edges()[source]

Compute the distance of affiliated edges in the multilayer circuit.

plot_circuit(*args, **kwargs)[source]

Use Plotly.GraphObjects to create interactive plots that have optionally the graph atributes displayed. Args:

kwargs (dictionary):

A dictionary for plotly keywords customizing the plots’ layout.

Returns:

plotly.graph_objects.Figure: A plotly figure displaying the circuit.

kirchhoff.circuit_dual.initialize_dual_from_catenation(dual_type='catenation', num_periods=1, circuit_type='default')[source]

Initialize a dual spatially embedded circuit, with internal graphs based on simple catenatednetwork skeletons.

Args:

dual_type (string):

The type of dual skeleton (simple, diamond, laves, catenation).

num_periods (int):

Repetition number of the lattice’s unit cell.

Returns:

dual_circuit: A dual circuit system.

kirchhoff.circuit_dual.initialize_dual_from_minsurf(dual_type='simple', num_periods=2, circuit_type='default')[source]

Initialize a dual spatially embedded flux circuit, with internal graphs based on the network skeletons of triply-periodic minimal surfaces.

Args:

dual_type (string):

The type of dual skeleton (simple, diamond, laves, catenation).

num_periods (int):

Repetition number of the lattice’s unit cell.

Returns:

dual_circuit: A flow_circuit object.

kirchhoff.draw_networkx

kirchhoff.draw_networkx.add_traces_edges(fig, options, input_graph, extra_data)[source]

Add line traces for interactive edge data display.

Args:

fig (plotly.graph_objects.Figure:

A plotly figure object

options (dictionary):

A dictionary for plotly keywords customizing the plots’ layout.

input_graph (nx.Graph):

A networkx graph.

extra_data (pandas.DataFrame):

A dataframe holding the data.

kirchhoff.draw_networkx.add_traces_nodes(fig, options, input_graph, extra_data)[source]

Add point traces for interactive node data display.

Args:

fig (plotly.graph_objects.Figure:

A plotly figure object

options (dictionary):

A dictionary for plotly keywords customizing the plots’ layout.

input_graph (nx.Graph):

A networkx graph.

extra_data (pandas.DataFrame):

A dataframe holding the data.

kirchhoff.draw_networkx.create_tag(vals, columns)[source]

Create a hover tag.

Args:

vals (list): A list of values. columns (list):A list of keywords.

Returns:

string: A string in makrdown format.

kirchhoff.draw_networkx.get_edge_invd_traces(input_graph, extra_data, **kwargs)[source]

Return individual line traces for interactive edge data display.

Args:

input_graph (nx.Graph):

A networkx graph.

extra_data (pandas.DataFrame):

A dataframe holding the data.

kwargs (dictionary):

A dictionary for plotly keywords customizing the plots’ layout.

Returns:

plotly.graph_objects.Scatter: A plotly scatter object

kirchhoff.draw_networkx.get_edge_mid_trace(input_graph, extra_data, **kwargs)[source]

Return transparent line traces for interactive edge data display.

Args:

input_graph (nx.Graph):

A networkx graph.

extra_data (pandas.DataFrame):

A dataframe holding the data.

kwargs (dictionary):

A dictionary for plotly keywords customizing the plots’ layout.

Returns:

plotly.graph_objects.Scatter: A plotly scatter object

kirchhoff.draw_networkx.get_hover_scatter_from_template(dim, options)[source]

Get scatter hover info for figure traces.

Args:

dim (int):

A dimensional identifier.

options (dictionary):

A dictionary for plotly keywords customizing the plots’ layout.

Returns:

plotly.graph_objects.Scatter: A plotly scatter object

kirchhoff.draw_networkx.get_line_from_template(dim, options)[source]

Get a line trace element.

Args:

dim (int):

A dimensional identifier.

options (dictionary):

A dictionary for plotly keywords customizing the plots’ layout.

Returns:

plotly.graph_objects.Scatter: A plotly scatter object

kirchhoff.draw_networkx.get_node_coords(input_graph, options)[source]

Return nodal coordinates in specified tuple format.

Args:

input_graph (nx.Graph):

A networkx graph.

options (dictionary):

A dictionary for circuit keywords for readout.

Returns:

list: A list of nodal postions [X, Y, Z]

kirchhoff.draw_networkx.get_node_scatter(node_xyz, extra_data, options)[source]

Return nodal traces for interactive node data display.

Args:

node_xyz (list):

A list of nodal postions [X, Y, Z].

extra_data (pandas.DataFrame):

A dataframe holding the data.

options (dictionary):

A dictionary for plotly keywords customizing the plots’ layout.

Returns:

plotly.graph_objects.Scatter: A plotly scatter object

kirchhoff.draw_networkx.get_node_trace(input_graph, extra_data, **kwargs)[source]

Return nodal traces for interactive node data display.

Args:

input_graph (nx.Graph):

A networkx graph.

extra_data (pandas.DataFrame):

A dataframe holding the data.

kwargs (dictionary):

A dictionary for plotly keywords customizing the plots’ layout.

Returns:

plotly.graph_objects.Scatter: A plotly scatter object

kirchhoff.draw_networkx.plot_networkx(input_graph, **kwargs)[source]
Return an interactive network plot, which shows the internal edge and node

data via hover and text.

Args:

input_graph (nx.Graph):

A networkx graph.

kwargs (dictionary):

A dictionary for plotly keywords customizing the plots’ layout.

Returns:

plotly.graph_objects.Figure: A plotly figure object

kirchhoff.draw_networkx.plot_networkx_dual(dual_circuit, *args, **kwargs)[source]
Return an interactive network plot, which shows the internal edge and node

data via hover and text for a multilayer system.

Args:

dual_circuit (dual_circuit):

A dual_circuit object.

args (list):

A list for keywoprd data for display.

kwargs (dictionary):

A dictionary for plotly keywords customizing the plots’ layout.

Returns:

plotly.graph_objects.Figure: A plotly figure object

kirchhoff.draw_networkx.set_edge_info(trace, XYZ_0, XYZ_1)[source]

Set hover info for figure traces.

Args:

trace (plotly.graph_objects.trace): A networkx graph. XYZ_0 (ndarray): Nodal position data. XYZ_0 (ndarray): Nodal position data.

kirchhoff.draw_networkx.set_hover_info(trace, XYZ, extra_data)[source]

Set hover info for figure traces.

Args:

trace (plotly.graph_objects.trace): A networkx graph. XYZ (ndarray): Nodal position data. extra_data (pandas.DataFrame): A dataframe holding the data.

kirchhoff.io_networkx

kirchhoff.init_random

class kirchhoff.init_random.NetworkxRandom(num_periods: int = 0, sidelength: float = 0)[source]

Bases: object

A base class for spatial, random networks.

num_periods(int):

Number of points for internal Voronoi construction.

sidelength (float):

Box length for spatial initialization.

G (dictionary):

An internal simple graph.

is_in_box(v, sl)[source]

Test whether new random point is inside the constraining boundaries.

Args:

v (list):

The point vector to be tested.

sl (float):

The sidelength, acting as scale for the transition vector.

Returns:

bool: The boolean value, True if inside the original volume.

mirror_boxpoints(points, sl)[source]

Periodically mirror points in 2D for voronoi construction.

Args:

points (list):

The original list of points (x,y)

sl (float):

The sidelength, acting as scale for the transition vector.

Returns:

ndarray: A matrix of all points and their mirrors

mirror_cubepoints(points, sl)[source]

Periodically mirror points in 3D for voronoi construction.

Args:

points (list):

The original list of points (x,y,z)

sl (float):

The sidelength, acting as scale for the transition vector.

Returns:

ndarray: A matrix of all points and their mirrors

class kirchhoff.init_random.NetworkxVoronoiPlanar(num_periods: int = 0, sidelength: float = 0)[source]

Bases: kirchhoff.init_random.NetworkxRandom

A class algorithms to generate spatial, 2D random networks, generated via voronoi tesselation of a periodic plane.

num_periods(int):

Number of points for internal Voronoi construction.

sidelength (float):

Box length for spatial initialization.

G (dict):

An internal simple graph.

construct_voronoi_periodic(number, sidelength)[source]

Generate random points in 2D, mirror them periodically and perform a Voronoi tesselation for a 2D random point set.

Args:

number (int):

The number of points to be generated.

sidelength (float):

The sidelength of the box which hold points

Returns:

Voronoi: A scipy.spatial.Voronoi output object

random_voronoi_periodic(number, sidelength)[source]

Build a spatially embedded in 2D, random networkx internally for given size parameters.

Args:

number (int):

The number of points to be generated.

sidelength (float):

The sidelength of the box which hold points

class kirchhoff.init_random.NetworkxVoronoiVolume(num_periods: int = 0, sidelength: float = 0)[source]

Bases: kirchhoff.init_random.NetworkxRandom

A class algorithms to generate spatial, 3D random networks, generated via

voronoi tesselation of a periodic volume.

num_periods(int):

Number of points for internal Voronoi construction.

sidelength (float):

Box length for spatial initialization.

G (dict):

An internal simple graph.

construct_voronoi_periodic(number, sidelength)[source]

Generate random points in 3D, mirror them periodically and perform a Voronoi tesselation for a 3D random point set.

Args:

number (int): The number of points to be generated. sidelength (float): The sidelength of the box which hold points

Returns:

Voronoi: A scipy.spatial.Voronoi output object

random_voronoi_periodic(number, sidelength)[source]
Build a spatially embedded in 3D, random networkx internally for given

size parameters.

Args:

number (int): The number of points to be generated. sidelength (float): The sidelength of the box which hold points

kirchhoff.init_random.init_graph_from_random(random_type, periods, sidelength)[source]

Initialize a random spatial graph customized by type and size.

Args:

random_type (string):

The type of random lattice to be constructed(voronoi_planar, voronoi_volume).

periods (int):

Number of random points.

sidelength (float):

The box size into which random points in space are generated.

Returns:

nx.Graph: A random spatial graph.

kirchhoff.init_crystal

class kirchhoff.init_crystal.NetworkxBcc(num_periods)[source]

Bases: kirchhoff.init_crystal.NetworkxCrystal

A derived class for spatial, simple bcc graphs.

bcc_unit_cell()[source]

Return a networkx graph of the simple bcc unit cell.

Returns:

nx.Graph:

A networkx graph.

simple_bcc_lattice(num_periods)[source]

Set the internal graph as simple bcc lattice.

Args:

num_periods (int):

Repetition number for the unit cell.

class kirchhoff.init_crystal.NetworkxChain(num_periods)[source]

Bases: kirchhoff.init_crystal.NetworkxCrystal

A derived class for spatial, 1D chain graphs.

simple_chain(num_periods)[source]

Set the internal graph as a simple 1D chain.

Args:

num_periods (int):

Length of the chain.

class kirchhoff.init_crystal.NetworkxCrystal[source]

Bases: object

A base class for spatial, crystal-like graphs.

G (nx.Graph):

An internal networkx graph variable.

dict_cells (dictionary):

A dictionary of the current cells.

lattice_constant (float):

Scale for the lattice. spacing

translation_length (float):

Scale for the translational offset.

lattice_translation(t, T)[source]

Return a networkx graph, initialzed from given unit cell and offset.

Args:

t (ndarray):

A translational offset for the lattice.

T (nx.Graph):

A networkx graph, unit cell.

Returns:

nx.Graph: A simple, periodic Graph.

periodic_cell_structure(cell, num_periods)[source]

Set the internal graph variable by periodically repeating the chosen unitcell type.

Args:

cell (nx.Graph):

A networkx graph, unit cell.

num_periods (int):

Repetition number for the unit cells.

class kirchhoff.init_crystal.NetworkxDiamond(num_periods)[source]

Bases: kirchhoff.init_crystal.NetworkxCrystal

A derived class for spatial, diamond graphs.

diamond_lattice(num_periods)[source]

Set the internal graph as diamond lattice.

Args:

num_periods (int):

Repetition number for the unit cell.

diamond_unit_cell()[source]

Return a networkx graph of the dioamond unit cell.

Returns:

nx.Graph:

A networkx graph.

class kirchhoff.init_crystal.NetworkxFcc(num_periods)[source]

Bases: kirchhoff.init_crystal.NetworkxCrystal

A derived class for spatial, simple fcc graphs.

fcc_unit_cell()[source]

Return a networkx graph of the simple fcc unit cell.

Returns:

nx.Graph:

A networkx graph.

simple_fcc_lattice(num_periods)[source]

Set the internal graph as simple fcc lattice.

Args:

num_periods (int):

Repetition number for the unit cell.

class kirchhoff.init_crystal.NetworkxHexagonal(tiling_factor, periodic=False)[source]

Bases: kirchhoff.init_crystal.NetworkxCrystal

A derived class for spatial, planar hexagonal graphs.

hexagonal_grid(tiling_factor, periodic_bool)[source]

Set the internal graph as hexagonal grid, using the networkx graph generator.

class kirchhoff.init_crystal.NetworkxLaves(num_periods)[source]

Bases: kirchhoff.init_crystal.NetworkxCrystal

A derived class for spatial, Laves graphs.

laves_lattice(num_periods)[source]

Set the internal graph as laves lattice.

Args:

num_periods (int):

Repetition number for the unit cell.

class kirchhoff.init_crystal.NetworkxSimple(num_periods)[source]

Bases: kirchhoff.init_crystal.NetworkxCrystal

A derived class for spatial, simple cubic graphs.

simple_cubic_lattice(num_periods)[source]

Set the internal graph as simple cubic lattice.

Args:

num_periods (int):

Repetition number for the unit cell.

simple_unit_cell()[source]

Return a networkx graph of the simbple cubic unit cell.

Returns:

nx.Graph:

A networkx graph.

class kirchhoff.init_crystal.NetworkxSquare(tiling_factor)[source]

Bases: kirchhoff.init_crystal.NetworkxCrystal

A derived class for spatial, simpley tiled graphs.

square_grid(num_periods)[source]

Set the internal graph as square grid.

class kirchhoff.init_crystal.NetworkxTriagonalPlanar(tiling_factor)[source]

Bases: kirchhoff.init_crystal.NetworkxCrystal

A derived class for spatial, planar triangulated graphs.

construct_wing(a, n)[source]

Generate new nodes and connections from the spines of the hexagon.

Args:

a (int):

+-1, setting the currently constructed hemisphere.

n (int):

Length of the hexagon’s outer sites.

triangulated_hexagon_lattice(n)[source]

Generate new nodes and connections for the spine of the hexagon.

Args:

n (int):

Length of the hexagon’s outer sites.

class kirchhoff.init_crystal.NetworkxTriagonalStack(stacks, tiling_factor)[source]

Bases: kirchhoff.init_crystal.NetworkxCrystal

A derived class for spatial, stacked, triangulated graphs, contained in hexagonal shapes.

construct_spine_stack(z, n)[source]
Generate new nodes and connections for spines of stacked hexagons of

the internal graph and set spine length internally.

Args:

z (float):

The current stack indicator.

n (int):

Length of the hexagon’s outer sites.

construct_wing_stack(z, a, n)[source]

Generate new nodes and connections from the spines for each stacked hexagon.

Args:

z (float):

The current stack indicator.

a (int):

+-1, setting the currently constructed hemisphere.

n (int):

Length of the hexagon’s outer sites.

Crosslink the stacked hexagons to closest layer neighbor.

triangulated_hexagon_stack(stacks, num_periods)[source]

Set the internal graph as stacked, triangulated lattice, contained in hexagonal shapes.

Args:

stacks (int):

The number of layers.

num_periods (int):

Length of the hexagon’s spine.

kirchhoff.init_crystal.init_graph_from_asymCrystal(crystal_type, periodsZ, periodsXY)[source]

Initialize a spatially embedded graph, with based on an asymmetric crystal lattice.

Args:

crystal_type (string):

The type of crystal skeleton (trigonal_stack).

periodsZ (int):

Vertical repetition number of the lattice’s unit cell.

periodsXY (int):

Lateral repetition number of the lattice’s unit cell.

Returns:

nx.Graph: A networkx graph.

kirchhoff.init_crystal.init_graph_from_crystal(crystal_type, periods)[source]

Initialize a spatially embedded graph, with based on crystal lattice.

Args:

crystal_type (string):

The type of crystal skeleton (default, simple, chain, bcc, fcc, diamond, laves, square, hexagonal, trigonal_planar).

periods (int):

Repetition number of the lattice’s unit cell.

Returns:

nx.Graph: A networkx graph.

kirchhoff.init_dual

class kirchhoff.init_dual.NetworkxDual[source]

Bases: kirchhoff.init_crystal.NetworkxCrystal

A base class for spatial, dual circuits.

layer (list):

List of the graphs contained in the multilayer network.

lattice_constant (float):

Scale for the spacing between the networks.

translation_length (float):

Scale for the translation difference between the multiple networks.

periodic_cell_structure_offset(cell, num_periods, offset)[source]

Repeat the unit cell with translational offset to create a graph.

Args:

cell (nx.Graph): unit cell in networkx graph format. num_periods (int): Repetition number for the unit cells. offset (ndarray): A translational offset for the lattice.

Returns:

nx.Graph: A simple, periodic Graph.

prune_leaves(G, H, adj)[source]

Remove non-affiliated edges in dual graphs.

Args:

G(nx.Graph):

A networkx graph.

H (nx.Graph):

A networkx graph.

adj (list):

A list of affiliated edge pairs of the two graphs.

Returns:

list: A list of networkx graphs.

relabel_networkx(G1, G2, adj)[source]

Relabel affiliations and graph attributes.

Args:

G(nx.Graph):

A networkx graph.

H (nx.Graph):

A networkx graph.

adj (list):

A list of affiliated edge pairs of the two graphs.

Returns:

list: A list of networkx graphs.

set_graph_adjacency(G, H)[source]

Relabel affiliations and graph attributes.

Args:

G (nx.Graph):

The inner networkx graph.

H (nx.Graph):

The outer networkx graph.

Returns:

list: A list of affiliated edge pairs of the two graphs.

class kirchhoff.init_dual.NetworkxDualCatenation(num_periods)[source]

Bases: kirchhoff.init_dual.NetworkxDual

A class for spatial, dual Laves circuits.

layer (list):

List of the mutlilayered circuits.

lattice_constant (float):

Scale for the spacing between the networks.

dual_ladder(num_periods)[source]

Set internal networkx structure, dual ladder.

Args:

num_periods (int):

Repetition number of the unit tile.

class kirchhoff.init_dual.NetworkxDualCrossMesh(num_periods)[source]

Bases: kirchhoff.init_dual.NetworkxDual

A class for spatial, dual Laves circuits.

layer (list):

List of the mutlilayered circuits.

lattice_constant (float):

Scale for the spacing between the networks.

dualCrossMesh(n_periods)[source]

Set internal networkx structure, dual crossed_mesh.

Args:

num_periods (int):

Repetition number of the unit tile.

class kirchhoff.init_dual.NetworkxDualDiamond(num_periods)[source]

Bases: kirchhoff.init_dual.NetworkxDual

A class for spatial, dual diamond circuits.

layer (list):

List of the mutlilayered circuits.

lattice_constant (float):

Scale for the spacing between the networks.

translation_length (float):

Scale for the translation difference between the multiple networks.

dualDiamond(num_periods)[source]

Set internal networks structure, dual diamond.

Args:

num_periods (int):

Repetition number of the unit cells.

init_graph(G_aux)[source]

Generate points for a diamond lattice return dual graph representations.

Args:

G_aux (nx.Graph):

A networkx graph.

Returns:

nx.Graph:

A networkx graph.

init_graph_nuclei(G_aux, H_aux)[source]
Generate points for a diamond lattice and its dual via copy+translation

and return dual graph representations.

Args:

G_aux (nx.Graph):

Inner networkx graph.

H_aux (nx.Graph):

Outer networkx graph.

Returns:

nx.Graph:

Inner networkx graph.

nx.Graph:

Outer networkx graph.

class kirchhoff.init_dual.NetworkxDualLaves(num_periods)[source]

Bases: kirchhoff.init_dual.NetworkxDual

A class for spatial, dual Laves circuits.

layer (list):

List of the mutlilayered circuits.

lattice_constant (float):

Scale for the spacing between the networks.

dualLaves(num_periods)[source]

Set internal networks structure, dual diamond.

Args:

num_periods (int):

A networkx graph.

init_graph(G_aux)[source]

Built labeled, attributed graphs from raw point sets.

Args:

G_aux (nx.Graph):

Inner networkx graph holding unlabeled data.

Returns:

nx.Graph: A networkx graph

init_graph_nuclei(G_aux, H_aux)[source]

Generate points for a Laves lattice and its dual via mirroring + translation and return dual graph representations.

Args:

G_aux (nx.Graph):

Inner networkx graph.

H_aux (nx.Graph):

Outer networkx graph.

Returns:

nx.Graph: A networkx graph

laves_graph(num_periods, chirality, offset)[source]

Generate points for a Laves lattice and its dual via mirroring + translation and return dual graph representations.

Args:

num_periods (int):

Repetition number of the unit cells..

chirality (string):

Chirality identifier for the current lattice generator.

offset (ndarray):

A translation vector.

Returns:

nx.Graph: A networkx graph

class kirchhoff.init_dual.NetworkxDualSimple(num_periods)[source]

Bases: kirchhoff.init_dual.NetworkxDual

A class for spatial, dual cubic circuits.

layer (list):

List of the mutlilayered circuits.

lattice_constant (float):

Scale for the spacing between the networks.

translation_length (float):

Scale for the translation difference between the multiple networks.

dualSimple(num_periods)[source]

Set internal networks structure, dual cubic.

Args:

num_periods (int):

A networkx graph.

init_graph_nuclei(V)[source]

Generate points for a cubic lattice and its dual via Voronois tesselation and return dual graph representations.

Args:

Voronoi (scipy.spatial.Voronoi):

A Tesselation object.

Return:

nx.Graph:

Inner networkx graph.

nx.Graph:

Outer networkx graph.

set_graph_adjacency(V, G, H)[source]

Return the affiliation list of two dual cubic lattices.

Args:

Voronoi (scipy.spatial.Voronoi):

A Voronoi-Tesselation object.

G (nx.Graph):

The inner networkx graph.

H (nx.Graph):

The outer networkx graph.

Return:

list:

The edge affiliation list of the dual cubic lattice.

kirchhoff.init_dual.init_dualCatenation(dual_type, num_periods)[source]

Initialize a dual spatially embedded multilayer graph, with internal graphs based on simple catenated network skeletons.

Args:

dual_type (string):

The type of dual skeleton (simple, diamond, laves, catenation).

num_periods (int):

Repetition number of the lattice’s unit cell.

Returns:

NetworkxDual: A dual networkx object.

kirchhoff.init_dual.init_dual_minsurf_graphs(dual_type, num_periods)[source]

Initialize a dual spatially embedded multilayer graph, with internal graphs based on the network skeletons of triply-periodic minimal surfaces.

Args:

dual_type (string):

The type of dual skeleton (simple, diamond, laves, catenation).

num_periods (int):

Repetition number of the lattice’s unit cell.

Returns:

NetworkxDual: A dual networkx object.