Skip to main content

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

Project description

Presentation

The OSCILATE project allows the application of the Method of Multiple Scales (MMS) to a nonlinear equation or systems of \(N\) coupled nonlinear equations.

The source codes of OSCILATE (Oscillators’ nonlinear analysis through SymboliC ImpLementATion of the mEthod of multiple scales) are hosted on GitHub. A full documentation is available.

Nonlinear systems considered

The nonlinear systems tackled are 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\), \(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), for instance 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

The package associated with the OSCILATE project is called oscilate. The package organisation is depicted below

oscilate
│   sympy_functions.py
│   __init__.py
│   __version__.py
│
└───MMS
        dyn_sys.py
        mms.py
        mms_oscillator.py
        mms_complex.py
        steady_state.py
        visualisation.py
        __init__.py

It contains two modules:

  • The MMS module is the MMS solver. . It is divided into six sub-modules:

    • The oscilate.MMS.dyn_sys sub-module defines the dynamical system of interest,

    • The oscilate.MMS.mms, oscilate.MMS.mms_oscillator and oscilate.MMS.mms_complex sub-modules apply the MMS to the dynamical system,

    • The oscilate.MMS.steady_state sub-module allows for a steady state analysis,

    • The oscilate.MMS.visualisation sub-module contains numerical evaluation and plotting functions,

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

Solver

The MMS module contains 5 main classes:

  • Dynamical_system: the dynamical system considered.

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

  • Multiple_scales_oscillator : a sub-class of Multiple_scales_system to treat the system’s equations in oscillator form (classical approach)

  • Multiple_scales_complex : a sub-class of Multiple_scales_system to treat the system’s equations in complex form (alternative approach)

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

These classes are described in detail in the documentation. A visual description of their interconnection with other classes is provided in the Main module architecture section.

Examples

Application examples are proposed in the documentation. They include several examples on one and multi-degrees-of-freedom systems:

  • Computation of forced responses with respect to the excitation frequency and amplitude

  • Stability analysis of forced responses, possibly using a cartesian transform

  • Computation of the backbone curve

  • Direct responses

  • Parametric responses

  • Presence of internal resonances

  • Systems subject to hard forcing, leading to secondary resonances

  • Self-sustained oscillations of autonomous systems

Outputs

Results are returned as SymPy expressions. They can be printed using \(\LaTeX\) if the code is run in an appropriate interactive window. Here are possibilities:

SymPy expressions can also be printed as unformatted \(\LaTeX\) using:

print(vlatex(the_expr))

In addition, symbolic results can be evaluated for given numerical parameters and plotted using the visualisation sub-module.

Documentation

A full documentation is available.

Citation

Please cite this package when using it. See the Citation section of the documentation for details. A regular entry and a LaTeX/BibTeX users entry are given.

Installation guide

To install the oscilate package, refer to the Installation guide section of the documentation.

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:

Your feedback is highly appreciated.

Vincent Mahé

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.6.tar.gz (47.4 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.6-py3-none-any.whl (53.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: oscilate-1.0.6.tar.gz
  • Upload date:
  • Size: 47.4 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.6.tar.gz
Algorithm Hash digest
SHA256 2ecf4d3d0fd783e41494968d9f5992e3b911c0700afd013248e0f6f357f04b36
MD5 0a9676625a93d6d792e2841165cf0783
BLAKE2b-256 369465d2bdff3ee5c5a6ef44d25c8bfcb8e38c87579cd001fcb70c5efa898835

See more details on using hashes here.

File details

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

File metadata

  • Download URL: oscilate-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 53.9 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b00d943b504d674b5e4a943c11aa07a3cf39e7a1791d4417dd2c1a952f39fbcb
MD5 6fae1e8215a1d77f864913cf222d4c85
BLAKE2b-256 338b46ca3c273418af7e832f10189519e0f8d2dd7d079c491046b709b13435ab

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