Skip to main content

Find dispersion relation in PDE, systems of PDE, and discrete analogs

Project description

SymDR

SymDR is a library made to automate the process of finding dispersion relations.

It was created in The Great Mathematical Workshop 2024 by the command of young ambitious scientists.

Features

Finding dispersion relation in:

  • Equations
  • System of equations
  • Discrete equations
  • Systems of discrete equations

Quickstart

For the best experience, we highly recommend using Jupyter Notebook or Google Collab.

SymDR supports Python >=3.7 and only depends on Sympy. Install the Python package using pip.

pip install symdr

Example

  • If you are new to symbolic mathematics in Python, read SymPy introduction first.
  • For the end-to-end example of equation analysis, see notebook.

!!!!!!! IMPORTANT !!!!!!!! Variables x, t, w, k must not be redefined. They are used by the algorithm. When working with discrete cases, the variables h, tau, a and n are also added to this list.

SymDR has own objects for grid functions. To turn on pretty-printing for these functions, you need to add:

init_printing(latex_printer=discrete_latex_printer)

Creation of a grid function is the same as standart function:

u = DiscreteGrid('u')

Consider a discrete analog of Korteweg–De Vries equation:

$$u_{t}=6uu_{x}-u_{xxx}$$

For the third order derivative, we are going to use next scheme: $$ f^{(3)}(x)=\frac{f(x+2h)-2f(x+h)+2f(x-h)-f(x-2h)}{2h^3}$$

And we can write our equation

equation = u.diff(t) + (u.at_x(a+2) - 2 * u.at_x(a+1) + 2 * u.at_x(a-1) - u.at_x(a-2)) / (2 * h ** 3)

The class allows us to denote a derivative at (a, n) with "diff" method exactly the same way as SymPy functions do. Shift at a point is done by any of three methods:

  • at_x - shift in space (i.e. u.at_x(a+2) means $u_{a+2}^n$)
  • at_t - shift in time (i.e. u.at_t(n-2) means $u_a^{n-2}$)
  • at - shift in both axes at once (i.e. u.at(a+2, n-1) means $u_{a+2}^{n-1}$)

Technical note: instead of moving the function into a subtree of Derivative object, as it is with SymPy functions, differentiation of DiscreteGrid object simply returns an object of the same class, but with different arguments.

Finally, let's find dispersion relation:

d_equation_dr(equation)

Also you can rewrite it with Euler formula:

d_equation_dr(equation, trig_rewrite=True)

And here's the full code:

from sympy import *
from symdr import *

u = DiscreteGrid('u')
equation = u.diff(t) + (u.at_x(a+2) - 2 * u.at_x(a+1) + 2 * u.at_x(a-1) - u.at_x(a-2)) / (2 * h ** 3)

d_equation_dr(equation)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

symdr-1.0.3.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

symdr-1.0.3-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file symdr-1.0.3.tar.gz.

File metadata

  • Download URL: symdr-1.0.3.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for symdr-1.0.3.tar.gz
Algorithm Hash digest
SHA256 630450637adefc2693ee180508fa4c6124d70cc41e34cd3ed735cc8143a47d4f
MD5 62839d6c3dc2452643cbbffdb1075cb0
BLAKE2b-256 c1f12436e1c181f518f50d83d72e957aedff9ef8f64fb463186778e403bacf30

See more details on using hashes here.

File details

Details for the file symdr-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: symdr-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for symdr-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 41fea215bf44ef7055968fa4a59280b4af1f1e4a3b9622ea78f6edf57dd7f294
MD5 02ee53f2d4a5d890029289869d34f9e9
BLAKE2b-256 d72696a86f7a5d76ef93a310b2116e70ba2684cf210212460b03e14025e90505

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page