-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFAST_Driver.m
103 lines (83 loc) · 2.68 KB
/
FAST_Driver.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
%% Simulate Non-Linear OpenFAST
clear all; close all; clc;
tests = {'WindWave_AboveRated_FOCAL_C4'};
FASTdir = 'C:\Umaine Google Sync\GitHub\FOWT_Optimal_Control';
model = 'FOCAL_Base';
for i = 1:length(tests)
% Run OpenFAST
runFAST(model,tests{i},FASTdir,'CheckSimFolder',false,'Version','FC4');
end
%% Perform OpenFAST Linearization
clear all; close all; clc;
tests = {'000_Linearize'};
FASTdir = 'C:\Umaine Google Sync\GitHub\FOWT_Optimal_Control';
% Linearization inputs
model = 'FOCAL_C4';
num_lin_times = 36; % Number of linearizations for rotor averaging
inflow_file_name = 'FOCAL_C4_InflowFile.dat';
inflow_line = 14; % line of inflow file for HWindSpeed
% wind_type_line = 5; % line of inflow file for WindType
wind_speed = 24; % constant wind speed for linearization
% wind_type = 0;
% Form inflow file directory
inflow_dir = sprintf('%s\\Models\\%s\\%s',FASTdir,model,inflow_file_name);
for i = 1:length(tests)
setInflow(inflow_dir,inflow_line,wind_speed);
runFAST(model,tests{i},FASTdir,'MoveFiles',false,'CheckSimFolder',false,'Version','v3_5_1');
end
%
cd(sprintf('%s\\Models\\%s\\Linear_Files',FASTdir,model));
processMBC3(num_lin_times,model)
cd('..')
load('OpenFAST_Results.mat')
%
figure
plot(sim_results.Time,sim_results.GenSpeed)
title('GenSpeed')
figure
plot(sim_results.Time,sim_results.PtfmPitch)
title('PtfmPitch')
figure
plot(sim_results.Time,sim_results.GenTq)
title('GenTorque')
figure
plot(sim_results.Time,sim_results.BlPitchC1)
title('Collective Pitch')
% hydro_system = ReadFASTLinear('FOCAL_C4.1.HD.lin');
%
% A = hydro_system.A;
% B = hydro_system.B;
% C = hydro_system.C;
% D = hydro_system.D;
%
% Hydro_OP = hydro_system.x_op;
%
% save('FOCAL_C4_HD_A.mat','A');
% save('FOCAL_C4_HD_B.mat','B');
% save('FOCAL_C4_HD_C.mat','C');
% save('FOCAL_C4_HD_D.mat','D');
% save('FOCAL_C4_Hydro_OP.mat','Hydro_OP');
%% Run State-Space Model
clear all; close all; clc;
% tests = {'FD_Surge','FD_Heave','FD_Pitch'}
tests = {'Test_04'};
% FD_IC = readmatrix('FD_IC.csv');
% FD_IC = FD_IC(:,2);
SLXdir = 'C:\Umaine Google Sync\GitHub\FOWT_Optimal_Control';
model = 'DT1_Locked';
for i = 1:length(tests)
IC_x = zeros(20,1);
% IC_x(i) = FD_IC(i);
simout = runSLX(model,tests{i},SLXdir,'SeparateOutput',true,'InitialConditions',IC_x);
end
%% Run State-Space w/ Kalman Filter
clear all; close all; clc;
tests = {'Test_01'};
measurements = {'PtfmPitch','PtfmRoll','FAIRTEN1','FAIRTEN2','FAIRTEN3'};
SLXdir = 'C:\Umaine Google Sync\GitHub\FOWT_Optimal_Control';
model = 'DT1_Locked';
for i = 1:length(tests)
IC_x = zeros(20,1);
runSLX(model,tests{i},SLXdir,'Observer',true,'MeasurementFields',measurements,...
'SeparateOutput',true,'InitialConditions',IC_x);
end