Finite Element MATLAB Code for Solving Boundary Value Problems

Click For Summary
SUMMARY

The discussion focuses on formulating a MATLAB code to solve a boundary value problem (BVP) defined by the differential equation $$-u''(x) = 1$$ with specified boundary conditions. The variational formulation requires finding a function u such that the bilinear form $$a(u,v)$$ equals the linear functional $$F(v)$$. Key elements include the stiffness matrix K and the coefficient matrix A, which is derived by modifying K for Dirichlet BVPs. The user seeks assistance in adjusting the MATLAB code to incorporate boundary conditions at x = 3.

PREREQUISITES
  • Understanding of boundary value problems (BVPs)
  • Familiarity with variational formulations in numerical methods
  • Proficiency in MATLAB programming, particularly with matrix operations
  • Knowledge of finite element methods (FEM) for solving differential equations
NEXT STEPS
  • Review MATLAB's sparse matrix functions, particularly spdiags, for constructing stiffness matrices
  • Study the implementation of Neumann and Robin boundary conditions in finite element analysis
  • Learn about the construction and manipulation of load vectors in variational formulations
  • Explore examples of MATLAB codes for solving similar boundary value problems
USEFUL FOR

Students and professionals in applied mathematics, engineering, and computational science who are working on finite element methods and boundary value problems using MATLAB.

squenshl
Messages
468
Reaction score
4

Homework Statement


Consider the problem
$$-u''\left(x\right) = 1, \;\; 0 < x < 3, \;\; u \left(0\right) = 0, \; -u' \left(3\right) = u\left(3\right)+1.$$
Formulate a MATLAB code to produce the solution and plot the solution from 0 to 3.

Homework Equations


The Attempt at a Solution


Multiply by a function v and integrating from 0 to 3 to get
$$v \left(3 \right)u \left(3 \right)+v \left(3 \right)+u'\left(0\right)v \left(0 \right)+\int_0^3 v'u' \; dx = \int_0^3 v \;dx$$
In this case the bilinear form is
$$a\left(u,v\right) = v \left(3 \right)u \left(3\right)+u'\left(0 \right)v\left(0 \right) + \int_0^3 v'u' \; dx$$
and the linear functional is
$$F(v) = \int_0^3 v \; dx - v\left(3\right).$$
The variational formulation is to find u such that $$a\left(u,v\right) = F(v).$$
I produced a MATLAB plot when we have the following boundary conditions
$$u(0) = 0, u(3) = 1$$
given in the attached file. Note that here we have the full stiffness matrix K, which involves the integrals
$$\phi_0 \quad \text{and} \quad \phi_n$$
and is useful for Neumann and Robin BVPs. The actual coefficient matrix A for the Dirichlet BVP is the matrix obtained by deleting the first and last rows and columns of K. The function f is defined
separately given by f.m. How do I alter the code to incorporate the boundary conditions at x = 3. I know that there must be an extra part in the line K = spdiags... to make the matrix of boundary terms in a(u,v) and we delete the line A = ... and we alter the 3 lines that make the load vector bd = ... given in F(v). Someone please help.
 

Attachments

Last edited:
Physics news on Phys.org
I am completely lost.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
8
Views
2K
Replies
12
Views
2K
  • · Replies 19 ·
Replies
19
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
6
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
9
Views
2K