20 三角网格填充等值线 tricontourf

20 三角网格填充等值线 tricontourf

用途

在 tricontour 基础上填充色阶,视觉冲击更强。

示例(5 张)

20-1 不规则网格温度场的填充等值线

不规则网格温度场的填充等值线

20-2 不规则网格电位场的填充等值线

不规则网格电位场的填充等值线

20-3 电缆终端电场的填充等值线

电缆终端电场的填充等值线

20-4 区域负荷密度的填充等值线

区域负荷密度的填充等值线

20-5 变压器铁心温升的填充等值线

变压器铁心温升的填充等值线

代码

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

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

def tf_01():
    """不规则网格温度场的填充等值线。"""
    fig, ax = new_fig(left=0.19, bottom=0.21, right=0.86)
    tri = _tri(2001, n=200)
    z = 30 + 26 * np.exp(-((tri.x - 0.45) ** 2 + (tri.y - 0.5) ** 2) / 0.09) + 6 * tri.y
    cs = ax.tricontourf(tri, z, levels=16, cmap=CMAP_SEQ)
    ax.set_xlabel("横向坐标 " + IT["x"] + " / m")
    ax.set_ylabel("纵向坐标 " + IT["y"] + " / m")
    ax.set_aspect("equal")
    cbar(fig, ax, cs, "温度 " + IT["T"] + " / °C")
    save(fig, "20_三角填充等值线", "20_三角填充等值线_不规则温度场填充")

def tf_02():
    """不规则网格电位场的填充等值线。"""
    fig, ax = new_fig(left=0.19, bottom=0.21, right=0.86)
    tri = _tri(2002, n=190)
    V = np.zeros_like(tri.x)
    for gx, gy, k in [(0.3, 0.35, 1.0), (0.72, 0.6, 0.85)]:
        V += k / np.sqrt((tri.x - gx) ** 2 + (tri.y - gy) ** 2 + 0.012) * 1.1
    cs = ax.tricontourf(tri, V, levels=16, cmap=CMAP_SEQ)
    ax.set_xlabel("东向距离 " + IT["x"] + " / m")
    ax.set_ylabel("北向距离 " + IT["y"] + " / m")
    ax.set_aspect("equal")
    cbar(fig, ax, cs, "电位 " + IT["U"] + " / V")
    save(fig, "20_三角填充等值线", "20_三角填充等值线_不规则电位场填充")

def tf_03():
    """电缆终端电场的填充等值线。"""
    fig, ax = new_fig(left=0.19, bottom=0.21, right=0.86)
    tri = _tri(2003, n=200)
    E = 42 * np.exp(-np.abs(tri.x - 0.5) / 0.16) * (1 - 0.45 * tri.y) + 6 * tri.y
    cs = ax.tricontourf(tri, E, levels=16, cmap=CMAP_SEQ)
    ax.tricontour(tri, E, levels=[10, 20, 30, 40], colors="0.15", linewidths=0.45)
    ax.set_xlabel("轴向位置 " + IT["x"] + " / mm")
    ax.set_ylabel("径向位置 " + IT["y"] + " / mm")
    ax.set_aspect("equal")
    cbar(fig, ax, cs, "场强 " + IT["E"] + " / (kV/mm)")
    save(fig, "20_三角填充等值线", "20_三角填充等值线_电缆终端电场填充")

def tf_04():
    """区域负荷密度的填充等值线。"""
    fig, ax = new_fig(left=0.19, bottom=0.21, right=0.86)
    tri = _tri(2004, n=190)
    dens = (1200 * np.exp(-((tri.x - 0.35) ** 2 + (tri.y - 0.55) ** 2) / 0.05)
            + 800 * np.exp(-((tri.x - 0.75) ** 2 + (tri.y - 0.32) ** 2) / 0.04))
    cs = ax.tricontourf(tri, dens, levels=16, cmap=CMAP_SEQ)
    ax.set_xlabel("东向距离 " + IT["x"] + " / km")
    ax.set_ylabel("北向距离 " + IT["y"] + " / km")
    ax.set_aspect("equal")
    cbar(fig, ax, cs, "负荷密度 / (kW/km²)")
    save(fig, "20_三角填充等值线", "20_三角填充等值线_负荷密度填充")

def tf_05():
    """变压器铁心温升的填充等值线。"""
    fig, ax = new_fig(left=0.19, bottom=0.21, right=0.86)
    tri = _tri(2005, n=190)
    dT = (24 + 18 * np.exp(-((tri.x - 0.5) ** 2 + (tri.y - 0.45) ** 2) / 0.07)
          + 5 * np.sin(tri.x * 4.0))
    cs = ax.tricontourf(tri, dT, levels=16, cmap=CMAP_SEQ)
    ax.set_xlabel("铁心长度 " + IT["x"] + " / mm")
    ax.set_ylabel("铁心高度 " + IT["y"] + " / mm")
    ax.set_aspect("equal")
    cbar(fig, ax, cs, "温升 Δ" + IT["T"] + " / K")
    save(fig, "20_三角填充等值线", "20_三角填充等值线_铁心温升填充")

说明

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