Skip to content

A C++ Designed Library used for Solving Boundary Value Problems (BVP)

Notifications You must be signed in to change notification settings

MRLintern/Boundary-Value-Problem_Library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

1D Boundary Value Problem Library

An Object Oriented Designed Library to solve 1D Boundary Value Problems (BVP) called bvplib.hpp

The type of BVP is 1D and time independent.

The differential equation is discretized using a Finite Difference Method. The resulting system of algebraic equations are solved via Gaussian elimination.

The typical form of a BVP:

Au''(x) + Bu'(x) + Cu(x) = f(x), X_0 < x < X_1.

A, B and C are coefficients; specified by the user.

f(x) is the source function.

u''(x) is the 2nd derivative w.r.t.x.

u'(x) is the 1st derivative w.r.t.x.

u(x) is the solution.

X_0 < x < X_1 is the interval in which the differential equation is discretized.

Boundary conditions: x = X_0 & x = X_1; specified by the user.

Requirements

  1. Compiler: g++/gcc 9.4.0
  2. Tested on Ubuntu 20.04
  3. Text editor: any will do; this project was developed using Sublime Text
  4. For unit testing: CxxTest
  5. make
  6. CMake as an alternative to just using make. Go to: src/build for instructions.

Unit Testing

CxxTest is a unit testing framework which was used to test the LinearSystems.hpp class and the BvpOde.hpp class.

Instalation:

$ sudo apt-get update -y
$ sudo apt-get install -y cxxtest

Example models

Two models are used.

Model 1:

u''(x) = -1, 0 < x < 1,

with Dirichlet Conditions:

u = 0 at x = 0 
u = 0 at x = 1 

Model 2:

u''(x) + 3*u'(x) - 4*u(x) = -34*sin*x, 0 < x < pi,

with Neumann conditions:

u'(x) = -5, at x = 0
u = 4, at x = pi

Two .dat files are generated, one each corresponding to one model problem. These can be used for plotting the solution.

Instructions

$ git clone https://github.com/MRLintern/Boundary-Value-Problem_Library.git
$ make
$ ./Driver

Note:

The user has to specify the boundary/initial conditions for the problem. To do this go to src/Driver.cpp. You'll see that these have already been applied for Model 1 and Model 2 listed above.

Additions

Added a Python script allowing the user to plot the results/solution of model problem. A CMakeLists.txt file has been added in the src/build directory. Alternative way to generate the executable if you prefer a build system. Note: the two .dat data files will be generated in the build directory.

TODO

Code needs to be well documented.

About

A C++ Designed Library used for Solving Boundary Value Problems (BVP)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages