✐ ✐ “APPENDIX-D˙WEB” — 2012/3/2 — 18:51 — page 1 — #1 ✐ ✐ ✐ ✐ ✐ ✐ 1 Solution of Linear Algebraic Equations by Gauss Elimination Simultaneous linear algebraic equations arise in methods for analyzing many different problems in solid mechanics, and indeed other branches of engineering science. In this book alone, we meet examples in the analysis of both statically determinate and statically indeterminate pin-jointed structures, the finite element analysis of beams, the analysis of strain gage measurements, and the determination of stresses in thick- walled cylinders. Gauss elimination is a direct method for solving such equations by successive elimination of the unknowns. Let us consider first an example involving just three equations 2x 1 + x 2 - x 3 =1 x 1 +3x 2 +2x 3 = 13 (1) x 1 - x 2 +4x 3 = 11 where x 1 ,x 2 , and x 3 are the unknowns to be found. We can use the first equation to eliminate x 1 from the other two equations. To do this, we divide the first equation through by 2 and subtract from the second and third equations to give 2x 1 + x 2 - x 3 =1 2.5x 2 +2.5x 3 = 12.5 (2) -1.5x 2 +4.5x 3 = 10.5 Similarly, the second of these is multiplied through by 1.5/2.5 and added to the third equation to eliminate x 2 2x 1 + x 2 - x 3 =1 2.5x 2 +2.5x 3 = 12.5 (3) 6x 3 = 18 Solving these equations in reverse order, a process known as back substitution, we obtain: x 3 = 3, then x 2 = (12.5 - 2.5 × 3)/2.5 = 2, and finally x 1 = (1 - 2+3)/2 = 1.
62
Embed
Solution of Linear Algebraic Equations by Gauss … of Linear Algebraic Equations by Gauss Elimination ... Gauss elimination is a direct method ... take advantage of this fact to simplify
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Solution of Linear AlgebraicEquations by Gauss Elimination
Simultaneous linear algebraic equations arise in methods for analyzing many differentproblems in solid mechanics, and indeed other branches of engineering science. Inthis book alone, we meet examples in the analysis of both statically determinate andstatically indeterminate pin-jointed structures, the finite element analysis of beams,the analysis of strain gage measurements, and the determination of stresses in thick-walled cylinders. Gauss elimination is a direct method for solving such equations bysuccessive elimination of the unknowns. Let us consider first an example involvingjust three equations
2x1 + x2 − x3 = 1
x1 + 3x2 + 2x3 = 13 (1)
x1 − x2 + 4x3 = 11
where x1, x2, and x3 are the unknowns to be found. We can use the first equation toeliminate x1 from the other two equations. To do this, we divide the first equationthrough by 2 and subtract from the second and third equations to give
2x1 + x2 − x3 = 1
2.5x2 + 2.5x3 = 12.5 (2)
−1.5x2 + 4.5x3 = 10.5
Similarly, the second of these is multiplied through by 1.5/2.5 and added to the thirdequation to eliminate x2
2x1 + x2 − x3 = 1
2.5x2 + 2.5x3 = 12.5 (3)
6x3 = 18
Solving these equations in reverse order, a process known as back substitution, weobtain: x3 = 3, then x2 = (12.5−2.5×3)/2.5 = 2, and finally x1 = (1−2+3)/2 = 1.
where A is an n×n square matrix, and X and B are column vectors or n×1 matrices.We may represent the general coefficients in these matrices as aij , xi, and bi, wheresubscript i specifies the row number, and j defines the column number.
In order to define the elimination process, let us give the initial coefficients of A
and B the notation a(1)ij and b
(1)i . After the first elimination, of x1 from all equations
from the 2nd to the nth, the modified coefficients in the corresponding rows of Aand B are
a(2)ij = a
(1)ij − fa
(1)1j
b(2)i = b
(1)i − fb
(1)1
(7)
for i = 2, 3, . . . , n and j = 1, 2, . . . , n, where the factor f is defined by
f = a(1)i1 /a
(1)11
Similarly, after the kth elimination
a(k+1)ij = a
(k)ij − fa
(k)kj
b(k+1)i = b
(k)i − fb
(k)k
(8)
for i = k + 1, k + 2, . . . , n and j = k, k + 1, . . . , n, where f is now defined by
It is important to notice that vector B is treated just like a column of A, and we cantake advantage of this fact to simplify the programming of the elimination process,by treating B as the (n+ 1)th column of A. The final set of equations, after (n− 1)eliminations have been performed, is
The solutions we require for the xi may now be obtained by back substitution
xn = b(n)n /a(n)nn (10)
xi =
b(i)i −n∑
j=i+1
a(i)ij xj
/ a(i)ii (11)
for i = n− 1, n− 2, . . . , 1.A great many arithmetic operations are involved in solving large sets of equations
by elimination. Any errors introduced, such as roundoff errors caused by representingnumbers with only a finite number of significant figures, tend to be magnified andmay become unacceptably large. Equations (8) show that the elimination processinvolves many multiplications by the factors f . In order to minimize the effects ofroundoff errors, we should make these factors as small as possible, and certainly less
than one. Therefore, the pivotal coefficient a(k)kk should be the largest coefficient in
the leading column of the remaining submatrix
|a(k)kk | > |a(k)ik | for i = k + 1, k + 2, . . . , n (12)
Satisfying this condition also helps to avoid division by zero in Equation (8), and wecan achieve it by a process known as partial pivoting. Immediately before each elim-ination, the leading column is searched for the largest coefficient. By interchangingequations, this can be made the pivotal coefficient to satisfy Equation (12). Thisprocess can be illustrated with the following equations
The largest coefficient of x1 occurs in the third equation, which is interchanged withthe first before the first elimination is performed to give
6x1 + 4x2 + x3 = 27
1.5x3 = 1.5 (14)
3x2 − 2.5x3 = 3.5
Now, we could not use the second of these equations to eliminate x2 from the thirdequation, because it does not involve x2, the coefficient of x2 having been reduced tozero by the first elimination. But, we can overcome this difficulty by interchangingthe second and third equations to satisfy Equation (12). In fact, no further elimi-nations are then necessary, and we may obtain the solutions by back substitution asx3 = 1, then x2 = (3.5 + 2.5× 1)/3 = 2, and finally x1 = (27− 4× 2− 1)/6 = 3.
We could extend the idea of partial pivoting to searching the whole of the re-maining submatrix for the largest coefficient. Such complete pivoting involves inter-changing both rows and columns, and is more difficult to program. Since it offersonly modest advantages in terms of accuracy over partial pivoting, it is rarely used.
Another refinement which helps to minimize the effects of roundoff errors is toscale the equations to make their coefficients similar in magnitude. One way we cando this is to normalize each equation so that the largest coefficient in each row ofA is of magnitude one. Scaling can be particularly important when correspondingcoefficients in different equations differ by several orders of magnitude.
Let us consider now another example, which presents a further type of difficulty
12x1 + 2x2 − x3 = 13
6x1 + 8x2 + 4x3 = 18 (15)
3x1 + 4x2 + 2x3 = 9
After the first elimination, of x1 from the second and third equations, we obtain
12x1 + 2x2 − x3 = 13
7x2 + 4.5x3 = 11.5 (16)
3.5x2 + 2.25x3 = 5.75
and after the second elimination, of x2 from the third equation
The coefficient of x3 is now zero, which makes it impossible to solve the equationsby back substitution. In fact, x3 could take any numerical value, including zero.The reason for this is that, in Equation (15), the third equation is merely the secondequation divided through by a common factor of 2, and therefore does not provideany new information about the unknowns. Alternatively, if the third equation had anumerical value on the right-hand side other than 9, then the second and thirdequations would have provided conflicting information, and the set of equationswould have been inconsistent. In either case, the matrix of coefficients A on theleft-hand sides of the equations is said to be singular, a condition which is due tothe determinant of matrix A being zero. For our present purposes, what we needto know is that such a condition can be detected during partial pivoting if it isimpossible to find a nonzero pivotal value at some stage of the elimination processor at the start of the back substitution process. What is more difficult to detect,however, is when a set of equations is nearly singular or ill-conditioned. This ariseswhen, for example, two equations provide very nearly the same information aboutthe unknowns. Alternatively, the effect of roundoff errors may be to make whatis a singular set of equations apparently ill-conditioned, in that rather than a zeropivotal coefficient, a very small value is obtained. Indeed, we may use the detectionof a very small pivotal coefficient as a convenient test for either a singular or veryill-conditioned set of equations, but without being able to distinguish between them.By very small pivotal coefficient, we mean a value very small in relation to themagnitudes of the coefficients of the matrix at the start of the elimination process,which are of order unity if we have previously applied scaling.
Subroutine SOLVE provides a fortran implementation of Gauss elimination.
SUBROUTINE SOLVE(A,X,NEQN,NROW,NCOL,IFLAG)
C
C SUBROUTINE FOR SOLVING SIMULTANEOUS LINEAR EQUATIONS BY GAUSSIAN
C ELIMINATION WITH PARTIAL PIVOTING.
C
DIMENSION A(NROW,NCOL),X(NROW)
IF(NEQN.GT.NROW.OR.NEQN.GE.NCOL) THEN
WRITE(6,’DIMENSION ERROR IN SOLVE - STOP’)
STOP
END IF
C
C INITIALIZE ILL-CONDITIONING FLAG.
IFLAG=0
C
C SCALE EACH EQUATION TO HAVE A MAXIMUM COEFFICIENT MAGNITUDE OF UNITY.
The following list provides the definitions of the fortran variables used, arrangedin alphabetical order.
Variable Type Definition
A real Coefficient matrix A extended to include vector Bas its last column
ABSA real Absolute value of coefficient aij
AMAX real Coefficient of maximum magnitude in current row of AATEMP real Temporary store for coefficients during equation interchangeFACT real Factor fI integer Row number in array AIMAX integer Value of row number I corresponding to the largest
coefficient in the leading column of AIFLAG integer Flag for a singular or very ill-conditioned coefficient matrix
(normally returned as 0 to the calling program, and 1 if theill-conditioning test is satisfied)
J integer Column number in array AJMAX integer Maximum value of the column number, J (equal to n + 1)K integer Elimination counter, kNCOL integer Number of columns in the DIMENSION for array ANEQN integer Number of equations to be solved, nNROW integer Number of rows in the DIMENSION for array ASUM real Temporary store for the summation term in Equation (11)X real Solution vector X
The arguments of subroutine SOLVE include the array of equation coefficients,A, which incorporates the vector of constants B as its last column, and the solutionvector, X. The variables NROW and NCOL, which enter the maximum numbersof rows and columns permitted in A and X, are used for dimensioning purposes.Normally, NCOL = NROW + 1, but the main consideration is that the dimensionsof A and X should be compatible with those in the calling program. The argumentNEQN enters the number of equations to be solved, while IFLAG returns an inte-ger flag value to the calling program to warn of a singular or very ill-conditionedcoefficient matrix.
The first action of the program is to test the acceptability of the number ofequations to be solved, in relation to the maximum array sizes. Then IFLAG is setto zero, before the equations are scaled to give a maximum coefficient magnitude ofunity in each row of A. The elimination process is then started: each equation, withthe exception of the last, is used in turn to eliminate the corresponding unknownfrom the subsequent equations. The current elimination number is given by K, andis equivalent to k in Equation (8). Before performing the necessary eliminationswith a particular equation, however, a search is made down the leading column ofthe remaining submatrix to find the coefficient of greatest magnitude, as defined byEquation (12). The search technique locates the row number of the largest coefficient,IMAX, by first assuming that it corresponds to the coefficient on the diagonal, andonly changing this if a larger coefficient is found. If the pivotal coefficient is not thelargest, the relevant equations are interchanged by interchanging all their coefficients.In computing terms, this movement of data between storage locations is inefficient.While it could be avoided by keeping a record of the revised order in which theequations are to be considered, this makes the program significantly more difficultto understand. For present purposes, we sacrifice computational efficiency in theinterests of clarity, in the knowledge that for the relatively small sets of equationswe wish to solve, the extra computing time involved is very small.
Despite the search for the largest coefficient, it is still possible for the pivotalcoefficient to be extremely small or zero if the coefficient matrix is singular or very ill-conditioned. Bearing in mind that the equations were scaled initially, an appropriatetest of magnitude on a computer working to 32 bit precision for real variables is
|akk| < 10−5 (18)
If this condition is satisfied at any stage of the elimination process, the problem isrejected. Rejection is indicated by setting the value of IFLAG to one, which may bedetected by the calling program. If the partial pivoting is successful, however, theeliminations defined by Equation (8) are performed, with the variable FACT beingused to store the values of the factor f .
After testing the magnitude of the last diagonal coefficient [a(n)nn in Equation (9)],
the back substitutions defined in Equations (10) and (11) are performed to findthe required solutions. The variable SUM is used to accumulate the results of thesummations indicated in Equation (11).
Nonlinear algebraic equations arise in the analysis of many different problems inengineering. In this book we meet examples of polynomial equations in the treat-ment of beam deflection problems, and equations involving trigonometric functionsin the analysis of buckling problems. Any nonlinear algebraic equation with a singlevariable can be expressed in the form
f(X) = 0 (1)
where f(X) is some nonlinear function of the variable X. Consider, for example, thecase arising in Example 6.8, Equation (6.51)
0.12X2 − 1
6(X − 0.2)3 − 0.024 = 0 (2)
The object of solving such an equation is to find a value of X which satisfies theequation. This value is said to be a root of the equation. Now, in general an equationin the form of (1) may have an arbitrarily large number of real roots (real as opposedto imaginary or complex): a cubic equation such as (2), may have as many as threereal roots. In practice, however, we are usually interested in only one of the roots,which we can often identify from the nature of the physical problem from which theequation is derived. In the case of Equation (2), for instance, we seek a root in therange 0.2 < X < 0.6, and we expect there to be only one root in that range.
Many different methods have been developed for solving nonlinear algebraic equa-tions, and are described in detail in numerical analysis textbooks. All are iterative innature: we first guess a value for the required root and then repeatedly obtain suc-cessively better values until one which is sufficiently close to the true root is achieved.Two properties of iterative methods are of great importance: the rate of convergence,which determines how fast the required root is approached, and the stability, whichdetermines whether the root is approached at all, or whether successive estimatesdiverge from the root. Unfortunately, those methods which show good rates of con-vergence under favorable conditions also tend to be the most unstable under adverseconditions. The best choice of method therefore depends on the conditions under
which it is to be used. If an equation is to be solved manually, then calculations areexpensive and the rate of convergence is important. Any tendency towards unstablebehavior can be rapidly detected and action taken. On the other hand, if an equa-tion is to be solved using a computer, calculations are cheap but more difficult tomonitor and control: stability of the method is then more important than its rate ofconvergence.
For present computational purposes we choose to use a technique often referredto as the bisection method, which is very simple, relatively slow, but highly stable.Indeed, provided we can first identify a range of the variable, say between X = aand X = b, in which there is at least one root of Equation (1), and provided thatthe function f(X) is continuous and single-valued over this range, then the bisectionmethod will find a root.
Figure 1 shows a typical plot of a function f(X) against X, which cuts the Xaxis at the root Xr, somewhere between X = a and X = b. We test for whether theroot lies between a and b by whether f(a) and f(b) are of different sign, that is
f(a)f(b) ≤ 0 (3)
If the product is exactly zero, then either a or b, or both, are roots of the equation.The way we proceed is to bisect the given range and to take the average of a and bas the first estimate of Xr
We then test (by the same function product method) whether the root lies in theleft-hand or right-hand half of the original range, and adjust either the upper or lowerlimit of the range accordingly. For example, if the product f(a)f(X1) is negativethen X1 replaces b as the upper limit The method is then applied repeatedly, eachtime halving the range of X in which the root must lie, thereby slowly but surelyconverging to this root.
Given a set of estimates of the required root, X1, X2, X3 . . . and so on, we mustdecide when we are sufficiently close to the true value so that the iterative processcan be stopped. To do this, we test the difference between successive estimates,Xi − Xi−1, and require that this be less than some small tolerance, say ε. Undercertain circumstances, we might prefer to test the magnitude of the difference relativeto the magnitude of the root, say (Xi −Xi−1)/Xi, but this is potentially hazardousas Xi might be zero, and computers normally reject division by zero. Because ofthe very simple nature of the bisection method, we are able to predict in advancehow many iterations will be required to achieve convergence to a given tolerance.Taking the initial estimate for the root as either a or b, the first iteration, definedby Equation (4), gives a new estimate which differs by (b − a)/2 from the initialone. After the second iteration, the difference is halved at (b− a)/22. Every furtheriteration halves the difference, until after n iterations it is (b − a)/2n, and in orderto achieve convergence to the given tolerance we require that
|b− a|2n
< ε (5)
from which we can define the number of iterations required as
n =ln|(b− a)/ε|
ln2(6)
In general this equation does not give an integer value for n, and the value obtainedshould be rounded up to the next integer to satisfy inequality (5).
Subroutine BISECT provides a fortran implementation of the bisection method.
C USE NEW ESTIMATE TO UPDATE EITHER THE LOWER OR UPPER LIMIT.
IF(FXNEW*FXMIN.LT.0.) THEN
XMAX=XNEW
FXMAX=FXNEW
ELSE
XMIN=XNEW
FXMIN=FXNEW
ENDIF
1 CONTINUE
C
C AFTER ITERATION, TAKE THE ROOT AS THE BEST AVAILABLE ESTIMATE.
XROOT=XNEW
RETURN
END
The following list provides the definitions of the fortran variables used, arrangedin alphabetical order.
Variable Type Definition
A real Lower limit, a, of the given range of variable XB real Upper limit, b, of the given range of variable XFN real Function subprogram to define the particular form of
nonlinear algebraic function, fFXMAX real Value of the nonlinear function f corresponding to value XMAX
of variable XFXMIN real Value of the nonlinear function f corresponding to value XMIN
of variable XFXNEW real Value of the nonlinear function f corresponding to value XNEW
of variable XIFLAG integer Flag for failure to find a root within the given range of X (set to one
if test shows no root, otherwise zero)ITER integer Iteration counterNITER integer Number of iterations to be performedPROD real Product of function valuesRATIO real Absolute value of the ratio (b− a)/εTOLER real Convergence tolerance, εXMAX real Current maximum possible value of XXMIN real Current minimum possible value of XXNEW real New estimate of the root, found by the bisection processXROOT real Value of the required root of the equation
The arguments of subroutine BISECT are the given limits, A and B, of the possiblerange for the root, the convergence tolerance, TOLER, the computed value of theroot, XROOT, and the variable IFLAG. While the first three of these provide datato the subroutine, the last two provide the results, the last one returning an integerflag value to the calling program to warn of no root in the given range.
The first action of the subroutine is to compute the values of the nonlinear func-tion, f in Equation (1), corresponding to the given limits of the possible range for X.This is done using a further function subprogram, FN, whose form must be suitedto the particular equation being solved. The reason for having two arguments forthis subprogram, the value of X and another integer quantity (here set to zero), isexplained below. We test for a root within the given range by testing the product ofthe two function values. A positive value of the product indicates that there is not asingle root in the range (although for a continuous function there could be an evennumber of roots), and a zero value indicates that either a or b (or both) must be aroot.
The number of iterations is then computed with the aid of Equation (6) (notethat, since fortran function INT truncates its argument to the integer immediatelybelow it, one is added to obtain the integer immediately above it). An iterationloop is then set up to bisect repeatedly the possible range for the root. If one ofthe resulting estimates for the root should happen to exactly satisfy the nonlinearequation, this value is returned as the root to the calling program. Otherwise, thevalue obtained from the last iteration is taken as the root.
Now, subroutine BISECT is designed as a piece of coding for applying the bisec-tion method which is independent of both the particular nonlinear equation to besolved and the program which requires the solution. It can therefore be used in anysituation where such an equation has to be solved, including, for example, programsibeam which is described in Section 6.4.2. Similarly, it can be used to solve thecubic equation derived in Example 6.8, which is repeated here in Equation (2). Todo this, we must prepare a small main program, and an appropriate form of functionsubprogram FN.
Program root provides the main program for entering the data for solving anonlinear algebraic equation. After writing out an appropriate title onto an outputfile named RESULTS, root calls function subprogram FN to also write out the formof nonlinear equation being solved. The values of a, b, and ε are then read in froman input file named DATA, and immediately written out, and subroutine BISECTis called to solve the equation. The computed results are written out, either in theform of the computed root or a warning message that there is no single solutionwithin the given range.
C PROGRAM TO FIND A ROOT OF A NONLINEAR ALGEBRAIC EQUATION.
C
OPEN(5,FILE=’DATA’)
OPEN(6,FILE=’RESULTS’)
C
C OUTPUT A TITLE AND THE FORM OF FUNCTION, BY CALLING THE
C DEFINING FUNCTION SUBPROGRAM.
WRITE(6,61)
61 FORMAT(’SOLUTION OF A NONLINEAR ALGEBRAIC EQUATION BY THE ’
1 ’BISECTION METHOD’ /)
F=FN(0.,1)
C
C INPUT AND OUTPUT THE LOWER AND UPPER LIMITS OF THE RANGE OF THE
C VARIABLE, ALSO THE CONVERGENCE TOLERANCE.
C
READ(5,*) A,B,TOLER
WRITE(6,62) A,B,TOLER
62 FORMAT(’LOWER LIMIT OF POSSIBLE RANGE OF VARIABLE X = ’,E12.4//
1 ’UPPER LIMIT OF POSSIBLE RANGE OF VARIABLE X = ’,E12.4//
2 ’MAXIMUM DIFFERENCE BETWEEN SUCCESSIVE ESTIMATES OF ’
3 ’THE ROOT = ’,E12.4 /)
C
C CALL SUBROUTINE TO APPLY THE BISECTION METHOD.
CALL BISECT(A,B,TOLER,XROOT,IFLAG)
C
C UNIT VALUE OF IFLAG INDICATES NO SOLUTION WITHIN THE GIVEN RANGE.
IF(IFLAG.EQ.1) THEN
WRITE(6,63)
63 FORMAT(’NO ROOT WITHIN THE GIVEN RANGE - STOP’)
STOP
END IF
C
C OUTPUT THE COMPUTED ROOT.
WRITE(6,64) XROOT
64 FORMAT(’COMPUTED ROOT = ’,E14.6)
STOP
END
Function subprogram FN displayed in Box 1 provides the definition of the cubicfunction defined in Equation (2). Note that the function has two arguments, X forthe current value of the variable X, and IOTEST, which is an integer parameterfor controlling the output of a message defining the form of function. A unit valueof IOTEST must be entered to obtain this output, in which case the value of thefunction is not computed and the value of argument X is irrelevant. In the contextof the program which comprises root, BISECT and FN, FN is only called once with
IOTEST set to unity, this being from main program root when the form of functionmessage is required. All calls from BISECT, where function values are required, aremade with IOTEST set to zero. The purpose of these arrangements is to ensure thatdetails of the particular function under consideration, both for computation andoutput messages, are confined to the single subprogram. This makes the analysis ofany other form of function straightforward to implement, as demonstrated.
Box 1
FUNCTION FN(X,IOTEST)
C
C FUNCTION SUBPROGRAM TO DEFINE THE NONLINEAR ALGEBRAIC FUNCTION
C WHICH IS REQUIRED TO BE ZERO.
C
C THIS VERSION DEFINES THE CUBIC FUNCTION DERIVED IN EXAMPLE 6.8
C
C IF IOTEST IS UNITY, ONLY OUTPUT THE FORM OF FUNCTION.
IF(IOTEST.EQ.l) THEN
WRITE(6,61)
61 FORMAT(‘FUNCTION IS 0.12*X**2 - (X-0.2)**3/6 - 0.024 = 0’/)
RETURN
END IF
FN=0.12*X**2-(X-0.2)**3/6.-0.024
RETURN
END
Box 2 shows the results obtained, the computed root being X = 0.4801.
Box 2
SOLUTION OF A NONLINEAR ALGEBRAIC EQUATION BY THE BISECTION METHOD
FUNCTION IS 0.12*X**2 - (X-0.2)**3/6 - 0.024 = 0
LOWER LIMIT OF POSSIBLE RANGE OF VARIABLE X = 0.2000E+00
UPPER LIMIT OF POSSIBLE RANGE OF VARIABLE X = 0.6000E+00
MAXIMUM DIFFERENCE BETWEEN SUCCESSIVE ESTIMATES OF THE ROOT = 0.1000E-05
COMPUTED ROOT = 0.480140E+00
Another illustration of the use of program root is provided by the nonlinearEquation (8.20) derived in Example 8.3, which is
with a root expected in the range 0 < X < 1. The subprogram displayed in Box 3provides the definition of this function, and Box 4 shows the results obtained. Notethat the upper limit of the possible range of X is set not at 1.0 exactly (which wouldcause computer overflow due to an infinite value of the secant function), but 0.99.The computed root is X = 0.6956.
Box 3
FUNCTION FN(X,IOTEST)
C
C FUNCTION SUBPROGRAM TO DEFINE THE NONLINEAR ALGEBRAIC FUNCTION
C WHICH IS REQUIRED TO BE ZERO.
C
C THIS VERSION DEFINES THE FUNCTION DERIVED IN EXAMPLE 8.3
C
C IF IOTEST IS UNITY, ONLY OUTPUT THE FORM OF FUNCTION.
IF(IOTEST.EQ.1) THEN
WRITE(6,61)
61 FORMAT(‘FUNCTION IS
1 ‘X(1 + 1.6*SEC(0.5*PI*SQRT(X))) - 5.014 = 0’/)
RETURN
END IF
PI=4.*ATAN(1.)
ANG=0.5*PI*SQRT(X)
SEC=1./COS (ANG)
FN=X*(1.+1.6*SEC)-5.014
RETURN
END
Box 4
SOLUTION OF A NONLINEAR ALGEBRAIC EQUATION BY THE BISECTION METHOD
FUNCTION IS X(1 + 1.6*SEC(0.5*PI*SQRT(X))) - 5.014 = 0
LOWER LIMIT OF POSSIBLE RANGE OF VARIABLE X = 0.0000E+00
UPPER LIMIT OF POSSIBLE RANGE OF VARIABLE X = 0.9900E+00
MAXIMUM DIFFERENCE BETWEEN SUCCESSIVE ESTIMATES OF THE ROOT = 0.1000E-05
COMPUTED ROOT = 0.695632E+00
A further example of the use of program root is provided by the nonlinearEquation (8.43), which can be written as
with a root expected in the range 4.0 < X < 4.7. The subprogram displayed in Box5 provides the definition of this function, and Box 6 shows the results obtained. Thecomputed root is X = 4.493.
Box 5
FUNCTION FN(X,IOTEST)
C
C FUNCTION SUBPROGRAM TO DEFINE THE NONLINEAR ALGEBRAIC FUNCTION
C WHICH IS REQUIRED TO BE ZERO.
C
C THIS VERSION DEFINES THE FUNCTION DERIVED FROM EQUATION (8.43)
C
C IF IOTEST IS UNITY, ONLY OUTPUT THE FORM OF FUNCTION.
IF(IOTEST.EQ.l) THEN
WRITE(6,61)
61 FORMAT (‘FUNCTION IS TAN(X) - X = 0’/)
RETURN
END IF
FN=TAN(X)-X
RETURN
END
Box 6
SOLUTION OF A NONLINEAR ALGEBRAIC EQUATION BY THE BISECTION METHOD
FUNCTION IS TAN(X) - X = 0
LOWER LIMIT OF POSSIBLE RANGE OF VARIABLE X = 0.4000E+01
UPPER LIMIT OF POSSIBLE RANGE OF VARIABLE X = 0.4700E+01
MAXIMUM DIFFERENCE BETWEEN SUCCESSIVE ESTIMATES OF THE ROOT = 0.1000E-05
All programs read information from a file named DATA, and write onto a file namedRESULTS. All READ statements call for free format input data. A list of fortranvariables used and their definitions in each of the computer program are presentedat the end of each program.
SDPINJ (analysis of Statically Determinate PIN-Jointedstructures)
PROGRAM SDPINJ
C
C PROGRAM TO FIND THE FORCES IN THE MEMBERS OF A STATICALLY DETERMINATE
A real Coefficient matrix A extended to include vector B as its last columnANG real Array storing angles (in degrees) at which roller supports are free to moveANGR real Angle in radians of roller supportCOSINE real Cosine of element angle θm at first node iELENGT real Element length, Lm [used in Equation (2.12)]FX, FY real Arrays storing the external force components in the global coordinate
directions at the nodesI integer Nodal point number (sometimes first node of an element)ICOL integer Column number in array AIFLAG integer Flag for a singular or very ill-conditioned coefficient matrix (normally
returned as 0 by SOLVE; 1, if the ill-conditioning test is satisfied)IROW integer Row number in array AJ integer Nodal point number (second node of an element)K integer A counter (used in READ and WRITE statements)M integer Element numberNEL integer Number of elementsNELMAX integer Maximum number of elements permitted by the array dimensionsNEQN integer Number of equations to be solvedNNP integer Number of nodal pointsNNPF integer Number of nodes at which external forces are appliedNNPMAX integer Maximum number of nodal points permitted by the array dimensionsNNPP integer Number of nodes at which structure is pinned to its surroundingsNNPR integer Number of nodes at which structure is supported on rollersNNPT integer Total number of nodes at which structure is supportedNODE integer Array storing node numbersNPI integer Array storing the numbers of the first nodes of the elementsNPJ integer Array storing the numbers of the second nodes of the elementsNUNK integer Total number of unknownsPI real The mathematical constant πSINE real Sine of element angle θm at first node iT real Array storing the vector of unknowns TX real Array storing X global coordinates of the nodesY real Array storing Y global coordinates of the nodes
The arrays used in sdpinj are dimensioned in such a way as to allow a structurewith up to 50 nodes and 100 elements to be analyzed, implying that up to 100equations (twice the number of nodes) may have to be solved. Note that array A,which stores the coefficient matrix A extended to include vector B, is allowed tohave up to 101 columns.
75 FORMAT(/ ’COMPUTED FORCES AND STRESSES IN THE ELEMENTS’
1 ’ (TENSILE POSITIVE)’
2 / 2(’ ELEMENT FORCE STRESS ’)
3 / (2(I8,2E14.4)))
STOP
END
Variable Type Definition
ANG real Array storing angles (in degrees) at which roller supports are free to moveANGR real Angle in radians of a roller supportAREA real Array storing the cross-sectional areas of the elementsCOSA real Cosine of the angle at which a roller support is free to moveCOSINE real Cosine of element angle θmCSVECT real Array storing cosine and sine terms used in forming element stiffness matrices
[Equation (4.6)]DELTA real Array storing the displacements of the nodal pointsDISPI real Displacement of the first node of an element in the direction along the ele-
ment from the first node to the second nodeDISPJ real Displacement of the second node of an element in the direction along the
element from the first node to the second nodeE real Array storing the Young’s moduli of the elementsELENGT real Element length, LmESTIFF real Element stiffness coefficientFACT real Common factor (the axial stiffness) in the element stiffness coefficientsFX, FY real Arrays storing the external force components in the global coordinate direc-
I integer Nodal point number (sometimes first node of an element)IC integer Column number in element stiffness matrixICOL integer Column number in array OSTIFFIFLAG integer Flag for a singular or very ill-conditioned coefficient matrix (normally
returned as zero by solve, one if the ill-conditioning test is satisfied)IR integer Row number in element stiffness matrixIROW integer Row number in array OSTIFFJ integer Nodal point number (second node of an element)K integer A counter (used in READ and WRITE statements)M integer Element numberNEL integer Number of elementsNELMAX integer Maximum number of elements permitted by the array dimensionsNEQN integer Number of equations to be solvedNNP integer Number of nodal pointsNNPF integer Number of nodes at which external forces are appliedNNPMAX integer Maximum number of nodal points permitted by the array dimensionsNNPP integer Number of nodes at which structure is pinned to its surroundingsNNPR integer Number of nodes at which structure is supported on rollersNNPT integer Total number of nodes at which structure is supportedNODE integer Array storing node numbersNPI integer Array storing the numbers of the first nodes of the elementsNPJ integer Array storing the numbers of the second nodes of the elementsNUNK integer Total number of unknownsOSTIFF real Array storing the coefficients of the overall stiffness matrix K, extended
to include external force vector F as its last columnPI real The mathematical constant πSINA real Cosine of the angle at which a roller support is free to moveSINE real Sine of element angle θmSTRAIN real Strain in an elementSTRESS real Array storing the stresses in the elementsT real Array storing the forces in the elementsX real Array storing X global coordinates of the nodesY real Array storing Y global coordinates of the nodes
The arrays used in sipinj are dimensioned in such a way as to allow a structurewith up to 50 nodes and 100 elements to be analyzed, implying that up to 100equations (twice the number of nodes) may have to be solved. Note that arrayOSTIFF, which stores the overall stiffness matrix K extended to include the forcevector F is allowed to have up to 101 columns. The array dimensions can of coursebe changed, provided the values of NNPMAX and NELMAX defined in the next twostatements are also adjusted.
A real Coefficient matrix A extended to include vector F as its last columnBM real Array storing the bending moments at the nodes of the elements (first
subscript defines the element number, second subscript the node numberwithin the element)
BMMAX real Array storing mathematical maximum and minimum values of bendingmoment within elements
C real Array storing the external concentrated couples (counterclockwise posi-tive) acting on the beam at the nodes
ELENGT real Element lengthF real Array storing the external concentrated forces (downwards positive) act-
ing on the beam at the nodesGRBMH real Greatest value of bending moment (hogging)GRBMS real Greatest value of bending moment (sagging)GRSF real Greatest value of shear forceI integer Nodal point number (sometimes first node of an element)IBMMAX integer Counter for mathematical maximum or minimum values of bending mo-
mentsICOL integer Column number in array AIEND integer Counter for the (two) ends of an elementIFLAG integer Flag for a singular or very ill-conditioned coefficient matrix (normally
returned as zero by SOLVE, one if the ill-conditioning test is satisfied)INODE integer Node numberIROW integer Row number in array AJ integer Nodal point number (second node of an element)K integer A counter (used in READ and WRITE statements)M integer Element numberNBMMAX integer number of mathematical maximum and minimum values of bending mo-
ment within elementsNEL integer Number of elementsNELEM integer Array storing element numbersNELMAX integer Maximum number of elements permitted by the array dimensionsNELW integer Number of elements over which external distributed forces actNEQN integer Number of equations to be solvedNNP integer Number of nodal pointsNNPBI integer Number of nodes at which the beam is built-inNNPC integer Number of nodes at which external concentrated couples are appliedNNPF integer Number of nodes at which external concentrated forces are appliedNNPMAX integer Maximum number of nodal points permitted by the array dimensionsNNPSS integer Number of nodes at which the beam is simply supportedNNPT integer Total number of nodes at which the beam is supportedNODE integer Array storing node numbersNPI integer Array storing the numbers of the first nodes of the elementsNPJ integer Array storing the numbers of the second nodes of the elementsNUNK integer Total number of unknown support reaction forces and momentsR real Array storing the reactions (forces or moments) at the supportsSF real Array storing the shear forces at the nodes of the elements (first subscript
defines the element number, second subscript the node number within theelement)
VMR real Array storing the vector of unknown shear forces, bending moments, andsupport reactions, V
W real Array storing the intensities of the external distributed forces (downwardspositive) acting on the elements
X real Array storing X global coordinates of the nodesXBMMAX real Array storing global coordinates of mathematical maximum and minimum
values of bending moment within elementsXGRBMH real Position (X coordinate) of the point of greatest hogging bending momentXGRBMS real Position (X coordinate) of the point of greatest sagging bending momentXGRSF real Position (X coordinate) of the point of greatest shear forceXLOCAL real Local coordinate, x, within an element
The arrays used in sdbeam are dimensioned in such a way as to allow a beam withup to 50 elements and 51 nodes to be analyzed, implying that up to 202 equations(four times the number of elements, plus two) may have to be solved. Note that arrayA, which stores the coefficient matrix A extended to include vector F is allowed tohave up to 203 columns. The array dimensions can of course be changed, providedthe values of NNPMAX and NELMAX defined in the next two statements are alsoadjusted.
1 /’GREATEST SAGGING BENDING MOMENT =’,E12.4,’ AT X =’,E12.4
2 /’GREATEST HOGGING BENDING MOMENT =’,E12.4,’ AT X =’,E12.4)
STOP
END
FUNCTION FN(X,IOTEST)
C
C FUNCTION SUBPROGRAM TO DEFINE THE CUBIC FUNCTION FOR SLOPE WITHIN
C AN ELEMENT.
COMMON /CONSTS/ C2,C3,C4,C5
FN=C2+2.*C3*X+3.*C4*X**2+4.*C5*X**3
RETURN
END
Variable Type Definition
BM real Array storing the bending moments at the nodes of the elements (firstsubscript defines the element number, second subscript the node numberwithin the element)
BMMAX real Array storing mathematical maximum and minimum values of bendingmoment within elements
C real Array storing the external concentrated couples (counterclockwise posi-tive) acting on the beam at the nodes
C1 to C5 real Shape function constants C1 to C5
DELTA real Array storing the deflections and slopes at the nodal pointsE real Young’s modulus of the beam materialELENGT real Element lengthELOAD real Array storing components of the element load vector fmESTIFF real Array storing the stiffness coefficients for all the elements (first subscript
defines the element number, second and third subscripts the row and col-umn numbers of the element stiffness matrix)
F real Array storing the external concentrated forces (downward positive) actingon the beam at the nodes
FACT real Common factor in the element stiffness coefficientsGRBMH real Greatest value of bending moment (hogging)GRBMS real Greatest value of bending moment (sagging)GRSF real Greatest value of shear forceGRVP real Greatest value of deflection (positive)GRVN real Greatest value of deflection (negative)I integer Nodal point number (sometimes first node of an element)IBMMAX integer Counter for mathematical maximum or minimum values of bending mo-
mentsIC integer Column number in array ESTIFFICOL integer Column number in array OSTIFF
IEND integer Counter for the (two) ends of an elementIFLAG integer Flag for a singular or very ill-conditioned coefficient matrix (normally
returned as zero by SOLVE, one if the ill-conditioning test is satisfied)INODE integer Node numberIR integer Row number in array ESTIFFIROW integer Row number in array OSTIFFISTEP integer Counter for steps along an element when searching for maximum or min-
imum deflectionsIVMAX integer Counter for mathematical maximum or minimum values of deflectionJ integer Nodal point number (second node of an element)K integer A counter (used in READ and WRITE statements)M integer Element numberNBMMAX integer Number of mathematical maximum and minimum values of bending mo-
ment within elementsNEL integer Number of elementsNELEM integer Array storing element numbersNELMAX integer Maximum number of elements permitted by the array dimensionsNELW integer Number of elements over which external distributed forces actNEQN integer Number of equations to be solvedNNP integer Number of nodal pointsNNPC integer Number of nodes at which external concentrated couples are appliedNNPF integer Number of nodes at which external concentrated forces are appliedNNPMAX integer Maximum number of nodal points permitted by the array dimensionsNNPBI integer Number of nodes at which the beam is built inNNPFL integer Number of nodes at which the beam is supported on flexible supportsNNPSS integer Number of nodes at which the beam is simply supportedNNPT integer Total number of nodes at which the beam is supportedNODE integer Array storing node numbersNPI integer Array storing the numbers of the first nodes of the elementsNPJ integer Array storing the numbers of the second nodes of the elementsNSTIFF integer Number of non-zero stiffnesses of flexible supportsNUNK integer Total number of unknown support reaction forces and momentsNVMAX integer Number of mathematical maximum and minimum values of deflection
within elementsOSTIFF real Array storing coefficients of the overall stiffness matrix K, extended to
include external force vector F∗ as its last columnPI real The mathematical constant πRSTIFF real Array storing the rotational stiffnesses of the flexible supports (in units
of moment per radian)SF real Array storing the shear forces at the nodes of the elements (first subscript
defines the. element number, second subscript the node number withinthe element)
SMA real Array storing the second moments of area of the elementsSMAC real Constant second moment of area for a uniform beam
THETA real Array storing the slopes (in radians) at the nodal pointsTHETAS real Array storing the slopes (in degrees) at the support pointsTHETA1 real Slope at the beginning of a step within an elementTHETA2 real Slope at the end of a step within an elementV real Array storing the deflections at the nodal pointsVMAX real Array storing mathematical maximum and minimum values of deflection
within elementsVS real Array storing the deflections at the support pointsVSTIFF real Array storing the vertical stiffnesses of the flexible supportsW real Array storing the intensities of the external distributed forces (downward
positive) acting on the elementsWLOAD real Array storing the external load terms Wm associated with the distributed
lateral forces, for all the elements (first subscript defines the element num-ber, second subscript the row number)
X real Array storing X global coordinates of the nodesX1 real Local coordinate at the beginning of a step within an elementX2 real Local coordinate at the end of a step within an elementXBMMAX real Array storing global coordinates of mathematical maximum and minimum
values of bending moment within elementsXGRBMH real Position (X coordinate) of the point of greatest hogging bending momentXGRBMS real Position (X coordinate) of the point of greatest sagging bending momentXGRSF real Position (X coordinate) of the point of greatest shear forceXGRVN real Position (X coordinate) of the point of greatest negative deflectionXGRVP real Position (X coordinate) of the point of greatest positive deflectionXLOCAL real Local coordinate, x, within an elementXVMAX real Array storing global coordinates of mathematical maximum and minimum
values of deflection within elements
The arrays used in sibeam are dimensioned in such a way as to allow a beam with upto 50 elements and 51 nodes to be analyzed, implying that up to 102 equations (twicethe number of nodes) may have to be solved. Note that array OSTIFF, which storesthe overall stiffness matrix K extended to include vector F∗ is allowed to have up to103 columns. The array dimensions can of course be changed, provided the valuesof NNPMAX and NELMAX defined in the next two statements are also adjusted.
The following list provides the definitions of the fortran variables used.
Variable Type Definition
A real Array storing the coefficients of linear equations in Equation (9.43)AESMAX real Absolute maximum shear strainANG real Angle θ of gage orientation in radiansASSMAX real Absolute maximum shear stressCOST real Cosine of angle θ of gage orientationDENOM real Denominator expression (1 − ν2) in Equation (9.45)E real Young’s modulusEN real Array storing the normal strains measured by the three gagesEP real Array storing the two in-plane principal strainsEP3 real Third (out of plane) principal strainESMAX real Maximum in-plane shear strainEXY real Array storing the strains ex, ey and γxyG real Shear modulusI integer A counterIFLAG integer Flag for a singular or very ill-conditioned coefficient matrix (normally
returned as zero by SOLVE, one if the ill-conditioning test is satisfied)NU real Poisson’s ratioPI real The mathematical constant πSE real Von Mises equivalent stressSIGP real Array storing the two in-plane principal stressesSIGXY real Array storing the stresses σx, σy and τxySINT real Sine of angle θ of gage orientationSSMAX real Maximum in-plane shear stressTHETA real Array storing the angular orientations (in degrees) of the three gagesTHETAP real Array storing the directions of the normals to the principal planes
C CONVERT ANGLES OF PRINCIPAL PLANES FROM RADIANS TO DEGREES.
THETAP(1)=THETAP(1)*180./PI
THETAP(2)=THETAP(2)*180./PI
RETURN
END
Variable Type Definition
ASHMAX real Absolute maximum shear stress or strainCASE character Label for the current case (either ‘STRESS’ for plane stress or
‘STRAIN’ for plane strain)I integer A counterPI real The mathematical constant πS real Array storing the two in-plane principal stresses or strainsSE real Von Mises equivalent stressSHMAX real Maximum in-plane shear stress or strainSXY real Array storing the stresses or strains in the (x, y) coordinate systemTEMP real A temporary store used during reordering of principal valuesTHETAP real Array storing the directions of the normals to the principal planesTWOPHI real A variable representing 2φ in equation [Equation (9.12)]
AB real Array storing the constants A1, B1, A2, and B2
ASHMAX real Absolute maximum shear stressA1 real The constant A1
A2 real The constant A2
B1 real The constant B1
B2 real The constant B2
COEFF real Array storing the coefficients of linear equations in Equation (10.69)DELTA real Radial interference between the two cylinders before assembly, δEH real Hoop strain, eθENDED character Label for the type of end condition (taken to be closed-ended unless
ENDED is ’OPEN’)E1 real Young’s modulus of the material of the inner cylinder, E1
E2 real Young’s modulus of the material of the outer cylinder, E2
I integer Row counterIFLAG integer Flag for a singular or very ill-conditioned coefficient matrix (normally
returned as zero by SOLVE, one if the ill-conditioning test is satisfied)J integer Column counterNCYL integer Cylinder number (1 for inner and 2 for outer)NU1 real Poisson’s ratio of the material of the inner cylinder, ν1NU2 real Poisson’s ratio of the material of the outer cylinder, ν2P real Internal pressure, pRATIO real Ratio of radii R3 and R1
R1 real Inner radius of the inner cylinder, R1
R2 real Nominal outer radius of the inner cylinder and inner radius of the outercylinder, R2
R3 real Outer radius of the outer cylinder, R3
SCOEFF real Array forming temporary store for array COEFFSIGE real Von Mises equivalent stress, σeSIGH real Hoop stress, σθSIGR real Radial stress, σrSIGZ real Mean axial stress, σzSURF character Label for inner or outer surface of a cylinder