|
Example - Ejection Seat
* The "\" symbol has been used at the end of lines to indicate that the line was too long for the display and has been
wrapped to the line below in order to fit within the width of the web page. These lines would need to be joined in the normal
program editor.
I. Introduction
This program models the ejection of a pilot from a jet plane. If the ejection is performed with inappropriate parameters (angle of ejection, speed of plane etc) then the pilot will fail to eject clear of the aircraft. The simulation uses a finite element array.

II. Mathematics Involved
This simulation keeps track of three values during the simulation, the x and y coordinates of the position of the pilot relative to the aircraft, and the horizontal speed of the pilot relative to the surrounding air. It is assumed that the vertical speed of the pilot relative to the air is the same as the vertical speed of the pilot relative to the aircraft. The three values (or attributes) of the simulation are called x, y and x2, where x2 represents xa , the position of the pilot relative to the surrounding air and whose first order derivative is the value of interest.
Throughout the simulation the accelerating force due to the ejection mechanism is taken into account. This acceleration is assumed to be constant. The horizontal and vertical components of it are calculated using simple trigonometry,
and 
where m is the mass of the pilot and ejector seat, F is the ejecting force and θ is the angle of ejection.
The second force that is considered is drag due to air resistance, which is assumed to be proportional to the square of velocity relative to the air. The horizontal and vertical components of these are calculated using similar formulae,
and  
The third consideration in the simulation is that the speed of the pilot relative to the air changes drastically when the pilot leaves the aircraft. Before that point the pilot's speed relative to the air is equal to the pilot's speed relative to the aircraft. After the pilot leaves the aircraft the speed relative to the air has to be adjusted by an amount equal to the aircraft's speed relative to the air.
Finally it should be noted that sign changes are used in some places to ensure that the direction of the various forces are consistent with each other.
III. How the Program Works
Initially the program allows the user to enter a choice of parameters. When the user clicks the button to start the simulation a procedure is called, which creates an object of type FiniteElmtArray and sets formulae in it which are based on the parameters specified.
SUB simulate(frm AS form)
DIM f AS finiteelmtarray
DIM x AS finiteelmtattribute
DIM x2 AS finiteelmtattribute
DIM y AS finiteelmtattribute
DIM xconst$
DIM yconst$
DIM aeroconst$
DIM constasstring$
DIM fc AS formcontrol
DIM pixperm%%
DIM xbase%%
DIM ybase%%
DIM x%,y%,y1%
' get the (constant) part of the x and y acceleration as a string
xconst$ = constasstring$( - (ejectforce% / mass%) * COS (ejectangle% \
* ( PI / 180)))
yconst$ = constasstring$((ejectforce% / mass%) * SIN (ejectangle% * (\
PI / 180)))
' and the drag constant
aeroconst$ = constasstring$(aeroconst% / mass%)
SET x = f.attributes.add("x")
SET x2 = f.attributes.add("x2")
SET y = f.attributes.add("y")
x.order = 2
x.setformula(xconst$ + "-" + aeroconst$ + "* x2(1) * sgn(x2(1)) * sqr\
(x2(1)*x2(1) + y(1)*y(1))",2)
x.allowableerrorfactor = 0.005
x2.order = 1
x2.setformula("if(y(0) < 1,x(1),x(1) + " + constasstring$(vel%) + ")"\
,1)
x2.allowableerrorfactor = 0.005
y.order = 2
y.setformula(yconst$ + "-" + aeroconst$ + "* y(1) * sqr(x2(1)*x2(1) +\
y(1)*y(1))",2)
y.allowableerrorfactor = 0.005
The x and y attributes have a formula set for their second order derivatives, since the accelerating force acting on the pilot in the horizontal and vertical directions is simply a sum of the accelerating forces caused by the ejector and that caused by drag. The x2 attribute that is used to give the speed relative to the air of the pilot has a formula set for the first order derivative. The value taken depends on the y position of the pilot and is either the speed of the pilot relative to the aircraft, or the sum of the speed of the pilot relative to the aircraft and the speed of the aircraft relative to the air. It would be possible to remove the x2 attribute and replace references to it in the other formulae by an expression based on the formula for x2 , but it is simpler, clearer and faster to introduce x2 as an intermediate value.
Performing the simulation is simply a case of advancing the time of the system in reasonable increments and noting the position of the pilot.
CLS
pixperm%% = 800 / 15
IF (pixperm%% > 600 / 10) THEN
pixperm%% = 60
END IF
xbase%% = 600
ybase%% = 520
WHILE ((f.x(0) > - 10) AND (f.x(0) < 5) AND (f.y(0) > - 2) AND (f.y\
(0) < 8))
SET fc = frm.controls.add("","Ellipse")
fc.forecolor = 9
x% = xbase%% + (pixperm%% * f.x(0)):y% = ybase%% - (pixperm%% * f\
.y(0))
fc.move(x%,y%,10,10)
IF ft%% = 0 THEN
SET fc = frm.controls.add("Imagex","Image")
fc.Move(x%,y% - 40,40,40)
fc.SetImage("jumper2.bmp",1)
ELSE
SET fc = frm.Imagex
IF ft%% = 1 THEN
fc.SetImage("jumper2.bmp",1)
END IF
END IF
ft%% = ft%% + 1
fc.Move(x%,y% - 40,40,40)
frm.pages.page1.setdirtyrect(x%,y% - 40,xbase%% + 40,ybase%%)
f.advanceto(f.t + 0.025)
frm.refresh()
WEND
y1% = superbase.form.imagex.top
IF y1% < 315 THEN
x% = xbase%% + (pixperm%% * f.x(0))
IF x% < 1 THEN x% = 60
y% = ybase%% - (pixperm%% * f.y(0))
SET fc = frm.Imagex
fc.SetImage("parachut.bmp",1)
fc.Move(x%,y% - 80,60,100)
frm.refresh()
ELSE
x% = xbase%% + (pixperm%% * f.x(0))
IF x% < 1 THEN x% = 60
y% = ybase%% - (pixperm%% * f.y(0))
SET fc = frm.Imagex
fc.SetImage("splat.bmp",1)
fc.Move(180,370,50,50)
frm.refresh()
END IF
ft%% = 1
END SUB
|