Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
174 commits
Select commit Hold shift + click to select a range
e3cb7c2
Update main_FEM.m
GerardFortuny Mar 20, 2024
2f9ba41
Comentaris
GerardFortuny Apr 2, 2024
916e4f2
Morecomments
GerardFortuny Apr 3, 2024
9b7e343
Morecomments2
GerardFortuny Apr 3, 2024
3d671ce
Create STOKES_GERARD.m
tarrut Apr 4, 2024
07a00e3
change mesh definition
tarrut Apr 5, 2024
7c5ce73
add gid file
tarrut Apr 5, 2024
1bbac88
fix errors in mesh generation
tarrut Apr 5, 2024
5fff4eb
Update STOKES_GERARD.m
tarrut Apr 5, 2024
a8b5fd5
Morecoments
GerardFortuny Apr 7, 2024
34189de
Reordenat
GerardFortuny Apr 7, 2024
d85af7c
change circle definition
tarrut Apr 7, 2024
50bee5c
Tests
GerardFortuny Apr 7, 2024
1bd28ae
Merge branch 'TFG_GerardF' of https://github.com/SwanLab/Swan into TF…
GerardFortuny Apr 7, 2024
564f227
Proves amb bc
GerardFortuny Apr 9, 2024
19120f2
Mogut STOKES_GERARD a la carpeta corresponent
GerardFortuny Apr 14, 2024
c278f6a
Ellipse
GerardFortuny Apr 14, 2024
d0ae834
Millores_ellipse
GerardFortuny Apr 14, 2024
ab89d43
Nova_classe
GerardFortuny Apr 14, 2024
fcf2bd4
Update STOKES_GERARD_Cilinder.m
tarrut Apr 17, 2024
58afb27
Aerodynamic forces
GerardFortuny Apr 19, 2024
3df76c8
Some changes
GerardFortuny Apr 19, 2024
baeea8b
Proves
GerardFortuny Apr 20, 2024
d4b588c
Prova_distribució
GerardFortuny Apr 20, 2024
fa73651
boundary plot idea
jose-antonio-torres Apr 26, 2024
cf60449
small changes
jose-antonio-torres Apr 26, 2024
67e93de
lift and drag
jose-antonio-torres Apr 26, 2024
2672c48
Prova
GerardFortuny Apr 26, 2024
f36341d
Merge branch 'TFG_GerardF' of https://github.com/SwanLab/Swan into TF…
GerardFortuny Apr 26, 2024
487c3ed
Forces al cercle
GerardFortuny Apr 26, 2024
9c0572d
Forces a l'el·lipse
GerardFortuny Apr 26, 2024
bdb2f9a
Autoajust
GerardFortuny Apr 26, 2024
0457849
Proves
GerardFortuny Apr 28, 2024
590ea01
Update STOKES_GERARD_Ellipse_autoajust.m
GerardFortuny May 4, 2024
f9bde39
Arreglat autoajust
GerardFortuny May 4, 2024
dd11134
Proves
GerardFortuny May 4, 2024
7a242af
Arreglat que la matriu es fes singular
GerardFortuny May 5, 2024
0be6f45
Més proves
GerardFortuny May 5, 2024
17cfb9e
Més proves
GerardFortuny May 5, 2024
9cb2a9e
Millores
GerardFortuny May 7, 2024
6dcb442
NODES SENSE MARGE
GerardFortuny May 7, 2024
54ac818
Petits canvis
GerardFortuny May 8, 2024
7515ac7
Millores
GerardFortuny May 8, 2024
f3a0d8f
Millores
GerardFortuny May 9, 2024
e588eaa
Optimization
GerardFortuny May 9, 2024
9f54ecf
Millores
GerardFortuny May 9, 2024
ea8c4c8
Més coses
GerardFortuny May 10, 2024
8fdbd30
Opti amb a i b
GerardFortuny May 14, 2024
708d2eb
Més coses
GerardFortuny May 15, 2024
01c38ab
Més
GerardFortuny May 15, 2024
e8aa377
Més
GerardFortuny May 17, 2024
cca22d0
Modificat
GerardFortuny May 17, 2024
050bfd5
Més proves
GerardFortuny May 17, 2024
4e7a9c5
Perfil fet
GerardFortuny May 18, 2024
1df34ec
Passat a net
GerardFortuny May 18, 2024
8a4d9a5
Millores
GerardFortuny May 18, 2024
0701ab2
Pressure bc
GerardFortuny May 18, 2024
7a511c8
Lift millorat
GerardFortuny May 18, 2024
e4a5dba
Canvis
GerardFortuny May 19, 2024
da260f1
Cavity
GerardFortuny May 21, 2024
3e37007
Millores
GerardFortuny May 21, 2024
a1dde9e
Millores
GerardFortuny May 23, 2024
6050cb2
Millores
GerardFortuny May 24, 2024
8a32411
Millora ellipse
GerardFortuny May 25, 2024
c3b6165
Caixa
GerardFortuny May 28, 2024
c420ad3
Millores caixa
GerardFortuny May 28, 2024
ffad8a1
Auto t
GerardFortuny May 28, 2024
604f6af
Auto caixa fet
GerardFortuny May 28, 2024
4c58e43
Prova
GerardFortuny May 28, 2024
f86aa68
Nou
GerardFortuny May 29, 2024
4ae75df
Proves
GerardFortuny May 29, 2024
6572cbf
Prova_pau arreglat
GerardFortuny May 31, 2024
d09df06
Codi maco
GerardFortuny May 31, 2024
be69814
Millores
GerardFortuny Jun 1, 2024
6ab866c
Universal
GerardFortuny Jun 1, 2024
57b5d12
Canviat LagrangianPlotter
GerardFortuny Jun 3, 2024
664e401
Afegit distribució parabólica
GerardFortuny Jun 9, 2024
b5a70dd
Més coses
GerardFortuny Jun 10, 2024
c56b9fb
Més
GerardFortuny Jun 11, 2024
69164d6
Merge branch 'TFG_GerardF' of https://github.com/SwanLab/Swan into TF…
GerardFortuny Jun 11, 2024
d9d69d1
Canvis
GerardFortuny Jun 11, 2024
aa9d8be
Més
GerardFortuny Jun 13, 2024
efde96a
Actualització
GerardFortuny Jun 17, 2024
997c84d
Merge branch 'TFG_GerardF' into TFG_Chang
jose-antonio-torres Oct 17, 2024
f4c4476
small changes
jose-antonio-torres Oct 17, 2024
173143d
bug line constant
jose-antonio-torres Nov 13, 2024
39f1f05
Update Find_fH_circles.m
jose-antonio-torres Nov 13, 2024
2e68e43
"upload Naca"
FerrerFerreAlex Jan 28, 2025
2db47dd
naca working
jose-antonio-torres Jan 28, 2025
f9df507
improving quality of mesh
jose-antonio-torres Jan 28, 2025
ea87b4a
Update for code refactoring
XCXAA Feb 3, 2025
00f416d
improving alpha shapes
jose-antonio-torres Feb 3, 2025
008bf9f
good cond solved
jose-antonio-torres Feb 3, 2025
4e04a36
Update with new refactoring
XCXAA Feb 5, 2025
8bb7496
Update AoA
XCXAA Feb 10, 2025
7a4e3b3
Correction for AoA
XCXAA Feb 10, 2025
f712763
Update GeometricalFunction.m
jose-antonio-torres Feb 13, 2025
f470487
was a mistake
jose-antonio-torres Feb 13, 2025
a9eae63
Airfoil Rotated
XCXAA Feb 15, 2025
3bda7f4
Merge branch 'TFG_Chang' of https://github.com/SwanLab/Swan into TFG_…
XCXAA Feb 15, 2025
2240055
Update print results
XCXAA Feb 17, 2025
1070f86
Update GeometricalFunction.m
jose-antonio-torres Feb 17, 2025
2fbd630
filter pressure
jose-antonio-torres Feb 17, 2025
4f55027
some changes
jose-antonio-torres Feb 18, 2025
22c3fe3
Update StokesProblemBoundaryCondition.m
jose-antonio-torres Feb 18, 2025
5e31b51
Update TestNaca.m
jose-antonio-torres Feb 18, 2025
9928b7c
Data generator + plot figures
XCXAA Feb 18, 2025
9f1b002
Merge branch 'master' into TFG_Chang
jose-antonio-torres Feb 19, 2025
d29b507
Delete plotejarmalla.m
jose-antonio-torres Feb 19, 2025
66e9626
code working
jose-antonio-torres Feb 19, 2025
182c8a4
Delete results.txt
jose-antonio-torres Feb 19, 2025
ab4ad98
Update LagrangianFunction.m
jose-antonio-torres Feb 19, 2025
6104c4c
checkout
jose-antonio-torres Feb 19, 2025
75aede9
Create navier_stokes_pautarres.m
tarrut Feb 19, 2025
c757486
Update navier_stokes_pautarres.m
tarrut Feb 20, 2025
ae67cc3
Update navier_stokes_pautarres.m
tarrut Feb 20, 2025
dcaf4b8
Update navier_stokes_pautarres.m
tarrut Feb 20, 2025
3bb127f
apply convective term
tarrut Feb 21, 2025
98c6813
small changes
jose-antonio-torres Feb 25, 2025
c1e3b7b
Update TestNaca.m
FerrerFerreAlex Feb 25, 2025
7a0c18b
"sm ch"
FerrerFerreAlex Feb 25, 2025
9eac87f
levelset plot
jose-antonio-torres Feb 25, 2025
7438126
Correct a small error
XCXAA Mar 3, 2025
e66aeb4
new geometrical function
jose-antonio-torres Mar 4, 2025
55ca840
update
XCXAA Mar 10, 2025
b9d090a
levelset study
jose-antonio-torres Mar 10, 2025
375ff4c
ls2
jose-antonio-torres Mar 11, 2025
fef301a
Updates for level set study
XCXAA Mar 16, 2025
d6a90fa
Create collapseMeshes.m
jose-antonio-torres Mar 17, 2025
8a78695
update for level set
XCXAA Mar 17, 2025
8c16496
Update LevelSetsStudy.m
jose-antonio-torres Mar 17, 2025
5c18952
Update for dataset stokes
XCXAA Mar 20, 2025
dfcacbb
Update for geometrical function
XCXAA Mar 24, 2025
00c6a65
EDataset generated + code organised
XCXAA Apr 6, 2025
d21bf1f
Create TrainingMain.m
jose-antonio-torres Apr 7, 2025
eb72246
Merge remote-tracking branch 'origin/PauCli-TO-ML-Sandbox' into TFG_C…
jose-antonio-torres Apr 8, 2025
b17338c
Create PlotterNN.m
jose-antonio-torres Apr 8, 2025
dfb1638
Delete Plotter2.m
jose-antonio-torres Apr 8, 2025
18986d3
last changes
jose-antonio-torres Apr 8, 2025
bb2354a
"chang"
FerrerFerreAlex Apr 24, 2025
4677ebc
Update Network and Optimizer
XCXAA May 7, 2025
4c0e6f2
Merge branch 'TFG_Chang' of https://github.com/SwanLab/Swan into TFG_…
XCXAA May 7, 2025
e768a0f
Correct small Error
XCXAA May 9, 2025
fa88589
tfm
tarrut May 11, 2025
bad4d83
Merge branch 'master' into navier_stokes_pautarres
tarrut May 11, 2025
0552e0e
tfm
tarrut May 11, 2025
414c8bd
Correction & Update
XCXAA May 12, 2025
c3438cc
tfm
tarrut May 13, 2025
13d5a7c
NV Solver Implementation
XCXAA May 17, 2025
1d0fc83
Correction VideoGenerator
XCXAA May 18, 2025
c8c1ab3
Update NV
XCXAA May 19, 2025
a248e46
Update video generator
XCXAA May 19, 2025
ac1de80
Merge branch 'TFG_Chang' of https://github.com/SwanLab/Swan into TFG_…
XCXAA May 19, 2025
c5ced3e
Clean Network and update NV Solver
XCXAA May 21, 2025
c3701c7
Merge branch 'TFG_Chang' of https://github.com/SwanLab/Swan into TFG_…
XCXAA May 21, 2025
ac97e56
Update Optimizer and material
XCXAA May 21, 2025
0a44d0d
NN model trained
XCXAA May 23, 2025
9dc4586
Merge branch 'TFG_Chang' of https://github.com/SwanLab/Swan into TFG_…
XCXAA May 23, 2025
931d610
small correction
XCXAA May 23, 2025
e324a33
Update video and Test NAC
XCXAA May 24, 2025
4bdcafb
Merge branch 'master' into navier_stokes_pautarres
tarrut May 26, 2025
6b7fd04
update
tarrut May 31, 2025
3c1fef8
Correction Stokes Network
XCXAA Jun 1, 2025
31bb6c5
Stokes Optimization Video Update
XCXAA Jun 2, 2025
a45d637
Update for convergence study ns
XCXAA Jun 5, 2025
bedb011
Convergence Study Update
XCXAA Jun 18, 2025
d439e1d
Clean and Definitive Code
XCXAA Jun 18, 2025
7e16670
Merge branch 'navier_stokes_pautarres' into TFG_Chang
jose-antonio-torres Aug 27, 2025
63724a1
Merge branch 'master' into TFG_Chang
jose-antonio-torres Aug 29, 2025
a01f505
material stokes not needed since nu is cte (incompr)
jose-antonio-torres Aug 29, 2025
aa4a4f5
fitted naca working
jose-antonio-torres Aug 29, 2025
026e4f0
Merge branch 'master' into TFG_Chang
jose-antonio-torres Aug 29, 2025
3fc2375
cleaning
jose-antonio-torres Aug 29, 2025
66f42fd
cleaning + moving files + fitted naca working
jose-antonio-torres Aug 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions TFGChang/AeroForcesCalculation.m
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
classdef AeroForcesCalculation < handle properties (Access = public) L D E end properties (Access = private) mesh nodesConditions pressureFun end properties (Access = private) connec bMesh pBoundary normalVectors lengthElement centroid centralPointsElement nX nY end methods (Access = public) function obj = AeroForcesCalculation(cParams) obj.init(cParams); obj.identifyBoundaryEdges(); obj.createBoundaryMesh(); obj.assignPressureToBoundary(); obj.defineVariables(); end function compute(obj) obj.computeNormalVectors(); obj.convertNorVectorsToLanFunctions(); obj.computeDragForces(); obj.computeLiftForces(); obj.computeEfficiency(); %obj.plotResults(); end end methods (Access = private) function init(obj,cParams) obj.mesh = cParams.mesh; obj.nodesConditions = cParams.nodesConditions; obj.pressureFun = cParams.pressureFun; end function identifyBoundaryEdges(obj) obj.mesh.computeEdges(); e = obj.mesh.edges.nodesInEdges; bE = ismember(e,obj.nodesConditions); bEIndices = find(prod(bE,2)); obj.connec = e(bEIndices,:); end function createBoundaryMesh(obj) ss.coord = obj.mesh.coord; ss.connec = obj.connec; ss.kFace = -1; obj.bMesh = Mesh.create(ss); obj.bMesh = obj.bMesh.computeCanonicalMesh(); end function assignPressureToBoundary(obj) obj.pBoundary = LagrangianFunction.create(obj.bMesh,1,obj.pressureFun.order); pVals = obj.pressureFun.fValues(obj.nodesConditions,1); obj.pBoundary.setFValues(pVals); end function plotPressureDistribution(obj) obj.pBoundary.plot(); end function defineVariables(obj) obj.normalVectors = zeros(obj.bMesh.nelem,obj.bMesh.ndim); obj.lengthElement = zeros(obj.bMesh.nelem,1); obj.centroid = mean(obj.bMesh.coord); obj.centralPointsElement = (obj.bMesh.coord(obj.bMesh.connec(:,1),:) + obj.bMesh.coord(obj.bMesh.connec(:,2),:))/2; end function computeNormalVectors(obj) node1 = obj.bMesh.coord(obj.bMesh.connec(:,1),:); node2 = obj.bMesh.coord(obj.bMesh.connec(:,2),:); distanceNodes = node2 - node1; obj.lengthElement = vecnorm(distanceNodes,2,2); tanVector = distanceNodes./obj.lengthElement; obj.normalVectors = tanVector * [0 1;-1 0]; end function convertNorVectorsToLanFunctions(obj) obj.nX = LagrangianFunction.create(obj.bMesh,1,'P0'); obj.nY = LagrangianFunction.create(obj.bMesh,1,'P0'); obj.nX.setFValues(obj.normalVectors(:,1)); obj.nY.setFValues(obj.normalVectors(:,2)); end function computeDragForces(obj) s.operation = @(x) -obj.pBoundary.evaluate(x).*obj.nX.evaluate(x); s.mesh = obj.mesh; pNX = DomainFunction(s); obj.D = Integrator.compute(pNX,obj.bMesh,2); end function computeLiftForces(obj) s.operation = @(x) -obj.pBoundary.evaluate(x).*obj.nY.evaluate(x); s.mesh = obj.mesh; pNY = DomainFunction(s); obj.L = Integrator.compute(pNY,obj.bMesh,2); end function computeEfficiency(obj) obj.E = obj.L/obj.D; end function plotResults(obj) obj.plotPressureDistribution(); figure; quiver(obj.centralPointsElement(:,1),obj.centralPointsElement(:,2),obj.normalVectors(:,1),obj.normalVectors(:,2)); hold on; quiver(obj.centroid(1,1),obj.centroid(1,2),obj.D,0); hold on; quiver(obj.centroid(1,1),obj.centroid(1,2),0,obj.L); hold on; obj.bMesh.plot() title("Lift and drag distribution"); xlabel("x"); ylabel("y"); end endend
Expand Down
78 changes: 78 additions & 0 deletions TFGChang/AeroForcesCalculationTestComputer.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
classdef AeroForcesCalculationTestComputer < handle

properties (Access = public)
comparingLiftMessage
comparingDragMessage
end

properties (Access = private)
tolerance
end

properties (Access = private)
LiftOriginal
DragOriginal
LiftTest
DragTest
end

methods (Access = public)

function obj = AeroForcesCalculationTestComputer(cParams)
obj.init(cParams);
end

function compute(obj)
obj.compareLift();
obj.compareDrag();
result = [obj.comparingLiftMessage, newline, obj.comparingDragMessage];
disp(result);
end

end


methods (Access = private)

function init(obj,cParams)
obj.saveInput(cParams);
obj.loadOriginalfinalMesh();
obj.tolerance = 1e-4;
end

function saveInput(obj,cParams)
obj.LiftTest = cParams.L;
obj.DragTest = cParams.D;
end

function loadOriginalfinalMesh(obj)
load("E_GF_N2412.mat","Li","Di");
obj.LiftOriginal = Li;
obj.DragOriginal = Di;
end

function compareLift(obj)
try
relativeError = abs(obj.LiftOriginal - obj.LiftTest) / abs(obj.LiftOriginal);
assert(relativeError < obj.tolerance, ...
sprintf('The lift force does not match the expected value.\nRelative error: %.4f', relativeError));
obj.comparingLiftMessage = 'The lift force corresponds to the expected value.';
catch ME
obj.comparingLiftMessage = ME.message;
end
end

function compareDrag(obj)
try
relativeError = abs(obj.DragOriginal - obj.DragTest) / abs(obj.DragOriginal);
assert(relativeError < obj.tolerance, ...
sprintf('The drag force does not match the expected value.\nRelative error: %.4f', relativeError));
obj.comparingDragMessage = 'The drag force corresponds to the expected value.';
catch ME
obj.comparingDragMessage = ME.message;
end
end

end

end
206 changes: 206 additions & 0 deletions TFGChang/AirfoilOptimizer.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
classdef AirfoilOptimizer < handle

properties (Access = public)
optimalParams
end

properties (Access = private)
features
learningRate
optimizer
tol
upperBC
lowerBC
ParamsMat
E
velFunMat
PFunMat
end

methods (Access = public)

function obj = AirfoilOptimizer(cParams)
obj.init(cParams);
end

function computeOptAirfoilParams(obj)
obj.computeOptimization();
end

function plotEEvolution(obj)
obj.plotE();
end

function generateAFSOPVideo(obj)
plotFun = @(s, i) AirfoilOptimizer.plotAirfoilContour(s, i);
VideoGenerator.compute("AirfoilOptimization", size(obj.ParamsMat,1),100, obj.ParamsMat, plotFun);
end

function generateVelVideo(obj)
plotFun = @(s, ~) TestNaca.plotVelocity(s);
VideoGenerator.compute('AirfoilOptimization-Velocity', size(obj.velFunMat,2), size(obj.velFunMat,2),obj.velFunMat, plotFun);
end

function generatePVideo(obj)
plotFun = @(s, ~) TestNaca.plotPressure(s);
VideoGenerator.compute('AirfoilOptimization-Pressure', size(obj.PFunMat,2), size(obj.PFunMat,2),obj.PFunMat, plotFun);
end

function saveData(obj)
save("OptData.mat","obj");
end

end

methods (Access = private)

function init(obj,cParams)
obj.features = cParams.features;
obj.optimizer = cParams.optimizer;
obj.tol = cParams.tol;
obj.learningRate = cParams.learningRate;
obj.upperBC = cParams.upperBC;
obj.lowerBC = cParams.lowerBC;
obj.optimalParams = obj.features;
obj.E(1) = obj.optimizer.computeOutputValues(obj.optimalParams);
obj.ParamsMat(1,:) = obj.features;
[obj.velFunMat{1}, obj.PFunMat{1}] = computeVelPFun(obj);
end

function projected = projectParams(obj,params)
projected = max(min(params, obj.upperBC), obj.lowerBC);
projected(2) = projected(2) * (projected(1) > 1e-6);
projected(1) = projected(1) * (projected(2) > 1e-6);
end

function computeOptimization(obj)
diff = 1;
iter = 1;
maxIter = 101;%301

rho = 0.9; %0.9 %0.5
epsilon = 1e-8;
cache = zeros(size(obj.optimalParams));

while diff > obj.tol && iter < maxIter

% if (iter > 70)
%
% obj.learningRate = 0.5;
% end
%
% if (iter > 97)
%
% obj.learningRate = 0.02;
% end

gradient = obj.optimizer.computeGradient(obj.optimalParams);

cache = rho * cache + (1 - rho) * (gradient.^2);

adjustedGradient = obj.learningRate * gradient ./ (sqrt(cache) + epsilon);
updatedParams = obj.optimalParams + adjustedGradient;

obj.optimalParams = obj.projectParams(updatedParams);

obj.E(end + 1) = obj.optimizer.computeOutputValues(obj.optimalParams);

diff = max(abs(obj.ParamsMat(end) - obj.optimalParams));

obj.ParamsMat(end + 1,:) = obj.optimalParams;

if mod(iter,2) == 0
[obj.velFunMat{end + 1}, obj.PFunMat{end + 1}] = computeVelPFun(obj);
end

iter = iter + 1;
end
end

function plotE(obj)
figure;
plot(1:length(obj.E), obj.E);
xlabel('Iteration');
ylabel('Aerodynamic Efficiency');
title('Evolution of Airfoil Aerodynamic Efficiency vs Optimization Iteration');
grid on;
end

function [velFun,PFun] = computeVelPFun(obj)
Naca.flowType = "Stokes";
Naca.length = 8;
Naca.height = 4;
Naca.nx = 420;
Naca.M = obj.optimalParams(1);
Naca.p = obj.optimalParams(2);
Naca.t = obj.optimalParams(3);
Naca.chord = 1;
Naca.AoA = obj.optimalParams(4);

NacaClass = TestNaca(Naca);
NacaClass.compute();
velFun = NacaClass.velocityFun;
PFun = NacaClass.pressureFun;

end


end

methods (Static)

function [xContour,yContour] = computeAirfoilContour(s)
x = 0:0.001:1;
m = s(1);
p = s(2);
t = s(3);

if (m > 1e-6)
yc = (x<=p).*(m/p^2.*(2*p*x - x.^2)) + ...
(x>p).*(m/(1-p)^2.*((1 - 2*p) + 2*p*x - x.^2));
dydx = (x<=p).*(2*m/p^2.*(p - x)) + ...
(x>p).*(2*m/(1-p)^2.*(p - x));
else
yc = 0;
dydx = 0;
end

yt = 5*t.*(0.2969*sqrt(x)-0.1260*x-0.3516*x.^2+0.2843*x.^3-0.1036*x.^4);
theta = atan(dydx);

xu = x - yt.*sin(theta);
yu = yc + yt.*cos(theta);
xl = x + yt.*sin(theta);
yl = yc - yt.*cos(theta);

xContour = [xu, fliplr(xl)];
yContour = [yu, fliplr(yl)];
end

function [xRot,yRot] = rotateAirfoil(xContour,yContour,AoA)
xRot = xContour*cos(AoA) - yContour*sin(AoA);
yRot = xContour*sin(AoA) + yContour*cos(AoA);
end

function plotAirfoilContour(s,i)

AoA = -deg2rad(s(4));

[xContour,yContour] = AirfoilOptimizer.computeAirfoilContour(s);

[xRot,yRot] = AirfoilOptimizer.rotateAirfoil(xContour,yContour,AoA);

plot(xRot, yRot, 'k-', 'LineWidth', 1);
xlim([-0.2 1.2]);
ylim([-0.6 0.6]);
axis equal;
xlabel('x'); ylabel('y');
title(sprintf('Airfoil Shape Optimization - Iteration %d', i - 1));
grid on;

end


end

end
Loading