image0

Introduction

%matplotlib inline
import networkx as nx
import leveldiagram as ld

To begin, the system is defined using a directional graph, provided by the networkx.DiGraph class. The nodes of this graph represent the levels, the edges represent the desired couplings.

Passing a simple graph to the base level diagram constructor LD will produce a passable output for simple visualization.

nodes = (0,1,2)
edges = ((0,1),(1,2))
graph = nx.DiGraph()
graph.add_nodes_from(nodes)
graph.add_edges_from(edges)
d = ld.LD(graph)
d.draw()
d.fig.savefig('basic_example.png', bbox_inches='tight', dpi=150)
../_images/output_6_01.png

In keeping with peak matplotlib form, getting something that looks nicer requires applying custom configuration settings that control many of the aspects of the diagram.

Gloabl settings can be controlled by passing in keyword argument dictionaries to the constructor.

d = ld.LD(graph, coupling_defaults = {'arrowsize':0.2,'lw':3})
d.draw()
../_images/output_9_01.png

NetworkX graphs take an internal structure of nested dictionaries. Leveldiagram utilizes this to provide keyword argument control over each element in the graph.

nodes = ((0,{'bottom_text':'ground'}),
         (1,{'right_text':'excited'}),
         (2,{'top_text':'rydberg'}))
edges = ((0,1, {'label':'$\\Omega_p$', 'lw':2}),
         (1,2, {'label':'$\\Omega_c$','lw':3, 'arrowsize':0.2}))
graph = nx.DiGraph()
graph.add_nodes_from(nodes)
graph.add_edges_from(edges)
d = ld.LD(graph)
d.draw()
d.fig.savefig('intermediate_example.png', bbox_inches='tight', dpi=150)
../_images/output_12_01.png

More detailed examples of element configuration and diagram creation, including embedding a diagram in a larger figure, are shown in the Example Notebooks.

ld.about()
        leveldiagram
    ====================

leveldiagram Version: 0.2.0

        Dependencies
    ====================

Python Version:       3.10.8
NumPy Version:        1.23.4
Matplotlib Version:   3.5.3
NetworkX Version:     2.8.4