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)
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.
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pygbs-0.4.1.tar.gz.
File metadata
- Download URL: pygbs-0.4.1.tar.gz
- Upload date:
- Size: 8.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6eff8cc570c25578af2ff7758c6a76049a2d1fd3ba6d0d9f2c430ee33b530eb
|
|
| MD5 |
c86f66e37ae06efce8f9f146b062ca8d
|
|
| BLAKE2b-256 |
a31f0c9b9c93403acd86f3018bfd23f5a74680d1c6bd06d938d6d6337310fcb6
|
File details
Details for the file pygbs-0.4.1-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: pygbs-0.4.1-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 1.8 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b627daabb17c1cb3d9450364cf76fa30cb95460f0f4993d976a9ee7f24c088e
|
|
| MD5 |
b2082b78c57235bc79c8bb4d94c45551
|
|
| BLAKE2b-256 |
34b4b1b342d319b7d5a59cbb8fc50016a4851703a55434109530206e8d85b6ee
|