PyWrithe Documentation

PyWrithe is a all python package to compute writhe of closed curves. Supports both numpy and jax.numpy for jit.

How to install

python3 -m pip install pywrithe

and you’ll be good to go.

Package contents

pywrithe.writhe.writhe(curve)

Returns writhe of given closed parametric curve.

Parameters

curve (np.array) – An N by 3 array describing locations of endpoints of N linear segments approximating the curve. All locations should be distinct.

Returns

Value of writhe for closed curve comprised of linear segments given.

Return type

float

Example

>>> import numpy as np
>>> curve = np.array([[-1,0,-1],[1,0,1],[0,-1,1],[0,1,1]])
>>> pywrithe.writhe(curve)
0.366
pywrithe.writhe_jax.writhe_jax(curve)

Returns writhe of given closed parametric curve.

Parameters

curve (jnp.array) – An N by 3 array describing locations of endpoints of N linear segments approximating the curve. All locations should be distinct.

Returns

Value of writhe for closed curve comprised of linear segments given.

Return type

float

Example

>>> import jax.numpy as jnp
>>> curve = np.array([[-1,0,-1],[1,0,1],[0,-1,1],[0,1,1]])
>>> pywrithe.writhe_jax(curve)
0.366