In [1]:
%matplotlib inline

创建带箭头的supercell


In [2]:
nodes, edges = [], []

创建 nodes 和 edges

top 位相关


In [3]:
from catplot.grid_components.nodes import Node2D
from catplot.grid_components.edges import Edge2D

In [4]:
top = Node2D([0.0, 0.0], size=800, color="#2A6A9C")
t1 = Node2D([0.0, 1.0])
t2 = Node2D([1.0, 0.0])

In [5]:
nodes.append(top)

In [6]:
e1 = Edge2D(top, t1, width=8)
e2 = Edge2D(top, t2, width=8)
edges.extend([e1, e2])

bridge 相关


In [7]:
bridge1 = Node2D([0.0, 0.5], style="s", size=600, color="#5A5A5A", alpha=0.6)
bridge2 = Node2D([0.5, 0.0], style="s", size=600, color="#5A5A5A", alpha=0.6)
b1 = bridge1.clone([0.5, 0.5])
b2 = bridge2.clone([0.5, 0.5])
nodes.extend([bridge1, bridge2])

In [8]:
e1 = Edge2D(bridge1, b1)
e2 = Edge2D(bridge1, bridge2)
e3 = Edge2D(bridge2, b2)
e4 = Edge2D(b1, b2)
edges.extend([e1, e2, e3, e4])

hollow 位相关


In [9]:
h = Node2D([0.5, 0.5], style="h", size=700, color="#5A5A5A", alpha=0.3)
nodes.append(h)

创建箭头


In [10]:
from catplot.grid_components.edges import Arrow2D

In [11]:
top_bri_1 = Arrow2D(top, bridge1, alpha=0.6, color="#ffffff", zorder=3)
top_bri_2 = Arrow2D(top, bridge2, alpha=0.6, color="#ffffff", zorder=3)
top_hollow = Arrow2D(top, h, alpha=0.6, color="#000000", zorder=3)

In [12]:
arrows = [top_bri_1, top_bri_2, top_hollow]

绘制


In [13]:
from catplot.grid_components.grid_canvas import Grid2DCanvas

In [14]:
canvas = Grid2DCanvas()


创建supercell


In [15]:
from catplot.grid_components.supercell import SuperCell2D

In [16]:
supercell = SuperCell2D(nodes, edges, arrows)

In [17]:
canvas.add_supercell(supercell)

In [18]:
canvas.draw()
canvas.figure


Out[18]:

扩展supercell


In [19]:
expanded_supercell = supercell.expand(4, 4)

In [20]:
canvas_big = Grid2DCanvas(figsize=(30, 20), dpi=60)



In [21]:
canvas_big.add_supercell(expanded_supercell)
canvas_big.draw()
canvas_big.figure


Out[21]: