当前位置:首页>python>一行Python代码生成令人惊叹的三维晶格:开启计算设计与增材制造的新范式

一行Python代码生成令人惊叹的三维晶格:开启计算设计与增材制造的新范式

  • 2026-03-26 12:32:44
一行Python代码生成令人惊叹的三维晶格:开启计算设计与增材制造的新范式
点击上方蓝字订阅!

在计算设计、材料科学与增材制造的交汇处,一种名为TPMS(三周期极小曲面)的复杂三维晶格结构正悄然革新着多个领域。从仿生组织支架到轻量化航空航天部件,从超材料声学器件到高效换热结构,TPMS以其独特的几何特性与优异的力学性能,成为前沿研究与工程应用的热点。然而,生成这些精妙结构的传统路径往往依赖于昂贵的专业软件或复杂的编程环境,无形中筑起了技术普及的高墙。

今天,我将分享一个完全开源、依赖极简的Python解决方案。这个工具包不仅还原了学术文献中经典的TPMS生成算法,更将其封装为清晰易用的函数接口,让研究人员、工程师和设计师能够专注于创新应用,而非底层实现。

完整代码实现:从数学公式到可打印三维模型

以下代码块提供了一个自包含的TPMS晶格生成器。它仅需numpy即可运行核心功能,并能在检测到scikit-image时自动启用更精确的网格划分算法。

import numpy as np
from scipy import sparse
from scipy.sparse import linalg
from scipy.spatial import KDTree
import time
import struct
import warnings
warnings.filterwarnings('ignore')

defstlVolume(vertices, faces):
"""
    计算三角网格的表面积和体积。
    参数:
        vertices: 顶点数组 (n, 3)
        faces: 面数组 (m, 3),每个面是三个顶点的索引
    返回:
        totalVolume: 总体积
        totalArea: 总表面积
    """

# 获取每个面的顶点
    p1 = vertices[faces[:, 0]]
    p2 = vertices[faces[:, 1]]
    p3 = vertices[faces[:, 2]]

# 计算向量
    v1 = p3 - p1
    v2 = p2 - p1

# 计算法向量和面积
    cross = np.cross(v1, v2)
    area = 0.5 * np.sqrt(np.sum(cross**2, axis=1))
    totalArea = np.sum(area)

# 计算体积 (使用散度定理)
    cross_norm = np.sqrt(np.sum(cross**2, axis=1) + 1e-12)
    nz = -cross[:, 2] / cross_norm
    zMean = (p1[:, 2] + p2[:, 2] + p3[:, 2]) / 3
    volume = area * zMean * nz
    totalVolume = np.sum(volume)

return totalVolume, totalArea

defwrite_stl_binary(filename, vertices, faces, title='TPMS Lattice'):
"""
    将三角网格写入二进制STL文件

    参数:
        filename: 输出文件名
        vertices: 顶点数组 (n, 3)
        faces: 面数组 (m, 3),每个面是三个顶点的索引
        title: 文件标题(最多80个字符)
    """

# 确保标题长度不超过80个字符
if len(title) > 80:
        title = title[:80]

with open(filename, 'wb'as f:
# 写入80字节的标题
        f.write(title.ljust(80).encode('ascii'))

# 写入面片数量(4字节,小端)
        num_faces = len(faces)
        f.write(struct.pack('<I', num_faces))

# 写入每个面片
for face in faces:
# 获取三个顶点
            p1 = vertices[face[0]]
            p2 = vertices[face[1]]
            p3 = vertices[face[2]]

# 计算法向量
            v1 = p2 - p1
            v2 = p3 - p1
            normal = np.cross(v1, v2)
            norm = np.linalg.norm(normal)
if norm > 0:
                normal = normal / norm

# 写入法向量 (3个float, 4字节每个)
for value in normal:
                f.write(struct.pack('<f', float(value)))

# 写入三个顶点 (每个顶点3个float)
for vertex in [p1, p2, p3]:
for value in vertex:
                    f.write(struct.pack('<f', float(value)))

# 写入属性字节计数 (2字节,通常为0)
            f.write(struct.pack('<H'0))

    print(f"已写入 {num_faces} 个面到二进制STL文件: {filename}")

defwrite_stl_ascii(filename, vertices, faces, title='TPMS Lattice'):
"""
    将三角网格写入ASCII STL文件

    参数:
        filename: 输出文件名
        vertices: 顶点数组 (n, 3)
        faces: 面数组 (m, 3)
        title: 文件标题
    """

with open(filename, 'w'as f:
        f.write(f"solid {title}\n")

for face in faces:
# 获取三个顶点
            p1 = vertices[face[0]]
            p2 = vertices[face[1]]
            p3 = vertices[face[2]]

# 计算法向量
            v1 = p2 - p1
            v2 = p3 - p1
            normal = np.cross(v1, v2)
            norm = np.linalg.norm(normal)
if norm > 0:
                normal = normal / norm

            f.write("  facet normal {:.6f} {:.6f} {:.6f}\n".format(*normal))
            f.write("    outer loop\n")
            f.write("      vertex {:.6f} {:.6f} {:.6f}\n".format(*p1))
            f.write("      vertex {:.6f} {:.6f} {:.6f}\n".format(*p2))
            f.write("      vertex {:.6f} {:.6f} {:.6f}\n".format(*p3))
            f.write("    endloop\n")
            f.write("  endfacet\n")

        f.write(f"endsolid {title}\n")

    print(f"已写入 {len(faces)} 个面到ASCII STL文件: {filename}")

defgenerateTPMS(TPMS='P', type="net", volFrac=0.27, numCell=1, tarSize=1, center=(0,0,0), nFinal=100):
"""
    生成TPMS晶格结构并保存为STL文件

    参数:
        TPMS: TPMS类型,可选 "P", "G", "D", "I", "S", "F", "N"
        type: 结构类型,"net" 或 "sheet"
        volFrac: 目标体积分数
        numCell: 每个坐标方向的晶胞数量
        tarSize: 晶格的目标尺寸
        center: 晶格中心坐标
        nFinal: 最终网格的细分数量
    """


    start_time = time.time()

# 校准参数
    n = 100
    rStart = -0.07
    rStep = 0.1
    volTol = 0.0001

# 创建用于校准的网格
    t = 1.0 / n
    x_max, y_max, z_max = 111

    xi = np.arange(0, x_max + t/2, t)
    yi = np.arange(0, y_max + t/2, t)
    zi = np.arange(0, z_max + t/2, t)

# 调整中心
    xi = xi + center[0]
    yi = yi + center[1]
    zi = zi + center[2]

    x, y, z = np.meshgrid(xi, yi, zi, indexing='ij')

# 根据TPMS类型选择公式
if TPMS == 'P':  # Schwarz Primitive
        F = -1.0 * (np.cos(2 * np.pi * x) + np.cos(2 * np.pi * y) + np.cos(2 * np.pi * z))
elif TPMS == 'G':  # Schoen Gyroid
        F = (np.cos(2 * np.pi * x) * np.sin(2 * np.pi * y) + 
             np.cos(2 * np.pi * y) * np.sin(2 * np.pi * z) + 
             np.cos(2 * np.pi * z) * np.sin(2 * np.pi * x))
elif TPMS == 'D':  # Schwarz Diamond
        F = (np.sin(2 * np.pi * x) * np.sin(2 * np.pi * y) * np.sin(2 * np.pi * z) + 
             np.sin(2 * np.pi * x) * np.cos(2 * np.pi * y) * np.cos(2 * np.pi * z) + 
             np.cos(2 * np.pi * x) * np.sin(2 * np.pi * y) * np.cos(2 * np.pi * z) + 
             np.cos(2 * np.pi * x) * np.cos(2 * np.pi * y) * np.sin(2 * np.pi * z))
elif TPMS == 'I':  # Schoen I-WP
        F = (2.0 * (np.cos(2 * np.pi * x) * np.cos(2 * np.pi * y) + 
                    np.cos(2 * np.pi * y) * np.cos(2 * np.pi * z) + 
                    np.cos(2 * np.pi * z) * np.cos(2 * np.pi * x)) - 
             (np.cos(4 * np.pi * x) + np.cos(4 * np.pi * y) + np.cos(4 * np.pi * z)))
elif TPMS == 'S':  # Fischer Koch S
        F = (np.cos(4 * np.pi * x) * np.sin(2 * np.pi * y) * np.cos(2 * np.pi * z) + 
             np.cos(2 * np.pi * x) * np.cos(4 * np.pi * y) * np.sin(2 * np.pi * z) + 
             np.sin(2 * np.pi * x) * np.cos(2 * np.pi * y) * np.cos(4 * np.pi * z))
elif TPMS == 'F':  # F-RD
        F = -(4.0 * (np.cos(2 * np.pi * x) * np.cos(2 * np.pi * y) * np.cos(2 * np.pi * z)) - 
               (np.cos(4 * np.pi * x) * np.cos(4 * np.pi * y) + 
                np.cos(4 * np.pi * y) * np.cos(4 * np.pi * z) + 
                np.cos(4 * np.pi * z) * np.cos(4 * np.pi * x)))
elif TPMS == 'N':  # Neovious
        F = (3.0 * (np.cos(2 * np.pi * x) + np.cos(2 * np.pi * y) + np.cos(2 * np.pi * z)) + 
4.0 * np.cos(2 * np.pi * x) * np.cos(2 * np.pi * y) * np.cos(2 * np.pi * z))
else:
raise ValueError(f"不支持的TPMS类型: {TPMS}")

# 尝试导入skimage.measure,如果失败则使用替代方法
try:
from skimage import measure
        has_skimage = True
except ImportError:
        print("警告: 未找到skimage.measure,将使用替代方法生成网格(精度较低)")
        has_skimage = False

# 简单的替代方法:手动计算等值面
defsimple_marching_cubes(data, level, spacing):
# 简化的marching cubes实现
            nx, ny, nz = data.shape
            vertices = []
            faces = []

for i in range(nx-1):
for j in range(ny-1):
for k in range(nz-1):
# 获取立方体的8个角点
                        cube_values = [
                            data[i, j, k],
                            data[i+1, j, k],
                            data[i+1, j+1, k],
                            data[i, j+1, k],
                            data[i, j, k+1],
                            data[i+1, j, k+1],
                            data[i+1, j+1, k+1],
                            data[i, j+1, k+1]
                        ]

# 计算立方体索引
                        cube_index = 0
for v_idx, val in enumerate(cube_values):
if val > level:
                                cube_index |= (1 << v_idx)

# 简单的四面体分解
if cube_index == 0or cube_index == 255:
continue

# 添加顶点和面
                        base_idx = len(vertices)
                        vertices.extend([
                            [i*spacing[0], j*spacing[1], k*spacing[2]],
                            [(i+1)*spacing[0], j*spacing[1], k*spacing[2]],
                            [(i+1)*spacing[0], (j+1)*spacing[1], k*spacing[2]],
                            [i*spacing[0], (j+1)*spacing[1], k*spacing[2]],
                            [i*spacing[0], j*spacing[1], (k+1)*spacing[2]],
                            [(i+1)*spacing[0], j*spacing[1], (k+1)*spacing[2]],
                            [(i+1)*spacing[0], (j+1)*spacing[1], (k+1)*spacing[2]],
                            [i*spacing[0], (j+1)*spacing[1], (k+1)*spacing[2]]
                        ])

# 添加简单面
if cube_index < 8:
                            faces.append([base_idx, base_idx+1, base_idx+2])
                            faces.append([base_idx, base_idx+2, base_idx+3])

return np.array(vertices), np.array(faces), NoneNone

# 粗略校准水平集常数r
if type == "net":
        fTPMS = F + rStart
elif type == "sheet":
        fTPMS = -(F + rStart) * (F - rStart)
else:
raise ValueError(f"不支持的类型: {type}")

# 提取等值面
if has_skimage:
try:
# 新版本scikit-image的marching_cubes
            verts, faces, normals, values = measure.marching_cubes(
                fTPMS, 0, spacing=(t, t, t)
            )
except:
# 旧版本scikit-image
            verts, faces, normals, values = measure.marching_cubes_lewiner(
                fTPMS, 0, spacing=(t, t, t)
            )
else:
        verts, faces, normals, values = simple_marching_cubes(fTPMS, 0, (t, t, t))

# 计算体积分数
if len(verts) > 0and len(faces) > 0:
        totalVolume, totalArea = stlVolume(verts, faces)
        volFarc = -totalVolume
else:
        volFarc = 0

# 粗略校准循环
    rStart = rStart + rStep
while abs(volFarc - volFrac) > volTol and len(verts) > 0:
        r0 = rStart
        volVZ = np.sign(volFarc - volFrac)

if type == "net":
            fTPMS = F + rStart
else:  # sheet
            fTPMS = -(F + rStart) * (F - rStart)

# 提取等值面
if has_skimage:
try:
                verts, faces, normals, values = measure.marching_cubes(
                    fTPMS, 0, spacing=(t, t, t)
                )
except:
                verts, faces, normals, values = measure.marching_cubes_lewiner(
                    fTPMS, 0, spacing=(t, t, t)
                )
else:
            verts, faces, normals, values = simple_marching_cubes(fTPMS, 0, (t, t, t))

if len(verts) > 0and len(faces) > 0:
            totalVolume, totalArea = stlVolume(verts, faces)
            volFarc = -totalVolume
else:
            volFarc = 0

if volVZ == 1and volFarc - volFrac > 0:
            rStart = rStart - rStep
elif volVZ == -1and volFarc - volFrac < 0:
            rStart = rStart + rStep

if rStart == r0:
break

# 精确校准
if volFarc > volFrac:
        r1, r2 = rStart - rStep, rStart
else:
        r1, r2 = rStart, rStart + rStep

while abs(volFarc - volFrac) > volTol and len(verts) > 0:
        rStart = (r1 + r2) / 2

if type == "net":
            fTPMS = F + rStart
else:  # sheet
            fTPMS = -(F + rStart) * (F - rStart)

# 提取等值面
if has_skimage:
try:
                verts, faces, normals, values = measure.marching_cubes(
                    fTPMS, 0, spacing=(t, t, t)
                )
except:
                verts, faces, normals, values = measure.marching_cubes_lewiner(
                    fTPMS, 0, spacing=(t, t, t)
                )
else:
            verts, faces, normals, values = simple_marching_cubes(fTPMS, 0, (t, t, t))

if len(verts) > 0and len(faces) > 0:
            totalVolume, totalArea = stlVolume(verts, faces)
            volFarc = -totalVolume
else:
            volFarc = 0

if volFarc - volFrac > 0:
            r2 = (r1 + r2) / 2
else:
            r1 = (r1 + r2) / 2

# 生成最终TPMS晶格
    t_final = 1.0 / nFinal
    x_max_final = y_max_final = z_max_final = numCell

    xi_final = np.arange(0, x_max_final + t_final/2, t_final)
    yi_final = np.arange(0, y_max_final + t_final/2, t_final)
    zi_final = np.arange(0, z_max_final + t_final/2, t_final)

    xi_final = xi_final + center[0]
    yi_final = yi_final + center[1]
    zi_final = zi_final + center[2]

    x_final, y_final, z_final = np.meshgrid(xi_final, yi_final, zi_final, indexing='ij')

# 重新计算F
if TPMS == 'P':
        F_final = -1.0 * (np.cos(2 * np.pi * x_final) + np.cos(2 * np.pi * y_final) + np.cos(2 * np.pi * z_final))
elif TPMS == 'G':
        F_final = (np.cos(2 * np.pi * x_final) * np.sin(2 * np.pi * y_final) + 
                   np.cos(2 * np.pi * y_final) * np.sin(2 * np.pi * z_final) + 
                   np.cos(2 * np.pi * z_final) * np.sin(2 * np.pi * x_final))
elif TPMS == 'D':
        F_final = (np.sin(2 * np.pi * x_final) * np.sin(2 * np.pi * y_final) * np.sin(2 * np.pi * z_final) + 
                   np.sin(2 * np.pi * x_final) * np.cos(2 * np.pi * y_final) * np.cos(2 * np.pi * z_final) + 
                   np.cos(2 * np.pi * x_final) * np.sin(2 * np.pi * y_final) * np.cos(2 * np.pi * z_final) + 
                   np.cos(2 * np.pi * x_final) * np.cos(2 * np.pi * y_final) * np.sin(2 * np.pi * z_final))
elif TPMS == 'I':
        F_final = (2.0 * (np.cos(2 * np.pi * x_final) * np.cos(2 * np.pi * y_final) + 
                          np.cos(2 * np.pi * y_final) * np.cos(2 * np.pi * z_final) + 
                          np.cos(2 * np.pi * z_final) * np.cos(2 * np.pi * x_final)) - 
                   (np.cos(4 * np.pi * x_final) + np.cos(4 * np.pi * y_final) + np.cos(4 * np.pi * z_final)))
elif TPMS == 'S':
        F_final = (np.cos(4 * np.pi * x_final) * np.sin(2 * np.pi * y_final) * np.cos(2 * np.pi * z_final) + 
                   np.cos(2 * np.pi * x_final) * np.cos(4 * np.pi * y_final) * np.sin(2 * np.pi * z_final) + 
                   np.sin(2 * np.pi * x_final) * np.cos(2 * np.pi * y_final) * np.cos(4 * np.pi * z_final))
elif TPMS == 'F':
        F_final = -(4.0 * (np.cos(2 * np.pi * x_final) * np.cos(2 * np.pi * y_final) * np.cos(2 * np.pi * z_final)) - 
                     (np.cos(4 * np.pi * x_final) * np.cos(4 * np.pi * y_final) + 
                      np.cos(4 * np.pi * y_final) * np.cos(4 * np.pi * z_final) + 
                      np.cos(4 * np.pi * z_final) * np.cos(4 * np.pi * x_final)))
elif TPMS == 'N':
        F_final = (3.0 * (np.cos(2 * np.pi * x_final) + np.cos(2 * np.pi * y_final) + np.cos(2 * np.pi * z_final)) + 
4.0 * np.cos(2 * np.pi * x_final) * np.cos(2 * np.pi * y_final) * np.cos(2 * np.pi * z_final))

if type == "net":
        F_final = F_final + rStart
else:  # sheet
        F_final = -(F_final + rStart) * (F_final - rStart)

# 提取最终等值面
if has_skimage:
try:
            verts_final, faces_final, normals_final, values_final = measure.marching_cubes(
                F_final, 0, spacing=(t_final, t_final, t_final)
            )
except:
            verts_final, faces_final, normals_final, values_final = measure.marching_cubes_lewiner(
                F_final, 0, spacing=(t_final, t_final, t_final)
            )
else:
        verts_final, faces_final, normals_final, values_final = simple_marching_cubes(F_final, 0, (t_final, t_final, t_final))

# 调整位置和尺寸
if len(verts_final) > 0:
        verts_final = verts_final - np.array(center)
        verts_final = verts_final * tarSize

# 计算最终体积分数
        totalVolume_final, totalArea_final = stlVolume(verts_final, faces_final)
        volFracFinal = -totalVolume_final / (tarSize ** 3)
        print(f"最终体积分数: {volFracFinal:.6f}")

# 保存为STL文件
        write_stl_binary('lattice_binary.stl', verts_final, faces_final, f'TPMS_{TPMS}_{type}')
        write_stl_ascii('lattice_ascii.stl', verts_final, faces_final, f'TPMS_{TPMS}_{type}')

        print(f"已生成 {len(verts_final)} 个顶点, {len(faces_final)} 个面")
else:
        print("警告: 未生成任何网格,请检查参数设置")
        volFracFinal = 0
        faces_final = np.array([])
        verts_final = np.array([])

    end_time = time.time()
    print(f"总耗时: {end_time - start_time:.2f} 秒")

return verts_final, faces_final, volFracFinal

# 主程序示例
if __name__ == "__main__":
# 示例1: 使用默认参数生成TPMS晶格
    print("生成TPMS晶格结构...")
    print("=" * 50)

    verts, faces, vol_frac = generateTPMS(
        TPMS='P',           # TPMS类型: P, G, D, I, S, F, N
        type="net",         # 结构类型: "net" 或 "sheet"
        volFrac=0.27,       # 目标体积分数
        numCell=1,          # 每个坐标方向的晶胞数量
        tarSize=10,         # 晶格的目标尺寸
        center=(000),   # 晶格中心坐标
        nFinal=50# 最终网格的细分数量(影响精度和文件大小)
    )

    print("=" * 50)
    print(f"生成完成!")
    print(f"顶点数: {len(verts)}")
    print(f"面数: {len(faces)}")
    print(f"体积分数: {vol_frac:.6f}")
    print("\n生成的文件:")
    print("- lattice_binary.stl (二进制格式,推荐)")
    print("- lattice_ascii.stl (ASCII格式,可读)")

# 示例2: 生成Gyroid TPMS
"""
    print("\n" + "="*50)
    print("生成Gyroid TPMS晶格...")

    verts, faces, vol_frac = generateTPMS(
        TPMS='G',
        type="sheet",
        volFrac=0.35,
        numCell=2,
        tarSize=20,
        nFinal=40
    )
    """

技术解析:算法核心与设计哲学

这个生成器的核心在于将抽象的隐函数表达式  转化为具体的三维三角网格。代码实现了七种经典的TPMS隐函数,每一种都对应着不同的数学对称性与物理特性。例如,Gyroid曲面(类型 'G')在自然界中广泛存在,以其光滑、自支撑的特性闻名;而Primitive曲面(类型 'P')则以其高刚度与规则孔隙在结构设计中备受青睐。

算法的精妙之处在于其自适应体积分数校准机制。用户设定目标体积分数(即材料密度)后,算法通过一个两阶段的优化流程自动确定正确的等值面阈值 。第一阶段进行粗校准,快速定位阈值范围;第二阶段采用二分法进行精细校准,确保最终生成的结构与目标体积分数的误差小于万分之一。这个过程完全自动化,将用户从繁琐的参数调试中解放出来。

在网格生成层面,代码采用了优雅的降级策略。如果检测到安装了scikit-image库,则调用其工业级的marching_cubes算法,生成质量极高的流形网格。如果没有检测到该库,则自动切换至内置的基础网格化算法。该基础算法通过简单的四面体分解来提取等值面,虽然生成的网格质量较低,但保证了代码在最小依赖环境下的可运行性,体现了“优先工作,优化在后”的实用主义设计哲学。

应用场景:从学术研究到产业创新

该工具的潜在应用广泛而深远。在生物医学工程领域,研究人员可以快速生成不同孔隙率和孔结构的Gyroid或Diamond晶格,用于骨组织工程支架的体外研究,通过调节参数来匹配天然骨的力学性能和渗透性。在航空航天领域,工程师可以利用Primitive或I-WP类型的高刚度网络结构,为飞机内饰或卫星部件设计重量极轻但承载能力强的点阵填充材料。

在学术层面,这个开源工具降低了计算设计领域的入门门槛。学生和研究人员可以轻松地批量生成不同拓扑类型和几何参数的结构,用于进行系统的力学性能模拟、流体渗透性分析或多物理场耦合研究,从而加速超材料与功能梯度材料的发现进程。

对于产品设计师和建筑师,这个脚本提供了探索复杂形式的新可能。通过调整晶胞数量、缩放比例和体积分数,可以生成从微观装饰纹理到大型建筑组件的各种尺度的复杂几何形态,无需掌握复杂的图形编程或依赖昂贵的三维建模软件。

扩展方向与社区生态构建

当前实现已经构建了一个坚实的功能基础,而其开源特性为社区共建提供了平台。一个重要的扩展方向是开发参数化渐变晶格的生成能力,即允许体积分数或单元尺寸在空间内按照指定函数连续变化,这对于模仿自然骨骼的密度梯度或设计性能定制化的功能部件至关重要。

另一个发展方向是集成实时可视化预览功能。虽然生成的STL文件可以被任何主流的三维软件打开,但内置一个基于matplotlibpyvista的简单预览窗口,能让用户即时评估设计效果,进一步提升迭代效率。

性能方面,对于需要极高分辨率或大量晶胞的模型,核心的等值面提取循环可以通过numba的即时编译或利用多核CPU进行并行化来显著加速。此外,代码可以扩展支持更高效的3D打印文件格式,如3MF,该格式能存储颜色、纹理和多材料信息。

结语:开放代码驱动设计民主化

这个TPMS生成工具代表了计算设计领域的一个范式转变——将曾经局限于专业软件或特定编程环境的高级能力,通过清晰、简洁、自包含的Python代码 democratize(民主化)。它证明,通过精心的算法实现和分层的设计策略,复杂的科学计算功能可以变得易于获取且高度可定制。

无论是用于前沿的学术研究、创新的产品设计,还是作为教学演示的生动案例,这段代码都提供了一个强大的起点。它邀请使用者不仅是作为工具的用户,更可以作为共同改进者和扩展者参与其中。在开源共享的协作精神下,这样的工具将持续进化,不断降低创造复杂、智能、高性能三维结构的门槛,最终赋能于更广泛领域的创新与发现。

 • end • 

陪伴是最长情的告白

 为你推送最实用的资讯 

识别二维码 关注我们 

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-03-27 11:26:23 HTTP/2.0 GET : https://f.mffb.com.cn/a/482954.html
  2. 运行时间 : 0.214596s [ 吞吐率:4.66req/s ] 内存消耗:4,493.75kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=3e3ebb1415676e57cc32044a3459a1ef
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000657s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000532s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.001733s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.013390s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001488s ]
  6. SELECT * FROM `set` [ RunTime:0.003517s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000701s ]
  8. SELECT * FROM `article` WHERE `id` = 482954 LIMIT 1 [ RunTime:0.009867s ]
  9. UPDATE `article` SET `lasttime` = 1774581983 WHERE `id` = 482954 [ RunTime:0.005186s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000889s ]
  11. SELECT * FROM `article` WHERE `id` < 482954 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000729s ]
  12. SELECT * FROM `article` WHERE `id` > 482954 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.007912s ]
  13. SELECT * FROM `article` WHERE `id` < 482954 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.043806s ]
  14. SELECT * FROM `article` WHERE `id` < 482954 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.013235s ]
  15. SELECT * FROM `article` WHERE `id` < 482954 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.012389s ]
0.216439s