[ PROMPT_NODE_26598 ]
output_analysis
[ SKILL_DOCUMENTATION ]
# 输出与分析
## 输出类型
FluidSim 在仿真过程中会自动保存多种类型的输出。
### 物理场
**文件格式**:HDF5 (`.h5`)
**位置**:`simulation_dir/state_phys_t*.h5`
**内容**:特定时间的流速、涡度及其他物理空间场
**访问**:
python
sim.output.phys_fields.plot()
sim.output.phys_fields.plot("vorticity")
sim.output.phys_fields.plot("vx")
sim.output.phys_fields.plot("div") # 检查散度
# 手动保存
sim.output.phys_fields.save()
# 获取数据
vorticity = sim.state.state_phys.get_var("rot")
### 空间平均值
**文件格式**:文本文件 (`.txt`)
**位置**:`simulation_dir/spatial_means.txt`
**内容**:随时间变化的体积平均量(能量、拟能等)
**访问**:
python
sim.output.spatial_means.plot()
# 从文件加载
from fluidsim import load_sim_for_plot
sim = load_sim_for_plot("simulation_dir")
sim.output.spatial_means.load()
spatial_means_data = sim.output.spatial_means
### 谱 (Spectra)
**文件格式**:HDF5 (`.h5`)
**位置**:`simulation_dir/spectra_*.h5`
**内容**:能量和拟能谱随波数的变化
**访问**:
python
sim.output.spectra.plot1d() # 1D 谱
sim.output.spectra.plot2d() # 2D 谱
# 加载谱数据
spectra = sim.output.spectra.load2d_mean()
### 谱能量预算
**文件格式**:HDF5 (`.h5`)
**位置**:`simulation_dir/spect_energy_budg_*.h5`
**内容**:尺度间的能量传递
**访问**:
python
sim.output.spect_energy_budg.plot()
## 后处理
### 加载仿真进行分析
#### 快速加载(只读)
python
from fluidsim import load_sim_for_plot
sim = load_sim_for_plot("simulation_dir")
# 访问所有输出类型
sim.output.phys_fields.plot()
sim.output.spatial_means.plot()
sim.output.spectra.plot1d()
用于快速可视化和分析,不会初始化完整的仿真状态。
#### 完整状态加载
python
from fluidsim import load_state_phys_file
sim = load_state_phys_file("simulation_dir/state_phys_t10.000.h5")
# 可以继续仿真
sim.time_stepping.start()
### 可视化工具
#### 内置绘图
FluidSim 通过 matplotlib 提供基础绘图功能:
python
# 物理场
sim.output.phys_fields.plot("vorticity")
sim.output.phys_fields.animate("vorticity")
# 时间序列
sim.output.spatial_means.plot()
# 谱
sim.output.spectra.plot1d()
#### 高级可视化
用于出版