18 三角剖分 triplot

18 三角剖分 triplot

用途

有限元网格、Delaunay 三角网的骨架展示。

示例(5 张)

18-1 有限元三角剖分网格

有限元三角剖分网格

18-2 温度测点的 Delaunay 三角网

温度测点的 Delaunay 三角网

18-3 不规则区域的计算网格

不规则区域的计算网格

18-4 接地网节点的三角剖分

接地网节点的三角剖分

18-5 电缆接头温度传感器的三角网

电缆接头温度传感器的三角网

代码

以下 5 个函数取自 code/第三批_场与三角网格261107.py,直接调用即可出图。样式(宋体 + Times、10 磅、刻度朝内四边、留白自检)由 code/公共配置261107.py 的 setup_cn_style() 和 save() 统一提供,本节不再重复。

# 摘自 code/第三批_场与三角网格261107.py

def tp_01():
    """有限元三角剖分网格。"""
    fig, ax = new_fig(left=0.19)
    tri = _tri(1801, n=120)
    ax.triplot(tri, color=C1, lw=0.4)
    ax.set_xlabel("横向坐标 " + IT["x"] + " / m")
    ax.set_ylabel("纵向坐标 " + IT["y"] + " / m")
    ax.set_aspect("equal")
    save(fig, "18_三角剖分", "18_三角剖分_有限元三角剖分")

def tp_02():
    """温度测点的 Delaunay 三角网。"""
    fig, ax = new_fig(left=0.19)
    tri = _tri(1802, n=90)
    ax.triplot(tri, color=C3, lw=0.5, marker="o", ms=1.6)
    ax.set_xlabel("测点横坐标 " + IT["x"] + " / m")
    ax.set_ylabel("测点纵坐标 " + IT["y"] + " / m")
    ax.set_aspect("equal")
    save(fig, "18_三角剖分", "18_三角剖分_温度测点三角网")

def tp_03():
    """不规则区域的计算网格。"""
    fig, ax = new_fig(left=0.19)
    rng = np.random.default_rng(1803)
    th = rng.uniform(0, 2 * np.pi, 110)
    r = np.sqrt(rng.uniform(0, 1, 110))
    x = r * np.cos(th)
    y = r * np.sin(th)
    ang = np.linspace(0, 2 * np.pi, 24, endpoint=False)
    x = np.concatenate([x, np.cos(ang)])
    y = np.concatenate([y, np.sin(ang)])
    tri = mtri.Triangulation(x, y)
    ax.triplot(tri, color=C1, lw=0.4)
    ax.set_xlabel("横向坐标 " + IT["x"] + " / m")
    ax.set_ylabel("纵向坐标 " + IT["y"] + " / m")
    ax.set_aspect("equal")
    save(fig, "18_三角剖分", "18_三角剖分_不规则区域网格")

def tp_04():
    """接地网节点的三角剖分。"""
    fig, ax = new_fig(left=0.19)
    rng = np.random.default_rng(1804)
    gx = np.linspace(0, 60, 7)
    gy = np.linspace(0, 60, 7)
    X, Y = np.meshgrid(gx, gy)
    x = X.ravel() + rng.normal(0, 1.2, X.size)
    y = Y.ravel() + rng.normal(0, 1.2, Y.size)
    tri = mtri.Triangulation(x, y)
    ax.triplot(tri, color=C5, lw=0.5, marker="s", ms=2.0)
    ax.set_xlabel("东向距离 " + IT["x"] + " / m")
    ax.set_ylabel("北向距离 " + IT["y"] + " / m")
    ax.set_aspect("equal")
    save(fig, "18_三角剖分", "18_三角剖分_接地网节点三角剖分")

def tp_05():
    """电缆接头温度传感器的三角网。"""
    fig, ax = new_fig(left=0.19)
    rng = np.random.default_rng(1805)
    x = rng.normal(0, 1, 60)
    y = rng.normal(0, 0.35, 60)
    x = np.concatenate([x, [-2.2, 2.2, -2.2, 2.2]])
    y = np.concatenate([y, [-0.6, -0.6, 0.6, 0.6]])
    tri = mtri.Triangulation(x, y)
    ax.triplot(tri, color=C3, lw=0.4, marker="^", ms=1.8)
    ax.set_xlabel("轴向位置 " + IT["x"] + " / m")
    ax.set_ylabel("径向位置 " + IT["y"] + " / m")
    ax.set_aspect("equal")
    save(fig, "18_三角剖分", "18_三角剖分_温度传感器三角网")

说明

  • 图片尺寸 1181×944 px(100 mm × 80 mm @ 300 dpi),三维图为 1181×1122 px。
  • 图内不放标题,图题由本文件的二级/三级标题承担。
  • 数据为贴近广东实际量级的仿真算例,随机种子固定,重跑结果一致。
posted @ 2026-11-07 08:36  小青蛙电气  阅读(3)  评论(0)    收藏  举报