Skip to main content

A Python implementation of the Method of Multiple Scales using SymPy for symbolic computation

Project description

Nonlinear systems considered

The OSCILATE (Oscillators’ nonlinear analysis through Symbolic ImplementATion of the mEthod of multiple scales) package allows the application of the Method of Multiple Scales (MMS) to a nonlinear equation or systems of \(N\) coupled nonlinear equations of the form

\begin{equation*} \begin{cases} \ddot{x}_0 + \omega_0^2 x_0 & = f_0(\boldsymbol{x}, \dot{\boldsymbol{x}}, \ddot{\boldsymbol{x}}, t), \\ & \vdots \\ \ddot{x}_{N-1} + \omega_{N-1}^2 x_{N-1} & = f_{N-1}(\boldsymbol{x}, \dot{\boldsymbol{x}}, \ddot{\boldsymbol{x}}, t). \end{cases} \end{equation*}

The \(x_i(t)\) (\(i=0,...,N-1\)) are the oscillators’ coordinates,

\begin{equation*} \boldsymbol{x}(t)^\intercal = [x_0(t), x_1(t), \cdots, x_{N-1}(t)] \end{equation*}

is the vector containing all the oscillators’ coordinates (the \(^\intercal\) denotes the transpose), \(\omega_i\) are their natural frequencies, \(t\) is the time and \(\dot{(\bullet)} = \textrm{d}(\bullet)/\textrm{d}t\) denotes a time-derivative. The \(f_i\) are functions which can contain:

  • Weak linear terms in \(x_i,\; \dot{x}_i\), or \(\ddot{x}_i\).

  • Weak linear coupling terms involving \(x_j,\; \dot{x}_j\), or \(\ddot{x}_j\) with \(j \neq i\).

  • Weak nonlinear terms. Taylor expansions are performed to approximate nonlinear terms as polynomial nonlinearities.

  • Forcing terms:

    • Can be hard (appearing at leading order) or weak (small).

    • Primarily harmonic, e.g., \(F \cos(\omega t)\), where \(F\) and \(\omega\) are the forcing amplitude and frequency, respectively.

    • Modulated by any function (constant, linear, or nonlinear) to model parametric forcing (e.g., \(x_i(t) F \cos(\omega t)\)).

Internal resonance relations among oscillators can be specified in a second step by expressing the \(\omega_i\) as a function of a reference frequency. Detuning can also be introduced during this step.

Overview

Solver

MMS.py is the MMS solver. It contains 3 main classes:

  • Dynamical_system : the dynamical system considered

  • Multiple_scales_system : the system obtained after applying the MMS to the dynamical system

  • Stead_state : the MMS results evaluated at steady state and (if computed) the system’s response and its stability.

These classes are described in details in the documentation.

Additional functions

sympy_functions.py contains additional functions that are not directly related to the MMS but which are used in MMS.py.

Examples

Application examples are proposed in the documentation. They include:

  • The Duffing oscillator

  • Coupled Duffing oscillators

  • Coupled nonlinear oscillators with quadratic nonlinearities

  • Parametrically excited oscillators

  • Hard forcing of a Duffing oscillator

  • Subharmonic response of 2 coupled centrifugal pendulum modes

Outputs

Results are returned as sympy expressions. They can be printed using LaTeX if the code is ran in an appropriate interactive Window. It is the case with VS Code’s interactive Window or Spyder’s IPython consol.

Here are possibilities:

  • VS Code’s interactive Window (powered by Jupyter)

  • Jupyter notebook

  • Spyder’s IPython consol

Sympy expressions can also be printed as unformatted LaTeX using

` print(vlatex(the_expr)) `

Documentation

A full documentation is available.

Citation

Please cite this package when using it – see the CITATION file for details.

Installation guide

Install from a GitHub release

To install from a GitHub release tagged as version vX.Y.Z, run:

pip install https://github.com/vinceECN/OSCILATE/archive/refs/tags/vX.Y.Z.tar.gz

Install from the repository (latest version)

To install the latest version directly from the GitHub repository, run:

git clone https://github.com/vinceECN/OSCILATE.git
cd OSCILATE
pip install .

Dependencies

  • Python 3.8 or higher is required.

  • For development or building documentation, install additional dependencies:

    pip install -r requirements-dev.txt
    pip install -r docs/requirements.txt

Test the install

To test the install, follow these steps:

  1. Open a python environment. Ideally one powered by Jupyter (see Outputs section) to display results as LaTeX.

  2. In the documentation, go to Application Examples/Example 1.

  3. Copy the example code.

  4. Run the example code in your python environment.

  5. You should see information about the ongoing computations.

  6. After the code is ran (a few seconds should be sufficient), figures of the forced response and its stability information are displayed.

  7. To access the analytical solutions computed, type, for instance, ss.sol.fa. They will be displayed as LaTeX if the python environment supports its.

Disclaimer

This code is provided as-is and has been tested on a limited number of nonlinear systems. Other test cases might trigger bugs or unexpected behavior that I am not yet aware of. If you encounter any issues, find a bug, or have suggestions for improvements, please feel free to: - Open an issue on the GitHub repository (if applicable). - Propose a solution. - Contact me directly at [vincent.mahe@ec-nantes.fr].

Your feedback is highly appreciated!

Vincent MAHE

License

This project is licensed under the Apache License 2.0 – see the LICENSE file for details.

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

oscilate-1.0.2.tar.gz (44.0 kB view details)

Uploaded Source

Built Distribution

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

oscilate-1.0.2-py3-none-any.whl (42.0 kB view details)

Uploaded Python 3

File details

Details for the file oscilate-1.0.2.tar.gz.

File metadata

  • Download URL: oscilate-1.0.2.tar.gz
  • Upload date:
  • Size: 44.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for oscilate-1.0.2.tar.gz
Algorithm Hash digest
SHA256 1206a8c6619d319e8bcc5365ea06d8800f403d1d11abe3a9432ee9ff70f0df64
MD5 a085797195f170ab2562e298da552a16
BLAKE2b-256 7c544346f95af458d8427ac5aeee23fd086632c94d6d4e172d46e58ef1d6c314

See more details on using hashes here.

File details

Details for the file oscilate-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: oscilate-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 42.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for oscilate-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dd362e0adf1ebb1eb0a5f032893e3aef59810e107d4583890d37f38f93d851c3
MD5 00c6dbad7c31c1855f2a6b3689670502
BLAKE2b-256 1b5e3d7bb1884987526bfe1a794acbf6543ccdcb5cd65f5f5b6bdbee01a718cb

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