Skip to main content

Numerical continuation of nonlinear equilibrium equations

Project description

contique

Numeric continuation of nonlinear equilibrium equations

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

Fig. 1 Archimedean spiral equation solved with contique

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 its 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.1,
    dlpfmax=0.1,
    maxsteps=75,
    maxcycles=4,
    maxiter=20,
    tol=1e-6,
)

For each step a summary is printed. This contains needed Newton-Rhapson iterations per cycle and an information about the control component at the beginning and the end of a cycle. Finally the lpf, control and equilibrium norm values are listed. As an example the ouput of Step 77 is shown below.

Begin of Step 72 
====================================================================

| Cycle | converged in                        | control component  |
|-------|-------------------------------------|--------------------|
| #   1 | Solution converged in  3 Iterations | from   -1 to   +2  |
| #   2 | Solution converged in  2 Iterations | from   +2 to   +2  |

*final lpf value     = -4.820e-01
*final control value = -5.739e-01
*final equilibrium   =  6.136e-11 (norm)

Next, we have to assemble the 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], "C0.-")
plt.xlabel('$x_1$')
plt.ylabel('$x_2$')
plt.plot([0],[0],'C0o',lw=3)
plt.arrow(X[-2,0],X[-2,1],X[-1,0]-X[-2,0],X[-1,1]-X[-2,1],
          head_width=0.075, head_length=0.15, fc='C0', ec='C0')
plt.gca().set_aspect('equal')

Fig. 2 Solution states of equilibrium equations solved with contique

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.4.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

contique-0.1.4-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file contique-0.1.4.tar.gz.

File metadata

  • Download URL: contique-0.1.4.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

File hashes

Hashes for contique-0.1.4.tar.gz
Algorithm Hash digest
SHA256 140652c09f39b19b1a0b5b6586ecc5439e6328b8bdefb22f679ced4f0601cfa6
MD5 c69756384fc2ad3c7d59b9c707bfe34e
BLAKE2b-256 524bad0dc49aabc7a0977e34b58a9a5290d6cd75e7696f8d060c621d0f60e2b8

See more details on using hashes here.

File details

Details for the file contique-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: contique-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

File hashes

Hashes for contique-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 979ac2ab064b8b943c77a142b569f776ea8a8c940c4cd22f7f5bba54feec8ed6
MD5 473f0fcd6673e52168fc24b3286c7831
BLAKE2b-256 818c181742dfd0b4033ab29713ce81bf7895fc809abf6ae33529924b846ea531

See more details on using hashes here.

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