前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >NACA翼型发生器对于导入icem建模有非常大的帮助。

NACA翼型发生器对于导入icem建模有非常大的帮助。

作者头像
裴来凡
发布于 2022-05-28 07:35:07
发布于 2022-05-28 07:35:07
31000
代码可运行
举报
运行总次数:0
代码可运行

NacaAirfoil.m

代码语言:javascript
代码运行次数:0
运行
复制
function [y,x] = NacaAirfoil(varargin)

switch nargin
    case 0
        AF= '0012';   % designation
        M = AF(1);   % The maximum value of the mean line as chord/100.
        P = AF(2);   % Is the chordwise position of the maximum chamber as chord/10.
        XX= AF(3:4); % Is the maximum thickness, t/c, in chord precent (x 100%).
        TE= 'zero';  % Trailing edge (TE)
        n = 30;      % x-nodes to describe airfoil
        xs='halfcos';% x-nodes spacing method
        wf= 0;       % writte solution file
    case 1
        AF= varargin{1}; 
        M = AF(1);
        P = AF(2);
        XX= AF(3:4);
        TE= 'zero';
        n = 30;      
        xs= 'halfcos';
        wf= 0;
  case 2
        AF= varargin{1}; 
        M = AF(1);
        P = AF(2);
        XX= AF(3:4);
        TE= varargin{2};
        n = 30;      
        xs= 'halfcos';
        wf= 0;
  case 4
        AF= varargin{1}; 
        M = AF(1);
        P = AF(2);
        XX= AF(3:4);
        TE= varargin{2};
        n = varargin{3};      
        xs= varargin{4};
        wf= 0;
  case 5
        AF= varargin{1}; 
        M = AF(1);
        P = AF(2);
        XX= AF(3:4);
        TE= varargin{2};
        n = varargin{3};      
        xs= varargin{4};
        wf= 1;
        pth=varargin{5};
    otherwise
        error('wrong number of input arguments, check again dummy.')
end

% set airfoil main characteristics
m=str2double(M)/100;   % mean line coord
p=str2double(P)/10;    % maximun chamber position
t=str2double(XX)/100;  % relative thickness (t/c)

% Fixed parameters
a0= 0.2969;
a1=-0.1260;
a2=-0.3516;
a3= 0.2843;
switch TE 
    case 'finite'   % For finite thick TE
        a4=-0.1015;  
    case 'zero'     % For zero thick TE
        a4=-0.1036;
    otherwise
        error('not a valid trailing edge')
end

%% Build Airfoil cross section
% Set spacing for discrete values in x-direction
switch xs 
    case 'halfcos'  % Half cosine based spacing
        beta=linspace(0,pi,n)'; x=(0.5*(1-cos(beta))); 
        header=['NACA',AF,':[',num2str(2*n),'panels,Half cosine x-spacing]'];  
    case 'uniform'  % uniform based spacing
        x=linspace(0,1,n)';
        header=['NACA',AF,':[',num2str(2*n),'panels,Uniform x-spacing]'];
    otherwise
        error('not a valid spacing method')
end

% find points before and after the maximum chamber position 'p'
xc1=x(x<=p);  % for t <= p
xc2=x(x> p);  % for t > p
xc=[xc1;xc2]; % concatenate vectors

% compute thickness function yt(x) 
yt=(t/0.2)*(a0*sqrt(x)+a1*x+a2*x.^2+a3*x.^3+a4*x.^4);

% 
if p==0  % symmetric airfoil
    % thickness embelope with camber or mean line.
    xu=x;    yu= yt;    % upper surface
    xl=x;    yl=-yt;    % lower surface
    yc=zeros(size(xc)); % camber line function
else  % non-symmetric airfoil
    % camber lines
    yc1=(m/p^2)*(2*p*xc1-xc1.^2);               % for t <= p
    yc2=(m/(1-p)^2)*((1-2*p)+2*p*xc2-xc2.^2);   % for t > p
    yc=[yc1;yc2];       % camber line function yc(x)

    dyc1_dx=(m/p^2)*(2*p-2*xc1);                % for t <= p
    dyc2_dx=(m/(1-p)^2)*(2*p-2*xc2);            % for t > p
    dyc_dx=[dyc1_dx;dyc2_dx];   % camber line slope dyc/dx
    theta=atan(dyc_dx);  % camber line slope angle 

    xu= x-yt.*sin(theta);  yu=yc+yt.*cos(theta); % upper surface
    xl= x+yt.*sin(theta);  yl=yc-yt.*cos(theta); % lower surface
end

% Plot airfoid embelope
plot(xu,yu,'bo-'); hold on  % upper surface
plot(xl,yl,'ro-'); hold off % lower surface
axis equal

% Output points
x=[flipud(xu) ; xl(2:end)];
y=[flipud(yu) ; yl(2:end)];


%% Write Points to file
if wf == 1
    F1=header;
    F2=num2str([x,y]);
    F=strvcat(F1,F2);
    fileName=[pth,'NACA',AF,'.dat'];
    dlmwrite(fileName,F,'delimiter','')
end

end

NACAAirfoilMesh.m

代码语言:javascript
代码运行次数:0
运行
复制

close all;
 
%-------------------------------------------------------------------------% 
% Define all the parameters 
%-------------------------------------------------------------------------% 
 
Na = 50;
M = 30;
A = 10; %Clustering points near leading edge, inf = no clustering
B = 2; %Clustering points near the surface, 1 = no clustering
t = .12;
c = 1;
L = 1;
N = floor(2*c/(2*c+L)*Na);
x1 = c*ones(1,N+1);
y1 = zeros(1,N+1);
x2 = x1;
y2 = y1;
y2(1) = c;
s1 = y1;
s2 = s1;
N2 = 250;

%-------------------------------------------------------------------------% 
% Solve Algebraic Method
%-------------------------------------------------------------------------%
for i = 2:N2+1
    x1(i) = c*(1-(i-1)/N2);
    y1(i) = max([t/.2*(.2969*x1(i)^.5-.126*x1(i)-.3516*x1(i)^2+.2843*x1(i)^3-.1015*x1(i)^4) 0]);
    s1(i) = s1(i-1)+sqrt((x1(i)-x1(i-1))^2+(y1(i)-y1(i-1))^2);
    x2(i) = c*(1-2*(i-1)/N2);
    if x2(i) >= 0;
        y2(i) = c;
    else
        y2(i) = sqrt(c^2-(x2(i))^2);
    end
    s2(i) = s2(i-1)+sqrt((x2(i)-x2(i-1))^2+(y2(i)-y2(i-1))^2);
end
S1 = s1(end)*(1-exp(-(0:N)/A))/(1-exp(-(N)/A));
S1(end)/s1(end)
S2 = (0:N)*s2(end)/N;
for i = 1:N+1
    X1(i) = interp1(s1,x1,S1(i));
    Y1(i) = interp1(s1,y1,S1(i));
    X2(i) = interp1(s2,x2,S2(i));
    Y2(i) = interp1(s2,y2,S2(i));
end
r = exp(((1:(M+1))-M+1)/((M+1)/B));
r = r-r(1);
r = r/max(r);
for i = 1:N+1
    for j = 1:M+1
        x(i,j) = X1(i) + r(j)*(X2(i)-X1(i));
        y(i,j) = Y1(i) + r(j)*(Y2(i)-Y1(i));
    end
end
N = Na-N;
x = [((L+c):-L/N:(c+L/N))'*ones(1,M+1); x];
y = [(c*r'*ones(1,N))'; y];
x = [x; x(end-1:-1:1,:)];
y = [y ;-y(end-1:-1:1,:)];
[n,m] = size(x);

%-------------------------------------------------------------------------% 
% Plot Algebraic Method
%-------------------------------------------------------------------------%
mesh(x,y,zeros(n,m))
view(0,90)
colormap([0 0 0])
axis('equal','tight');
xlabel('Length [unitless]','FontSize',14);
ylabel('Length [unitless]','FontSize',14);
title('Algebraic Method ','FontSize',18);

%-------------------------------------------------------------------------% 
% Predetermined Constants
%-------------------------------------------------------------------------%
de = 1/M;
de2 = de^2;
dn = 1/Na;
dn2 = dn^2;
dedn = 2/(M*Na);
P = 100; %number of iterations for the elliptic solver.

%-------------------------------------------------------------------------% 
% Solve Elliptic Method
%-------------------------------------------------------------------------%
 
for k = 1:P
    for i = 2:2*Na-1
        for j = 2:M-1
            xn = (x(i+1,j)-x(i-1,j))/(2*dn);
            yn = (y(i+1,j)-y(i-1,j))/(2*dn);
            xe = (x(i,j+1)-x(i,j-1))/(2*de);
            ye = (y(i,j+1)-y(i,j-1))/(2*de);
            a(i,j) = xn^2+yn^2;
            b(i,j) = xe*xn+ye*yn;
            c(i,j) = xe^2+ye^2;
        end
    end
    for i = 2:2*Na-1
        for j = 2:M-1
            x(i,j) = (a(i,j)/de2*(x(i+1,j)+x(i-1,j))+c(i,j)/dn2*(x(i,j+1)+x(i,j-1))...
                -b(i,j)/dedn*(x(i+1,j+1)-x(i+1,j-1)+x(i-1,j-1)-x(i-1,j+1)))...
                /(2*(a(i,j)/de2+c(i,j)/dn2));
            y(i,j) = (a(i,j)/de2*(y(i+1,j)+y(i-1,j))+c(i,j)/dn2*(y(i,j+1)+y(i,j-1))...
                -b(i,j)/dedn*(y(i+1,j+1)-y(i+1,j-1)+y(i-1,j-1)-y(i-1,j+1)))...
                /(2*(a(i,j)/de2+c(i,j)/dn2));
        end
    end
end
xn = ones(Na,M)/0;
yn = xn;
xe = xn;
ye = xn;
for i = 2:Na-1
    for j = 2:M-1
        xn(i,j) = (x(i+1,j)-x(i-1,j))/(2*dn);
        yn(i,j) = (y(i+1,j)-y(i-1,j))/(2*dn);
        xe(i,j) = (x(i,j+1)-x(i,j-1))/(2*de);
        ye(i,j) = (y(i,j+1)-y(i,j-1))/(2*de);
        J(i,j) = yn(i,j)*xe(i,j)-xn(i,j)*ye(i,j); % Jacobian
    end
end
figure(2)
mesh(x,y,zeros(n,m))
xlabel('Length [unitless]','FontSize',14);
ylabel('Length [unitless]','FontSize',14);
title('Elliptic Method ','FontSize',18);
axis('equal','tight');

%-------------------------------------------------------------------------% 
% Plot Elliptic Method
%-------------------------------------------------------------------------%
 
view(0,90)
colormap([0 0 0])

%-------------------------------------------------------------------------% 
% Plot Jacobian
%-------------------------------------------------------------------------%
 
figure(3)
x=2:30; y=2:50; [X,Y]=meshgrid(x,y);
surf(X,Y,J);
view(-45,45)
title('Jacobian ','FontSize',18);
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2020-05-25,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 图像处理与模式识别研究所 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
LeetCode 第 23 场双周赛(970/2044,前47.5%)
做出来了 1、3 两题,继续加油! 第二道字符串的题,又是看错题,以后要多读几遍题目,题目说要使用所有字符,我视而不见,去排列组合。。。 第四题,想到了贪心,又转到动态规划去做,没做出来。
Michael阿明
2020/07/13
3350
隐马尔科夫模型(HMM)笔记(公式+代码)
隐马尔科夫模型(hidden Markov model,HMM)是可用于标注问题的统计学习模型,描述由隐藏的马尔可夫链随机生成观测序列的过程,属于生成模型。隐马尔可夫模型在语音识别、自然语言处理、生物信息、模式识别等领域有着广泛的应用。
Michael阿明
2020/07/13
5.6K0
隐马尔科夫模型(HMM)笔记(公式+代码)
条件随机场(Conditional Random Field,CRF)
概率无向图模型(probabilistic undirected graphical model),又称为马尔可夫随机场(Markov random field),是一个可以由无向图表示的联合概率分布。
Michael阿明
2020/07/13
1.7K0
条件随机场(Conditional Random Field,CRF)
灰色理论预测模型
灰色理论 通过对原始数据的处理挖掘系统变动规律,建立相应微分方程,从而预测事物未来发展状况。  优点:对于不确定因素的复杂系统预测效果较好,且所需样本数据较小;  缺点:基于指数率的预测没有考虑系统的随机性,中长期预测精度较差。 灰色预测模型 在多种因素共同影响且内部因素难以全部划定,因素间关系复杂隐蔽,可利用的数据情况少下可用,一般会加上修正因子使结果更准确。  灰色系统是指“部分信息已知,部分信息未知“的”小样本“,”贫信息“的不确定系统,以灰色模型(G,M)为核心的模型体系。 灰色预测模
Angel_Kitty
2018/04/08
2.1K0
灰色理论预测模型
计算机图形学(OpenGL版)书中其它代码
本处代码主要为各章中除章节末的编程实例之外的有关代码,现全部贴出以飨读者。 第3章 二维图形生成 3.1 直线生成算法 3.1.1 数值微分法 void LineDDA(int x1, int y1, int x2, int y2, int color) { int dm=0; if (abs(x2-x1)>= abs(y2-y1) //abs是求绝对值的函数 dm=abs(x2-x1); //x为计长方向 else dm=abs(y2-
步行者08
2018/10/09
1.7K0
【优先算法】专题——前缀和
数组的元素是从标为1开始的,n是数组的个数,q是查询的次数,查询l到r这段区间的和。
用户11375356
2025/02/04
1540
【优先算法】专题——前缀和
FPGA图像处理之边缘检测算法的实现
边缘检测是图像处理和计算机视觉中的基本问题,边缘检测的目的是标识数字图像中亮度变化明显的点。图像属性中的显著变化通常反映了属性的重要事件和变化。这些包括(i)深度上的不连续、(ii)表面方向不连续、(iii)物质属性变化和(iv)场景照明变化。边缘检测是图像处理和计算机视觉中,尤其是特征提取中的一个研究领域。
FPGA开源工作室
2019/10/29
1.3K0
FPGA图像处理之边缘检测算法的实现
bzoj 3225: [Sdoi2008] 立方体覆盖 题解「建议收藏」
Time Limit: 2 Sec Memory Limit: 128 MB Submit: 51 Solved: 36 [ Submit][ Status]
全栈程序员站长
2022/07/10
2140
【算法刷题指南】前缀和
南桥
2024/12/14
1050
用节点DG求解二维热方程包括创建了一个特殊的集成电路用于测试。
heat2D.m clear all; close all; clc; %% Preprocessing % Parameters cfl = 0.2; N = 50; tEnd = 0.05; % build grid x = linspace(-1,1,N+1); dx = 1/N; y = linspace(-1,1,N+1); dy = 1/N; [x,y] = meshgrid(x,y); % set thermal diffusivity coef k=0.1; % Set
裴来凡
2022/05/28
3200
前缀和与差分 Krains 2020-07-28 16:05:15
s[i]=a[0]+a[1]+a[2]+...+a[i−1]s[i] = a[0]+a[1]+a[2]+...+a[i-1]s[i]=a[0]+a[1]+a[2]+...+a[i−1]
Krains
2020/08/05
2850
c语言游戏小型程序代码,C语言小游戏源码「建议收藏」
if(MouseX>280&&MouseX<300&&MouseY>65&&MouseY<85)
全栈程序员站长
2022/08/30
9K0
【前缀和的力量:高效解决子数组和矩阵问题的秘笈】—— 蓝桥杯高频热点题型知识点
前缀和(Prefix Sum)是一种常用的算法技巧,用于快速计算数组中某一范围的元素之和。
用户11286421
2025/03/17
1240
【前缀和的力量:高效解决子数组和矩阵问题的秘笈】—— 蓝桥杯高频热点题型知识点
jarvisoj-Crypto
jarvisoj-Crypto Medium RSA 题目到手后给了一个公钥和一个密文 我们对这个公钥提取信息: 可以得到 N = 0xC2636AE5C3D8E43FFB97AB09028F1AAC
安恒网络空间安全讲武堂
2018/02/06
4.6K0
jarvisoj-Crypto
前缀和、二维前缀和与差分的小总结
如果我给你一串长度为n的数列a1,a2,a3......an,再给出m个询问,每次询问给出L,R两个数,要求给出区间[L,R]里的数的和,你会怎么做,若是没有了解过前缀和的人看到这道题的想法可能是对于m次询问,我每次都遍历一遍它给的区间,计算出答案,这样子的方法固然没错,但是其时间复杂度达到了O(n*n),如果数据量稍微大一点就有可能超时,而我们如果使用前缀和的方法来做的话就能够将时间复杂度降到O(n+m),大大节省了运算时间。至于怎么用,请看下面一小段代码
ACM算法日常
2019/07/05
2.5K0
3.1.2 使用绘图API绘制Contour的思路
A week or so back I wrote about a package I ported/modified to create the Delaunay triangulation in Flash with a few AS3 classes. As I noted there, such atriangulated irregular network (TIN) allows us to interpolateisolines — lines of constant value (aka isarithms, commonly called contours).
周星星9527
2018/08/08
5390
3.1.2 使用绘图API绘制Contour的思路
算法思想总结:前缀和算法
小陈在拼命
2024/03/23
1210
算法思想总结:前缀和算法
深度解析算法之前缀和
这个题的话就是下面的样子,我们第一行输入 3 2的意思即是这个数组是3个元素大小的数组,2是接下来我们是需要输入两行数据下标的 然后第二行我们输入的n个整数表示的就是我们数组中的元素 然后后面的2行就是我们想计算数组中从哪里到哪里的和 这里的话我们是第一个数到第二个数的和,那么我们这里的就是3了
Undoom
2025/04/21
590
深度解析算法之前缀和
100个经典的动态规划方程
F[i,j,k] = max{f[i-1,j',k']+(T-(j-j')*p1-(k-k')*p2)div p3}
xindoo
2021/01/21
1.3K0
利用matlab实现非线性拟合(补)
之前在群里看有人问过三维拟合的问题。回去思考了一下,感觉和之前的非线性拟合还是有很多共同之处的。所以,这次将之前PSO方法的非线性拟合代码改动了一下,将其更改为适用性更广的高维拟合。
巴山学长
2021/05/08
1.6K0
利用matlab实现非线性拟合(补)
相关推荐
LeetCode 第 23 场双周赛(970/2044,前47.5%)
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档