一、文件结构
DFIG_Simulation/
│
├── DFIG_Average_Model/
│ ├── DFIG_Average.slx % Simulink 平均值模型
│ ├── DFIG_Average_Controller.m % 控制器参数与初始化
│ └── run_average.m % 运行脚本
│
├── DFIG_Switch_Model/
│ ├── DFIG_Switch.slx % Simulink 详细开关模型
│ ├── DFIG_Switch_Controller.m % 控制器参数与初始化
│ └── run_switch.m % 运行脚本
│
└── compare_results.m % 两种模型结果对比
二、平均值模型(Average Model)——系统级仿真
2.1 模型特点
- 变流器用 受控电压源 / 电流源 表示
- 忽略开关纹波,用平均值方程
- 适合 电网稳定性、功率控制、故障穿越 研究
2.2 核心方程
%% DFIG_Average_Controller.m
% 双馈风机平均值模型参数
clear; clc;% 风机参数
Pn = 2e6; % 额定功率 2 MW
Vn = 690; % 定子额定电压 (V)
fn = 50; % 电网频率 (Hz)
ws = 2*pi*fn; % 电角速度% 电机参数(标幺值基准)
Sn = Pn; % 功率基准
Vbase = Vn; % 电压基准
Ibase = Sn/(sqrt(3)*Vbase);
Zbase = Vbase^2/Sn;Rs = 0.01; % 定子电阻 (pu)
Rr = 0.01; % 转子电阻 (pu)
Ls = 0.15; % 定子电感 (pu)
Lr = 0.15; % 转子电感 (pu)
Lm = 2.9; % 励磁电感 (pu)% 传动链
J = 100; % 转动惯量 (kg·m²)
B = 0.01; % 阻尼系数
Kt = 0.8; % 转矩系数% 控制器参数
Kp_pll = 0.5; Ki_pll = 10;
Kp_id = 0.1; Ki_id = 5;
Kp_iq = 0.1; Ki_iq = 5;
Kp_speed = 0.5; Ki_speed = 10;% 初始条件
theta = 0; % 转子位置
omega_r = 1.0; % 转子电角速度 (pu)
P_ref = 0.8; % 有功参考 (pu)
Q_ref = 0.0; % 无功参考 (pu)
2.3 Simulink 模型结构(DFIG_Average.slx)
子系统划分:
[Wind Turbine]↓
[Drive Train (2-mass)]↓
[DFIG Machine]↓
[Grid Side Converter (Average)]
[Grid Side Controller]
[Rotor Side Converter (Average)]
[Rotor Side Controller]↓
[Grid]
关键模块(用 MATLAB Function 写):
function di_s = stator_current(v_s, flux_r, Rs, Ls, Lm)
% 定子电流平均值模型
psi_s = v_s / ws; % 定子磁链
psi_r = Lm * i_s; % 转子磁链
di_s = (v_s - Rs*i_s - 1j*ws*psi_s) / Ls;
end
2.4 运行脚本(run_average.m)
%% run_average.m
clear; clc;% 加载参数
DFIG_Average_Controller;% 运行 Simulink
sim('DFIG_Average.slx', 'StopTime', '10');% 绘图
figure('Color','w');
subplot(2,2,1); plot(tout, P_grid); ylabel('P (pu)'); grid on;
subplot(2,2,2); plot(tout, Q_grid); ylabel('Q (pu)'); grid on;
subplot(2,2,3); plot(tout, speed_r); ylabel('Speed (pu)'); grid on;
subplot(2,2,4); plot(tout, theta_r); ylabel('Rotor Angle (rad)'); grid on;
三、详细开关模型(Switch Model)——电磁暂态仿真
3.1 模型特点
- 变流器用 IGBT/二极管开关器件
- 包含 PWM 调制、死区、开关损耗
- 适合 电磁暂态、谐波分析、硬件在环
3.2 Simulink 模型结构(DFIG_Switch.slx)
关键模块:
[Grid Side Converter]├─ IGBT Bridge (Universal Bridge)├─ PWM Generator└─ LC Filter[Rotor Side Converter]├─ IGBT Bridge├─ PWM Generator└─ DC Link Capacitor[DFIG Machine]├─ Stator Winding├─ Rotor Winding└─ Motion Sensor
3.3 控制器(DFIG_Switch_Controller.m)
%% DFIG_Switch_Controller.m
% 与平均值模型参数基本一致,但增加 PWM 频率
fpwm = 5000; % PWM 频率 5 kHz
Tdead = 2e-6; % 死区时间 2 us
Vdc = 1200; % 直流母线电压
3.4 运行脚本(run_switch.m)
%% run_switch.m
clear; clc;% 加载参数
DFIG_Switch_Controller;% 设置仿真步长(必须很小)
sim('DFIG_Switch.slx', 'StopTime', '0.5', ...'Solver', 'ode23tb', 'FixedStep', '1e-6');% 分析谐波
figure;
subplot(2,1,1); plot(tout, i_grid); ylabel('Grid Current (A)'); grid on;
subplot(2,1,2); fft_analysis(i_grid, 50, 1/1e-6);
四、对比脚本(compare_results.m)
%% compare_results.m
clear; clc;% 加载两种模型结果
load('average_result.mat');
load('switch_result.mat');figure('Color','w','Position',[100 100 1200 400]);% 有功功率对比
subplot(1,3,1);
plot(t_avg, P_avg, 'b', 'LineWidth', 1.5); hold on;
plot(t_sw, P_sw, 'r--', 'LineWidth', 1.5);
xlabel('Time (s)'); ylabel('Active Power (pu)');
legend('Average Model', 'Switch Model'); grid on;
title('有功功率对比');% 无功功率对比
subplot(1,3,2);
plot(t_avg, Q_avg, 'b', 'LineWidth', 1.5); hold on;
plot(t_sw, Q_sw, 'r--', 'LineWidth', 1.5);
xlabel('Time (s)'); ylabel('Reactive Power (pu)'); grid on;
title('无功功率对比');% 转子电流 THD
subplot(1,3,3);
fft_analysis(i_rotor_sw, 50, 1/1e-6);
title('转子电流谐波分析(开关模型)');
参考代码 双馈风力发电机平均值模型与详细开关模型的matlab仿真文件 www.youwenfan.com/contentcnw/81767.html
五、关键差异总结
| 特性 | 平均值模型 | 详细开关模型 |
|---|---|---|
| 仿真速度 | 快(秒级) | 慢(分钟级) |
| 开关纹波 | 无 | 有 |
| 谐波分析 | 不支持 | 支持 |
| 适用场景 | 系统稳定性、电网故障穿越 | 电磁暂态、硬件在环 |
| 精度 | 稳态精确,暂态近似 | 全频段精确 |
