Sie sind auf Seite 1von 11

WB4422-11

MATLAB for Advanced Users


Assignment-1
4517059

Thermal Power Plants

Aditya Kumar

Mechanical Engineering
23 February 2016

Question 1
(a)
for n=200
the minimum value for x is 1.7539.
The total time for the solution is 3.1838 seconds.
The percentage of time, spent in making the decomposition against the total time is as follows

Figure 1: Share of time spent in the decomposition in the total time


(b) for n= 200
The minimum value for x is 1.7539
The total time for the solution is 0.4409, seconds.
The number of iterations needed, to satisfy the tolerance of e8 is 205.
For the ILU Factorization with zero level of fill in (ILU(0))
The minimum value for x is 1.7539
The total time for the solution is 0.3587, seconds.
The number of iterations needed, to satisfy the tolerance of e8 is 54.
For the crout version of the ILU
The minimum value for x is 1.7539
The total time for the solution is 7.4507, seconds.

Matlab for Advanced Users

Delft University of Technology

The number of iterations needed, to satisfy the tolerance of e8 is 1.


Discuss?
(c)

Figure 2: Time required by both iterative and non iterative methods


Based on this graph, the use of some iterative methods is definitely recommended, as the time it takes
to solve, as the number of variables increases is drastically less.
(d)

Figure 3: Semilog plot of Iteration Number vs Residual

Matlab for Advanced Users

Delft University of Technology

Question 2
(a)
The geometry turns out to be

Figure 4: Geometry
(b)
lu(a,thresh)..proceed in this direction .

Matlab for Advanced Users

Delft University of Technology

(c)
The sparsity patterns of the matrices are

Figure 5: Sparsity Pattern of the Matrices


From the patterns, it can be seen that, the sparsity pattern of L is equal to the sparsity of U T
After reordering, the Sparsity Pattern comes out to be

Matlab for Advanced Users

Delft University of Technology

Figure 6: Sparsity Pattern of the Matrices


(d)
After Applying Minimum-Degree Reordering
The Sparsity Pattern obtained is

Matlab for Advanced Users

Delft University of Technology

Figure 7: Sparsity Pattern of the Matrices


(e)
L-Matrix Type

Percentage of Non-Zero Elements(%)

LU Decomposition
Reverse Cuthill-Mckee
Minimum-Degree Reordering

1.1873
1.7724
0.4129

The bar plot of the percentages obtained are

Matlab for Advanced Users

Delft University of Technology

Figure 8: Sparsity Pattern of the Matrices

Question 3
Solution
x = 4.923;

(1)

y = 1.3846;

(2)

z = 0;

(3)

The solution is not unique, because the rank of the matrix is lesser than the number of rows.

Matlab for Advanced Users

Delft University of Technology

Question 4
(a)
(4)

c = 0.3708
The commands used to generate the Matrix A and implementation of c are as follows
1
2
3
4

n=39;
c=o n e s ( 1 , n ) ;
A=g a l l e r y ( t r i d i a g , n ) ( 0 . 5 / ( 0 . 0 5 0 . 0 5 ) ) ( 1) ;
cnew=mtimes ( expm (A. 1 ) , c ) ;
(b)
(c)

Question 5
Solution
The vital parts of the code are as follows.
The main function is as follows
1
2
3
4
5
6
7
8
9

%%BNM1
%%%1: c y l i n d e r
%%%%2: h e m i s p h e r e
clear all ;
close all ;
lb =[2 ,0];
ub=[6 4 0 ] ;
o p t i o n s=o p t i m s e t ( MaxFunEvals , 5 0 0 0 , MaxIter , 1 0 0 0 ) ;
[ x , f v a l , e x i t f l a g , output ]= fmincon ( @objfun , [ 6 , 6 ] , [ ] , [ ] , [ ] , [ ] , lb , ub , @cofun ,
options ) ;
The Sub-Functions listed in the optimization routine are as follows
The objfun and cofun in the optimzation routine are as follows.
objfun

1
2
3
4
5

f u n c t i o n o=o b j f u n ( x )
a1=2 p i x ( 1 ) x ( 2 )+p i x ( 1 ) x ( 1 ) ; %%x ( 1 ) i s r a d i u s x ( 2 ) i s h e i g h t
a2=2 p i x ( 1 ) x ( 1 ) ;
o=300 a1 +400 a2 ;
end
cofun

1
2
3
4
5

f u n c t i o n [ c , ceq ]= c o f u n ( x )
v1=p i x ( 1 ) x ( 1 ) x ( 2 ) ;
v2=2 p i power ( x ( 1 ) , 3 ) / 3 ;
ceq=v1+v2 500;
c =[];

6
7

end

Matlab for Advanced Users

Delft University of Technology

The Motivation for the choices of r0 and h0 are taken from the graph presented in the question.
(b)
For r0 = 5,
r = 4.0858

(5)

h = 6.8097

(6)

cost = 1.1014 105

(7)

The number of Iterations needed are 11.


(c)
The number of iterations needed by fmincon can be presented through the graph for various values of r0
The mean of the iterations are 10.3514.

Figure 9: Number of Iterations and Number of Function Evaluations


Function Evaluations done per iteration ?
Explanation for sudden jump in iterations for a particular range ?
(d)
The number of iterations needed by fmincon can be presented through the graph for various values of r0
The mean of the iterations are 9.3641.

Matlab for Advanced Users

Delft University of Technology

Figure 10: Number of Iterations and Number of Function Evaluations

Matlab for Advanced Users

10

Delft University of Technology