Real-Time Missile Guidance System
Real-Time Missile Guidance System
RANDOM 4.
ACCESS
MEMORY
ALGNMENT AUTOPLOT 49
FUNCTON FUNCION READ 42
ONLY
NAVIGATION GUIDANCE MEMORY
FUNCTION FUNCTION 51 43
FLOATING-PONT
COPROCESSOR
26
23--- - -
22- - -
21 - - -
FIG 1
U.S. Patent July 25, 1995 Sheet 2 of 7 5,435,503
U.S. Patent July 25, 1995 Sheet 6 of 7 5,435,503
WHOA
GUIDANCE
(A)
61 69
YES c
E (x)
CONVERGED
NYES
-x-x-xfc NO calculate
ADGN-g(x)
64
NC -- NC- RETURN
K -- 1 7O
YES
65
TRANSFORM MISSILE 76
VELOCITY AND POSITION, NO
AND TARGET INTERCEPT NC NC-1
ATTTUDE AND POSITION, ADG-ADG
TO CONSISTENT UNITS
67
66 REDEFNE 71 RETURN
(a) 74
75
FIG 8 CHECK CONTROL BOUNDARIES
AND CONSTRAN SOLUTION
U.S. Patent July 25, 1995 Sheet 7 of 7 5,435,503
ADJUST
FOR MTS FIG 9
81 82
<> NO
84 85
YES NO MOVE U OFF
BOUNDARY |
SET u =O AND
CALCULATE K
RETURN )
88
YES YES MOVE U ON
BOUNDARY
89 9O
CALCULATE K SET K=O AND
CALCULATE L
92 (Kz O RETURN )
.AND. Liz O) YES
.O.R. (K=O AND.
40) YES
94
SET K=O AND
CALCULATE Ll
SET u =O AND
CALCULATE K
RETURN )
5,435,503
1. 2
The Euler-Lagrange equations are obtained by set
REAL TIME MISSILE GUIDANCE SYSTEM ting the “first variation' of the integral in Equation 4 to
zero. The first variation is found by varying each of the
BACKGROUND OF THE INVENTION functions hi(x) by an amount eiu(x) where ei is an arbi
A. Field of the Invention trary constant independent of X and h(x), and ui(x)
This invention relates to missile guidance, and more denotes any arbitrary function of X which is indepen
particularly to real-time computation of missile guid dent of ei. Then the integral I-8I is defined by:
ance commands for optimal guidance of the missile.
B. Description of the Related Art O tf (Equation 6)
1. General Theoretical Art I - 6 =? Whi(t) + eui(t), ..., hi(t) + eru;(t), ...,idt.
o
a. Calculus of Variations
The basic objective of the calculus of variations is to Upon solving for 6I to obtain a power series expan
find the unknown function which will locate an extre
mum for a definite integral. Ordinary calculus locates sion of ÖI in terms of powers of ei, the “first variation
the extremum for a function of one or more variables.
15 is the coefficient of the term for ei to the first power.
For example: It is still necessary, for the problems of the type in
optimal control, to solve a variational problem with
==Withrz,x,y,u) auxiliary conditions. Now consider that the functionsh;
(Equation 1)
are not independent but restricted by some auxiliary
is a velocity function. This function varies with the 20 conditions. Initially we considered velocity as a func
positions x,y,z, the thrust (thr) and the control variable tion of several variables x, y, z, thr and u. In solving the
u. To find the extremum of the velocity, the first varia definite integral we allowed the integral of velocity to
tion of the velocity equation is used: be several functions of one variable t. Now we will
consider a system composed of several functions of
25 several variables. The auxiliary system functions will be
(Equation 2)
aV portrayed as fi, with the variables as xi and t, creating
82 82 -- aathr
V
8thr a8.V 8.u. the set of equations:
Following it has been shown that the aforementioned f(xii) = 0, (i = 1,mi = 1,n), (Equation 7)
variational relation simplifies to the following set of
equations: with Vh;(x,t) as before. The auxiliary condition on the
integrand creates a problem when the system functions
a y (Equation 3) are not known to be independent. As an expletive, if the
8.
35
System functions were independent, the independent
equations could be expressed under separate integrals as
follows:
tf (Equation 3)
t = ? f(x,t)dt, (i = 1,m) and
o
V
thr
V
al
45
The variables which solve these equations define an From this set of equations would follow m-1 indepen
extremun for velocity. dent Euler-Lagrange equations. However, since it is not
As noted earlier, it is the extremum of a definite inte known that the functions are independent, knowledge
gral which is formally in the domain of the calculus of of the other relationships is required. Using a Lagrange
variations. Using another function for velocity provides 50 multiplier, the previously assumed independent equa
the example: tions may be expressed as dependent equations under
the same integral as:
tf (Equation 4)
Is ? Vh1(t), h2(t), . . . hi'(t), h(t), ...,tdt. tf (Equation 9)
o 55 8 st ? (ÖV -- A1&f -- . . . An 8f)di = 0.
to
In lieu of an extremum for a function, an extremun
for a definite integral is found. And in lieu of finding the A solution set utilizing the Euler-Lagrange equations
appropriate variables, the appropriate functions (h) are can be shown to be:
found. It has been shown that the necessary and suffi
cient condition for the solution to this type of extremum (Equation 10)
problem can be the solution of the Euler-Lagrange 2 - - d. a y
Al
af
-- . . . -- An
afn = 0.
equations: axi di axi oxi axi
sI(4)-(+)-(+)- a
A =-
add
o
(Equation 9)
-(+)-(+)-(+)-cis 50 A.
f=-
d (Equation 20)
(Equation 24-1)
fk + j k - -A- f= 0; j = 1, number of phases (nph)
1 1 1; k = 1, number of states (ns)
(Equation 24-2)
f* - -A-fk + jk - --fc = 0. i = 1, if of elements in
i i i + 1 i - l; a phase - 1 (ne(j) - 1)
(Equation 24-3)
(Equation 24-4)
(Equation 24-5)
2 d
i -- 1 jk jk i -- 1 jk j
i -- 1 i -- 1 i -- i --
- - - T M
(Equation 24-6)
frk -- A2 d t +-22a. f^k + F- = 0
ne(i) jk jk nei) jk j jk
ne(j) ne(j) ne(j) ne(i) 2
aL3. -- 9au : 2G p"2-n
= 0; i -
= 1, if element in
G+ K2 = 0 (Equation 24-9)
j j
i i
6+ k2 = 0 (Equation 24-10)
j j
i i
A. ad T
ak -
(Equation 24-13)
f^k + aik -- v a3k T
1 j J
1
A ad ak (Equation 24-14)
jk + i + v i =
- T -
2 j J
2 2
f =0 (Equation 24-15)
In accordance with an aspect of the present inven- -continued
tion, the control variables (up) include a set of control d = arctan(A3/A2)
variables functionally related to the angle of attack (a)
and bank angle (d) in such a way that convergence 25 The inverse transformation is:
problems are avoided when the angle of attack is ap
proximately zero. When the angle of attack (a) and (Equation 27)
bank angle (d) are used as two of the control variables g = tana - N p, g?
(uk), there are convergence problems in the iterative
solution procedure. These convergence problems arise 30 A = Acosdb
A3 = gsind
when the angle of attack (a) is approximately zero, db = arccos(32/3) = arcsin(33/13)
because the bank angle (d) may assume any value when
angle of attack (a) is zero. To solve these convergence It is also convenient to define an intermediate vari
problems, at least two control variables are used that are able (3 such that:
related to the angle of attack (a) and the bank angle (g) 35
by a predefined mathematical transformation of vari As2 = cosdbtana. (Equation 25)
ables such that the two control variables assume appro As3 = sindstana.
priate values for typical flight characteristics of the
missile. Moreover, because the guidance function does The control variables are used in the state equations
not directly sense the actual values of the angle of attack 40 of the missile, and in particular are related to forces in
(a) or the bank angle (3), nor does the guidance func the equations of motion for the missile. The forces along
tion directly control the angle of attack (a) or the bank the missile body axes are given by:
angle (3), the two control variables related to the angle
of attack (a) and the bank angle (3) are more precisely (Equation 28)
referred to as "virtual' control variables. 45
Thrust - Drag
The angle of attack is shown in FIG. 6 in relation to Fody = Lift
the body axes (b1b2, b3) of the tactical missile 20. The O
b body axis is the longitudinal axis of the missile 20.
The angle of attack (a) is defined as the total angle
between the longitudinal axis (b1) of the missile and the 50 It is convenient to define a 3x3 transformation matrix
relative wind vector rw. The relative wind vector is the Cwb) between the wind frame and the missile body
velocity of the wind relative to the missile. Therefore, frame, and a 3x3 transformation matrix Cw between
when the velocity of the missile with respect to an the wind frame and the local inertial frame. Then the
inertial frame greatly exceeds the velocity of the wind forces originating in the inertial frame are due to the
with respect to an inertial frame, the relative wind vec 55 mass (m) of the missile and the acceleration (g) due to
tor will become approximately anti-parallel to the ve gravity:
locity vector of the missile, and the angle of attack (a)
will become relatively small. (Equation 29)
The bank angle (b) is shown in FIG. 7. The bank 0.
angle (dB) is the angle of the relative wind vector rw Fravity = 0
with respect to the -b1 body axis of the missile 20. Ing
The preferred set of control variables are 32 and g3
such that:
The forces in the wind frame are therefore given by:
(Equation 26) 65
a = arctan \ 622 + 63? Find = (Cwb) Fody + (Cwl) Fravity (Equation 30)
5,435,503
17 18
The matrix Cwb) is a function f(a,100) of the angle of i=1,2,3, is defined to be fixed in W, and we write the
attack (a) and the bank angle (db) according to: associated direction cosine matrix
CwB=f(a,d) (Equation 31) Cij= widi (34-3)
Equation 24-7 and 24-8 above, however, can be satisfied in terms of Rodrigues parameters so that
with a negative eigenvalue for the optimality condition
when a st0. The eigenvalues of the optimality condition
are eigenvalues of the matrix (34-4)
- AT -- A.T
O
C=
(-4 97), 44 9T3 - 6
i = 1, # controls (Equation 32)
a Hk j = 1, # controls
1 + i.1. 979
auiaui
k = 1, it states
5
where CCT-CTC=I, the 3x3 identity matrix, and
where; H = Alf -- L -- 2To
34-5
81 O -63 62 (34-5)
A negative eigenvalue indicates that the solution con
verges upon a stationary point other than the desired e = 62 6- 63 O -6
extremum. Another formulation that has a negative 83 -82 (91 O
eigenvalue is Cwb) = f(a1, a2), where a1 is a “vertical'
angle of attack, and a2 is a “horizontal' angle of attack. Since there are three 6 and we only need two parame
Negative eigenvalues are avoided by the "tangent vari ters, we will need to constrain 6. We choose to do so
able' formulation such that:
with a nonholonomic constraint on the angular velocity
25 below.
(Ecuation 53
g2 = g22 + 332 Equating expressions for V from Eqs. (34-1) and
CWB = f(g,62,83) where: £3 = cosdbtance (34-2), and using (34-3), we obtain three kinematical
A3 = sindbtan cc
equations of the form
30 i=uwai (34-6)
A set of equations governing the motion of the missile or, in matrix form
20 is needed for trajectory optimization. It is assumed i=uCTel (34-7)
that the missile 20, represented as a rigid body M, is
moving in an inertial frame A subject to inertial, aero 35
where
dynamic, and body forces. The inertial properties of M
are idealized to be those of a particle M* of mass m. The (34-8)
gravity force at M is mgk, where k is a unit vector
directed vertically downward. The geometry of M is
axisymmetric, and the aerodynamic forces acting at M*
can be characterized in terms of a frame B in which the
unit vector b1 is fixed, parallel to the axis of M, and in
which the direction of V, the velocity of M* in A, is Denoting the angular velocity of W in A by cy, we let
known. Thus, the aerodynamic forces consist of an axial
force (T-DOb1 and a lift force Lin, where n is normal to 45
b1 and parallel to the plane which contains b1 and V. (34-9)
The quantities D and L are known functions of v=v) c)
and a, the angle between V and b1; T is a known func 2.
tion of time. (In the degenerate case for which V is c3
parallel to b1, L=0. Note that the frame B, in which b1 50
is fixed, is not a body-fixed frame. The missile is free to
spin about its axis in B.) Initial conditions affect only the where co1=a).Wi. Based on Eq. (26-4), one can show
initial position and velocity of M in A. that
First, we define a point 0 and a dextral triad ai, for
is 1,2,3, all fixed in A. Letting p denote the position 55 (34-10)
vector of M* relative to 0 and x=p-ai, we can form the
velocity of M in A as
V=k1a1+:2a2-isa3 (34-1)
Denoting the unit vector tangent to the path of M* as 60
w1 we can also write the velocity as the inverse of which is given by
(34-11)
duce an intermediate frame Wassociated with the path We need the acceleration of M*, which can be writ
of M* and in which V is fixed. A dextral triad wi, for ten as the inertial time derivative of uw so that
19
5,435,503
20
This concludes the definition of all kinematical quan
A = w + vo X w. (34.12) tities needed to express the equations of motion.
The equations of motion can be written in accordance
with Newton's second law
Finally, we need to define the relationship between B F=ma (35-1)
and A to define the aerodynamic forces. We will actu
ally work in terms of relating B to W, but first W must where, if k is taken as parallel to as, the active force
be well defined. We will set col=0, which non resultant acting at M is given by
holonomically constrains the set of coordinates 6. This 10
way the orientation of frame W is governed only by the
path of M*, and only the orientation of b1 and the lift Introducing the column matrix of force components in
force need to be defined relative to W. the W system
As with pointing the velocity vector in A, we only 15
need two parameters to accomplish this: the angle of (35-3)
attack a and the "bank” angle d to orient the plane in W Fl
which contains the missile axis. Let B be tentatively F - F2
oriented so that bi coincides with wi for i=1,2,3. Now, F3
to get to the final orientation, we rotate Babout b1 by an 20
angle db. Next, rotate B about bi by an angle a. This
brings b1 into alignment with the axis of M during flight, where Fis [Link] so that
and the lift is assumed to act along b2. Thus, (34-13)
F = mgCl3+ (IP) - LE=- (35-4)
25 \ 2 \ , , e.
b coso sino. 0 1 O O w
b2 = -sina cosa 0 || 0 cosd sind w2 F2 = mgC23 + (T - DB2 -- - E
b3 O O 1 || 0 -sind cosd '3 le: e\ 62
cosa cosdbsina sindbsina. w
30 F, - mgcs + 2g; + -6\ E =
162
- -sina cosqbcosa sindbcosa. w2.
O -sing costs w3 and taking the dot product of Eq. (35-1) with will, and
making use of Eqs. (34-12) and (35-4), one obtains three
35 equations of motion of the form
Now, to avoid convergence difficulties created by the
vanishing of a in which db then becomes undefined, we
introduce two variables (32 and 33 such that
A2=cos distan a 40
-nuo2=F3 (35-5)
f33=sin d tan a (34-14)
Eqs. (35-5b) and (35-5c), along with the definition of c)
so that and the constraint this col=0,
45
g2=622-632=tana. (34-15)
o) = - 1F (35-6)
Thus,
The system equations can now be written as a system
(34-16) 50 of seven first-order ordinary differential equations. The
b1 three equations embodied in Eq. (34-7) are already in a
b2 = matrix form. Eq. (35-5a) is one scalar equation. Finally,
b3 Eqs. (34-11) and (35-6) can be written as one matrix
equation. Thus, the system equations are
55
- -- - - - i: = uCTel (36-1)
\ , i.e. \ , , e. \ 1 e2 w = - e, TF
-B B2 A3 w2.
\ 1- 2 e\ 1 2 e\ 1 - 2 '3 60
O -£83
As
f32
B 8 --- 1-a-, - AAT
= (1 + +G++ dor) if
When combined with the expressions for the force and where Fi is given by Eqs. (35-4). Control variables g2
with the () operator notation introduced below, an 65 and g3 can be used to determine the trajectory of M*.
orientation description such as embodied in Eq. (34-16) Eqs. (35-4) appear to be quite complex. The reason
should be free of convergence difficulties when a and g for the complexity is, at least in part, related to the fact
vanish. that L and D are functions of a while (3 appears explic
5,435,503
21 22
itly in the coefficients of L and D, as well as that of T. in the vicinity of g=0 every time there is differentiation
To circumvent this, L and D can be expressed in terms with respect to one of the control variables.
of 6 instead. All explicit 6 dependence can be grouped The first derivative of any even function of 6 will be
into implicit functions which can be splined or approxi odd, but its first derivative divided by 6 will be even.
mated as a series. One way to do this is to introduce Motivated by this observation, the following notation is
introduced: ()*=()'/g such that ()' = a()/ag. Now,
D=HucA
L= Lucy (37-1)
O
o' =--Or:
a- C" =--- r" - a
a-C," =- (37-7)
where
and so forth for higher derivatives
pSA (37-2)
p =- (37-8)
15 o** = -(2-
g = -l-
g - Cg -
and where CN and CA are considered functions of £3 and
Mach number. Thus, the force components become
(37-3) C."kk ---(C)a----- ( Cag )
F.1 = ngul3
C3 -- T uv°CA |LucNf3 20
- - - see - E
\ , , e. N a e.
C."... -- - A ---- i?( ga )
F2 = mgC23 +
2 se mon T(32 uu’CA62 --
anawaaaaaa- uu’CNf32
---
6 - Pg -
ag2
(37-6) 82F (37-13)
60 se2
which will have the effect of introducing indeterminate
forms
which are well behaved in the limit of small (3. In fact,
65 Fi and all their first and second derivatives with respect
to £32 and 63 are also well behaved, as has been demon
strated by Mathematica 5 computations. For 6=0 it can
be shown that
5,435,503
23 24
time to the end-of-phase, taph; and the time to the end
a?Fy (37-14) of-flight, tigo. An initial solution vector XFCC is down
-
afésaf3n . = 0 8, n, and yy =
n, and = 22 an
and 3 loaded into the guidance processing unit (21 in FIG. 3)
from a fire control computer (not shown) external to the
while missile. ECX) is the vector used in Equations 21 to 23
above and which contains the residuals from the equa
a2F 37.15
(37.15) tions when the equations are evaluated with the vector
af320A3 p=0 Xji.
The variable NC is the cycle counter. NC is initial
and 10 ized to zero, and NC is incremented every time that the
(37-16)
WHOA optimal guidance routine is called. The variable
'k' is a Newton-Raphson iteration counter, which is
E;
agile-0 ag3 8-0 reinitialized before the Newton-Raphson iteration
scheme is called each cycle. The variable "kna, is the
15
where the fact that Q(0)= -1 is used. maximum value number of Newton-Raphson iterations
If H is the Hamiltonian, and u is the column matrix allowed for convergence. ADG is the acceleration
which contains the control variables (32 and 33, then command vector for the missile. The acceleration com
Hu for this problem becomes a diagonal matrix in the mand vector ADG is the output from the guidance
limit as 6 approaches zero. Both diagonal elements are 2 procedure.
the same and are given by In the first step 61 of FIG. 8, execution branches to
step 62 if NC is zero. In step 62, the solution vector X11
(Huu)11 g=0 = (37-17) is initialized with the solution vector XFCC down
My 2
loaded from the fire control computer. If NC is not
zero, then step 63 is performed, which loads the initial
(Hui).2b-0 = -- (T + w(C.'(0) + 2C,"(0)} 25 solution vector X1NC with the last best solution vector
It is therefore evident that Hu will be positive definite vector for thisthecycle
X1 NC1 from last cycle. Once the initial solution
is obtained in steps 63 or 64, the
in the vicinity of a = 6=0 if A (0. execution continues in step 64.
A specific solution depends on the mass, thrust, gravi
tational, atmospheric, and aerodynamic data. In the 30 In step 64, the cycle counter NC is incremented, and
following data, for example, the thrust is presumed to the iteration counter 'k' is initialized to 1. In step 65, the
have discontinuities at Stage1-time seconds and input units
boundary conditions are transformed to consistent
used by the program. These input boundary condi
Stage2 time seconds after launch. Therefore, it is con
venient to divide the performance integral J into three tions include the missile position and velocity vector as
phases; a first phase from t=0 seconds to 35 well as the desired target intercept position and attitude.
t=Stage1-time seconds; a second phase from In step 66, execution branches to step 67 if it is desirable
t=Stagel-time seconds to t=13 seconds; and a third to re-size the Jacobian. An increase in the number of
phase from t=13 seconds to the time of intercept with elements, for example, increases the precision of the
the target. solution, but also increases the computation time needed
40 for computing a solution and obtaining convergence.
The computation time is dependent on the particular
MASS = F(time): phase of flight. Therefore, it is generally desirable to
weight time
re-size the Jacobian if a flight phase transition occurs. In
300 kg 0.0 sec. step 67, the solution vector [Link] is redefined based
273 .09 X Stage2-time 45
240 .18 X Stage2-time upon the re-sized Jacobian matrix. In step 68, the com
207 .27 X Stage2 time putation of the equation residuals ECXi NC) is done in
200
180
.29 X Stage2-time
4 X Stage2-time
vector form using the proposed solution vector Xk.N.C.
170 .55 X Stage2 time This is the initial step in the Newton-Raphson iteration
160 .69 X Stage2-time 50 loop including the following steps 68 to 75. During each
150 .83 X Stage2 time iteration 'k', the Newton-Raphson iteration loop com
143 .95 X Stage2-time putes a new solution Xk-1NC-1 as a predetermined
140 Stage2 time
solution function S(XkNC) of the last solution XkNC.
THRUST = F(time,ambient condition): The computation of the new solution, however, in
Thrusto = Stage1 thrust Newtons, for: 0-Stagel-time
Thrusto = Stage2 thrust Newtons, for: Stagel-time-Stage2-time 55 volves steps 71, 72 and 73 in addition to the initial step
Aexit = 024 meters squared 68.
Thrust = Thrusto - (ambient pressure) X Aexit Once the equation residuals are defined, they are
validated against convergence criteria, in step 69. The
Turning now to FIG. 8, there is shown a top-level convergence criteria, for example, are specified by a
flowchart of the guidance function (introduced as box 60 vector of predefined error limits, and if any element of
51 in FIG. 4). This flowchart includes a number of the vector of equation residuals ECXkNC) has a magni
variable names and symbols. Xi denotes the solution tude that exceeds it corresponding error limit, then the
vector for the jth cycle and the ith Newton-Raphson solution vector XkWC fails the convergence criteria.
iteration. The solution vector Xi is composed of values Otherwise, if each element of the vector of equation
for the states, x; the costates, A; the Lagrangian multipli- 65 residuals ECXkNC) has a magnitude that is less than its
ers u for the control constraint equations; the slack corresponding error limit, then the solution vector
variables K for the control constraint equations; the XNC passes the convergence criteria, and in step 77, the
controls, u; the boundary condition multipliers v; the acceleration command requisite for optimal flight
5,435,503
25 26
(AGDWC) is computed as a predetermined function dure is performed on each respective set of K, G, u, and
g(XNC) of the converged solution vector [Link]. u values.
If the convergence criteria are not met, then in step In a first step 81 of FIG.9, execution branches to step
70, the Newton-Raphson iteration counter k is com 82 when the computed time to the end of flight (tgok) is
pared againstkmax. This step is used to control the com not greater than zero. In step 82, the time to the end of
putation time used by the procedure. If k is greater than flight tgok for the present iteration 'k' is set equal to the
knac, then an acceleration command vector is computed time to the end of flight for the previous iteration k-1.
either based upon the last best acceleration command When the computed time to the end of flight tgok is
vector or by using a conventional proportional naviga found to be greater than zero in step 81, or after step 82,
tion scheme, depending upon the time-off-light. This is O execution continues in step 83.
done in step 76. In step 83, execution branches depending on the logi
If the Newton-Raphson iteration counter k does not cal value of the proposition “ud0. AND. K=0'. When
exceed the limit "kna, execution continues from step 70 this proposition is true, then execution branches to step
to step 71. In step 71, the Jacobian matrix is updated by 84. Execution branches in step 84 depending on
re-evaluating all of the non-zero elements of the Jaco 5 whether G is greater than or equal to zero. When G is
bian matrix J for the previously-computed solution not greater than or equal to zero, an inequality con
vector XNC. In step 72 the Jacobian matrix is inverted, straint is violated, and execution branches from step 84
and the inverted Jacobian matrix is multiplied by the to step 85. In step 85, the value of the control (u) is
previously-computed solution vector Xk NC in order to moved off of the constraint boundary. The degree to
compute the next delta value AX on the solution vector which the new value of the control (u) differs from its
X. Therefore, in step 73, the new solution vector limit at the control boundary is not critical, and the new
Xk-1NC is computed by subtracting the delta value AX value may be set to a value that differs from its limit by
from the previously-computed solution vector XNCIn an amount proportional to the value of u. Then, in step
step 74 the Newton-Raphson counter, 'k', is incre 86, the discrete Lagrangian multiplier u is set to zero,
mented by one. Then, in step 75, the control constraint 25 and K is calculated based on the value of the control (u)
equations are checked using the control values (u) in the and for u = 0, or example, such that K2=-G(u). Then
new solution vector Xk-1NC. This step is essential to execution returns.
free up the controls (u) to move on and off of control When G is greater than or equal to zero, none of the
boundaries. The Newton-Raphson iteration scheme is constraints are violated. However, in this case, execu
resumed again in step 68, until either the convergence 30 tion branches from step 84 to step 86, because conver
criteria are passed in step 69 or the maximum number of gence can be accelerated in this case by setting u = 0
iterations kna is exceeded in step 70. and calculating K for u =0, for example, such that
Turning now to FIG.9, there is shown a flowchart of K2=-G(u).
a procedure for checking whether control limits are When it is not true that “u0. AND. K=0”, then
exceeded in each iterative solution XkWC, and adjusting 35 execution branches from step 83 to step 87. Execution
the iterative solution when the controls move on or off branches from step 87 depending on the logical value of
a boundary or when a new time solution exceeds the the proposition “KCO. AND. u =0'. When this propo
bounds of realizability. The virtual angle of attack (a), sition is true, execution branches to step 88. In step 88,
for example, should be limited to less than a predeter execution branches depending on whether G is greater
mined value such as 20. This could be done by impos than or equal to zero. When G is found to be less than
ing a constraint involving g2 and S3 such as zero, then execution branches to step 89. In step 89, Kis
tan2(20)-322-g32=G. The limit of 20 represents a calculated from the values of the other parameters, for
constraint boundary for the angle of attack. If the example as K2=-G(u), and execution returns. When
boundary is exceeded, then the constraint can be en G is found in step 88 to be greater than or equal to zero,
forced by either setting the specified value for the angle 45 then execution branches to step 90. In step 90, the con
of attack to 20 or some value less than 20. Sometimes trol (u) is moved on the constraint boundary. Next, in
the constraint is enforced by setting the specified value step 91, K is set to zero and u is calculated for the value
for the angle of attack (a) to the limit of 20, because the of the control (u) and for K=0, for example, by apply
limit value might be optimum. This is a case where a ing Equation 24-7 above. Then execution returns.
control is set on the constraint boundary, in order to SO When step 87 finds that “K(0. AND. L=0” is not
enforce the constraint. Sometimes the constraint is en true, then execution branches to step 92. In step 92,
forced by setting the specified value for the angle of execution branches depending on the logical value of
attack (a) to a value less than 20. In this case, the con the proposition "(K-7.0. AND. uz-0) .OR. (K=0
trol is said to be moved off of the boundary. The proce .AND. u = 0)'. If this proposition is false, then execu
dure of FIG. 9 may also check for solution constraints 55 tion returns. Otherwise, execution branches to step 93.
imposed for the express purpose of manifesting realiza In step 93, execution branches depending on whether
bility thereby accelerating realizable convergence. For G20. When G is greater than or equal to zero, then
example, when it is known that the time step At must be execution branches to step 94. In step 94, K is set to
greater than a certain predetermined amount, then a Zero, u is calculated for K=0, for example by applying
solution constraint can be imposed on At to accelerate Equation 24-7 above, and execution returns. When G is
convergence. less than zero, then execution branches to step 95. In
In general, the procedure in FIG. 9 enforces the con step 95, u is set equal to zero, and K is calculated for
straints k20, u'K=0, GSO, to20 and pu20 in the K=0, for example such that K2=-G(u). Then execu
iterative solution Xi NC. Although a true solution to the tion returns.
system of algebraic equations being solved satisfies the 65 Additional features and advantages of the present
constraints, an iterative solution does not necessarily invention are illustrated in the program listed below in
satisfy the constraints because an iterative solution is Appendix I to the specification. The entry point of the
only a guess at the true solution. Moreover, the proce program is a subroutine Whoa flight. The subroutine
27
5,435,503
28
Whoa flight receives, as an input parameter, a speci a subroutine Eval-cc to check control boundaries and
fied time after launch of the missile. The specified time constrain the solution, and calls a subroutine
is used to determine the thrust of the rocket motor and Evaluate-convergence to check the new solution. The
the weight of the missile, because the thrust and weight : subroutine Newton returns when a converged solution .
are assumed to be predetermined functions of time. The has been found, or after a predetermined number of
subroutine WHOA-flight also receives, as input pa iterations.
rameters, the present vehicle velocity, vehicle position, The subroutine Eval cc calls either a subroutine
and the anticipated final azimuth, final elevation, and Check ccl. to check a single control constraint equa
final position. The subroutine Whoa flight returns a tion, or a subroutine Check-cc2 to check two control
parameter body-guidance cmdC3), which specifies the 10 constraint equations. The subroutine Check-ccl calls a
acceleration in g’s, along each of the three body axes subroutine Eval-bindry cnd1 to evaluate the single
(b1, b2, b3), that the missile should have to be guided boundary condition, and the subroutine Check-cc.2
along an optimal trajectory. calls a subroutine Eval-bindry cn2-to evaluate two
The subroutine Whoa flight first calls a subroutine boundary conditions. These subroutines are specific
Whoal init flight that sets up what needs to be initial 15 examples of programming for the flowchart of FIG. 9,
ized for computing the Hamiltonian in flight. Then the as described above.
subroutine Whoa-flight calls a subroutine Whoal opti A large portion of the program in Appendix I is de
mize to compute an optimal trajectory. If a converged voted to subroutines called by the subroutine Errjac
solution is obtained, or if the time is less than 0.001 and used to fill the Jacobian matrix. A low-level routine
seconds since launch, then the subroutine Whoa flight 20 Get f -g-eqn der, for example, computes the deriva
calls a subroutine Inert-guidance to compute a new tives for the elements of the Jacobian matrix, and also
guidance command. Otherwise, the previous guidance computes the derivative terms appearing in Equation
command is used. In any case, the subroutine Whoal-f- 17.
light is finished. In view of the above, there has been described a weak
The first time that the subroutine Whoa init flight 25 Hamiltonian finite element method for real-time itera
is called, it obtains an initial solution by calling a subrou tive computation of missile guidance acceleration con
tine Initialize-I-O(sol), which creates aerodynamic mands that define and optimal solution for maximizing
data tables by calling a subroutine Bcuaero. Otherwise, the missile's terminal velocity while satisfying control
the subroutine Whoa init-flight uses the present ve authority limits and terminal attitude constraints. The
hicular states as boundary conditions. The subroutine 30 guidance acceleration commands include commands for
Whoa init flight then calls a subroutine Find matrix controlling the angle of attack (a) and the bank angle
size to determine the number of elements needed, and (d) of the missile. In the virtual model of the missile
thus determine the size of the Jacobian matrix. If the contained in the guidance procedure, control variables
size needs to be changed, then the subroutine (32 and B2 are utilized in lieu of a and d to avoid conver
Whoa init flight calls a subroutine Gen 35 gence problems when the angle of attack is approxi
whoa init-param in order to alter the solution vector mately zero. This transformation avoids negative eigen
to accommodate a new matrix size. Finally, the subrou values in the Hamiltonian corresponding to the perfor
tine Whoa init flight determines an initial estimate for mance function (J). Iterative convergence is permitted
the time-of-flight (tgo). when control inequality constraint parameters are
The subroutine Whoal-optimize first determines the reached by modifying iterative solutions between itera
number of non-zero elements in the Jacobian matrix. tions so that the iterative solutions satisfy the inequality
This information is used by low-level matrix manipula constraints. This facilitates the movement of the con
tion routines (e.g., Factor matrix, Invert-matrix) that trols on and off of constraint boundaries. Moreover,
are from the Harwell Subroutine Library, as cited solution constraints can be imposed for the purpose of
above. The subroutine Whoa optimize then calls a 45 accelerating convergence by using this technique.
subroutine Newton that performs the Newton-Raphson Preferably, an optimal trajectory is calculated at each
iterations. The subroutine Whoal-optimize is then fin guidance cycle during missile flight using data that are
ished. revised during each guidance cycle. The revised data
The subroutine Newton calls a subroutine Errjac to include current position data for the target and the
compute the error of a solution, to fill in the Jacobian 50 current position for the missile. The revised data are
matrix, and to invert the Jacobian matrix, which is actu taken from the most reliable source currently available,
ally done by the Invert matrix routine from the Har such as on-board target-seeking radar when the target
well Subroutine Library. The subroutine Newton com seeking radar is locked onto the target, uplink data from
putes a new solution from the previous solution and the ground or airborne tracking radar when an uplink is
inverted Jacobian matrix. The subroutine Newton calls 55 operational, or inertial guidance data.
APPENDIX I
return
end
C et atmos situation w
grav inv = 1. OdO/grav
CALL ATMOS62 METRIC (-state (3), RHO, P, TEMP, A)
C Get Mach Number
vel = state (4)
MACH = vel/A
C Get Lift And Drag Coefficient
5,435,503
35 36
, c clear out the COIn hands
did i = 1, 3
body guid CInd (i) = 0 . OdC)
inert guid CInd (i) = 0 . Od. O
acc wind from body (i) = 0. Od0
endido
c define the wind to inertial matrix
denon = ( State (5) * state (5)
S + State (6) * state (6)
S + state (7) * state (7)
S ) /4 - 0 + 1. Odo
c (1,1) = (state (5) * state (5)
S - State (6) * state (6)
S - state (7) * state (7)
S ) /4 - O + 1. OdO
c (2,2) = (state (6) * state (6)
S - State (5) * state (5)
S - State (7) * state (7)
S ) /4. O + 1. Odo
c (3, 3) = (state (7) * state (7)
S - State (6) * state (6)
S - State (5) * state (5)
S ) / 4.0 + 1. OdO
c (1,2) = (state (5) * state (6) /2.0) - State (7)
c (1,3) = (state (5) * state (7) /2.0) + State (6)
c (2, 1) = (state (5) * state (6) /2.0) + state (7)
c (2, 3) = (state (6) * state (7) /2.0) - State (5)
c (3,1) = (state (5) * state (7) /2.0) - State (6)
c (3,2) = (state (6) * state (7) / 2. O) + State (5)
define the gravity acceleration Vector in the Wind frame
gW (1) = c (3, 1)
gw. (2) = c (3, 2)
gW (3) = c (3, 3)
C
return
end
O OutS :
real-8 sol (1) ! initialization parameters
logical factor. Inatrix ! initially true
c Local variables
: f
resize = . false.
c set the time; everytine
d2 phase 1
drop cc eq
drop title eq, Sol)
n = ns + inp
intot = 2* n + In
NETOT = 0 v .
DO 5 = 1, NPH - -
NETOT = NETOT + XNE (I) count the number of elements
5 CONTINUE
IORDER = NTOT* (NETOT + 2*NPH) + NBC + NPH
5,435,503
45 46
This shifts everything Straight from old phase 2
to new phase 1.
if (switch phase 32) then
inp offset = (xne (1) +2) *ntot start of next phase
do i = 1, iorder - nbc-nph -
sol (i) = sol (i+inp offset)
endido
print derivatives
save first solution
cap cc, final conver Crit
print derivatives Start time, pn Kn, pnks
print derivatives end tille,
final convertine
time go 1st divide, title go 2nd divide
set drop title, drop time
write initial derivatives
f Set drop cc, drop cc, CCV8, ccV9
S
cdy CInd Sf, use spline thrust, use spline mass
Data Conver/5* 0.0001/ avg. eqn. Convergence Criteria
Sf ulimit r1/0. 09/ new uliinit set at 'drop tine'
SW newton scale factor/835* 1. Od0/
init. newton scale factor
Sr title go 1st divide /10. Odo/
S time go 2nd divide /5. 0d 0/, nptr/1/
S Inax nurn of iterations/5*4/
Illax number of iterations
Sf pn kn/0. 1557/, pn ks/1.8/ between the error vector
Calculation before the
iteration file saves the
! difference in the error vector
calculation of the Itax error.
C INPUTS -
C OUTPUTS -
Yale k .
C
r x x * x k is x * x x . x sex k k k k l k k k x x x * * * * x x * x x x x x x k k k k k + k is k . . . . . . . . . . . . . . . . .
se se
C
IMPLICIT REAL * 8 (A-H, O-Z)
DIMENSION H (8), TEMP (8), DELT (8), DTDH (8)
THIS IS THE 1962 U. S. STANDARD ATMOSPHERE DEFINITION
H, HKM ARE IN GEOPOTENTIAL KELOMETERS. ALT SHOULD BE
GEOPOTENTIAL METERS.
TEMP IS IN DEGREES. K.
C=G*MO/R G=9.80665 M/SEC** 2, MO=28.9644 R=8.31432 (METRIC)
DTDH IS DEGREES K/KM
5,435,503
59 60
DATA C /34 . 1632/
DATA H /O. , 11. , 20. , 32. , 47. , 52. , 61. , 79. W
DATA DELT
1. , .223361,.0540328, .00856663, .001094.55, .000582289,
OOO 179718, . OOOO 10241/
DATA DTDH /- 6.5, O. , 1 . , 2.8, 0 . , -2. , -4. , 0./
DATA R /287. 04/
DATA SLPRES /101325.0/ - --
DATA TEMP /288. 15, 216. 65,216. 65, 228. 65,270. 65,270. 65,
252. 65, 180 - 65/
DATA VSCON /20. 04645/
HKM = ALT * 0.001
DO 10 J-2, 8
IF (HKM.L.E. H. (J) ) GO TO 20
= -- .
10 CONTINUE
20 DH=HKM-H (I)
DELTA=DEL
PRESS = SIPRES * DELTA
VSOUND = WSCON * SQRT (TK)
RHO = PRESS / (R* TK)
RETURN
END
C
SUBROUTINE BCUAERO .
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
C ROUTINE TO CALCULATE GRIDPOINT DERVATIVES USING FORWARD &
C BACKWARD PERTURBATONS OR ONE-DIRECTIONAL PERTURABTION IF
C GRIDPOINT IS ON THE EDGE.
C SHOULD BE FIRST EXECUTED IN THE MAIN PROGRAM BEFORE ANY
C CALCULATION IS DONE.
Include ' -- includelwfc bcu ré.inc
OPEN (1, FILE= aero. ini', STATUS= 'OLD ' )
DO 5 = 1, 1
READ (1, *) J1, K1
READ (1, *) (X1A (I,J), J =1, J1) MACH NO.
READ (1, *) (X2A (I, K), K=1, K1) ALPHA
DO 3 J = 1, J1.
DO 3 L = 1, 12 originally cl and cd
3 READ. ( 1, *) (YA (I, L, J, K), K=1, K1)
C YA=YA (STAGE, COEFF, MACH, ALPA)
N MACH (I) =J1 ! Illach
N ALPHA (I) =K1 ! alpha
5 CONTINUE
CLOSE (UNIT=1, STATUS= "KEEP')
3EST AVAILABLE COPY
5,435,503
67 68
SO CONTINUE
RETURN
END
R = X(N) - X (N-2)
DEL = (Y (NM1) - Y (N-2))/B(NM1)
A (N) = ( (B (N) + 2. O*R) * B (NM1) * C (N) + B (N) * B (N)* DEL)/R
C (N) = B (NM1)
GO TO OO
if (stop_nri) return
if (factor matrix) then
endilf
DO 5 J= 1, 2*NS*NPH
SUM= 0 . OD+OO
Do 10 I=1, NBC
SUM=SUM+PSIX (J, ) * GNU (I)
10 CONTINUE
CAPHIX (J) =PHIX (J) +SUM
5 CONTINUE
IL=IL-2 *NS
DO 37 K=1,2 *NS*NPH
DO 38 J = 1, 2*NS*NPH
SUM= 0 . OD+00
DO 40 I=1, NBC
SUM=SUM+PSIXX (K, J, I) * GNU (I)
40 CONTINUE
CAPHXX (K, J) =PHIXX (K, J) +SUM
38 CONTINUE
37 CONTINUE
INJ = 0
DO 1.25 = 1, NP
DO 1.20 J-1, NS
INJ = INJ-1
a (ijt-inj) =puVCCIllu (f(ns+i, j, 0),xhat (ins+i, 2, pn)
S, lhat (nS+i, 2, pn))
120 CONTINUE
125 CONTINUE
J = IJ--NPNS
A140
(IJ-FINJ)=puvccmu. (F (NS+I, ins+j, 0), XHAT (ins+i, 2, PN), LHAT (ins+i, 2, PN))
CONTINUE
150 CONTINUE
IJ = IJ+NPM
RETURN
END
SUBROUTINE INTER (KSW, IRTOT, IJTOT, IJTIM1, IJTIM2, PN EN
S DELT, A, B, IRN, ICN)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
Include ' - . include wifc proborder rö.inc
Include ' -- includelwfc soil ré.inc
INTEGER PN, EN, ten w
DOUBLE PRECISION X (IX X), U (IX u), F (Inx eqn, 0:Inx ux, 0:Inx ux)
S, L (0:Inx ux, O:Inx ux)
DIMENSION A (*), B (*), IRN (*), ICN (*)
C=DELT/2. OD+00
C COMPUTE RIGHT HAND SIDE:
5,435,503
87 88
C TWO SETS OF STATE EQUATIONS
DO 10 I=1, NS
B (IL--I) = B (IL--I) - XBAR(I, EN, PN) + C*F (I, O, O.)
B (IK+I) = B (IK+I) + XBAR (I, EN, PN) + C*F (I, 0, 0) .
10 CONTINUE
L=I--NS
K=TK+NS
B (IK+I)=-vccmu. (F (NS+I, 0, 0), Xbar (ins+i, en, PN), Lbar (ins+i, en, PN))
55 CONTINUE
K=K--NP
C=DELT/2. OD+00
CN=2. OD+00 * xNE (PN)
TAKE DERIVATIVES OF STATE EQUATIONS FOR THIS ELEMENT (IJR)
AND THE PREVIOUS (IJ)
(OR, FOR EN = 1, THE EQUATIONS AT THE START OF THE PHASE)
IR = TOTAL NUMBER OF JACOBIAN ELEMENTS IN BLOCK FOR PREVIOUS
ELEMENT
IJ = IJ--NSSQ
JR = IJ--IR
77 CONTINUE
JTIM2=IJTIM2+2 *NS
ENDIF
DO 235 I=1 NP
A (IJR+I) =pmuVCck (F (NS+I, 0, 0), Xbar (ins+i en PN),
S Lbar (ns--i, en, PN) )
A (IJR+NP+I) = pkvcck (F (NS+I, O, C), Xbar (ins+i en, PN),
S Lbar (ins+i, en , PN) )
235 CONTINUE
5,435,503
99 100
JR = JR+2+NP
JTOT = JR
RETURN
END
THIS ROUTINE LOADS THE PART OF THE EQUATIONS FOR THE FIRST
ELEMENT IN A PHASE THAT DEPENDS ON THE QUANTITIES AT THE
NODES, I. E. HATTED QUANTITIES w
EN=1
DO 7 I = 1, NS
X (I) = XHAT (I, EN, PN)
7 CONTINUE
DO 8 E = i, M
U (I) = UHAT (I, EN, PN)
8 CONTINUE
ten = 0
do i = 1, pn-1
ten = ten +Xne (i) +2
endido
ten = ten -- e.
CALL GET F. G. EQN DER (PN, ten, X, U, F, L)
ENDIF
NPNS = NP *NS
DERIVATIVE OF STATE AND COSTATE EQUATIONS W. R.T. X AND
AMBDA
DO 55 =1, NS
5,435,503
103 104
A (IJ--I) = -1. OD+00
A (IJ--NS+I) = 1. OD+00
55 CONTINUE
C W. R. T. CONTROLS (U HAT)
N = 0
DO 150 = 1, NP
DO 14 O J = 1, M
INJ = INJ + 1 .
A (IJ--INJ) =puVccitlu (F (NS+I, Is+j, 0), Xhat (ins+i, 1, PN)
S, Linat (Ins--i, 1, PN) )
14 O CONTINUE
50 CONTINUE
J = IJ--NPM
II, RTO
IJ JTOT
DO 5 = 1, NS
IRN (IJ--I) IL--
ICN (IJ--I) L+
IRN (IJ--NS+I) L+NS+.
ICN (IJ--NS+I) IL--N--
5 CONTINUE
IJ = J + 2*NS
C W. R. T. CONTROL (U)
5,435,503 r
111 112
=IJ-2*NP
IJTOT = J
IRTOT =- IL+2*N+M
RETURN
END
THE POINTERS ERTOT AND JTOT MARK WHICH BLOCKS YOURE FILLING
220 CONTINUE
225 CONTINUE
JR = IJR-NPM
235 CONTINUE
IJR = IJR-2*NP
IJTOT IJR
RTOT IRTOT-i-NTOT
RETURN
END
J=JTOT
L=IRTOT
NSM NS*M
NM = N* M.
MSQ MkM
NPM NP kM
NPNS = NP *NS
NJ = 0
DO 44, K=1, NPH
IF (K . EQ. 1) THEN
PTST=O
ELSE
IPTST=IPTEND-NTOT
ENDIF
IPTEND=IPTST+NTOT* (xNE (K) +1)
IF (K . EQ. PN) THEN
KEEPS=IPTST
KEEPE=IPTEND
5,435,503
123 124
IRN (IJ--INJ) =IL+2*NS+I
ICN (IJ--INJ) =IL-2*N+J
45 CONTINUE
50 CONTINUE
IJ =IJ--MSO
C DERIVATIVES OF CONTROL CONSTRAINTS :
C W. R. T. STATES X
INJ = 0
DO 65 I=1, NP
DO 60 J-1, NS
NJ - NJ-1.
75 CONTINUE
J=IJ--NP
c W. R. T. Multipliers (Mul)
76 CONTINUE
J=J--NP
c Initialize
ul IIlax disqrt (ulirclit)
k. On bV - ccerr / 2. O
k off blin O. 0d.O -ccerr*1000. O
highest Inu value = 0. 0d 0
Inul lower error = u Inax*Inu percent error
Inu upper error = u Inax*Inu percent error
c do for each unit (ie. elements and phase nodes)
do i = 1, netot-2*nph
xi = soil (nitot * (i-1) + 1)
yi = sol (ntot (i-1) + 2)
Zi = Sol (Intot (i-1) + 3)
k off bmx = disqrt (dabs (g eqin (0. OdO, O. 0d 0, xi, yi, zi) ))
do k = 1,ns .
surn = sum + f(k,ns+j, 0) * costate (k)
endido
endido
do j = 1, Inp . .
if (dabs (g_i (j)).lt. ulimit"alpha percent error ) then
u_o (j) = dSign (u Inax, u_i(j))
go (j) = 0
endif
if (Inui () . gt. Itu off bV
S . . and. Inui (j).lt. Ithu upper error) then
Inu o (j) = -Inui (j)
endilf
endido
Okay the bndary conditions have been evaluated and the proper
values have been set for "u". Now, I have to check to see if I
need to calculate values for Itu or k and do so.
enddo
return w
end
if (Inu. lt. Itu off bv. and . k. eq. kon bV) then
if ([Link]. 0) then ! Illul: On , , k: On, u : On
staying on the bndry
u ride = . true.
l = disign (u. Itax, u)
g = 0 . OdO
elseif (g. ed. 0. OdO) then ! Illu: On , , k: On, u : on
! staying on the bndry
u ride F . . trille.
else Illul: On , , k: On , u : On
if ( (u Inax - dabs (u)) /u. [Link]. 0.40) then
leaving bindry
Click = . trule.
U = Inu off bV
refactor = . . true.
else ! staying on bndry
Clc Inu. = . trille.
u ride = . true.
l = [Link] (u Inax, u)
9 = 0. OdO
endilf
endilf
elseif ([Link]. Inu off bV. and. k. ed. kon bv) then
! Inu: off, k: on the bndry
if (g. St. 0) then
l = Inu off bv.
click = . true.
refactor = . . true.
else ! Illul: Off, k: On, u : on; leaving bndry
Click = trlle.
refactor = . . true.
9 = - percent leaving bndry
l
disign (u max* (1-dabs (Inu) *percent leaving bndry), u)
if (dabs (u). gt. l. lax) u =
S -
disign (u Inax* (1-percent leaving bindry), u)
Ill = Inu off bV
endilf
elseif ([Link] off [Link]. k_of_bmn) then
! Illu: off, k: off
if (g. lt. 0) then ! u: off staying off bndry
refactor = . false.
elseif (g. eq. 0) then u : on, staying off
click F . . trille.
9 = - percent leaving bndry
5,435,503
153 154
l = [Link] (u Inax* (1-percent leaving bindry), u)
else ul: On
if (dabs (g) . ge.k) then Illoving on bindry
Clic Illu = . true.
u ride = . true.
refactor = . . true.
C = 0 . Od. O
k = k on bV
l = disign (u, Illax, u)
else ! staying off bndry
= Inu off bV
Click = . trile.
l = disign (u Inax* (1-percent leaving bndry), u)
endilf
endilf
elseif (Illu . . ed. Inu off [Link]. [Link].k off bmn) then
Illu: off, k: on
if (g. ge. 0) then ul: O ; InoVing on bindry
Clc Inu. . . true.
u ride . . trie.
refactor . . true.
l disign (u tax, ll)
g O. Od. O
k k on bV
else u : off ; staying off bndry
clic k . . true.
I Inu off bV
endif
elseif ([Link]. k on bV. and. ( (k. lt. k Off bran ) . . O
S ([Link]. k off brux) ) ) then l k is out of good bounds,
check ul
if (g. ge. 0) then Ilove on bindry
k = k on bV v
u ride = . trlle.
= disign (u, Itax, u)
if (Inu. ge. Illu off bV) clic Inu. = . true.
if (Inu. eq. Inu off bV) refactor = . true.
g = 0 . OdC)
else Inove off bndry
Click = . true.
if (mu. ed. Inu off bV) refactor = . false.
IU = Inu off bV -
endilf
elseif ( ([Link]. k off brun. and. [Link]. Inu off bv) .or.
S (k. eq.k on bV. and. Inu. ed. Itu off bV) ) then
if (g. ge. O) then Inoving on bridry
clic Itill = . trille.
u ride = . true.
refactor = . . trule.
k = k on bV
9 = 0. Odi O
l = [Link] (u Inax, u)
else leaving bindry
Click = true.
refactor = . . true.
I = Inu off bV
endilf ..
endilf
return
end
5,435,503
155 156
SUBROUTINE ENDPH (KSW, IRTOT, IJTOT, PN, delt, A, B, IRN, ICN)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
Include ' - . . include) wifc proborder ré.inc
Include ' -- includelwfc soil ré.inc
INTEGER PN, ten
DOUBLE PRECISION X (IX x), U (Itx u), F (IX eqn, 0:Inx ux, 0:mx ux)
S, I (0 : Tax uX, 0:Itxux)
DIMENSION A (*), B (*), IRN (*), ICN (*)
C THIS ROUTINE LOADS THE PART OF THE EQUATIONS FOR THE LAST
EEMENT
C IN A PHASE THAT DEPENDS ON THE QUANTITIES AT THE
C NODES, I. E. HATTED QUANTITIES
C
C ALL DERIVATIVES ARE WITH RESPECT TO THESE HATTED QUANTITIES
C
C KSW = 1 ==X FILL IN INDICES OF JACOBIAN ELEMENTS
C KSW = 2 ==X FILL IN RIGHT HAND SIDES OF EQUATIONS
C KSW = 3 ==X FILL IN ACTUAL, JACOBAN ELEMENTS
DO 15 I=1, NS
A (IJ--I) = 1. OD+00
A (IJ--NS-I) = -1. OD+00
15 CONTINUE
IJ = IJ + 2*NS
RETURN
END
C
SUBROUTINE ERRJAC (sol, KSW, factor, NZ1 NZ2, NZ
S, b, good vector)
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
Include ' - . . includelwfc prob order ré.inc
Include ' -- include wifc controls re...inc
Include ' - . . include wifc soiré.inc
Include ' - includel wifc mass rô.inc
Include ' - . . includel wife harwell ré.inc
C THIS ROUTINE FILLS THE INDICES, THE ERROR VECTOR, OR THE
C JACOBAN DEPENDING ON KSW. IIT ALSO SOLVES THE LINEARIZED
C SYSTEM IF NEEDED
C inputS :
real * 8 sol (*) ! contains the guessed solution vector
integer KSW 0: . GET INDICES
1. GET ERROR VECTOR (B)
2: GET JACOBAN (A)
logical factor decides whether or not to factor the
1 thatrix
5,435,503
159 160
integer nz1 integer nonzero counter
integer in Z2 integer nonzero counter
integer. In Z. integer total non-zero counter
c Outputs :
C
logical good Vector
real * 8 b (*) the error Vector from the Iatrix
c local
integer livect (80000) row index
integer jvect (80000) Column index
DOUBLE PRECISION PHIX (Inx bo), PHIXX (inx bo, Ink bc),
& PSIX (Inx bc, Incx nu), PSIXX (IX bc, Inx bo., Inx nu)
S, PHIT (Inx nph), PSI (Inx nu), PSIT (mx nph, inx nu)
DOUBLE PRECISION A (200000), W (8325), tenpa (60000), temp b (835)
S, uu/1. OdO/
INTEGER -
IRN (80000), ICN (200000), IKEEP (41625), IW (66600), iflag/0/
S, icn/200000/, lirn/80000/
C
good vector = . false.
initialize harwell results indicator.
C BREAK THE SOLUTION VECTOR INTO WARIABLES
C THIS IS THE ORDER OF THE COLUMNS IN THE JACOBAN
C OBTAIN PHI, PSI AND THEIR DERIVATIVES W. R.T. TIME AND THE
C STATES
DO = 1, NZ
temp a (i) = a (i)
endido
CALL
factor matrix a (IORDER, NZ, A., LICN, IVECT, JVECT, ICN, IKEEP
S, W, W, IFLAG)
if (iflag. lt. 0) then
do i = 1, inz
a (i) = tellipa (i)
endido
goto 88
endif
CALL invert Imatrix (IORDER, A, LICN, ICN, IKEEP, B, W, 1)
ENDIF for the invert matrix question
ENDIF ! if we want to get the correction vector
good vector = . true.
RETURN
END
DO 5 T=1, NS
IRN (IJ--I) IL-NTOT-I
ICN (IJ--I) -- -
INJ = 0
DO 85 = 1, NS
DO 80 J-1, M
INJ = INJ + 1
IRN (IJ--INJ) = IL-NTOT+I
ICN (IJ--INJ) = IL-2*N+J
80 CONTINUE
85 CONTINUE
J=J--NS*M
IJTOT =J
RETURN
END
5,435,503
167 168
SUBROUTINE INDEX5 (IRTOT, IJTOT, IRN, ICN)
THES ROUTINE MARKS THE PLACE IN THE JACOBAN FOR PARTIA
DERIVATIVES OF THE PRESCRIBED BOUNDARY CONDITIONS, PSI, WITH
RESPECT TO THE WALUES OF THE STATES AT THE BEGINNING AND END
OF EACH PHASE
IL=IRTOT
Js IJTOT
DO 20 = 1, NPH
IF (I . EQ. 1) THEN
PTST=O
ELSE
PTST=PTEND+NTOT
ENDIF w
IPTEND=IPTST+NTOT* (xNE (I) +1)
NJ = 0
DO 3 O J = 1, NBC
DO 40 K=1, NS
INJ = INJ
IRN (IJ--INJ) =IL+J
ICN (IJ+INJ) =IPTST+K
IRN (IJ--INJ--NS) =IL-J
ICN (IJ--NJ--NS) =IPTEND+K
40 CONTINUE
J=J-2 nS-1
NJ = 0
IRN (IJ) =IL--J
ICN (IJ) =IORDER-NPH+I
3O CONTINUE
2O CONTINUE
IJTOT =J
IRTOT=IL+NBC
RETURN
END
JJTOT
5,435,503
171 172
J = IJ--NBC
NPTR = NPTR-NTOT
ESE
NPTR=ORDER-NPH-NBC-NTOT
I= ORDER
RETURN
END
real * 8 err avg., erraVg best, err Inax, err Illax best
logical child refactor , factor
logical dum f/. false. /, good inversion
DMENSION correction vector (835), sol best (835), b (835)
INTEGER trijidx/0/, cycle/0/
S, index jacobian/0/, get error/1/,
S, fill invert jacobian/2/
S, get avg err/1/, get tax err/2/
S, locelle err Illax, loc Var err Inax, loc err Inax
c Initialize
converged = . false.
cycle = cycle + 1
totCint = 0
CALL ERRJAC (Sol, get error, durif, NZ1, NZ2, NZ, b, dun f)
call evaluate error (get a Vg err, i, b, erraVg best, i, i, ii)
call evaluate error (get Inax err, i , b, err Inax best
S, locelle err Inax, loc Var err tax, loc err Inax)
err avg err avg best
err Tax err Inax best
110 continue
CATI ERRJAC (sol, fill invert jacobian, factor, NZ1, NZ2, NZ
5,435,503
175 176
S, b, good inversion)
DO = 1, IORDER
correction vector (i) = b (i)
SOL best (I) =SOL (I) save what right be the best guess
endido - -
CALL ERRJAC (sol, get error, durin f, NZ1, NZ2, NZ, b, durin f)
call evaluate convergence (totcInt, err Inax best
trijidx, Correction Vector, b
Sol, Sol best, factor
p int converg eval)
goto (130, 110, 120, 140, 150) int converg eval
130 converged = . true.
RETURN
SUBROUTINE PSITER (KSW, IRTOT, IJTOT, PSI, PSIX, PSIT, A, B, IRN, ICN)
THIS ROUTINE CAICULATES THE ERROR VECTOR OR JACOBAN ELEMENTS
CORRESPONDING TO THE PRESCRIBED BOUNDARY CONDITIONS
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
Include ' - . . include wifc prob order ré.inc
Include ' - . . include wifc Solre...inc
DOUBLE PRECISION
PS (Inx nu), PSIX (IX bc, IX nu), PSIT (six riph, Inx nu)
DIMENSION A (*), B (*)
INTEGER IRN (*) , ICN (*)
IF (KSW . EQ. O) CALL INDEX5 (IRTOT, IJTOT, IRN, ICN)
IF (KSW .EQ. 1) THEN
CCCCCCCCCCCCCCCCC BEGIN ERROR VECTOR FILL IN CCCCCCCCCCCCCCC
IL = IRTOT
DO 10 = 1, NBC
B (IL--I) = - PSI (I)
10 CONTINUE
RTOT IL + NBC
ccCCCCCCCCCCCCCCC END ERROR VECTOR FILL IN CCCCCCCCCCCCCCCCC
ENDIF
J=JTOT
DO 20 = 1, NPH
IPSIST= 2*NS* (I-1)
NJ-0
DO 30 J-1, NBC
IDO 40 K=1, NS
INJ = INJ--
A (IJ--INJ) =PSIX (IPSIST+K, J)
A (IJ--INJ--NS) =PSIX (IPSIS.--K--NS, J)
40 CONTINUE
5,435,503
183 184
J=IJ-2* IS-1
NJ = 0
A (IJ) =PSIT (I,J)
CONTINUE
2O CONTINUE
JTOT=IJ
RETURN
END