Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 61

1

DEPARTMENT OF AGRICULTURAL AND ENVIRONMENTAL ENGINEERING,

COLLEGE OF ENGINEERING, UNIVERSITY OF AGRICULTURE, MAKURDI

NAME: TANKO BAKO

REGISTRATION NUMBER: 15/8978/PhD

COURSE: COMPUTER MODELING OF AGRICULTURAL SYSTEMS (AEE 704)


ASSIGNMENT 1

COURSE LECTURER: ENGR. PROF. S.E. OBETTA

DATE: 1ST APRIL, 2016


2

QUESTIONS:
No. 1. (a) Write short notes on the followings

i. Arithmetic IF statement
ii. Logical IF statement
iii. Computed GOTO statement
iv. DATA statement

(b) Explain and give examples of the followings, defining all the components

i. F-Descriptor
ii. I-Descriptor
iii. E-Descriptor
iv. A-Descriptor
v. X-Descriptor
vi. H-Descriptor

No. 2 (a) What are the differences between modeling a process and simulating the same process
(b) What advantages can simulation offer in real Research?
(c) What do you understand by Numerical Methods and steps involved in the use of it in
solving problems
(d) When is the term optimization used in the solution of complex equations?

No. 3. Express linearly the determinant of this Matrix

a11 a12 a13

a21 a22 a23

a31 a32 a33

and calculate the inverse A-1 of

2 0 0
A =(0 2 0)
0 0 2
3

No. 4. What is a Flowchart?

In the flow chart below, you are required to find the value of t when n = 8. Given that values of
the variables are given in the table as in below also.

start

n 4
44

i, j, k

t= i + j + k

n n+2
44

n≤6

stop

i J K
2 1 2
1 2 3
8 9 10
3 4 6
1 0 1
3 3 3
4

SOLUTION:

No. 1.

(a)

i. Arithmetic IF Statement

The arithmetic IF statement is a three-way branching statement based on an arithmetic

expression. It is a three-way arithmetic conditional statement, first seen in the first release of

Fortran in 1957, and found in all later versions, and some other programming languages, such as

FOCAL. It is a three way branch statement of the form, IF (<expression>) <label 1>, <label 2>,

<label 3>.

Here <expression is any expression producing a result of type INTEGER, REAL or DOUBLE

PRECISION, and the three labels are statement labels of executable statements. If the value of

the expression is negative execution transfers to the statement labeled <label 1>. If the

expression is zero transfer is to the statement labeled <label 2> and a positive result causes

transfer to <label 3>. The same label can be repeated.

The arithmetic IF statement conditionally transfers control to one of three statements, based on

the value of an arithmetic expression. It is an obsolescent feature in FORTRAN 95 and

FORTRAN 90.

The form of an arithmetic IF statement is: IF (e) s1, s2, s3.

Where;

e is an integer, real, or double precision expression s1, s2, and s3 are each the statement

label of an executable statement that appears in the same program unit as the arithmetic

IF statement.
5

The same statement label may appear more than once in the same arithmetic IF statement.

Execution of arithmetic IF statement causes evaluation of the expression e followed by a transfer

of control. The statement identified by s1, s2, or s3 is executed next as the value of e is less than

zero, equal to zero, or greater than zero, respectively.

During execution, the expression is evaluated first depending on the value of the expression;

control is then transferred as follows:

IF the value of EXPR is : Control transfers to:


Less than 0 Statement label 1

Equal to 0 Statement label 2

Greater than 0 Statement label 3

ii. Logical IF Statement

An important part of any programming language is the conditional statements. The most

common such statement in Fortran is the if statement, which actually has several forms. The

simplest one is the logical if statement. The logical IF statement is from FORTRAN 66 which is

an improvement over the FORTRAN I arithmetic IF. The logical IF statement is used to execute

an instruction conditionally. IF logical-expression is true, statement is executed. Otherwise,

execution goes through. The statement can be assignment and input/output form.

The form of a logical IF statement is: IF (e) st

Where;

e is a logical expression
6

st is any executable statement except a DO, block IF, ELSE IF, ELSE, END IF, END, or

another logical IF statement.

Execution of a logical IF statement causes evaluation of the expression e. If the value of e is true,

statement st is executed. If the value of e is false, statement st is not executed and the execution

sequence continues as though a CONTINUE statement were executed. Note that the execution of

a function reference in the expression e of a logical IF statement is permitted to affect entities in

the statement st.

If (logical expression) executable statement

This has to be written on one line. This example finds the absolute value of x:

if (x .LT. 0) x = -x

If more than one statement should be executed inside the if, then the following syntax should be

used:

if (logical expression) then

statements

end if

The most general form of the If statement has the following form:

if (logical expression) then

statements

else if (logical expression) then

statements

else
7

statements

end if

The execution flow is from top to bottom. The conditional expressions are evaluated in sequence

until one is found to be true. Then the associated statements are executed and the control resumes

after the end If.

Unlike the logical IF statements seen in other languages, the Fortran statement defines three

different branches depending on whether the result of an expression is negative, zero, or positive,

in said order, written as: IF (expression) negative, zero, positive.

iii. Computed GO TO Statement

Goto (goto, GOTO, GO TO or other case combinations, depending on the programming

language) is a statement found in many computer programming languages. It performs a one-

way transfer of control to another line of code; in contrast a function call normally returns

control. The jumped-to locations are usually identified using labels, though some languages use

line numbers. At the machine code level, a goto is a form of branch or jump statement.

Computed GOTO statement is an extended form of the simple GOTO statement, which is used to

go to one of several sets of statements depending on the value of an integer variable. The

computed GOTO statement transfer control to one of a set of labeled branch target statements

based on the value of an expression. In FORTRAN, a computed GOTO jumps to one of several

labels in a list, based on the value of an expression. An example is goto (20, 30, 40) i. The

equivalent construct in C is the switch statement and in newer Fortran a CASE statement is the
8

recommend syntactical alternative. BASIC has the ON ... GOTO construct that achieves the

same goal.

The form of a computed GO TO statement is: GO TO (s [,s]...) [,]i

Where;

i is an integer expression

s is the statement label of an executable statement that appears in the same program unit

as the computed GO TO statement.

The same statement label may appear more than once in the same computed GO TO statement.

Execution of a computed GO TO statement causes evaluation of the expression i. The evaluation

of i is followed by a transfer of control so that the statement identified by the ith statement label

in the list of statement labels is executed next, provided that 1 ≤ i ≤ n, where n is the number of

statement labels in the list of statement labels. If i< 1 or i > n, the execution sequence continues

as though a CONTINUE statement were executed.

iv. DATA Statement

The DATA statement is a non-executable statement used to initialise variables. It is particularly

useful for initialising arrays. The DATA statement must follow the type specification statements

but can appear anywhere else in the program unit. By convention, they always appear directly

after the specification statements and before the executable statements.

The DATA statement is the only attribute specification statement for which there is no

corresponding attribute that may appear in a type declaration statement. It is, however, possible

to initialize a variable in an entity-oriented type declaration statement. When an initialization


9

expression appears in a declaration for an object that does not have the PARAMETER attribute,

the object (which is a variable) is given the specified initial value. The same rules apply to the

assignment of the initial value as apply when an assignment statement is executed. For example,

if the variable is of type real but the value is an integer value, the variable will be assigned the

real equivalent of the integer value. If the kind of the variable is different from the kind of the

value, the value will be “converted” to the kind of the variable. Array constructors may be used

to initialize arrays, and structure constructors may be used to initialize variables of user-defined

type.

The important difference between the DATA and PARAMETER statements is that the DATA

statement specifies an initial value for a variable or array element which may be subsequently

changed during program execution. The value of a named constant defined by a PARAMETER

statement may not be changed.

It takes the form; DATA var-list1 /value-list1/, var-list2 /value-list2/, …, var-listn /value-listn/

Where;

var-list is a list of variable names, array names, substring names and implied DO lists,

and value-list is a list of literal or named constants, optionally preceded by a repeat-count

and an asterisk *. The repeat-count is either an unsigned integer value or a named

constant.

Each variable-list is a list of variables, and each constant-list a list of constants, separated by

commas in each case. Each constant-list must contain the same number of items as the preceding

variable-list and corresponding items in sequence in the two lists must be of the same type.
10

The DATA statement assigns to each variable in each variable-list a value equal to the

corresponding constant in the corresponding constant-list.

For example: DATA A, B, N/1.0, 2.0, 17/ assigns the values 1. and 2. respectively to the REAL

variables A and B, and 17 to the INTEGER variable N. A constant may be repeated by

proceeding it by the number of repetitions required (an integer) and an asterisk. Thus: DATA

N1, N2, N3, N4/4*0/ assigns a value of zero to each of the variables N1, N2, N3 and N4.

Items in a variable-list may be array elements. Thus, if A is an array of dimension 20, the DATA

statement: DATA A(1),A(2),A(3),A(4)/4*0.0/,A(20)/-1.0/ assigns a value of zero to the first four

elements, -1.0 to the last element, and leaves the remaining elements undefined.

The DATA statement can be used also for arrays and variables of derived type. It is also the only

way to initialise just parts of such objects, as well as to initialise to binary, octal or hexadecimal

values:

TYPE (triplet): t1, t2

DATA t1/triplet (0., (/ 0., 1., 2. /) )/, t2%u/0./

DATA array (1:64) / 64*0/

DATA i, j, k/ B'01010101', O'77', Z'ff'/

(b)

i. F-Descriptor

The F edit descriptor defines a field for real and complex values. The value is rounded to d digits

to the right of the decimal point. The field width, w, should be four greater than the expected
11

length of the number to provide positions for a leading blank, the sign, the decimal point, and a

roll-over digit for rounding if needed. This is used to convert data of type real with no exponent

on output. The Fw.d descriptor is for REAL output. The general form is rFw.d

The meaning of r, w and d are:

F = is for REAL

r = is the repetition indicator, which gives the number of times the edit descriptor should

be repeated. For example, 3F5.3 is equivalent to F5.3, F5.3, F5.3.

w = is the width of field, which indicates that a real number should be printed with w

positions.

d = indicates the number of digits after, the decimal point.

More precisely, of these w positions, the right-most d positions are for the fraction part of a real

number, and d+1 position from the right is a decimal point. The remaining w-(d+1) positions are

for the integral part. This shown in the figure below:


d

When a real number is printed, its integral part is printed as if it uses Im-(d+1). Therefore, if the

number of positions is not enough to print the integral part completely, all w position will be

filled with asterisks. Please note that the integral part contains a sign and as a result w should be

greater than or equal to d+2.

The fractional part may have more than d digits. In this case, the (d+1) digit will be rounded to

the dth one. For example, if 1.73 is printed with F3.1 (using 3 positions to print a real number
12

with the right-most position for the fractional part), since the second digit of the fractional part is

3, the result is 1.7. However, if 1.76 is printed with F3.1, the result becomes 1.8 because 6 is

rounded.

The fractional part may have fewer than d digits. In this case, trailing zeros will be added.

Note that d can be zero. In this case, no fractional part will be printed. More precisely, the right-

most position is the decimal point.

Examples

Let us look at the following example. There are two REAL variables a and b with values 123.345

and -123.345 respectively. In the following table, the WRITE statements are shown in the left

and their corresponding output, all using five positions, are shown in the right.

REAL : : a = 123.345, b = -123.345


1 WRITE(*,”(F10.0)”) a 1 2 3 .
2 WRITE(*,”(F10.1)”) a 1 2 3 . 3
3 WRITE(*,”(F10.2)”) a 1 2 3 . 3 5
4 WRITE(*,”(F10.3)”) a 1 2 3 . 3 4 5
5 WRITE(*,”(F10.4)”) a 1 2 3 . 3 4 5 0
6 WRITE(*,”(F10.5)”) a 1 2 3 . 3 4 5 0 0
7 WRITE(*,”(F10.6)”) a 1 2 3 . 3 4 5 0 0 0
8 WRITE(*,”(F10.7)”) a * * * * * * * * * *
9 WRITE(*,”(F10.4)”) b - 1 2 3 . 3 4 5 0
10 WRITE(*,”(F10.5)”) b - 1 2 3 . 3 4 5 0 0
11 WRITE(*,”(F10.6)”) b * * * * * * * * * *
1 2 3 4 5 6 7 8 9 10
13

The first line prints 123.345 with F10.0. This means that of the ten positions the right-most one

should contain a decimal point (since d is zero). Therefore, no fractional part is printed.

The second line is easy.

The third line uses F10.2 to print 123.345. Of these ten positions, the last two are used to print

the fractional part (i.e., 345). Therefore, the third digit, 5, is rounded yielding 35. Hence the

result is 123.35.

The fourth line uses F10.4 to print 123.345. Since there are four positions for the fractional part

which is larger than the number of actual digits, a trailing zero is added.

The eighth lines F10.7 to print, 123.345. Since there are only 10-(7+1) = 2 positions for printing

the integral part which has three digits, all 10 positions are filled with asterisks.

The eleventh line has the same result. There are 10-(6+1) = 3 positions for the integral part.

However, the integral part – 123 requires four positions. As a result, all 10 positions are filled

with asterisks.

Consider the following example. The WRITE statement has three REAL variables and

consequently the format must also have three I edit descriptors, one for each variable.

REAL :: a = 12.34, b = -0.945, c = 100.0

WRITE (*,"(3F6.2)") a, b, c

The edit descriptor is 3F6.2 and the format is equivalent to (F6.2, F6.2, F6.2) because the

repetition indicator is 3. Therefore, each of these three REAL variables is printed with F6.2.

Based on the discussion earlier, the result is the following:


14

1 2 . 3 4 - 0 . 9 5 1 0 1 . 0 0

ii. I-Descriptors

The integer (I) edit descriptor defines a field for an integer number. The internal descriptors are

used to convert data of type integer. As an Intel Fortran extension, it can also be used on real and

logical data. The Iw and Iw.m descriptors are for INTEGER output. The general forms of these

descriptors are as follows: rIw and rIw.m.

The meaning of r, w and m are:

I = is for INTEGER

r = is the repetition indicator, which gives the number of times the edit descriptor should

be repeated. For example, 3I5.3 is equivalent to I5.3, I5.3, I5.3.

w = is the width of field, which indicates that an integer should be printed with w

positions.

m = indicates that at least m positions (of the w positions) must contain digits.

If the number to be printed has fewer than m digits, leading 0s are filled. If the number to be

output has more than m digits, m is ignored and in this case Iw.m is equivalent to Iw. Note that w

must be positive and larger than or equal to m. It is interesting to note that m can be zero. That is,

no digits should be printed. In this case, if the number to be printed is non-zero, it will be printed

as if Iw is used. However, if the number is zero, all w positions will be filled with spaces.

The sign of a number also needs one position. Thus, if -234 is printed, w must be larger than or

equal to 4. The sign of a positive number is not printed.


15

What if the number of positions is less than the number of digits plus the sign? In other words,

what if a value of 12345 is printed with I3? Three positions are not enough to print the value of

five digits. In this case, traditionally, all w positions are filled with *'s. Therefore, if you see a

sequence of asterisks, you know your edit descriptor does not have enough length to print a

number.

Examples

Let us look at the following example. There are three INTEGER variables a, b and c with values

123, -123 and 123456, respectively. In the following table, the WRITE statements are shown at

the left and their corresponding output, all using five positions, are shown at the right.

WRITE(*,”(15)”) a 1 2 3
WRITE(*,”(15.2)”) a 1 2 3
WRITE(*,”(15.4)”) a 0 1 2 3
WRITE(*,”(15.5)”) a 0 0 1 2 3
WRITE(*,”(F15)”) b - 1 2 3
WRITE(*,”(F15.2)”) b - - 1 2 3
WRITE(*,”(F15.4)”) b 1 0 1 2 3
WRITE(*,”(F15.5)”) b * * * * *
WRITE(*,”(F15.2)”) c * * * * *

The first line uses (I5) to print the value of 123. Thus, digits 1, 2 and 3 appear at the right end

and two leading spaces are filled.


16

The second line uses (I5.2) to print 123. This means of the five positions, two positions must

contain digits. Since the value 123 has already had 3 digits. Therefore, .2 is ignored and the

result is the same as that of the first line.

The third line uses (I5.4) to print 123. Since m = 4, four positions must be filled with digits.

Since 123 has only three digits, a leading 0 must be inserted. Thus, in the output, the five

positions contain a space, 0, 1, 2 and 3.

The fourth line uses I5.5 and therefore forces two 0s to be inserted.

The fifth line uses (I5) to print -123. Since the number is negative, a minus sign is printed. The

sixth line produces the same result as that of the fifth line.

The seventh line tells us that if leading zeros must be inserted, they are inserted between the

minus sign and the number.

The eighth line uses (I5.5) to print -123. This is not a good edit descriptor. I5.5 means to print a

number using five positions and all five positions must be filled with digits. If the number is

positive, there is no problem as shown in the fourth line. However, if the number is negative,

there will be no position for the minus sign. As a result, all five positions are filled with asterisks,

indicating a problem has occurred.

The last line uses I5.2 to print 123456. The number has six digits and the number of positions to

print this number is five. Thus, the given number 123456 cannot be printed completely and all

five positions are filled with asterisks.


17

Consider the following example. The WRITE statement has three INTEGER variables and

consequently the format must also have three I edit descriptors, one for each variable.

INTEGER :: a = 3, b = -5, c = 128

WRITE (*,"(3I4.2)") a, b, c

The edit descriptor is 3I4.2 and the format is equivalent to (I4.2, I4.2, I4.2) because the repetition

indicator is 3. Therefore, each of the three INTEGER variables is printed with I4.2. Based on the

discussion earlier, the result is the following:

0 3 - 0 5 1 2 8

iii. E-Descriptor

The E edit descriptors define a normalized floating-point field for real and complex values. The

value is rounded to d digits. The exponent part consists of e digits. This descriptor converts data

of type real with an exponent. The edit descriptor E is used to control the format of real numbers

where a floating decimal point notation is required. The Ew.d and Ew.dEe descriptors are for

REAL output. The printed numbers will be in an exponential form. The general forms of these

descriptors are of two different kinds; ESw.d and ENw.d which are also stated as: rEw.d and

rEw.dEe.

The meaning of r, w, d and e are:

E = is for REAL numbers in exponential forms.


18

r = is the repetition indicator, which gives the number of times the edit descriptor

should be repeated. For example, 3E20.7E2 is equivalent to E20.7E2, E20.7E2,

E20.7E2.

w = is the width of field, which indicates that a real number should be printed with w

positions.

d = the number of digits to the right of the decimal point

e = the number of digits in the exponent part

To print a number in an exponential form, it is first converted to a normalized form

s0.xxx...xxx*10sxx, where s is the sign of the number and the exponent and x is a digit. For

example, 12.345, -12.345, 0.00123 and -0.00123 are converted to 0.12345*102, 0.12345*102,

0.123*10-2 and -0.123*10-2.

The EW.d descriptor generates real numbers in the following form:

d 3

0 . E

Of these w positions, the last three are for the exponent, including its sign, the middle d positions

are for the number in normalized form. Therefore, excluding the exponent part, there are w-4

positions for printing the digits of the normalized number. In fact, you can consider the

normalized number is printed with FW-4.d. The above figure also includes a 0 and a decimal

point. If the number is negative, we must also include its sign. Hence, 4+3 = 7 positions are not

available for printing the normalized number and, as a result, when you use the E edit descriptor,
19

W must be greater than or equal to d+7, otherwise, your number may not be printed properly and

all w positions will be filled with asterisks.

The EW.dEe descriptor generates real numbers in the following form:

d e

0 . E +

As you can see, the only difference is that the exponent part now has e positions. If your data has

an exponent larger than 99 or less than -99, Ew.d will not be able to print it properly because

there are only two positions for the exponent(therefore, all w positions will be filled with

asterisks). As shown in the figure, in addition to the d positions for the exponent, we need four

more positions for printing the sign in the exponent, a decimal point, a leading o and the

character E. Moreover, it the number is negative, a sign before the O is needed. This means that

w must be greater than or equal to d+e+5.

Examples

In the following table, the WRITE statements use different E edit descriptors to print the value of

3.1415926. The WRITE statements are shown in the left and their corresponding output, all

using 12 positions, are shown in the right.

REAL : : PI = 3.1415926
1 WRITE(*,”(E12.5)”) PI 0 . 3 1 4 1 6 E + 0 1
2 WRITE(*,”(E12.3E4)”) PI 0 . 3 1 4 E + 0 0 0 1
3 WRITE(*,”(E12.7E1)”) PI 0 . 3 1 4 1 5 9 3 E + 1
1 2 3 4 5 6 7 8 9 10 11 12
20

The first example uses E12.5 to print. 3.1415926. This number is first converted to

0.31415926x101. Therefore, the normalized number is 0.31415926 and the exponent is 1. The

exponent part is printed as E+01. Since we have only 5 positions for printing 0.31415926 which

has 8 digits, the sixth one will be rounded to the fifth and the result is 0.31416.

The second example uses E12.3E4 to print the same number. This E descriptor indicates that

four positions are fir the exponent and, as a result, the printed exponent part is E+0001.

The last example is obvious. However, if the number is changed to -31415926, the results will 12

asterisks, since there is no position for the sign of the number.

Editor Descriptor ESw.d and ESw.dEe

Scientists write the exponential form in a slightly different way. This ES edit descriptor is for

printing a real number in scientific form, which has a non-zero digit as the integral part. If the

number is a zero, then all digits printed will be zero. The following shows the printed form:

d 3

x . E

d e

x . E +

If you understand the form of normalized number, you can just shift the decimal point to the

right one position and decrease the exponent by one. The result is in scientific form. For

example, if the number is 34.5678, it has a normalized form 0.345678*102. Now shifting the
21

decimal point to the right one position gives 3.45678*101. The following shows the output

printed with ES12.3E3:

3 . 4 5 7 E + 0 0 1

Editor Descriptor ENw.d and ENw.dEe

Engineers write the exponential form in yet another way. In an engineering form, the exponent is

always a multiple of three, and the printed number always has no more than three and at least

one non-zero digits. For example, suppose the given number is 1234.567. The integral part has

four digits and the exponent is zero. To convert this number to an engineering form, the decimal

point should be shifted to the left three positions. Thus, the given number has a new form

1.234567*103. Similarly, if the given number is 0.00001234567, shifting the decimal point to the

right three positions gives 0.01234567*103.

However, this is not yet in the engineering form, because the integral part is still zero. Therefore,

we need to shift the decimal point to the right three positions again and this gives 12.34567*10-6.

Now, the number is in engineering form. The following shows the output of ENw.d and

ENw.dEe. For ENw.d, it requires 4 positions for the exponent, d positions for the fractional part

of the number, 3 positions for the integral part, one position for the decimal point, and one

position for the possible sign. It requires at least d+9 positions and consequently for ENw.d, w

must be larger than or equal to d+9. The same counting yields that for ENw.dEe, w must be
d 3
larger than or equal to d+e+7.
x x x . E

d e

x x x . E +

W
22

iv. A-Descriptor

The A edit descriptor defines fields for character data. The A edit descriptor specifies left-

justification and converts data of type character. The A edit descriptor is used to control the

format of characters and strings. It has the form A or Aw. The A descriptor will writes as many

characters as required while Aw writes a string of width w.

The Aw edit descriptor is used with an input/output list item of type CHARACTER. If a field

width w is specified with the A edit descriptor, the field consists of w characters. If a field width

w is not specified with the A edit descriptor, the number of characters in the field is the length of

the corresponding list item.

The A and Aw descriptors are for CHARACTER output. The general forms of these descriptors

are as follows: rA and rAw.

The meaning of r and w are:

r = is the repetition indicator, which gives the number of times the edit descriptor should

be repeated. For example, 3A5 is equivalent to A5, A5, A5, and 3A is equivalent to

A, A, A.

A = is for CHARACTER.

w = is the width of field, which indicates that a character string should be printed with w

positions.

The output of the character string depends on two factors, namely the length of the character

string and the value of w. Here are the rules:


23

If w is larger than the length of the character string, all characters of the string can be printed and

are right-justified. Also, leading spaces will be added. The following example prints the string

"12345" of length 5 (i.e., five characters) using A6.

WRITE (*,'(A6)') "12345"

Since w is larger than the length of the string, all five characters are printed and right-justified.

The result is shown below:

1 2 3 4 5

If w is less than the length of the character string, then the string is truncated and only the left-

most w positions are printed in the w positions. The following example prints the string

"12345678" of length 8 (i.e., eight characters) using A6.

WRITE (*,'(A6)') "12345678".

Since w is less than the length of the string, only the first six characters are printed. The result is

shown below:

1 2 3 4 5 6

If w is equal to the length of the character string, then it is an exact match. All characters can be

printed and all w positions are filled.

If w is missing (i.e., edit descriptor A), then the value of w is assumed to be the length of the

string. The following example shows two WRITE statements. The first one uses A to print a, a

string of length 5. The second one also uses A to print b, a string of length 2.

CHARACTER(LEN=5) :: a = "abcde"
24

CHARACTER (LEN=2) :: b = "MI"

WRITE (*,'(A)') a

WRITE (*,'(A)') b

Since the A edit descriptor will use the length of the string as the value of w, the above is

equivalent to the following:

CHARACTER (LEN=5) :: a = "abcde"

CHARACTER (LEN=2) :: b = "MI"

WRITE (*,'(A5)') a

WRITE (*,'(A2)') b

Therefore, the A edit descriptor is more convenient than Aw.

Please keep in mind that the length of the string includes trailing spaces. For example, if we have

the following:

CHARACTER (LEN=5) :: a = "123"

CHARACTER :: b = "*"

WRITE (*,"(A, A)") a, b

it is equivalent to

CHARACTER (LEN=5) :: a = "123"

CHARACTER :: b = "*"

WRITE(*,"(A5,A1)") a, b

And the result is

1 2 3 *
25

The first string, a, is of length 5 and hence the first five positions are used. Why are two extra

spaces when the string is written as a = "123"? Since the length of a is five and "123" has only

three characters, two spaces are added to the right end to make up five characters. Therefore,

variable, a, actually contains five characters: 1, 2, 3 and two spaces. This is why two spaces are

between 123 and * in the above output.

Examples

Let us look at the following example.

CHARACTER (LEN=5) :: a = "12345"

CHARACTER :: b = "*"

In the following table, the WRITE statements are shown at the left and their corresponding

output are shown at the right.

1 WRITE(*,”(A1, A)”) a, b 1 *
2 WRITE(*,”(A2, A)”) a, b 1 2 *
3 WRITE(*,”(A3, A)”) a, b 1 2 3 *
4 WRITE(*,”(A4, A)”) a, b 1 2 3 4 *
5 WRITE(*,”(A5, A)”) a, b 1 2 3 4 5 *
6 WRITE(*,”(A6, A)”) a, b 1 2 3 4 5 *
7 WRITE(*,”(A7, A)”) a, b 1 2 3 4 5 *
8 WRITE(*,”(A, A)”) a, b 1 2 3 4 5 *
1 2 3 4 5 6 7 8

In WRITE statements 1 to 5, since the first A edit descriptor is less than or equal to the length of

the character variable, the strings to be printed are truncated from the right.
26

In WRITE statements 6 and 7, since the first A edit descriptor is greater than the length of the

character variable, leading spaces are added.

Finally, in the eighth WRITE statement, since the first A has no width of field, it is assumed to

be equal to the length of the variable. As a result, A5 is used and the result is identical to that of

the fifth WRITE.

v. X-Descriptor

The nX edit descriptor controls the character position in the current record to or from which the

next character will be transferred. The new position can be in either direction from the current

position. This makes possible the input of the same record twice, possibly with different editing.

It also makes skipping characters in a record possible. The nX edit descriptor provides for

skipping characters in input or specifying blank characters in output. The nX edit descriptor tabs

n characters right from the current position. If the position is changed to beyond the length of the

current record, the next data transfer to or from the record causes the insertion of blanks in the

character positions not previously filled.

Control edit descriptors determine the position, form, layout, and interpretation of characters

transferred to and from formatted records in a file. The X edit descriptors position the cursor on

the input or output record. The general form of this descriptor is; nX

Where;

n = is a positive integer constant, specifying the number of column positions to

skip for positioning within the current output or input record.

X Indicates a move of as many positions as indicated by n


27

The value of n is an integer number greater than O. On X input, n characters are read but

ignored. On X output, n spaces are output.

Negative –Valued X Descriptor

Tab right the specified number of positions. A negative value could be used with the x descriptor

to indicate a move to the left. This has been replaced by the TL descriptor. This is defined by;

-bX

Where;

B Any nonzero, unsigned integer constant

X Indicates a move of as many positions as indicated by b

Example

-55X! Move current position 55 spaces left

vi. H-Descriptor

The Hollerith (H) Edit Descriptor outputs a specified number of characters. The cH edit

descriptor causes character information to be written from the next c characters (including

blanks) following the H of the cH edit descriptor in the list of format items itself. The c

characters are called a Hollerith constant. The general form of this descriptor is; nH character-

sequence

Where;

H = Designates Hollerith fields.


28

n = is a positive integer that specifies the number of characters to output. This number

must exactly match the actual number of characters in character-sequence.

Character-sequence = is the string of representable characters (including blanks) to

output.

Transfer of text to output record. H-Descriptor is a computer image device that integrates colour,

texture, and shape wavelet for object and scene image classifications.

Field descriptor: nHa1 a2 a3 ... an

The numbers of characters specified by n immediately following the H descriptor are transmitted

to or from the external device. Blanks may be included in the alphanumeric string. The value of

n must be greater than zero (0).

On Hollerith input, n characters read from the external device replace the n characters following

the letter H.

In output mode, the n characters following the letter H, including blanks, are output.

Examples

3HABC

17H THIS IS AN ERROR

16H JANUARY 1, 1966


29

No. 2.

(a) The Differences between Modeling a Process and Simulating the Same Process

Modeling and simulations are two closely related computer applications which play a major role

in science and engineering today. Both computer modelling and simulations are computer

applications which represent a real world or imaginary system. Both computer modelling and

simulations help designers to save time and money.

Modeling is the act of building a model. A model is a product (physical or digital) that represents

a system of interest. A model is similar to but simpler than the system it represents, while

approximating most of the same salient features of the real system as close as possible. A good

model is a judicious tradeoff between realism and simplicity. A key feature of a model is

manipulability. A model can be a physical model (for example a physical architectural house

scale model, a model aircraft, a fashion mannequin, or a model organism in biology research); or

a conceptual model (for example a computer model, a statistical or mathematical model, a

business model.

Modeling is creating a ‘model’ which represents an object or system with its all or subset of

properties. A model may be exactly the same as the original system or sometimes

approximations make it deviates from the real system. As an example, a computer model of a

ship may provide the 3D visualization of the ship so that user can rotate and zoom to get a clear

idea of the dimensions of the ship. A mathematical model is something different from a 3D

model. A mathematical model describes a system with equations.


30

Modeling can reduce the cost of a process and make the progress faster. As an example when

you need to build a ship you can create few models of it and find the best solution. This is not

possible in absence of modelling because you cannot build several ships and select one in reality.

Therefore present designers are able to optimize their design.

Simulating is the act of using a model for a simulation. A simulation is the process of using a

model to study the behavior and performance of an actual or theoretical system. In a simulation,

models can be used to study existing or proposed characteristics of a system. The purpose of a

simulation is to study the characteristics of a real-life or fictional system by manipulating

variables that cannot be controlled in a real system. Simulations allow evaluating a model to

optimize system performance or to make predictions about a real system. Simulations are useful

to study properties of a model of a real-life system that would otherwise be too complex, too

large/small, too fast/slow, not accessible, too dangerous or unacceptable to engage. While a

model aims to be true to the system it represents, a simulation can use a model to explore states

that would not be possible in the original system.

In a simulation process, one or more variable of the mathematical model is changed and resulted

changes in other variables are observed. Simulations enable users to predict the behavior of the

real world system. As an example, behavior of a ship can be simulated using a mathematical

model describes the governing laws of physics (fluid statistics and dynamics). Users can change

the variable such as speed, weight and observe the stability of the ship.

Simulations are also used to train people for some specific activities and reactions to unexpected

situations. Car and flight simulators training drivers and pilots are examples of such simulations.
31

Simulations help designers to optimize their systems by doing necessary changes thereby

obtaining good results. They can try different designs while changing properties in virtual

environment so that money and time can be saved. Users can run simulations slower or faster

than the real world and that may helps to figure out more details.

Some of the differences between modeling a process and simulating the same process include;

i. The term modeling refers to the development of a mathematical representation of a physical

situation. On the other hand, simulation refers to the procedure of solving the equations that

resulted from model development.

ii. Modeling obtains a set of equations (mathematical model) that describes the behavior of the

system. A model describes the mathematical relationship between inputs and outputs. While

simulation uses the mathematical model to determine the response of the system in different

situation.

iii. A simulation is changing one or more variables of a model and observing the resulted

changes.

iv. Although a model always tries to represent the actual system, a simulation may try to observe

the results by doing impossible (in real world) changes.

v. A model can be considered as a static and a simulation can be considered as dynamic as the

variables of a simulation get always changed.

vi. Process simulation is merely one of the activities that can be performed with that process
model.
32

(b) Advantages Simulation Can Offer in Real Research

Simulation is a technique of studying and analyzing the behavior of a real world or an imaginary

system by mimicking it on a computer application. Simulations help designers to optimize their

systems by doing necessary changes and obtain good results. They can try deferent designs while

changing properties in virtual environment so that money and time can be saved. Users can run

simulations slower or faster than the real world and that may helps to figure out more details.

One of the primary advantages of simulators is that they are able to provide users with practical

feedback when designing real world systems. This allows the designer to determine the

correctness and efficiency of a design before the system is actually constructed. Consequently,

the user may explore the merits of alternative designs without actually physically building the

systems. By investigating the effects of specific design decisions during the design phase rather

than the construction phase, the overall cost of building the system diminishes significantly. As

an example, consider the design and fabrication of integrated circuits. During the design phase,

the designer is presented with a myriad of decisions regarding such things as the placement of

components and the routing of the connecting wires. It would be very costly to actually fabricate

all of the potential designs as a means of evaluating their respective performance. Through the

use of a simulator, however, the user may investigate the relative superiority of each design

without actually fabricating the circuits themselves. By mimicking the behaviour of the designs,

the circuit simulator is able to provide the designer with information pertaining to the correctness

and efficiency of alternate designs. After carefully weighing the ramifications of each design, the

best circuit may then be fabricated.


33

Another benefit of simulators is that they permit system designers to study a problem at several

different levels of abstraction. By approaching a system at a higher level of abstraction, the

designer is better able to understand the behaviors and interactions of all the high level

components within the system and is therefore better equipped to counteract the complexity of

the overall system. This complexity may simply overwhelm the designer if the problem had been

approached from a lower level. As the designer better understands the operation of the higher

level components through the use of the simulator, the lower level components may then be

designed and subsequently simulated for verification and performance evaluation. The entire

system may be built based upon this ``top-down'' technique. This approach is often referred to as

hierarchical decomposition and is essential in any design tool and simulator which deals with the

construction of complex systems. For example, with respect to circuits, it is often useful to think

of a microprocessor in terms of its registers, arithmetic logic units, multiplexors and control

units. A simulator which permits the construction, interconnection and subsequent simulation of

these higher level entities is much more useful than a simulator which only lets the designer

build and connects simple logic gates. Working at a higher level abstraction also facilitates rapid

prototyping in which preliminary systems are designed quickly for the purpose of studying the

feasibility and practicality of the high-level design.

Thirdly, simulators can be used as an effective means for teaching or demonstrating concepts to

students. This is particularly true of simulators that make intelligent use of computer graphics

and animation. Such simulators dynamically show the behavior and relationship of all the

simulated system's components, thereby providing the user with a meaningful understanding of

the system's nature. Consider again, for example, a circuit simulator. By showing the paths taken

by signals as inputs are consumed by components and outputs are produced over their respective
34

fan out, the student can actually see what is happening within the circuit and is therefore left with

a better understanding for the dynamics of the circuit. Such a simulator should also permit

students to speed up, slow down, stop or even reverse a simulation as a means of aiding

understanding. This is particularly true when simulating circuits which contain feedback loops or

other operations which are not immediately intuitive upon an initial investigation.

Educational simulations are generally grouped into four categories: physical, iterative,

procedural or situational.

Physical simulations allow the learner to manipulate variables in an open-ended scenario and

observe the results. An example of a physical simulation would be a model of global weather

patterns in which the student can manipulate certain parameters and observe the outcome.

Iterative simulations tend to focus on discovery learning by providing the student with

opportunities to conduct scientific research, build and test hypothesis and observe the results.

This type of simulation typically focuses on teaching phenomena which are not readily

observable in real-time, for example, phenomena from biology, geology or economics. In this

case, the student would repeatedly run the simulation, altering variables with each iteration to

test a hypothesis.

In a procedural simulation the student manipulates simulated objects with the goal of mastering

the skills required to correctly and accurately manipulate physical objects in a real-world setting.

A typical example of a procedural simulation is a chemistry lab experiment in which the student

manipulates simulated laboratory equipment with the goal of preparing the student for working

in a real-world laboratory setting.


35

Situational simulations generally model human behavior focusing on attitudes of individuals or

groups in specific settings. These simulations often employ role playing as a vehicle to allow

students to explore different options and decision paths. Situational simulations are usually

designed to be run several times with each participant in the simulation scenario playing a

different role in each iteration. It should be noted that, because of their open-ended design, and

due to the complexity of modeling human behavior, situational simulations tend to be the most

difficult type of simulation to design and utilize effectively.

For most companies and research institutions, the benefits of using simulation go beyond just

providing a look into the future. These benefits are mentioned by Law and Kelton (2000) and are

included in the following:

Choose Correctly: Simulation lets you test every aspect of a proposed change or addition

without committing resources to their acquisition. This is critical, because once the hard

decisions have been made, the bricks have been laid, or the material-handling systems have been

installed, changes and corrections can be extremely expensive. Simulation allows you to test

your designs without committing resources to acquisition. Evaluation of a proposed system

design for the purpose of assessing its quality characteristics such as operational effectiveness,

integrated system effectiveness, deployment readiness, performance, interoperability, and

security.

Time Compression and Expansion: By compressing or expanding time simulation allows you

to speed up or slow down phenomena so that you can thoroughly investigate them. You can

examine an entire shift in a matter of minutes if you desire, or you can spend two hours

examining all the events that occurred during one minute of simulated activity. Understand
36

"Why?" Managers often want to know why certain phenomena occur in a real system. With

simulation, you determine the answer to the "why" questions by reconstructing the scene and

taking a microscopic examination of the system to determine why the phenomenon occurs. You

cannot accomplish this with a real system because you cannot see or control it in its entirety.

Explore Possibilities: One of the greatest advantages of using simulation software is that once

you have developed a valid simulation model, you can explore new policies, operating

procedures, or methods without the expense and disruption of experimenting with the real

system. Modifications are incorporated in the model, and you observe the effects of those

changes on the computer rather than the real system.

Diagnose Problems: The modern factory floor or service organization is very complex. So

complex that it is impossible to consider all the interactions taking place in one given moment.

Simulation allows you to better understand the interactions among the variables that make up

such complex systems. Diagnosing problems and gaining insight into the importance of these

variables increases your understanding of their important effects on the performance of the

overall system. The last three claims can be made for virtually all modeling activities, queuing,

linear programming, etc. However, with simulation the models can become very complex and,

thus, have a higher fidelity, i.e., they are valid representations of reality.

Identify Constraints: Production bottlenecks give manufacturers headaches. It is easy to forget

that bottlenecks are an effect rather than a cause. However, by using simulation to perform

bottleneck analysis, you can discover the cause of the delays in work-in-process, information,

materials, or other processes.


37

Develop Understanding: Many people operate with the philosophy that talking loudly, using

computerized layouts, and writing complex reports convinces others that a manufacturing or

service system design is valid. In many cases these designs are based on someone's thoughts

about the way the system operates rather than on analysis. Simulation studies aid in providing

understanding about how a system really operates rather than indicating an individual's

predictions about how a system will operate.

Visualize the Plan: Taking your designs beyond CAD drawings by using the animation features

offered by many simulation packages allows you to see your facility or organization actually

running. Depending on the software used, you may be able to view your operations from various

angles and levels of magnification, even 3-D. This allows you to detect design flaws that appear

credible when seen just on paper on in a 2-D CAD drawing.

Build Consensus: Using simulation to present design changes creates an objective opinion. You

avoid having inferences made when you approve or disapprove of designs because you simply

select the designs and modifications that provided the most desirable results, whether it be

increasing production or reducing the waiting time for service. In addition, it is much easier to

accept reliable simulation results, which have been modeled, tested, validated, and visually

represented, instead of one person's opinion of the results that will occur from a proposed design.

Prepare for Change: We all know that the future will bring change. Answering all of the "what

if" questions is useful for both designing new systems and redesigning existing systems.

Interacting with all those involved in a project during the problem-formulation stage gives you

an idea of the scenarios that are of interest. Then you construct the model so that it answers

questions pertaining to those scenarios. What if an automated guided vehicle (AGV) is removed
38

from service for an extended period of time? What if demand for service increases by 10

percent? What if....? The options are unlimited.

Wise Investment: The typical cost of a simulation study is substantially less than 1% of the total

amount being expended for the implementation of a design or redesign. Since the cost of a

change or modification to a system after installation is so great, simulation is a wise investment.

Train the Team: Simulation models can provide excellent training when designed for that

purpose. Used in this manner, the team provides decision inputs to the simulation model as it

progresses. The team, and individual members of the team, can learn by their mistakes, and learn

to operate better. This is much less expensive and less disruptive than on-the-job learning.

Specify Requirements: Simulation can be used to specify requirements for a system design. For

example, the specifications for a particular type of machine in a complex system to achieve a

desired goal may be unknown. By simulating different capabilities for the machine, the

requirements can be established.

In addition, Simulation process can help achieve the following in real research;

i. Simulation can be used to study systems in the design stage.

ii. Simulation enables the study of experimentation with the internal interactions of a complex

system, or of a subsystem within a complex system.

iii. Simulation can be used as a pedagogical device to reinforce analytic solution methodologies.

iv. Simulation can be used to verify analytic solutions.

v. Animation shows a system in simulated operation so that the plan can be visualized.
39

vi. The modern system (factory, water fabrication plant and service organization) is so complex

that the interactions can be treated only through simulation.

vii. Time can be compressed or expanded allowing for a speedup or slowdown of the phenomena

under investigation.

viii. Insight can be obtained about the interaction of variables.

ix. Insight can be obtained about the importance of variables to the performance of the system.

x. A simulation study can help in understanding how the system operates rather than how

individuals think the system operates.

xi. Predict performance of current processes against effectiveness, readiness and cost to

determine areas of significant improvement potential.

xii. Enable rapid analysis in situations with either extensive data or no data.

xiii. Provide an understanding of why key factors have the highest impact on results and where

to focus efforts.

xiv. Meet quality objectives by determining optimal specifications and tolerances.

xv. Communicate findings in a simple, highly visual manner.

xvi. Simulation can be very purposive and for certain students very useful, such as students who

need some insight before they are able to learn and understand a new concept.

(c) Numerical Methods

Numerical methods are techniques by which mathematical problems are formulated so that they

can be solved with arithmetic operations. Numerical solutions are approximations where the

continuous model equations are approached in discrete steps, both in time, and for spatial

models, also in space. Numerical methods are used to approximate solutions of equations when
40

exact solutions cannot be determined via algebraic methods. They construct successive

approximations that converge to the exact solution of an equation or system of equations.

The advantage of numerical methods is that there is virtually no limit to the complexity of

problems that can be solved, but the price to be paid for this generality is the introduction of a

new kind of errors, so-called numerical errors which must be controlled. Numerical methods

provide a way to solve problems quickly and easily compared to analytic solutions.

Although there are many kinds of numerical methods, they have one common characteristic: they

invariably involve large numbers of tedious arithmetic calculations. It is little wonder that with

the development of fast, efficient digital computers, the role of numerical methods in engineering

problem solving has increased dramatically in recent years.

Generally, numerical solutions are obtained by writing a computer programme. As numerical

models generally proceed by stepping through time, a model calculation is often called a

simulation, or we talk about running a model.

Many physical problems that are modeled by scientist and engineers are highly non linear and

may be difficult to solve analytically, in this case. Numerical methods are efficient tools for

providing accurate approximate results at discrete points. This point can be joined together by

using suitable interpolation methods. For example, a couple of systems of non-linear differential

equations can be solved using fourth-order range-Kutta method, while this may not be achievable

using analytical methods. Similarly, an nth order non linear ordinary differential equation can be

reduced to a system of nth first order differential equations and solve by a suitable numerical

technique. This is also true for partial differential equation.


41

In many instances scientist and engineers work tabulated data. Working with this data may not

be easy as working with a function. To differentiate, integrate or use the tabulated data at points

not recorded may in general be achieved by either using a suitable numerical method to solve the

problem at discrete points or by replacing the points with a function which may be by

interpolation or extrapolation.

Thus, numerical methods are techniques for solving difficult problems at discrete points;

i. Advanced numerical methods are essential in making numerical weather prediction

feasible.

ii. Computing the trajectory of a spacecraft requires the accurate numerical solution of a

system of ordinary differential equations.

iii. Car companies can improve the crash safety of their vehicles by using computer

simulations of car crashes. Such simulations essentially consist of solving partial

differential equations numerically.

iv. Hedge funds (private investment funds) use tools from all fields of numerical analysis

to attempt to calculate the value of stocks and derivatives more precisely than other

market participants.

v. Airlines use sophisticated optimization algorithms to decide ticket prices, airplane

and crew assignments and fuel needs. Historically, such algorithms were developed

within the overlapping field of operations research.

vi. Insurance companies use numerical programs for actuarial analysis.

vii. Automatic preservation of airline seat and automatic printing of pack cheques and

telephone bills.
42

There are several reasons for the study numerical methods:

1. Numerical methods are extremely powerful problem-solving tools. They are capable of

handling large systems of equations, nonlinearities, and complicated geometries that are not

uncommon in engineering practice and that are often impossible to solve analytically. As

such, they greatly enhance your problem-solving skills.

2. During your careers, you may often have occasion to use commercially available prepackaged,

or “canned,” computer programs that involve numerical methods. The intelligent use of these

programs is often predicated on knowledge of the basic theory underlying the methods.

3. Many problems cannot be approached using canned programs. If you are conversant with

numerical methods and are adept at computer programming, you can design your own

programs to solve problems without having to buy or commission expensive software.

4. Numerical methods are an efficient vehicle for learning to use computers. It is well known that

an effective way to learn programming is to actually write computer programs. Because

numerical methods are for the most part designed for implementation on computers, they are

ideal for this purpose. Further, they are especially well-suited to illustrate the power and the

limitations of computers. When you successfully implement numerical methods on a

computer and then apply them to solve otherwise intractable problems, you will be provided

with a dramatic demonstration of how computers can serve your professional development. At

the same time, you will also learn to acknowledge and control the errors of approximation that

are part and parcel of large scale numerical calculations.


43

5. Numerical methods provide a vehicle for you to reinforce your understanding of mathematics.

Because one function of numerical methods is to reduce higher mathematics to basic

arithmetic operations, they get at the “nuts and bolts” of some otherwise obscure topics.

Enhanced understanding and insight can result from this alternative perspective.

Steps involved in the use of numerical methods in solving problems

Analytical solution steps

Solutions were derived for some problems using analytical, or exact, methods. These solutions

were often useful and provided excellent insight into the behavior of some systems. However,

analytical solutions can be derived for only a limited class of problems. These include those that

can be approximated with linear models and those that have simple geometry and low

dimensionality. Consequently, analytical solutions are of limited practical value because most

real problems are nonlinear and involve complex shapes and processes.

Solving mathematical equations is an important requirement for various branches of science. The

field of numerical analysis explores the techniques that give approximate solutions to such

problems with the desired accuracy.

The steps involved in the use of numerical methods in solving problems analytically are;

i. Look for Distributive Property and solve. Pay close attention to the signs. Example: -

3(x+6) is simplified to -3x – 18

ii. Combine ‘like’ terms on both sides of the equation. Example: 6x + 8 – 3x = x – 7 + 4x is

simplified to 3x + 8 = 5x – 7
44

iii. Using adding and subtracting and Inverse Operation (opposite operation), get all of the

variables on one side of the equation and the integers on the other. Example: 5x – 20 = 3x

+ 10 subtract 3x on both sides to get 2x on the left side of the equal sign and add 20 to

each side to get 30 on the right side. We now have 2x = 30

iv. The final step is isolating the variable on one side of the equation. In the final step, start

on the side with the variable and use multiplication or division to find out what the

variable equals. Your problem is finished when you have the variable on one side of the

equal sign and what it equals on the other. Example: 2x = 30 divide by 2 on both sides of

the equation. x = 15

v. The final step is variable substitution to check your answer. In the previous problem x =

15. Take 15 and substitute it back in for x in the original problem. 5x – 20 = 3x + 10,

x = 15, 5(15) – 20 = 3(15) + 10, 75 – 20 = 45 + 10, 55 = 55 Correct!

Computer based solution steps

Today, computers and numerical methods provide an alternative for such complicated

calculations. Using computer power to obtain solutions directly, you can approach these

calculations without recourse to simplifying assumptions or time-intensive techniques. Although

analytical solutions are still extremely valuable both for problem solving and for providing

insight, numerical methods represent alternatives that greatly enlarge your capabilities to

confront and solve problems. As a result, more time is available for the use of your creative

skills. Thus, more emphasis can be placed on problem formulation and solution interpretation

and the incorporation of total system, or “holistic,” awareness.

The major steps involved to solve a given problem using a computer are:
45

i. Modeling: Setting up a mathematical model, i.e., formulating the problem in mathematical

terms, taking into account the type of computer one wants to use.

ii. Choosing an appropriate numerical method (algorithm) together with a preliminary error

analysis (estimation of error, determination of steps and size).

iii. Programming, usually starting with a flowchart showing a block diagram of the procedures to

be performed by the computer and then writing, say, a C++ program.

iv. Operation or computer execution.

v. Interpretation of results, which may include decisions to rerun if further data are needed.

(d) When the Term Optimization is used in the Solution of Complex Equations

Optimization is a balance between engineering and economics. The optimum is searched

considering all factors involved. Optimization is an act, process, or methodology of making

something (as a design, system, or decision) as fully perfect, functional, or effective as possible;

specifically : the mathematical procedures (as finding the maximum of a function) involved in

this.

Finding an alternative with the most cost effective or highest achievable performance under the

given constraints, by maximizing desired factors and minimizing undesired ones. In comparison,

maximization means trying to attain the highest or maximum result or outcome without regard to

cost or expense. Practice of optimization is restricted by the lack of full information, and the lack

of time to evaluate what information is available (see bounded reality for details). In computer

simulation (modeling) of business problems, optimization is achieved usually by using linear

programming techniques of operations research.


46

One of Fermat's theorems states that optima of unconstrained problems are found at stationary

points, where the first derivative or the gradient of the objective function is zero (see first

derivative test). More generally, they may be found at critical points, where the first derivative or

gradient of the objective function is zero or is undefined, or on the boundary of the choice set.

An equation (or set of equations) stating that the first derivative(s) equal(s) zero at an interior

optimum is called a 'first-order condition' or a set of first-order conditions.

While the first derivative test identifies points that might be extrema, this test does not

distinguish a point that is a minimum from one that is a maximum or one that is neither. When

the objective function is twice differentiable, these cases can be distinguished by checking the

second derivative or the matrix of second derivatives (called the Hessian matrix) in

unconstrained problems, or the matrix of second derivatives of the objective function and the

constraints called the bordered Hessian in constrained problems. The conditions that distinguish

maxima, or minima, from other stationary points are called 'second-order conditions' (see

'Second derivative test'). If a candidate solution satisfies the first-order conditions, then

satisfaction of the second-order conditions as well is sufficient to establish at least local

optimality.

Both the operating and economic models typically will include constraints on;

1. Sales limited by production: In this type of market, sales can be increased by increasing

production. This can be achieved by optimizing operating conditions and production

schedules.
47

2. Sales limited by market: This situation is susceptible to optimization only if improvements in

efficiency at current production rates can be obtained. An increase in thermal efficiency, for

example, usually leads to a reduction in manufacturing costs (e.g., utilities or feedstocks).

3. Large throughput: Units with large production rates (or throughputs) offer great potential for

increased profits. Small savings in product costs per unit throughput or incremental

improvements in yield, plus large production rates, can result in major increases in profits.

4. High raw material or energy consumption: These are major cost factors in a typical plant

and thus offer potential savings. For example, the optimal allocation of fuel supplies and

steam in a plant can reduce costs by minimizing fuel consumption.

5. Product quality better than specification: If the product quality is significantly better than

the customer requirements, it can cause excessive production costs and wasted capacity. By

operating closer to the customer requirement (e.g., impurity level), cost savings can be

obtained, but this strategy also requires lower process variability.

6. Losses of valuable or hazardous components through waste streams: The chemical

analysis of plant waste streams, both to air and water, will indicate whether valuable materials

are being lost. Adjustment of air/fuel ratios in furnaces to minimize unburned hydrocarbon

losses and to reduce nitrogen-oxide emissions is one such example.

7. Operating conditions: Process variables must be within certain limits due to valve ranges

(0% to 100% open) and environmental restrictions (e.g., furnace firing constraints).

8. Feed and production rates: A feed pump has a maximum capacity; sales are limited by

market projections.

9. Storage and warehousing capacities: Storage tank capacity cannot be exceeded during

periods of low demand.


48

10. Product impurities: A salable product cannot contain more than the maximum amount of a

specified contaminant or impurity. Process operating situations that are relevant to

maximizing operating profits included.

Timmons et al. (2000) have discussed opportunities for the application of on-line optimization or

supervisory control in refinery operations. Three general types of optimization problems

commonly encountered in industrial process operations are discussed next.

i. Operating Conditions

Common examples include optimizing distillation column reflux ratio and reactor temperature.

Consider the RTO of a fluidized catalytic cracker (FCC). The FCC reaction temperature largely

determines the conversion of a light gas oil feedstock to lighter (i.e., more volatile) components.

The product distribution (gasoline, middle distillate, fuel oil, light gases) changes as the degree

of conversion is increased. Accurate process models of the product distribution as a function of

FCC operating conditions and catalyst type are required for real-time optimization. Feedstock

composition, downstream unit capacities (e.g., distillation columns), individual product prices,

product demand, feed preheat, gas oil recycle, and utilities requirements must be considered in

optimizing an FCC unit. The large throughput of the FCC implies that a small improvement in

yield translates to a significant increase in profits. A full plant model can have as many as 1,500

submodels, based on the development of fundamental chemical engineering relations for all unit

operations involved that is, furnaces, distillation columns, mixers, compressors, and heat

exchangers. In the ExxonMobil olefins plant (Beaumont, TX), the detailed model contained

about 200,000 variables and equations, and optimization is used to obtain the values of about 50

targets or set points. Although standard approaches are used for developing separation and heat
49

exchange models, the furnace models are quite elaborate and are typically usually proprietary. In

the ExxonMobil application, 12 furnaces are operated in parallel with up to eight possible gas

feeds and five liquid feeds (different hydrocarbons) to be cracked, along with three different coil

geometries. The key optimization variables are conversion, feed rate, and steam/oil ratio, subject

to feedstock availability and equipment constraints. This particular application has led to benefits

in the range of millions of dollars per year.

ii. Allocation

Allocation problems involve the optimal distribution of a limited resource among several parallel

(alternative) process units. Typical examples include;

Steam Generators: Optimum load distribution among several boilers of varying size and

efficiency.

Refrigeration Units: Optimum distribution of a fixed refrigeration capacity among several low

temperature condensers associated with distillation columns.

Parallel Distillation Columns: Minimization of “off-spec” products and utilities consumption

while maximizing overall capacity.

iii. Planning and Scheduling

Examples of scheduling problems encountered in continuous plants include catalyst

regeneration, furnace decoking, and heat exchanger cleaning, which deal with the tradeoff

between operating efficiency and lost production due to maintenance. Planning problems

normally entail optimization of continuous plant operations over a period of months. This

approach is commonly used in refinery optimization. In batch processing, optimal scheduling is


50

crucial to match equipment to product demands and to minimize cycle times. In a batch

campaign, several batches of product may be produced using the same recipe. In order to

optimize the production process, the engineer needs to determine the recipe that satisfies product

quality requirements; the production rates to fulfill the product demand; the availability of raw

material inventories; product storage availability; and the run schedule.

No. 3.

a11 a12 a13

a21 a22 a23

a31 a32 a33

Expressing linearly and expanding by the first row, the determinants of the matrix;

a22 a23 a21 a23 a21 a22


A = a11 − a12 + a13
a32 a33 a31 a33 a31 a32

A = a11 (a22 a33 − a23 a32) − a12 (a21 a33 − a23 a31) + a13 (a21 a32 − a22 a31)

2 0 0
And to calculate the inverse A-1 of A = (0 2 0)
0 0 2

adjA Transpose of cofactor matrix


A−1 = =
det (A) det (A)

Where; adjA = adjugate or adjoint of A,

det (A) = The determinant of a matrix A

2 0 0
The determinant of the matrix A
0 2 0

0 0 2
51

A = a11 (a22 a33 − a23 a32) − a12 (a21 a33 − a23 a31) + a13 (a21 a32 − a22 a31)

= 2(2×2−0×0) − 0(0×2−0×0) + 0(0×0 −2×0) = 8+0+0 = 8

Cofactor matrix

The cofactor Cij associated with the element aij in determinant is defined in terms of the minor

Mij as Cij = (−1)i+j Mij for i, j= 1,2,...,n.

2 0 0

0 2 0

0 0 2

2 0
C11= + 1 = + 1(4) = 4
0 2

0 0
C12= − 1 = − 1(0) = 0
0 2

0 2
C13= + 1 = +1(0) = 0
0 0

0 0
C21= − 1 = − 1(0) = 0
0 2

2 0
C22= + 1 = +1(4) = 4
0 2

2 0
C23= − 1 = − 1(0) = 0
0 0

0 0
C31= + 1 = +1(0) = 0
2 0
52

2 0
C32= − 1 = − 1(0) = 0
0 0

2 0
C33= + 1 = +1(4) = 4
0 2

4 0 0

C= 0 4 0

0 0 4

Transpose of cofactor matrix;

4 0 0

CT = 0 4 0

0 0 4

The inverse of the matrix;

1
4 0 0 0 0
2
1 T 1 1
A−1 = |A|
C =8 0 4 0 = 0 0
2
1
0 0 4 0 0 2

No. 4.

Flowchart

A flowchart is a pictorial or graphical representation of an algorithm. A flowchart shows the flow

of control of an algorithms or program. The flowchart is a diagram which visually presents the

flow of data through processing systems. This means by seeing a flow chart one can know the

operations performed and the sequence of these operations in a system. Algorithms are nothing
53

but sequence of steps for solving problems. So a flow chart can be used for representing an

algorithm. A flowchart, will describe the operations (and in what sequence) are required to solve

a given problem. You can see a flow chart as a blueprint of a design you have made for solving a

problem.

For example when you have a problem to solve using computer or in other word you need to

write a computer program for a problem then it will be good to draw a flowchart prior to writing

a computer program. Flowchart is drawn according to defined rules.

General Rules for flowcharting

i. All boxes of the flowchart are connected with Arrows. (Not lines).

ii. Flowchart symbols have an entry point on the top of the symbol with no other entry

points. The exit point for all flowchart symbols is on the bottom except for the

Decision symbol.

iii. The Decision symbol has two exit points; these can be on the sides or the bottom and

one side.

iv. Generally a flowchart will flow from top to bottom. However, an upward flow can be

shown as long as it does not exceed 3 symbols.

v. Connectors are used to connect breaks in the flowchart. Examples are from one page

to another page, from the bottom of the page to the top of the same page, an upward

flow of more than three symbols.

vi. Subroutines and Interrupt programs have their own and independent flowcharts.

vii. All flow charts start with a Terminal or Predefined Process (for interrupt programs or

subroutines) symbol.
54

viii. All flowcharts end with a terminal or a contentious loop.

Symbols used in flowcharting

Flowcharting uses symbols that have been in use for a number of years to represent the type of

operations and/or processes being performed. The standardised format provides a common

method for people to visualize problems together in the same manner. The use of standardised

symbols makes the flow charts easier to interpret, however, standardizing symbols is not as

important as the sequence of activities that make up the process.

Flow line ( ): It is a line with an arrow head. It shows the direction of flow of control.

It connects different flowcharting symbols.

Terminal Symbol ( ): It is an oval shape. It is used to begin or end a flowchart. It

indicates the starting or ending of the program, process, or interrupt program.

Example, start stop

Input/ Output Symbol ( ): A parallelogram represents the Input / Output

operations in a flowchart. It indicates any type of internal operation inside the Processor or

Memory. Example, Read A, B Print A

Processing Symbol ( ): A rectangular represents processing in a flowchart. It

indicates any type of internal operation inside the Processor or Memory. Example, n=n+2

Decision Symbol ( ): A diamond represents decision in a flowchart. It has one incoming

flow line and two outgoing flow lines. It is labeled with a condition. Each outgoing flow line is

labeled with „yes‟ or „no‟. If the condition inside the decision box is true then the control is
55

transferred to the arrow labeled „yes‟. Otherwise the control is transferred to the arrow labeled

„no‟. It is used to ask a question that can be answered in a binary format (Yes/No, True/False).

On-page Connector Symbol ( ): Shows where a document or process continues on the same

page. This allows the flowchart to be drawn without intersecting lines or without a reverse flow.

Off-page Connector Symbol ( ): If the flowchart consists of more than one page then off-

page connector symbol is used. Control is transferred from one connector to the other labeled

with the same number.

Predefined Process ( ): it is used to invoke a subroutine or an Interrupt program.

Advantages of using Flowcharts

Flow chart is used for representing algorithm in pictorial form. This pictorial representation of a

solution/system is having many advantagrs.These advantages are as follows:

i. Communication: A Flowchart can be used as a better way of communication of the

logic of a system and steps involve in the solution, to all concerned particularly to the

client of system. It expresses the basic structure of the program.

ii. Effective analysis: A flowchart of a problem can be used for effective analysis of the

problem. It demonstrates clearly the logical flow of the computer program.

iii. Documentation of Program/System: Program flowcharts are a vital part of a good

program documentation. Program document is used for various purposes like

knowing the components in the program, complexity of the program.


56

iv. Efficient Program Maintenance: Once a program is developed and becomes

operational it needs time to time maintenance. With help of flowchart maintenance

become easier.

v. Coding of the Program: Any design of solution of a problem is finally converted into

computer program. Writing code referring the flowchart of the solution become easy.

It can help a person to review the program.

Flowchart example
57

Flowchart of finding t when n = 8

start

n 4
44

i, j, k

t= i + j + k

yes
n =8 stop

No

n n+2
44

No
n≤6

yes

stop
58

Step by step solution start

n 4
44

i, j, k = 2, 1, 2

i, j, k = 1, 2, 3

i, j, k = 8, 9, 10

i, j, k = 3, 4, 6

i, j, k = 1, 0, 1

i, j, k = 3, 3, 3

t= i + j + k = 2+1+2

t =5

yes
n =8 stop

No

n n+2
44
59

n 6
44

i, j, k = 2, 1, 2

i, j, k = 1, 2, 3

i, j, k = 8, 9, 10

i, j, k = 3, 4, 6

i, j, k = 1, 0, 1

i, j, k = 3, 3, 3

t= i + j + k = 1+2+3

t=6

yes
n =8 stop

No

n n+2
44
60

n 8
44

i, j, k = 2, 1, 2

i, j, k = 1, 2, 3

i, j, k = 8, 9, 10

i, j, k = 3, 4, 6

i, j, k = 1, 0, 1

i, j, k = 3, 3, 3

t= i + j + k = 8+9+10

t = 27

n n+2
44

n ≤ 10

stop
61

REFERENCES

David W. Kelton (2000). Experimental design for simulation. Proceedings of the 2000 Winter
Simulation Conference. J. A. Joines, R. R. Barton, K. Kang, and P. A. Fishwick, eds. Pp
32-38

Intel FORTRAN Programmer’s Reference (2002). http://developer.intel.com

Jeanne C. Adams, Walter S. Brainerd, Jeanne T. Martin, Brian T. Smith and Jerrold L. Wagener
(1992). Fortran 90 Handbook. New York: Intertext Publications, McGraw-Hill Book
Company. 835 pp

Law M. Averill and Kelton W. David (2000). Simulation Modeling and Analysis, third edition.
Mc Graw-Hill.

Maria, A. (1997). Introduction to modeling and simulation. In Proceedings of the 29th


conference on winter simulation.

Rafel, Hekmat Hameed (2012). FORTRAN 90. BSC lecture notes, department of mechanical
engineering, college of engineering, University of Babylon. Pp 1-5

Rajarishi Sinha, Christiaan J.J. Paredis, Vei-Chung Liang and Pradeep K. Khosla (2001).
Modeling and Simulation Methods for Design of Engineering Systems. USA: ASME, pp
1-13

SJBIT (2010). System Simulation and Modeling. Department of ISE, Faculty Development
Program, SJBIT. Pp 1-152

Steven C. Chapra and Raymond P. Canale (2000).Numerical Methods for Engineers, sixth
edition. New York: Mc Graw Hill, 994pp

Timmons, C., J. Jackson, and D. C. White (2000). Distinguishing On-line Optimization; Benefits
from those of Advanced Controls, Hydrocarbon Proceedings, 79(6), 69.

You might also like