Skip to main content

Numerical continuation of nonlinear equilibrium equations

Project description

contique

Numeric continuation of equilibrium equations

PyPI version shields.io PyPI pyversions Made with love in Graz Code style: black

Example

A given set of equilibrium equations in terms of x and lpf (a.k.a. load-proportionality-factor) should be solved by numeric continuation of a given initial solution.

Function definition

def fun(x, lpf, a, b):
    return np.array([-a * np.sin(x[0]) + x[1]**2 + lpf, 
                     -b * np.cos(x[1]) * x[1]      + lpf])

with it's initial solution

x0 = np.zeros(2)
lpf0 = 0.0

and function parameters

a = 1
b = 1

Run contique.solve and plot equilibrium states

Res = contique.solve(
    fun=fun,
    x0=x0,
    args=(a, b),
    lpf0=lpf0,
    dxmax=0.05,
    dlpfmax=0.05,
    maxsteps=80,
    maxcycles=4,
    maxiter=20,
    tol=1e-6,
)

Assemble results

X = np.array([res.x for res in Res])

and plot the solution curve.

import matplotlib.pyplot as plt

plt.plot(X[:, 0], X[:, 1], ".-")
plt.xlabel('$x_1$')
plt.ylabel('$x_2$')

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

contique-0.1.0.tar.gz (19.9 kB view hashes)

Uploaded Source

Built Distribution

contique-0.1.0-py3-none-any.whl (22.2 kB view hashes)

Uploaded Python 3

Supported by

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