Coder Social home page Coder Social logo

sandeep026 / bvp_lgl Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 109 KB

Solving boundary value problem (BVP) using Legendre Gauss Lobatto (LGL) collocation

License: GNU Lesser General Public License v3.0

MATLAB 100.00%
boundary bvp collocation gauss legendre problem pseudospectral value lobatto

bvp_lgl's Introduction

Pseudospectral methods for boundary value problems

Given below is a boundary value problem from Ref. 1.

$$ \begin{equation} \ddot{x}-t\dot{x}-x=0 \end{equation} $$

$$ \begin{aligned} x(t=-1)&=1\\ x(t=1)&=1 \end{aligned} $$

$x^*(t)=\exp(\frac{t^2-1}{2})$ is the solution to the boundary value problem.

Numerical solution

Pseudospectral collocation requires the following steps

  1. discretize domain, state and control at $n+1$ points
  2. discrete state and control input are the variables
  3. approximate state $(x(t))$ and control $(u(t))$ using global polynomials
  4. differentiate the polynomial to the required degree and evaluate at the collocation points
  5. evaluate the boundary value problem at the collocation points
    • dynamics evaluated at interior points
    • boundary conditions at -1 and 1
  6. depending on the dynamics, system of linear/nonlinear system of equations need to be solved

Implementation

An optimization problem without an objective function and inequality constraints is simply a system of equation which may be linear or nonlinear. Using the principle, we use IPOPT to solve the system of nonlinear equations. CasADi's Opti() (meant as modelling language for optimization problems) is used to model the equations. The codes serve the following purposes.

  • bvp_main.m - solve the BVP for a given grid size and compare with analytical solution
  • bvp.m, convergence.m - study exponential/spectral convergence of discretization error
  • legslb.m, legslbdiff.m, lepoly.m, lepolym.m - supplementary files for LGL collocation

Requirements

  • OCTAVE-6.1.0
  • CasADi-3.5.5

Comparison of numerical and analytical results

side by side plot

image

error plot

image

Spectral/exponential convergence

A key feature of pseudospectral collocation is rapid decrease in discretization error with increasing grid size. However, for larger N ($\geq 100$), the problem can get numerically ill-conditioned.

Some methods to mititgate ill-conditioning include using knotting, preconditioners and Birkhoff collocation.

image

References

Footnotes

  1. Wang, L. L., Samson, M. D., & Zhao, X. (2014). A well-conditioned collocation method using a pseudospectral integration matrix. SIAM Journal on Scientific Computing, 36(3), A907-A929. โ†ฉ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.