14 等值线 contour / contourf

用途

二维标量场的等值与填充等值线,如温度场、地表电位、电机效率 MAP。

示例(5 张)

14-1 电机效率 MAP 等值线

电机效率 MAP 等值线

14-2 开关柜内部温度场分布

开关柜内部温度场分布

14-3 接地网地表电位分布

接地网地表电位分布

14-4 电缆终端电场强度分布

电缆终端电场强度分布

14-5 变压器铁心损耗分布等值线

变压器铁心损耗分布等值线

代码

以下 5 个函数取自 code/第三批_面积与场261106.py,直接调用即可出图。版式(宋体 + Times、10 磅、刻度朝内四边、图内无标题、留白自检)由 code/公共配置261106.py 的 setup_cn_style() 与 save() 统一提供。

# 摘自 code/第三批_面积与场261106.py

def cont_01():
    """电机效率 MAP 等值线。"""
    fig, ax = new_fig(left=0.17, bottom=0.19, right=0.86)
    n = np.linspace(600, 3000, 160)
    tq = np.linspace(0, 120, 160)
    N, T = np.meshgrid(n, tq)
    eta = 94.5 - 8.0 * ((T - 62) / 90) ** 2 - 3.4 * ((N - 2100) / 1500) ** 2 \
        - 2.0 * ((T - 40) / 80) * ((N - 1800) / 1400)
    cs = ax.contourf(N, T, eta, levels=np.linspace(78, 95, 18), cmap=CMAP_SEQ)
    cl = ax.contour(N, T, eta, levels=[82, 86, 89, 91, 93], colors="0.15",
                    linewidths=0.5)
    ax.clabel(cl, fmt="%.0f", fontsize=FS - 3, inline=True)
    ax.set_xlabel("转速 " + IT["n"] + " / (r/min)")
    ax.set_ylabel("转矩 " + IT["T"] + " / (N·m)")
    _cbar(fig, ax, cs, "效率 " + IT["eta"] + " / %")
    save(fig, "14_等值线", "14_等值线_电机效率MAP")

def cont_02():
    """开关柜内部温度场分布。"""
    fig, ax = new_fig(left=0.17, bottom=0.19, right=0.86)
    x = np.linspace(0, 0.6, 180)
    y = np.linspace(0, 0.9, 200)
    X, Y = np.meshgrid(x, y)
    Z = 28 + 34 * np.exp(-(((X - 0.32) / 0.16) ** 2 + ((Y - 0.46) / 0.14) ** 2)) \
        + 14 * np.exp(-(((X - 0.14) / 0.10) ** 2 + ((Y - 0.74) / 0.10) ** 2)) \
        + 8 * (Y / 0.9)
    cs = ax.contourf(X, Y, Z, levels=22, cmap=CMAP_SEQ)
    cl = ax.contour(X, Y, Z, levels=[40, 50, 60, 70], colors="0.15", linewidths=0.5)
    ax.clabel(cl, fmt="%.0f", fontsize=FS - 3, inline=True)
    ax.set_xlabel("柜宽 " + IT["x"] + " / m")
    ax.set_ylabel("柜高 " + IT["y"] + " / m")
    _cbar(fig, ax, cs, "温度 " + IT["T"] + " / °C")
    save(fig, "14_等值线", "14_等值线_开关柜温度场")

def cont_03():
    """接地网地表电位分布。"""
    fig, ax = new_fig(left=0.17, bottom=0.19, right=0.86)
    x = np.linspace(-30, 30, 200)
    y = np.linspace(-30, 30, 200)
    X, Y = np.meshgrid(x, y)
    V = 0.0
    for gx, gy, I in [(-8, -6, 1.0), (8, -6, 0.85), (0, 8, 0.92)]:
        r2 = (X - gx) ** 2 + (Y - gy) ** 2
        V += I / np.sqrt(r2 + 1.2) * 62
    cs = ax.contourf(X, Y, V, levels=20, cmap=CMAP_SEQ)
    cl = ax.contour(X, Y, V, levels=[60, 120, 200, 300], colors="0.15",
                    linewidths=0.5)
    ax.clabel(cl, fmt="%.0f", fontsize=FS - 3, inline=True)
    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, "14_等值线", "14_等值线_接地网地表电位")

def cont_04():
    """电缆终端电场强度分布。"""
    fig, ax = new_fig(left=0.17, bottom=0.19, right=0.86)
    x = np.linspace(-40, 40, 200)
    y = np.linspace(0, 120, 200)
    X, Y = np.meshgrid(x, y)
    E = 42 * np.exp(-(np.abs(X) / 14) ** 1.3) * (1 - 0.004 * Y) \
        + 12 * np.exp(-((np.abs(X) - 22) / 7) ** 2) * np.exp(-Y / 60)
    cs = ax.contourf(X, Y, E, levels=20, cmap=CMAP_SEQ)
    cl = ax.contour(X, Y, E, levels=[10, 20, 30, 40], colors="0.15",
                    linewidths=0.5)
    ax.clabel(cl, fmt="%.0f", fontsize=FS - 3, inline=True)
    ax.set_xlabel("轴向位置 " + IT["x"] + " / mm")
    ax.set_ylabel("径向位置 " + IT["y"] + " / mm")
    _cbar(fig, ax, cs, "电场强度 " + IT["E"] + " / (kV/mm)")
    save(fig, "14_等值线", "14_等值线_电缆终端电场")

def cont_05():
    """变压器铁心损耗分布等值线。"""
    fig, ax = new_fig(left=0.17, bottom=0.19, right=0.86)
    x = np.linspace(0, 200, 180)
    y = np.linspace(0, 160, 180)
    X, Y = np.meshgrid(x, y)
    P = 2.1 + 1.4 * np.sin(X / 42 + 0.6) * np.cos(Y / 38) \
        + 0.8 * np.exp(-(((X - 100) / 70) ** 2 + ((Y - 80) / 56) ** 2))
    cs = ax.contourf(X, Y, P, levels=18, cmap=CMAP_SEQ)
    cl = ax.contour(X, Y, P, levels=[1.5, 2.0, 2.5, 3.0], colors="0.15",
                    linewidths=0.5)
    ax.clabel(cl, fmt="%.1f", fontsize=FS - 3, inline=True)
    ax.set_xlabel("铁心长度 " + IT["x"] + " / mm")
    ax.set_ylabel("铁心高度 " + IT["y"] + " / mm")
    ax.set_aspect("equal")
    _cbar(fig, ax, cs, "单位损耗 / (W/kg)")
    save(fig, "14_等值线", "14_等值线_铁心损耗分布")

说明

  • 图片 1181×944 px(100 mm × 80 mm @ 300 dpi),三维图为 1181×1122 px。
  • 图内不放标题,图题由本文件的标题承担。
  • 数据为 10 kV 配网、380 V 低压、50 Hz 量级的仿真算例,随机种子固定,重跑结果一致。
posted on 2026-11-07 01:03  小青蛙电气  阅读(3)  评论(0)    收藏  举报