## octave-cvsupdate

 [Octave-cvsupdate] SF.net SVN: octave: [5133] trunk/octave-forge/extra/nlwing2 From: - 2008-06-22 21:00:27 ```Revision: 5133 http://octave.svn.sourceforge.net/octave/?rev=5133&view=rev Author: highegg Date: 2008-06-22 14:00:08 -0700 (Sun, 22 Jun 2008) Log Message: ----------- update README, delete redundant file Modified Paths: -------------- trunk/octave-forge/extra/nlwing2/README Removed Paths: ------------- trunk/octave-forge/extra/nlwing2/inst/ppder.m Modified: trunk/octave-forge/extra/nlwing2/README =================================================================== --- trunk/octave-forge/extra/nlwing2/README 2008-06-22 13:40:59 UTC (rev 5132) +++ trunk/octave-forge/extra/nlwing2/README 2008-06-22 21:00:08 UTC (rev 5133) @@ -1,7 +1,10 @@ -coordinate system -x : streamwise +Global coordinate system +-------------------------------------------------------------------------------- + +The spatial coordinates are bound to the aircraft: +x : frontal y : vertical -z : spanwise left +z : spanwise left (horizontal) ^ ____ y |/ / @@ -16,27 +19,60 @@ \_\_\ \ z \| - -Flow control spanwise quantity is g_i, defined as gamma_i/c_i, -i.e. local circulation divided by local chord length (= approximately local cl). +x-y is the wing symmetry plane, while the wing lies along z axis. The origin is +the center of the wing. -An inner product is defined on the linear space of all g_i vectors, defined as -g*g' = sum g_i*g'_i * dz_i +Physics +-------------------------------------------------------------------------------- +The method is based on approximation the flowfield around the wing by the +potential flow induced by an ensemble of horseshoe vortices, with bound +segments aligned along the wing's centerline, and the free segments shedding +in the streamwise direction. Their strengths, i.e. circulations, are unknown +and need to be determined using the flow equations. With known strengths, +the flowfield velocity can be calculated at an arbitrary point using +Biot-Savart law. -The equation to be satisfied locally is -+-------------------------------------------------------+ -| rho * v * gamma = 1/2 * rho * v^2 * cl * c | -+-------------------------------------------------------+ +The control (unknown) spanwise quantity on i-th vortex is + +---------------------+ + | g_i = gamma_i/c_i | (1) + +---------------------+ +where gamma_i is the circulation and ch_i is local chord length (this gives +approximately local cl). +The flow equation to be satisfied locally follows from expressing +the lift created on a particular section in two ways: +from the Kutta-Joukowski law (the left-hand side) and +using the 2D section data (the right-hand side) + +-------------------------------------------------------+ + | rho * v * gamma = 1/2 * rho * v^2 * cl * c | (2) + +-------------------------------------------------------+ + giving -+----------------------------+ -| g = v * cl / 2 | -+----------------------------+ + +----------------------------+ + | g = v * cl / 2 | (3) + +----------------------------+ -cl = cl(alfa) -alfa = atan(vy/vx) -v = sqrt(vx^2 + vy^2) +where + +--------------------------+ + | cl = cl(alfa) | + | alfa = atan(vy/vx) | (4) + | v = sqrt(vx^2 + vy^2) | + +--------------------------+ +Numerics +-------------------------------------------------------------------------------- +Using Biot-Savart law, it is possible to express the induced velocity at each +collocation point caused by unit circulation on each vortex, thus obtain the +"influence" tensor. Thus, from g_i, vx_i and vy_i are obtained by applying +appropriate influence matrices. atan(vy_i/vx_i) then gives alfa_i - see (4) +(at this point, nonlinearity is introduced). cl_i is then obtained from alfa_i +by interpolating the provided 2D section data (a combination of spanwise and +angle-wise interpolation is used). Finally, (3) closes the cycle, arriving +at g_i again. +In this fashion, for any global angle of attack we obtain a system of nonlinear +equations. This parametric system is solved by starting at a low angle of attack +and tracking the nonlinear solution to higher angles while possible, using a +predictor-corrector strategy. Deleted: trunk/octave-forge/extra/nlwing2/inst/ppder.m =================================================================== --- trunk/octave-forge/extra/nlwing2/inst/ppder.m 2008-06-22 13:40:59 UTC (rev 5132) +++ trunk/octave-forge/extra/nlwing2/inst/ppder.m 2008-06-22 21:00:08 UTC (rev 5133) @@ -1,35 +0,0 @@ -% Copyright (C) 2008 VZLU Prague, a.s., Czech Republic -% -% Author: Jaroslav Hajek -% -% This file is part of NLWing2. -% -% NLWing2 is free software; you can redistribute it and/or modify -% it under the terms of the GNU General Public License as published by -% the Free Software Foundation; either version 3 of the License, or -% (at your option) any later version. -% -% This program is distributed in the hope that it will be useful, -% but WITHOUT ANY WARRANTY; without even the implied warranty of -% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% GNU General Public License for more details. -% -% You should have received a copy of the GNU General Public License -% along with this software; see the file COPYING. If not, see -% ;. -% - -function ppd = ppder (pp) - -ppd.x = pp.x; -ppd.n = pp.n; -ppd.d = pp.d; - -if (pp.k <= 1) - ppd.k = 1; - pp.P = zeros (size (pp.P, 1), 1); -else - k = ppd.k = pp.k - 1; - ppd.P = dmult (pp.P(:,1:k), k:-1:1); -endif -endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```
 [Octave-cvsupdate] SF.net SVN: octave: [5137] trunk/octave-forge/extra/nlwing2 From: - 2008-06-23 16:51:51 ```Revision: 5137 http://octave.svn.sourceforge.net/octave/?rev=5137&view=rev Author: highegg Date: 2008-06-23 09:51:48 -0700 (Mon, 23 Jun 2008) Log Message: ----------- implement stand-alone polar 'feature interpolation' Modified Paths: -------------- trunk/octave-forge/extra/nlwing2/INDEX trunk/octave-forge/extra/nlwing2/inst/calcwing.m trunk/octave-forge/extra/nlwing2/inst/loadpolars.m trunk/octave-forge/extra/nlwing2/inst/qcalc.m Added Paths: ----------- trunk/octave-forge/extra/nlwing2/inst/combinepolars.m trunk/octave-forge/extra/nlwing2/inst/polppder.m Removed Paths: ------------- trunk/octave-forge/extra/nlwing2/inst/testit.m Modified: trunk/octave-forge/extra/nlwing2/INDEX =================================================================== --- trunk/octave-forge/extra/nlwing2/INDEX 2008-06-23 16:25:11 UTC (rev 5136) +++ trunk/octave-forge/extra/nlwing2/INDEX 2008-06-23 16:51:48 UTC (rev 5137) @@ -1,6 +1,7 @@ nlwing2 >> NLWing2 NLWing2 calcwing + combinepolars corrector floweqj floweq @@ -9,7 +10,7 @@ loadwing makeflow makewing - ppder + polppder predictor qcalc setalfa Modified: trunk/octave-forge/extra/nlwing2/inst/calcwing.m =================================================================== --- trunk/octave-forge/extra/nlwing2/inst/calcwing.m 2008-06-23 16:25:11 UTC (rev 5136) +++ trunk/octave-forge/extra/nlwing2/inst/calcwing.m 2008-06-23 16:51:48 UTC (rev 5137) @@ -86,8 +86,8 @@ flw = flw1; ns++; als{ns} = flw.alfad; - [cls{ns}, cdis{ns}, cds{ns}, cms{ns}, alcs{ns}] = qcalc (flw); - zsep{ns} = max (wing.zc (alcs{ns} > wing.amax)); + [cls{ns}, cdis{ns}, cds{ns}, cms{ns}, ads{ns}] = qcalc (flw); + zsep{ns} = max (wing.zc ((wing.alfa + ads{ns}) > wing.amax)); if (isempty (zsep{ns})) zsep{ns} = NaN; elseif (! wassep) @@ -125,14 +125,22 @@ clq.cdi = cell2mat (cdis); clq.cd = cell2mat (cds); clq.cm = cell2mat (cms); - clq.aloc = cell2mat (alcs); + clq.ad = cell2mat (ads); clq.zsep = cell2mat (zsep); # integral quantities dS = wing.ch .* diff (wing.zac); - clq.clw = dS.' * clq.cl / wing.area; - clq.cdw = dS.' * clq.cd / wing.area; - clq.cdiw = dS.' * clq.cdi / wing.area; + area = wing.area; + if (wing.sym) + area /= 2; + endif + cad = cos (clq.ad); sad = sin (clq.ad); + clq.clw = dS.' * (clq.cl .* cad) / area; + clq.cdiw = dS.' * (clq.cdi .* sad) / area; + clq.cdw = dS.' * (clq.cd .* cad)/ area; + if (wing.sym) + clq.bmw = (dS .* wing.zc).' * (clq.cl .* cad); + endif # TODO: moment calculation Added: trunk/octave-forge/extra/nlwing2/inst/combinepolars.m =================================================================== --- trunk/octave-forge/extra/nlwing2/inst/combinepolars.m (rev 0) +++ trunk/octave-forge/extra/nlwing2/inst/combinepolars.m 2008-06-23 16:51:48 UTC (rev 5137) @@ -0,0 +1,49 @@ +% Copyright (C) 2008 VZLU Prague, a.s., Czech Republic +% +% Author: Jaroslav Hajek +% +% This file is part of NLWing2. +% +% NLWing2 is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this software; see the file COPYING. If not, see +% ;. +% + +% -*- texinfo -*- +% @deftypefn{Function File} {pol =} combinepolars (pol1, pol2) +% Combines two polars to get a specific interpolation. Useful when +% you repeatedly change the chord length at a particular section, +% and you don't want to recalculate each time using different local +% Reynolds number. A good streategy here is evaluate the boundary values +% or a few more and then interpolate. +% @end deftypefn + +function pol = combinepolars (pol1, pol2, c) + d = 1-c; + pol.a0 = c*pol1.a0 + d*pol2.a0; + pol.amax = c*pol1.amax + d*pol2.amax; + pol.clmax = c*pol1.clmax + d*pol2.clmax; + alpha1 = pol1.cl.x; alpha2 = pol2.cl.x; + n = round (c*length (alpha1) + d*length (alpha2)); + in = linspace (0, 1, n); + in1 = linspace (0, 1, length (alpha1)); + in2 = linspace (0, 1, length (alpha2)); + alpha = c*interp1 (in1, alpha1, in) + d*interp1 (in2, alpha2, in); + pol.cl = pchip (alpha, c*ppval (pol1.cl, alpha) + d*ppval (pol2.cl, alpha)); + pol.cld = polppder (pol.cl); + pol.cd = pchip (alpha, c*ppval (pol1.cd, alpha) + d*ppval (pol2.cd, alpha)); + pol.cm = pchip (alpha, c*ppval (pol1.cm, alpha) + d*ppval (pol2.cm, alpha)); + if (isfield (pol1, "z")) + pol.z = c*pol1.z + d*pol2.z; + endif +endfunction Modified: trunk/octave-forge/extra/nlwing2/inst/loadpolars.m =================================================================== --- trunk/octave-forge/extra/nlwing2/inst/loadpolars.m 2008-06-23 16:25:11 UTC (rev 5136) +++ trunk/octave-forge/extra/nlwing2/inst/loadpolars.m 2008-06-23 16:51:48 UTC (rev 5137) @@ -44,7 +44,7 @@ pol.a0 = a0; pol.amax = amax; alpha = (alpha - a0) ./ (amax - a0); pol.cl = pchip (alpha, dat(:,2)); - pol.cld = ppder (pol.cl); + pol.cld = polppder (pol.cl); pol.cd = pchip (alpha, dat(:,3)); pol.cm = pchip (alpha, dat(:,4)); elseif (iscellstr (pn)) @@ -58,18 +58,3 @@ endif endfunction - -% assistant function -function ppd = ppder (pp) - ppd.x = pp.x; - ppd.n = pp.n; - ppd.d = pp.d; - - if (pp.k <= 1) - ppd.k = 1; - pp.P = zeros (size (pp.P, 1), 1); - else - k = ppd.k = pp.k - 1; - ppd.P = dmult (pp.P(:,1:k), k:-1:1); - endif -endfunction Added: trunk/octave-forge/extra/nlwing2/inst/polppder.m =================================================================== --- trunk/octave-forge/extra/nlwing2/inst/polppder.m (rev 0) +++ trunk/octave-forge/extra/nlwing2/inst/polppder.m 2008-06-23 16:51:48 UTC (rev 5137) @@ -0,0 +1,37 @@ +% Copyright (C) 2008 VZLU Prague, a.s., Czech Republic +% +% Author: Jaroslav Hajek +% +% This file is part of NLWing2. +% +% NLWing2 is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this software; see the file COPYING. If not, see +% ;. +% + +% @deftypefn{Function File} {ppd =} polppder (pp) +% Differentiates a piecewise polynomial structure. +% @end deftypefn +function ppd = polppder (pp) + ppd.x = pp.x; + ppd.n = pp.n; + ppd.d = pp.d; + + if (pp.k <= 1) + ppd.k = 1; + pp.P = zeros (size (pp.P, 1), 1); + else + k = ppd.k = pp.k - 1; + ppd.P = dmult (pp.P(:,1:k), k:-1:1); + endif +endfunction Modified: trunk/octave-forge/extra/nlwing2/inst/qcalc.m =================================================================== --- trunk/octave-forge/extra/nlwing2/inst/qcalc.m 2008-06-23 16:25:11 UTC (rev 5136) +++ trunk/octave-forge/extra/nlwing2/inst/qcalc.m 2008-06-23 16:51:48 UTC (rev 5137) @@ -20,19 +20,17 @@ % % -*- texinfo -*- -% @deftypefn{Function File} {[cl, cdi, cd, cm, alc] =} qcalc (flow) +% @deftypefn{Function File} {[cl, cd, cm, ad] =} qcalc (flow) % Calculates local spanwise quantities for a given flow state. % @table @var % @item cl % local lift coefficient -% @item cdi -% local induced drag coefficient % @item cd -% local viscous + induced drag coefficient +% local viscous drag coefficient % @item cl % local moment coefficient % @item cm -% local effective angle of attack +% local flow twist (difference of local induced angle of attack and global angle of attack) % @item alc % @end deftypefn @@ -42,11 +40,10 @@ vy = flow.vyg*flow.g + flow.vy0; % local angles of attack alfa = atan2 (vy, vx); - alc = alfa; + alc = alfa - flow.alfa; % interpolate local lifts wing = flow.wing; cl = spwinterp (alfa, wing, [wing.pol.cl]); - cdi = cl .* sin (flow.alfa - alfa); cd = cdi + spwinterp (alfa, wing, [wing.pol.cd]); cm = spwinterp (alfa, wing, [wing.pol.cm]); endfunction Deleted: trunk/octave-forge/extra/nlwing2/inst/testit.m =================================================================== --- trunk/octave-forge/extra/nlwing2/inst/testit.m 2008-06-23 16:25:11 UTC (rev 5136) +++ trunk/octave-forge/extra/nlwing2/inst/testit.m 2008-06-23 16:51:48 UTC (rev 5137) @@ -1,14 +0,0 @@ -[ac, pn, ref] = loadwing ('cesar_wing'); -pols = loadpolars (pn); -wing = makewing (ac, pols, ref, 64); - -#AC = [wing.xac wing.yac wing.zac]; -#CP = (AC(1:end-1,:) + AC(2:end,:))/2; -# -#i = 3; j = 3; -#flw.vyg (i,j) -#vi = horseshoe (AC(j,:), AC(j+1,:), 0, CP(i,:)); -#vi -= horseshoe (-AC(j,:), -AC(j+1,:), 0, CP(i,:)) - -clq = calcwing (wing, "tol", 1e-4); - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```
 [Octave-cvsupdate] SF.net SVN: octave: [5139] trunk/octave-forge/extra/nlwing2 From: - 2008-06-24 12:20:19 ```Revision: 5139 http://octave.svn.sourceforge.net/octave/?rev=5139&view=rev Author: highegg Date: 2008-06-24 05:19:17 -0700 (Tue, 24 Jun 2008) Log Message: ----------- revamp induced drag computation Modified Paths: -------------- trunk/octave-forge/extra/nlwing2/inst/calcwing.m trunk/octave-forge/extra/nlwing2/inst/makewing.m trunk/octave-forge/extra/nlwing2/inst/qcalc.m Added Paths: ----------- trunk/octave-forge/extra/nlwing2/ChangeLog Added: trunk/octave-forge/extra/nlwing2/ChangeLog =================================================================== --- trunk/octave-forge/extra/nlwing2/ChangeLog (rev 0) +++ trunk/octave-forge/extra/nlwing2/ChangeLog 2008-06-24 12:19:17 UTC (rev 5139) @@ -0,0 +1,5 @@ +2008-06-24 Jaroslav Hajek + + * inst/qcalc.m: Remove cdi. + * inst/makewing.m: Automatic span and sym properties. + * inst/calcwing: Revamp cdi calculation. Modified: trunk/octave-forge/extra/nlwing2/inst/calcwing.m =================================================================== --- trunk/octave-forge/extra/nlwing2/inst/calcwing.m 2008-06-23 18:32:11 UTC (rev 5138) +++ trunk/octave-forge/extra/nlwing2/inst/calcwing.m 2008-06-24 12:19:17 UTC (rev 5139) @@ -86,8 +86,8 @@ flw = flw1; ns++; als{ns} = flw.alfad; - [cls{ns}, cdis{ns}, cds{ns}, cms{ns}, ads{ns}] = qcalc (flw); - zsep{ns} = max (wing.zc ((wing.alfa + ads{ns}) > wing.amax)); + [cls{ns}, cds{ns}, cms{ns}, ads{ns}] = qcalc (flw); + zsep{ns} = max (wing.zc ((flw.alfa + ads{ns}) > wing.amax)); if (isempty (zsep{ns})) zsep{ns} = NaN; elseif (! wassep) @@ -122,7 +122,6 @@ clq.alfa = cell2mat (als); clq.cl = cell2mat (cls); - clq.cdi = cell2mat (cdis); clq.cd = cell2mat (cds); clq.cm = cell2mat (cms); clq.ad = cell2mat (ads); @@ -136,7 +135,7 @@ endif cad = cos (clq.ad); sad = sin (clq.ad); clq.clw = dS.' * (clq.cl .* cad) / area; - clq.cdiw = dS.' * (clq.cdi .* sad) / area; + clq.cdiw = -dS.' * (clq.cl .* sad) / area; clq.cdw = dS.' * (clq.cd .* cad)/ area; if (wing.sym) clq.bmw = (dS .* wing.zc).' * (clq.cl .* cad); Modified: trunk/octave-forge/extra/nlwing2/inst/makewing.m =================================================================== --- trunk/octave-forge/extra/nlwing2/inst/makewing.m 2008-06-23 18:32:11 UTC (rev 5138) +++ trunk/octave-forge/extra/nlwing2/inst/makewing.m 2008-06-24 12:19:17 UTC (rev 5139) @@ -93,4 +93,14 @@ if (! isfield (wing, 'area')) wing.area = sum (wing.ch .* diff (wing.zac)); endif + if (! isfield (wing, 'span')) + wing.span = wing.zac(end) - wing.zac(1); + endif + if (! isfield (wing, 'sym')) + wing.sym = true; + endif + if (wing.sym) + wing.area *= 2; + wing.span *= 2; + endif endfunction Modified: trunk/octave-forge/extra/nlwing2/inst/qcalc.m =================================================================== --- trunk/octave-forge/extra/nlwing2/inst/qcalc.m 2008-06-23 18:32:11 UTC (rev 5138) +++ trunk/octave-forge/extra/nlwing2/inst/qcalc.m 2008-06-24 12:19:17 UTC (rev 5139) @@ -34,7 +34,7 @@ % @item alc % @end deftypefn -function [cl, cdi, cd, cm, alc] = qcalc (flow) +function [cl, cd, cm, alc] = qcalc (flow) % calc local velocities vx = flow.vxg*flow.g + flow.vx0; vy = flow.vyg*flow.g + flow.vy0; @@ -44,6 +44,6 @@ % interpolate local lifts wing = flow.wing; cl = spwinterp (alfa, wing, [wing.pol.cl]); - cd = cdi + spwinterp (alfa, wing, [wing.pol.cd]); + cd = spwinterp (alfa, wing, [wing.pol.cd]); cm = spwinterp (alfa, wing, [wing.pol.cm]); endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```
 [Octave-cvsupdate] SF.net SVN: octave: [5142] trunk/octave-forge/extra/nlwing2 From: - 2008-06-26 06:45:22 ```Revision: 5142 http://octave.svn.sourceforge.net/octave/?rev=5142&view=rev Author: highegg Date: 2008-06-25 23:45:29 -0700 (Wed, 25 Jun 2008) Log Message: ----------- fix area and span in makewing Modified Paths: -------------- trunk/octave-forge/extra/nlwing2/DESCRIPTION trunk/octave-forge/extra/nlwing2/inst/makewing.m Modified: trunk/octave-forge/extra/nlwing2/DESCRIPTION =================================================================== --- trunk/octave-forge/extra/nlwing2/DESCRIPTION 2008-06-24 20:15:43 UTC (rev 5141) +++ trunk/octave-forge/extra/nlwing2/DESCRIPTION 2008-06-26 06:45:29 UTC (rev 5142) @@ -1,5 +1,5 @@ Name: NLWing2 -Version: 1.0.0 +Version: 1.0.1 Date: 2008-06-18 Author: Jaroslav Hajek Title: Nonlinear Lifting Line for Wings Modified: trunk/octave-forge/extra/nlwing2/inst/makewing.m =================================================================== --- trunk/octave-forge/extra/nlwing2/inst/makewing.m 2008-06-24 20:15:43 UTC (rev 5141) +++ trunk/octave-forge/extra/nlwing2/inst/makewing.m 2008-06-26 06:45:29 UTC (rev 5142) @@ -90,17 +90,19 @@ for [val,key] = ref wing.(key) = val; endfor + if (! isfield (wing, 'sym')) + wing.sym = true; + endif if (! isfield (wing, 'area')) wing.area = sum (wing.ch .* diff (wing.zac)); + if (wing.sym) + wing.area *= 2; + endif endif if (! isfield (wing, 'span')) wing.span = wing.zac(end) - wing.zac(1); + if (wing.sym) + wing.span *= 2; + endif endif - if (! isfield (wing, 'sym')) - wing.sym = true; - endif - if (wing.sym) - wing.area *= 2; - wing.span *= 2; - endif endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```