You are on page 1of 11

Weekly report

Ha-Ninh NGUYEN

2021/07/09

Computational Optimization Laboratory

Department of Mechanical Engineering


Kunsan National University
Weekly report by Ha-Ninh NGUYEN

Objective

Order Task description Status

1 Learning Optimization using ADCME 70%

Structural modeling analysis by COMSOL


2 1. Static 80%
2. Transient

3 Numerical Methods in Engineering with Python 3 50%

2
Weekly report by Ha-Ninh NGUYEN

Table of content
I. Numerical Methods in Engineering with Python 3

1. Systems of Linear Algebraic Equations


2. Interpolation and Curve Fitting

II. Parameter Inverse Problem (ADCME)


III. Conclusion

3
Weekly report by Ha-Ninh NGUYEN

I. Numerical Methods in Engineering with Python 3


1. Systems of Linear Algebraic Equations
a) Gauss Elimination Method
The function gaussElimin combines the elimination and the back substitution phases. During
back substitution b is overwritten by the solution vector x, so that b contains the solution upon
exit.

Example 1.1: Use Gauss elimination to solve the equations AX = B, where

Solution. The augmented coefficient matrix is

4
Weekly report by Ha-Ninh NGUYEN

The elimination phase consists of the following two passes:

In the solution phase, we first compute x1 by back substitution:

Thus the first solution vector is

The second solution vector is computed next, also using back substitution:

Therefore,

5
Weekly report by Ha-Ninh NGUYEN

Example 1.2: An n ×n Vandermode matrix A is defined by

where v is a vector. Use the function gaussElimin to compute the solution of Ax = b, where A is
the 6 × 6 Vandermode matrix generated from the vector

And

Also evaluate the accuracy of the solution (Vandermode matrices tend to be ill conditioned).

The program produced the following results:

6
Weekly report by Ha-Ninh NGUYEN

x=
[ 416.66666667 -3125.00000004 9250.00000012 -13500.00000017 9709.33333345 -
2751.00000003]
det = -1.13246207999e-006
Check result: [a]{x} – b =
[0.00000000e+00 3.63797881e-12 0.00000000e+00 1.45519152e-11 0.00000000e+00
5.82076609e-11]
As the determinant is quite small relative to the elements of A, we expect a detectable roundoff
error. Inspection of x leads us to suspect that the exact solution is
x = [1250/3 −3125 9250 −13500 29128/3 −2751]T
in which case the numerical solution would be accurate to about 10 decimal places. Another
way to gauge the accuracy of the solution is to compute Ax – b (the result should be 0). The
printout indicates that the solution is indeed accurate to at least 10 decimal places.
b) L U decomposition
L U decomposition of a matrix is the factorization of a given square matrix into two triangular
matrices, one upper triangular matrix and one lower triangular matrix, such that the product of
these two matrices gives the original matrix.

7
Weekly report by Ha-Ninh NGUYEN

2. Interpolation and Curve Fitting

8
Weekly report by Ha-Ninh NGUYEN

9
Weekly report by Ha-Ninh NGUYEN

II. Parameter Inverse Problem (ADCME)


Example: Consider solving the following problem

where

Assume that we have observed u(0.5)=1, we want to estimate b. In this case, the true value
should be b=1.
Solution
In this example, I would like to demonstrate a programing code which is applied the command
of “using LinearAlgebra” in order to solve the problem.
Using LinearAlgebra
using ADCME

n = 101 # number of grid nodes in [0,1]


h = 1/(n-1)
x = LinRange(0,1,n)[2:end-1]

b = Variable(10.0) # I use Variable keyword to mark the unknowns


A = diagm(0=>2/h^2*ones(n-2), -1=>-1/h^2*ones(n-3), 1=>-1/h^2*ones(n-3))
B = b*A + I # I stands for the identity matrix
f = @. 4*(2 + x – x^2)
u = B\f # solve the equation using built-in linear solver
ue = u[div(n+1,2)] # extract values at x=0.5

loss = (ue-1.0)^2

# Optimization
sess = Session(); init(sess)
BFGS!(sess, loss)

println(“Estimated b = “, run(sess, b))

Expected output

10
Weekly report by Ha-Ninh NGUYEN

III. Conclusion
In the Numerical Methods in Engineering with Python 3 book, the author introduces a lot of
way to solve the problem by using Python3 to code. The problem also is various which I can list
such as “Linear Algebraic Equations” which is very common, “Interpolation” to solve
mathematical geometry which also included many other methods. The goal of learning this
numerical method is trying to understand Python code. From then, I could deploy the same
code so as to solve other complex problems in future.
In term of ACDME progress, I reached to Parameter Inverse Problem part and been studying
some basic problem by using “LinearAlgebra” command. The main ideal is finding the
parameter by talking the value of the output. In the next week, I would achieve some more
various example.

11

You might also like