From a872c403895a45113745a092c83134fe05f43921 Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 13 Dec 1999 21:43:41 +0000 Subject: [PATCH] Updates from Tony. --- src/FDM/LaRCsim/c172_aero.c | 63 ++++++++++++++++++++----------------- src/FDM/LaRCsim/c172_gear.c | 2 +- src/FDM/LaRCsim/c172_main.c | 19 +++++------ 3 files changed, 46 insertions(+), 38 deletions(-) diff --git a/src/FDM/LaRCsim/c172_aero.c b/src/FDM/LaRCsim/c172_aero.c index 0e0fae67c..04da35502 100644 --- a/src/FDM/LaRCsim/c172_aero.c +++ b/src/FDM/LaRCsim/c172_aero.c @@ -145,7 +145,7 @@ void aero( SCALAR dt, int Initialize ) { static int init = 0; - static int flap_dir=0; + static int fi=0; static SCALAR lastFlapHandle=0; static SCALAR Ai; @@ -155,6 +155,7 @@ void aero( SCALAR dt, int Initialize ) { static SCALAR CLtable[NCL]={-0.22,0.25,1.02,1.252,1.354,1.44,1.466,1.298,0.97}; static SCALAR flap_ind[Ndf]={0,10,20,30}; + static SCALAR flap_times[Ndf]={0,4,2,2}; static SCALAR dCLf[Ndf]={0,0.20,0.30,0.35}; static SCALAR dCdf[Ndf]={0,0.0021,0.0085,0.0191}; static SCALAR dCmf[Ndf]={0,-0.0654,-0.0981,-0.114}; @@ -252,51 +253,57 @@ void aero( SCALAR dt, int Initialize ) { if(Flap_handle < flap_ind[0]) { - Flap_handle=flap_ind[0]; + fi=0; + Flap_handle=flap_ind[0]; + lastFlapHandle=Flap_handle; Flap_Position=flap_ind[0]; } - else if(Flap_handle > flap_ind[3]) + else if(Flap_handle > flap_ind[Ndf-1]) { - Flap_handle=flap_ind[3]; - Flap_Position=flap_ind[3]; + fi=Ndf-1; + Flap_handle=flap_ind[fi]; + lastFlapHandle=Flap_handle; + Flap_Position=flap_ind[fi]; } else { - - if((Flap_handle != lastFlapHandle) && (dt > 0)) + if(dt <= 0) + Flap_Position=Flap_handle; + else { - Flaps_In_Transit=1; - - } - else if(dt <= 0) - Flap_Position=Flap_handle; - - lastFlapHandle=Flap_handle; - if((Flaps_In_Transit) && (dt > 0)) - { - if(Flap_Position < 10) - flap_transit_rate = 2.5; - else - flap_transit_rate=5; - + if(Flap_handle != lastFlapHandle) + { + Flaps_In_Transit=1; + } if(Flaps_In_Transit) { + fi=0; + while(flap_ind[fi] < Flap_handle) { fi++; } if(Flap_Position < Flap_handle) - flap_dir=1; + { + if(flap_times[fi] > 0) + flap_transit_rate=(flap_ind[fi] - flap_ind[fi-1])/flap_times[fi]; + else + flap_transit_rate=(flap_ind[fi] - flap_ind[fi-1])/5; + } else - flap_dir=-1; - + { + if(flap_times[fi+1] > 0) + flap_transit_rate=(flap_ind[fi] - flap_ind[fi+1])/flap_times[fi+1]; + else + flap_transit_rate=(flap_ind[fi] - flap_ind[fi+1])/5; + } if(fabs(Flap_Position - Flap_handle) > dt*flap_transit_rate) - Flap_Position+=flap_dir*flap_transit_rate*dt; - - if(fabs(Flap_Position - Flap_handle) < dt*flap_transit_rate) + Flap_Position+=flap_transit_rate*dt; + else { Flaps_In_Transit=0; Flap_Position=Flap_handle; } } - } + } + lastFlapHandle=Flap_handle; } if(Aft_trim) long_trim = long_trim - trim_inc; diff --git a/src/FDM/LaRCsim/c172_gear.c b/src/FDM/LaRCsim/c172_gear.c index df3a44855..9bb23952d 100644 --- a/src/FDM/LaRCsim/c172_gear.c +++ b/src/FDM/LaRCsim/c172_gear.c @@ -36,7 +36,7 @@ $Header$ $Log$ -Revision 1.12 1999/12/08 18:48:55 curt +Revision 1.13 1999/12/13 20:43:41 curt Updates from Tony. diff --git a/src/FDM/LaRCsim/c172_main.c b/src/FDM/LaRCsim/c172_main.c index 919dc793f..67e3944b5 100644 --- a/src/FDM/LaRCsim/c172_main.c +++ b/src/FDM/LaRCsim/c172_main.c @@ -317,7 +317,7 @@ int main(int argc, char *argv[]) { IC.psi=0; IC.weight=2400; IC.cg=0.25; - IC.flap_handle=30; + IC.flap_handle=10; IC.long_control=0; IC.rudder_pedal=0; @@ -333,15 +333,16 @@ int main(int argc, char *argv[]) { altmin=Altitude; printf("\tAltitude: %g, Theta: %g, V_down: %g\n\n",Altitude,Theta*RAD_TO_DEG,V_down); - printf("%12s %10s %10s\n","Alpha (deg)","Alpha","Drag"); - for(i=-5;i<=22;i++) + while(time < 5.0) { - IC.alpha=i; - setIC(IC); - ls_loop(0,-1); - printf("%12f %10f %10f\n",Alpha*RAD_TO_DEG,Alpha,cd); - } - + printf("Time: %g, Flap_handle: %g, Flap_position: %g, Transit: %d\n",time,Flap_handle,Flap_Position,Flaps_In_Transit); + if(time > 2.5) + Flap_handle=20; + else if (time > 0.5) + Flap_handle=20; + ls_update(1); + time+=0.01; + }