Coder Social home page Coder Social logo

hcbh96 / parabolic_pde_solver Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 81 KB

A general code using the finite difference methods specifically Forward Euler Backward Euler and Crank-Nicholson to solve a parabolic partial differential equation.

License: MIT License

Python 100.00%

parabolic_pde_solver's Introduction

Project Parabolic Pde Solver

Parabolic PDE solver (the solver) is a solver for parabolic partial differential equa- tions over a 1d space (L) and a given time (T). The solver can be used to plot or analyse the results to the heat equation over time. The solver makes it easy to evaluate solutions with non-homogeneous Dirichlet boundary conditions, internal heat sources and/or non-constant diffusion coefficients.

The solver has been vectorised and uses sparse matrices to improve computa- tional efficiency. Visualisation functionality has also been included with the solver able to produ- ce 3d surface plots of the temperature of the bar or of an internal heat source as a function of postion (x ∈ [0, L]) and time (t ∈ [0, T]).

The solver has been broken down into subroutines and internal function calls, some of which have been made ecternally available. These functions can be used separately to create and solve a range of Euler and Crank Nicholson matrices required by the heat equation i.e functions to create, compute and solve the matrices required by the separate methods used to solve the heat equation including Forward Euler (FE), Backward Euler (BE) and Crank-Nicholson (CN) respectively. Any external facing functions have been fully documented.

The solver is able to handle non-homogeneous Dirichlet boundary values. The user needed to pass in a function bcf(t) which was then used to calculate the boundary conditions for various values of t ∈ [0, T].

The solver is able to handle internal heat sources. An internal heat source could be specified using heat_source(x,t). This meant that a heat source could change with both respect to position x ∈ [0, L] and time t ∈ [0, T].

Users could specify non-constant diffusion coefficients by specifying f_kappa(x). This means bars with varying conductivity can be simulated by passing in a function that returns the diffusion coefficient along x ∈ [0, L].

Project Accuracy Explorer

Accuracy is an untested function designed to explore the accuracy of the various methods I implemented in the solver. The function was designed to test the accuracy/truncation error (E) of the FE, BE and CN methods. The calculation of E was based on the L2-Norm calculation.

The function calculated the approximate error for a variety of step sizes passed in. It then returned the approximated error over x ∈ [0, L] for each step size in an array.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

python3 python3

SciPy Scipy

pytest [pytest](pip install pytest)

Installing

A step by step series of examples that tell you how to get a development env running

Clone git directory

git clone https://github.com/hcbh96/parabolic_pde_solver.git

Navigate to the directory

cd parabolic_pde_solver

Visualse Solutions to the Heat equation

python3 parabolic_pde_solver.py

Visualise the Truncation Errors

python3 accuracy_explorer.py

Running the tests

Tests can be run using the terminal command

py.test

Authors

  • Harry Blakiston Houston - Initial work - hcbh96

License

This project is licensed under the MIT License - see the LICENSE.md file for details

parabolic_pde_solver's People

Contributors

hcbh96 avatar

Stargazers

leonee avatar  avatar

Watchers

James Cloos avatar  avatar

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.