From: Nils Forssén Date: Tue, 27 Sep 2022 07:51:31 +0000 (+0200) Subject: push X-Git-Url: https://gitweb.forssennils.se/?a=commitdiff_plain;h=e4d8bffeb70cfc44296ca471e4b17305dce38236;p=TANA21.git push --- diff --git a/Lagrange_interpolation.m b/Lagrange_interpolation.m new file mode 100644 index 0000000..e53a219 --- /dev/null +++ b/Lagrange_interpolation.m @@ -0,0 +1,32 @@ +function [pnx] = Lagrange_interpolation(z,) +%% +% Implementation to evaluate an interpolating polynomial p_n(x) +% at the point x = z. The polynomial uses the standard Lagrange +% basis functions. +% +% INPUT: +% +% z - 1x1 value to evaluate +% ??? +% +% OUTPUT: +% +% pnx - value of the polynomial interpolant at x = z +% + +%% +% compute the polynomial interpolation sum evaluated at x = z + pnx = + for i = + + + + for j = + + + + end + + pnx = + end +end diff --git a/diff.asv b/diff.asv new file mode 100644 index 0000000..41e56bc --- /dev/null +++ b/diff.asv @@ -0,0 +1,55 @@ +%% Center + +D_x_center = diag(0.5*ones(5,1),1) - diag(0.5*ones(5,1),-1); +D_x_center(1,1) = 1; +D_x_center(6,6) = 1; +interval = [0:1/5:1]; +h = 1/5; +D_x_center + +f_x_1 = [1;1;1;1;1;1]; +f_x_2 = interval.'; +f_x_3 = (interval.^2).'; + +diff1 = 1/h * D_x_center * f_x_1 +diff2 = 1/h * D_x_center * f_x_2 +diff3 = 1/h * D_x_center * f_x_3 + +%% Forward + +D_x_forward = diag(ones(5,1),1) - diag(ones(6,1), 0); +D_x_forward(6,5) = -1; +D_x_forward(6,6) = 1; + +interval = [0:1/5:1]; +h = 1/5; + +f_x_1 = [1;1;1;1;1;1]; +f_x_2 = interval.'; +f_x_3 = (interval.^2).'; + +diff1 = 1/h * D_x_forward * f_x_1 +diff2 = 1/h * D_x_forward * f_x_2 +diff3 = 1/h * D_x_forward * f_x_3 + +%% Backwards + +D_x_back = D_x_forward; + +interval = [0:1/5:1]; +h = 1/5; + +f_x_1 = [1;1;1;1;1;1]; +f_x_2 = interval.'; +f_x_3 = (interval.^2).'; + +diff1 = 1/h * D_x_back * f_x_1 +diff2 = 1/h * D_x_back * f_x_2 +diff3 = 1/h * D_x_back * f_x_3 + + + +%% Bias + +bound_low = ((-3*f_x_1(1)) + (4*f_x_1(2)) - (f_x_1(3)))/(2*h) +bound_up = ((f_x_1(4)) - (4*f_x_1(5)) + (3*f_x_1(6)))/(2*h) \ No newline at end of file diff --git a/diff.m b/diff.m new file mode 100644 index 0000000..64eff1a --- /dev/null +++ b/diff.m @@ -0,0 +1,86 @@ +%% Center + +D_x_center = diag(0.5*ones(5,1),1) - diag(0.5*ones(5,1),-1); +D_x_center(1,1) = 1; +D_x_center(6,6) = 1; +interval = [0:1/5:1]; +h = 1/5; +D_x_center + +f_x_1 = [1;1;1;1;1;1]; +f_x_2 = interval.'; +f_x_3 = (interval.^2).'; + +diff1 = 1/h * D_x_center * f_x_1 +diff2 = 1/h * D_x_center * f_x_2 +diff3 = 1/h * D_x_center * f_x_3 + +%% Forward + +D_x_forward = diag(ones(5,1),1) - diag(ones(6,1), 0); +D_x_forward(6,5) = -1; +D_x_forward(6,6) = 1; + +interval = [0:1/5:1]; +h = 1/5; + +f_x_1 = [1;1;1;1;1;1]; +f_x_2 = interval.'; +f_x_3 = (interval.^2).'; + +diff1 = 1/h * D_x_forward * f_x_1 +diff2 = 1/h * D_x_forward * f_x_2 +diff3 = 1/h * D_x_forward * f_x_3 + +%% Backwards + +D_x_back = D_x_forward; + +interval = [0:1/5:1]; +h = 1/5; + +f_x_1 = [1;1;1;1;1;1]; +f_x_2 = interval.'; +f_x_3 = (interval.^2).'; + +diff1 = 1/h * D_x_back * f_x_1 +diff2 = 1/h * D_x_back * f_x_2 +diff3 = 1/h * D_x_back * f_x_3 + + + +%% Bias + +bound_low = ((-3*f_x_3(1)) + (4*f_x_3(2)) - (f_x_3(3)))/(2*h) +bound_up = ((f_x_3(4)) - (4*f_x_3(5)) + (3*f_x_3(6)))/(2*h) + + + +%% EXP + +D_x_center = diag(0.5*ones(5,1),1) - diag(0.5*ones(5,1),-1); +D_x_center(1,1) = 1; +D_x_center(6,6) = 1; + +N = 5; +interval = [0:1/N:1]; +h = 1/N; + +f_prim = zeros(length(interval), 1); +for i=1:length(interval) + f_prim(i) = 4*exp(sin(4*interval(i)))*cos(4*interval(i)); +end +f_prim + + + + + + + + + + + + + diff --git a/joukowsky_airfoil_data.m b/joukowsky_airfoil_data.m new file mode 100644 index 0000000..63bb3a1 --- /dev/null +++ b/joukowsky_airfoil_data.m @@ -0,0 +1,2 @@ +x_joukow = [-1.7550, -1.7400, -1.6960, -1.6010, -1.4830, -1.2950, -1.0430, -0.8354, -0.5833, -0.2872, 0.1997, 0.8372, 1.3570, 1.69500]; +y_joukow = [ 0.0893, 0.1461, 0.2196, 0.3199, 0.4088, 0.5115, 0.6042, 0.6529, 0.6852, 0.6903, 0.6297, 0.4284, 0.1643, -0.04687]; \ No newline at end of file diff --git a/joukowsky_airfoil_image.m b/joukowsky_airfoil_image.m new file mode 100644 index 0000000..e120675 --- /dev/null +++ b/joukowsky_airfoil_image.m @@ -0,0 +1,30 @@ +function joukowsky_airfoil_image +%% +% This perfoms the conformal mapping to create a particular instance of a Joukowsky airfoil +% + theta = linspace(0,2*pi,300); % angles + r = 1.0; % radius + s = 0.175 + 1i*0.215; % circle origin + zeta = s + r*exp(1i*theta); % original circle values in complex space (written in polar form) + k = r - s; % transformation parameter + z = zeta + k^2./zeta; % conformal mapping of airfoil surface in complex space + z = z*exp(1i*pi/11); % rotate airfoil location + + plot(-real(z),imag(z),'-k','LineWidth',1.5) % plot the transformed airfoil + +% plot the top and bottom curves +% plot(topx,topy,'-k',botx,boty,'-k','LineWidth',1.5) + hold on +% set limits and size of figure + set(gcf,'Position',[10, 10, 1500, 400]) + set(gca,'FontSize',16); + xlim([-2.0 2.0]) + ylim([-0.2 0.9]) +% fill with gray color for better visualization + h1 = fill(-real(z),imag(z),'k','LineStyle','none'); + set(h1,'facealpha',0.05); +% +% for i = 1:length(z) +% plot(-real(z(i)),imag(z(i)),'ro','MarkerSize',10) +% end +end \ No newline at end of file