Skip to main content

Python bindings for the GBS library

Project description

PyGbs is the new binding of GBS

The original c++ project can be found at: https://github.com/ssg-aero/gbs

Introduction

Py Gbs is fast.

Compared to scipy interpolation PyGbs runs roughly 10x faster.

import numpy as np
from scipy.interpolate import CubicSpline
x = np.arange(10)
y = np.sin(x)
from pygbs import core
from pygbs import interpolate

points = [[x_, y_] for x_, y_ in zip(x, y)]
%%timeit
cs = CubicSpline(x, y)

86.8 μs ± 3.41 μs per loop (mean ± std. dev. of 7 runs, 10,000 loops each)

%%timeit
crv = interpolate.interpolate_cn(points, 3)

14.8 μs ± 406 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)

Object oriented

Implements most of the NURBS's Book algorythm

Examples

Direct curves creation

from pygbs import core

    poles = [
        [0.,0.,0.], # Pole 1 [x, y, z]
        [1.,0.,0.], # Pole 2 [x, y, z]
    ]
    knots          = [0.0, 1.0] # Curve parametrization
    multiplicities = [1, 1]
    degree         = 1
    curve = core.BSCurve3d(
        poles,
        knots,
        multiplicities,
        degree
    )

    point = crv(0.5)

Points interpolation

For instance point interpolation with tangency control:

from pygbs.core import BSCurve2d
from pygbs.interpolate import interpolate_c1
from pygbs.plotlyplot import plot_bs_curve_2d

constraints = [
    [ [0.,0.], [0., 1.] ], # [ [x0, y0], [dx0/du, dy0/du] ]
    [ [1.,0.], [0.,-2.] ], # [ [x1, y1], [dx1/du, dy1/du] ]
]

curve = interpolate_c1(constraints)

plot_bs_curve_2d(curve)

"Interpolation"

Points approximation

# Create points
import requests

foil_name = 'e1098'
url = f"http://airfoiltools.com/airfoil/seligdatfile?airfoil={foil_name}-il"

response = requests.get(url)
lines = response.text.split("\n")
lines .pop(0)
lines .pop(-1)

points = [ list(map(float, line.split())) for line in lines]
# Create an approximation of degree 3
from pygbs import core
from pygbs import interpolate

curve = interpolate.approx(
    points,
    deg=3
)

The green dots are representing the foil's points and the purple ones the control points of the approximating curve. "Points approximation"

A closer look shows the benefit of approximation on stiff interpolation, in the case of a poorly discretized profile the algorythm is able to produce a smooth curve.

"Points approximation"

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

pygbs-0.4.1.1.tar.gz (9.6 MB view details)

Uploaded Source

Built Distribution

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

pygbs-0.4.1.1-cp311-cp311-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.11Windows x86-64

File details

Details for the file pygbs-0.4.1.1.tar.gz.

File metadata

  • Download URL: pygbs-0.4.1.1.tar.gz
  • Upload date:
  • Size: 9.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.11

File hashes

Hashes for pygbs-0.4.1.1.tar.gz
Algorithm Hash digest
SHA256 83c45f4f3e15ef1ec8a3e3be9e868888484bc2b4151cace46daac377c6dea747
MD5 238f4499f69a53b3d5c51f94e3842bb9
BLAKE2b-256 aebd2f1116439609dbe6bac4f0ccdaa8a2c0ba351b6c61f38d432e22b0f00bcf

See more details on using hashes here.

File details

Details for the file pygbs-0.4.1.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pygbs-0.4.1.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.11

File hashes

Hashes for pygbs-0.4.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c3e9d970c3ba1a5d183dfe623a6e69692bf977d0b646b18e63c5528673c90593
MD5 ff09c7e55021a76f70abedd937fb44a9
BLAKE2b-256 4f7e80fd59ff9adc32a68285b5c53742f875aff6d0fa193eed76131feef122dc

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