Giter Club home page Giter Club logo

pyspectralpde's Introduction

pySpectralPDE: Solver for Partial Differential Equations (PDEs) in its deterministic and stochastic versions. (building)

Code style: black License: MIT

pySpectralPDE is a Python package for solving the partial differential equations (PDEs) using spectral methods such as Galerkin and Collocation schemes. This package using different integrator methods to solving in time, for example euler in its explicit and implicit version, also contains plot tools to built 3D or 2D graphics about solutions.

A first example is the known Burgers' equation in its deterministic and stochastic version. The associated differential operators are computed using a numba-compiled implementation of spectral methods. This allows defining, inspecting, and solving typical PDEs that appear for instance in the study of dynamical systems in physics. The focus of the package lies on easy usage to explore the behavior of PDEs. However, core computations can be compiled transparently using numba for speed.

Try it out online!

Installation

pySpectralPDE is available on pypi, so you should be able to install it through pip:

pip install pySpectralPDE

Usage

A simple example showing the evolution of the deterministic equation in 1d:

from pySpectralPDE import spectralPDE
import numpy as np


def u0(z):
    return np.exp(- 5.0 ** (-3) * z ** 2)

params = dict(nu=1.0, N=32, xL=-60.0, xR=60.0, dt=0.01, t0=0.0, tmax=100.0)     # setting params
solver = spectralPDE.setup_solver(u0, params)        				# solve the pde
solver.views.plot.graph_3d()                 		     			# plot datas

which can be solved for different values of Diffusion coefficient in the example above.

This PDE can also be solved in its stochastic version with random forces. For instance, the stochastic Burgers' equation can be implemented as

from pySpectralPDE import spectralSPDE
import numpy as np

def u0(x):
    return np.sin(np.pi * x)

   
t = np.linspace(0, 10, 512)
x = np.linspace(0, 1, 256)    
params = {"nu": 0.1, "N": int(5), "M": int(11), "x": x, "t": t}	   # setting params

sol = spectralSPDE.setup_solver(u0=u0, params=params)		   # solve the pde
sol.get_data                                                    
sol.plot                                                           # plot datas
sol.u0_approx
sol.stability

More information

pyspectralpde's People

Contributors

alanmatzumiya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

arunkv7 navi2310

pyspectralpde's Issues

Final verson of pySpectralPDE

Thank you for releasing codes for solving Burgers' equation.

I want to solve the stochastic version of Burgers' equation using your codes. However, I've tried running the codes following README.md, but I can't reproduce Figure 5 in your paper. "sol.get_data" just returns a 512*256 zero array. I'm curious if the publicly available codes are the final version.

Best,
Wonmo Koo

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.