Skip to main content

Collection of routines for creation and manipulation of Kirchhoff circuits based on resistor-only networks, together with 2D/3D spatial embeddings.

Project description

kirchhoff

A module for generating kirchhoff circuits on the basis of networkx graphs. To be used in conjunction with the package 'goflow'. For further details and documentation see: https://felixk1990.github.io/kirchhoff-circuits/

Introduction

This module 'kirchhoff' is part of a series of pyton packages encompassing a set of class and method implementations for a kirchhoff network datatype, which includes a visualization routine based on plotly. The concept is to build kirchhoff networks from networkx graphs, by providing a container for the graphs as well as separate containers for network attributes meant for fast(er) computation in the follow-up modules 'hailhydro' and 'goflow'

Installation

pip install kirchhoff

Usage

Generally, just take a weighted networkx graph and read it in as shown. You can plot the network interactivly, with full display of edge and node attributes if desired. Default attributes are 'source'/'potential' for nodes and 'conductivity'/'flow_rate' for edges.

import kirchhoff.circuit_init as ki
n=3
G=nx.grid_graph(( n,n,1))
K = ki.initialize_circuit_from_networkx(G)

import kirchhoff.circuit_dual as kid
kid.initialize_dual_flux_circuit_from_minsurf('simple',3)

Single and dual networks are supported at the moment, and can be constructed from networkx generator or custom pre-defined types of spatially embedded graphs such as

  • crystals/periodic, initialize_circuit_from_crystal(crystal_type='default',periods=1): 'default': simple cubic lattice 3D, 'chain': 1D chain, 'bcc': bcc lattice 3D, 'fcc': fcc lattice 3D,'diamond': diamond lattice 3D,'laves': laves lattice 3D,'triagonal_stack': triagonal lattice stacked and interconnected 3D, 'square': simple cubic lattice 2D, 'hexagonal': hexagonal lattice 2D,'triagonal_planar': triagonal lattice 2D
  • random voronoi tesselation, initialize_circuit_from_random(random_type='default',periods=10,sidelength=1): 'default': planar voronoi tesselation with periodic boundaries, 'voronoi_volume': 3D voronoi tesselation with periodic boundaries
  • intertwined systems, initialize_dual_circuit_from_minsurf(dual_type='simple',num_periods=2): supporting most of the above in 3D

Further one can define 'flow' and 'flux' circuits for hydrodynamic simulations which are based on Hagen-Poiseuille flow and transport of solutes via advection-diffusion. Doing so will enable more specifically tailored methods for source/solute influx topology control:

import kirchhoff.circuit_flow as kfc
kfc.initialize_circuit_from_networkx(G)
kfc.initialize_flow_circuit_from_crystal('simple',3)
kfc.initialize_flow_circuit_from_random(random_type='voronoi_volume')

import kirchhoff.circuit_flux as kfx
kfx.initialize_circuit_from_networkx(G)
kfx.initialize_flux_circuit_from_crystal('simple',3)
kfx.initialize_flux_circuit_from_random(random_type='voronoi_volume')

To set node and edge attributes ('source','potential' ,'conductivity','flow_rate') use the set_source_landscape(), set_plexus_landscape() methods of the kirchhoff class and use the class method plot_circuit for plotly output:

import kirchhoff.circuit_flow as kfc

K=kfc.initialize_flow_circuit_from_crystal('hexagonal',3)
K.set_source_landscape()
K.set_plexus_landscape()

fig=K.plot_circuit()
fig.show()

hex ./notebook contains examples to play with in the form of jupyter notebooks Binder

Requirements

networkx==2.5
numpy==1.19.1
pandas==1.1.1
plotly==5.3.1
scipy==1.5.2

Gallery

simple dual voronoi

Acknowledgement

kirchhoff written by Felix Kramer

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kirchhoff-0.2.7.tar.gz (25.4 kB view details)

Uploaded Source

File details

Details for the file kirchhoff-0.2.7.tar.gz.

File metadata

  • Download URL: kirchhoff-0.2.7.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.8.2 requests/2.27.1 setuptools/61.2.0 requests-toolbelt/0.9.1 tqdm/4.64.0 CPython/3.7.3

File hashes

Hashes for kirchhoff-0.2.7.tar.gz
Algorithm Hash digest
SHA256 b13d7b3eddfd50ca252296501e69a71c91ededddc8305cf8d200c739f072090a
MD5 5aabc80f27630160d456ea7d05736ce5
BLAKE2b-256 a1a35e4391678dca3d32916582e2fb37528e72eff671f8642aee0339f3816cc2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page