User:Eml5526.s11.team6.tupsakhare/hwk5

=Problem 5.2 - Solutions using weak form and appropriate families of basis functions=

Strong Form
The strong form as referred from General one dimensional Model 1.0/Data set 1b on page 2 of Mtg 9:-

Boundary Conditions
The Essential Boundary condition as applied on the boundary $$\Gamma_g = [1]$$, is -- $$ u(1)=4 $$, The Natural Boundary condition as applied on the boundary $$\Gamma_h = [0]$$, is -- $$ -\frac{\partial u(x=0)}{\partial x}=6 $$

Solve for $$ u(x) $$ and $$ u^h(x) $$
To solve the above problem for $$ u(x) $$ and $$ u^h(x) $$ using appropriate basis functions of the following types until convergence of $$u^h(0.5)$$ to $$10^{-6}$$ -- 1. Polynomial basis function 2. Fourier basis function 3. Exponential basis function

Solution
Using weighting function $$ w(x) $$ such as $$ w(1) = 0 $$ and the technique of integration by parts, we have derived the weak form as follows --

Solving the above ordinary differential equation, we get the exact solution of governing equation as follows -

Now, using the technique from Mtg 18 and Mtg 19 we can write the discretized weak form as -

Also we have - as we choose the basis functions such that $$ w(n=0) = 1 $$, using technique from page -1 Mtg 22, we can write - $$ {{d}_{0}}=4, with- : i=1,2,\cdots $$,  $$ j=1,2,\cdots $$

Now we select legitimate families of basis functions as follows -

Fourier basis function
Note - the trial solution need to satisfy the essential boundary condition,$$u(x=1)=4$$ as stated in Eq. 5.2.2 Also, as we choose the basis functions such that $$ w(n=0) = 1 $$, using technique from page -1 Mtg 22, we can write - $$ {{d}_{0}}=4, with- : i=1,2,\cdots $$,  $$ j=1,2,\cdots $$

Now we can write the trial solution as follows -

Now we solve for the remaining coefficients $${{d}_{j}},_ – ^ – j=1,2,\cdots $$, by constructing the stiffness matrix and force matrix as follows:

Note- Here 1st equation is valid when 'i' and 'j' both are even, 2nd expression is valid when 'i' and 'j' both are is odd, 3rd expression is valid for remaining combination of values of 'i' and 'j'

Note- Here 1st expression is valid when 'i' and 'j' both are even, 2nd expression is valid when 'i' and 'j' both are odd

Now we need to have convergence of the solutions to the order of 10^(-6), hence we use a Matlab code demonstrated below to build the above matrices which are obtained then as follows-

By the equation that$$Kd=F$$, we can solve the remaining of $$d$$ as

Hence, the trial solution of the governing equation is

As seen from the Figure 5.2.1 below, it is evident that the approximate solution $$ u^h(x) $$ very closely imitates the exact solution $$ u(x) $$

Also it can be seen from Figure 5.2.2. that the error very rapidly converges to almost zero value when 5 or 6 basis functions are used





Exponential basis function
=Problem 5.7:Solving a strong form with Linear Lagrangian Element Basis Function (LLEBF)=

Given
The given ordinary differential equation is:

Boundary conditions
The Essential Boundary condition as applied on the boundary $$\Gamma_g = [0]$$, is -- $$ u\left(0\right) = 4$$ The Natural Boundary condition as applied on the boundary $$\Gamma_h = [1]$$, is -- $$\frac{du}{dx}\left(1\right) = -6 $$

Descritization
Here we want to use Uniform Descritization such that Element nodes are equidistant with number of elements as $$ nel = 4, 6, 8, ..$$

Find
1. Explain how Linear Lagrangian Element Basis Function (LLEBF) are used as Costraint Breaking Solution. 2. Plot all LLEBF used for $$ nel =4 $$. 3. Solve the system using 3 elements (nel = 4) and increase the number of elements or $$ nel =4,6,8..$$ until the error at x = 0.5 converges to the order of 10^-6 4. Plot for Exact solution $$ u (x)$$ and Approximate solution $$ u^h (x) $$. 5. Convergence - Plot of error vs. number of nodes (n).

LLEBF as Constraint Breaking Solution (CBS)
Consider a basis function $$b_{i}$$ such that we have, $$b_{0}\left(\beta\right) = 1$$, and $$b_{i}\left(\beta\right) = 0; i = 1, 2, ...$$. In such a case as per the discussion in Mtg 20, $$b_{i}$$ becomes a Constraint Breaking Solution (CBS)

LLEBFs (N1 and N2 below) for a 2 node linear element can be used to represent the unknown variable u(x)in a given domain which is written as -


 * {| style="width:100%" border="0"

$$u\left ( x \right )=u_{1}\frac{x-x_{2}}{x_{1} - x_{2}}+u_{2}\frac{x-x_{1}}{x_{2} - x_{1}} =u_{1}N_{1}+u_{2}N_{2} $$
 * $$\displaystyle (5.7.2) $$
 * }
 * }

Here $$u_{1}, u_{2}$$ are the nodal values of the unknown u(x) at the nodes 1 and 2 respectively.

The Lagrange Polynomials follow the property of Partition of Unity i.e. they have the value of 1 at the respective node and 0 at the others nodes. It means the basis function $$ b_{i} $$ carries value as 1 at the i th node and has a zero value at any other nodes in the domain.

Plot all LLEBF used for $$ nel =4 $$
The straight line plots (common for all elements of the 3 used with $$ nel =4 $$) irrespective of the elemental sizes for the 2 LLEBFs given in Eq. 5.7.2, following the Partition of Unity model are shown in the Figure 5.7.1.



Solve the system using 3 elements (nel = 4) and increase the number of elements or $$ nel =4,6,8..$$ until the error at x = 0.5 converges to the order of 10^-6
The weighted residual form with weighting function $$ w (x) $$ is given as:

We develop the corresponding weak form using the technique of integration by parts, with $$ w(0) = 0$$ owing to the fact that the flux is unknown at $$ x = 0 $$.

The expression for the weak form is as below -

To get the element stiffness matrices leading to the global stiffness matrix $$ K $$, we make coordinate change to the coordinate $$\phi$$ with value of -1 at node 1 and 1 at node 2.



The new coordinate $$\phi$$ is given by:


 * {| style="width:100%" border="0"

$$\varphi = \frac{2\left ( x-x_{1} \right )}{x_{2}-x_{1}}-1=\frac{2\left ( x-x_{1} \right )}{l}-1 $$
 * $$\displaystyle (5.7.5) $$
 * }
 * }
 * {| style="width:100%" border="0"

$$ d\varphi =\frac{2dx}{l}$$
 * $$\displaystyle (5.7.6) $$
 * }
 * }

Hence the expression for $$ u(x) $$ in this changed coordinate system becomes-


 * {| style="width:100%" border="0"

$$u\left ( \varphi \right )=\begin{bmatrix} \frac{1-\varphi }{2} & \frac{1+\varphi }{2} \end{bmatrix}\begin{bmatrix} u_{1}\\

u_{2}\end{bmatrix}=\left [ N \right ]\begin{bmatrix} u_{1}\\

u_{2}\end{bmatrix} $$
 * $$\displaystyle (5.7.7) $$
 * }
 * }

Applying same operations on $$ w (x) $$, we can write -


 * {| style="width:100%" border="0"

$$\left [w\left(x\right)= N \right ]\begin{bmatrix} g_{1}\\ g_{2}\end{bmatrix}=\begin{bmatrix} g_{1} & g_{2} \end{bmatrix}\left [N \right ]^{T} $$ Now by using the chain rule of derivation:
 * $$\displaystyle (5.7.8) $$
 * }
 * }


 * {| style="width:100%" border="0"

$$\frac{du}{dx}=\frac{du}{d\varphi }\frac{d\varphi }{dx}=\frac{du}{d\varphi }\frac{2}{l} $$
 * $$\displaystyle (5.7.9) $$
 * }
 * }


 * {| style="width:100%" border="0"

$$\frac{dw}{dx}=\frac{dw}{d\varphi }\frac{d\varphi }{dx}=\frac{dw}{d\varphi }\frac{2}{l} $$ From Eq. (5.7.7) we can take the derivative with respect to $${d\varphi} $$ and then we can write:
 * $$\displaystyle (5.7.10) $$
 * }
 * }


 * {| style="width:100%" border="0"

$$\frac{du}{d\varphi }=\begin{bmatrix} -\frac{1}{2} & \frac{1}{2} \end{bmatrix}\begin{bmatrix} u_{1}\\ u_{2}\end{bmatrix}=\left [ B \right ]\begin{bmatrix} u_{1}\\ u_{2}\end{bmatrix} $$ In similar way for the weighting function $$ w(x) $$, we can say:
 * $$\displaystyle (5.7.11) $$
 * }
 * }


 * {| style="width:100%" border="0"

$$\frac{dw}{d\varphi}=\begin{bmatrix} g_{1} & g_{2} \end{bmatrix}\left [ B \right ]^{T} $$ The stiffness matrix is obtained as below -
 * $$\displaystyle (5.7.12) $$
 * }
 * }

The force matrix is obtained as below -

We assemble the system using a Matlab code given below where integration is performed using the Gauss Quadrature.

Plot for Exact solution $$ u (x)$$ and Approximate solution $$ u^h (x) $$ along x
It can be observed from the Figure 5.7.3 (Using 4 nodes) and Figure 5.7.4 (Using 6 nodes) that the exact solution is nearly linear and can be very well approximated by the LLEBFs considered with least 4 number of nodes and obviously also when the number of nodes is increased to 6. This is as the approximated solution $$ u^h (x) $$ very closely imitates the curve for the exact solution $$ u (x)$$.



Convergence - Plot of error vs. number of nodes (n)
At x = 0.5, to plot the error ( $$ u (x)$$ - $$ u^h (x) $$ ), we use Eq. 5.7.2 with the interpolation functions.

(n = 4), sufficiently low number of elements (around 20 -25) gives satisfactory convergence to an order of to 10^-3. We need around 125-130 elements for convergence to the order of of 10^-6. Figure 7.5.6 depicts the error as a function of the number of elements.