The quantum graph module¶
Quantum graph construction module.
A quantum graph is a networkx graph with additional parameters in graph.graph[‘param’] and specific node/edges attributes.
-
netsalt.quantum_graph.
construct_incidence_matrix
(graph)[source]¶ Construct the quantum incidence matrix B(k).
- Parameters
graph (graph) – quantum graph
-
netsalt.quantum_graph.
construct_laplacian
(wavenumber, graph)[source]¶ Construct quantum laplacian from a graph.
The quantum laplacian is L(k) = B^T(k) W^{-1}(k) B(k), with quantum incidence and weight matrix.
- Parameters
wavenumber (complex) – wavenumber
graph (graph) – quantum graph
-
netsalt.quantum_graph.
construct_weight_matrix
(graph, with_k=True)[source]¶ Construct the quantum matrix W^{-1}(k).
The with_k argument is needed for the graph laplcian, not for computing the edge amplitudes.
- Parameters
graph (graph) – quantum graph
with_k (bool) – multiplies or not the laplacian by k
-
netsalt.quantum_graph.
create_quantum_graph
(graph, params=None, positions=None, lengths=None, seed=42, noise_level=0.001)[source]¶ Extend a networkx graph with necessary attributes for being a quantum graph.
- Parameters
graph (networkx graph) – pure networkx graph to consider as a quantum graph
params (dict) – specific parameters to setup the quantum graph (depends on use cases)
positions (list) – node positions, if Non networkx.spring_layout is used
lengths (list) –
seed (int) – seed for rng
noise_level (float) – adds some noise if too manuy edges of equal lengths are found
-
netsalt.quantum_graph.
get_total_inner_length
(graph)[source]¶ Get the total inner length of the graph (considering inner edges only).
Inner edges are defined as edges without degree one nodes.
- Parameters
graph (graph) – quantum graph
-
netsalt.quantum_graph.
get_total_length
(graph)[source]¶ Get the total length of a quantum graph.
- Parameters
graph (graph) – quantum graph
-
netsalt.quantum_graph.
laplacian_quality
(laplacian, method='eigenvalue')[source]¶ Return the quality of a mode encoded in the quantum laplacian.
If quality is low, the wavenumber of the laplacian is close to a solution of the quantum graph.
- Parameters
laplacian (sparse matrix) – laplacian matrix
method (str) – either eigenvalue or singular value
-
netsalt.quantum_graph.
mode_quality
(mode, graph)[source]¶ Quality of a mode, small means good quality, thus the mode is close to a correct mode.
- Parameters
mode (complex) – complex mode
graph (graph) – quantum graph
-
netsalt.quantum_graph.
oversample_graph
(graph, edge_size)[source]¶ Oversample a graph by adding points on edges.
- Parameters
graph (graph) – quantum graph
edge_size (float) – edge size to sample the graph
-
netsalt.quantum_graph.
set_inner_edges
(graph, params=None, outer_edges=None)[source]¶ Set the inner edges to True, according to a given model in params[‘open_model’].
WARNING: this modifies params, which has to be set to graph with update_parameters TODO: improve implementation along with update_parameters
- Parameters
graph (graph) – quantum graph
params (dict) – has to contain ‘open_model’ of the form open, closed, custom
outer_edges (list) – if open_model == custom, pass the list of outer edges.
-
netsalt.quantum_graph.
set_total_length
(graph, total_length=None, max_extent=None, inner=True, with_position=True)[source]¶ Set the (inner) total lengths of the graph to a given value.
- Parameters
graph (graph) – quantum graph
total_length (float) – total length to set
max_extent (float) – only if total_length is None, set the maximal extent
inner (bool) – if True, only consider inner edges
with_position (bool) – if True, also rescale node positions
-
netsalt.quantum_graph.
set_wavenumber
(graph, wavenumber)[source]¶ Set edge wavenumbers with dispersion relation defined in graph[‘dispersion_relation’].
- Parameters
wavenumber (complex) – wavenumber
graph (graph) – quantum graph
-
netsalt.quantum_graph.
simplify_graph
(graph)[source]¶ Remove degree 2 nodes.
- Parameters
graph (graph) – quantum graph
-
netsalt.quantum_graph.
update_parameters
(graph, params, force=False)[source]¶ Set the parameter dictionary to the graph.
TODO: improve this implementation
- Parameters
graph (graph) – quantum graph
params (dict) – specific parameters to setup the quantum graph (depends on use cases)
force (bool) – I forgot