Springable

raw JSON →
1.0.1 verified Sat May 09 auth: no python

Nonlinear spring assembly solver and visualization library. Version 1.0.1 supports Python >=3.10. Uses flexel formulation for modeling complex spring networks. Active development, monthly releases.

pip install springable
error AttributeError: module 'springable' has no attribute 'Flexel'
cause Import from wrong module path; Flexel is not in a submodule.
fix
Use: from springable import Flexel
error ValueError: rest_length must be positive
cause Provided zero or negative rest length to Spring constructor.
fix
Set rest_length > 0.
gotcha Rest lengths must be positive floats; zero or negative values cause solver errors.
fix Ensure rest_length > 0 for all springs.
breaking Import paths changed between v0.x and v1.0.0; submodule imports no longer work.
fix Use from springable import Flexel, Spring, Node, Assembly instead of from springable.x import y.
deprecated The old syntax using ast.Num is deprecated and will be removed in Python 3.14. Version 1.0.1 fixes this bug.
fix Upgrade to 1.0.1.
gotcha Assembly.solve() may return List[float] or generator; check return type.
fix Wrap with list() if you need all results immediately.

Basic usage: create nodes and springs, solve, and visualize.

from springable import Node, Spring, Assembly

# Create nodes
n1 = Node(0, 0)
n2 = Node(1, 0)
n3 = Node(0.5, 0.866)

# Create springs
spring1 = Spring(n1, n2, stiffness=10.0, rest_length=1.0)
spring2 = Spring(n2, n3, stiffness=10.0, rest_length=1.0)
spring3 = Spring(n3, n1, stiffness=10.0, rest_length=1.0)

# Assemble and solve
assembly = Assembly([n1, n2, n3], [spring1, spring2, spring3])
solution = assembly.solve()
print(solution.node_positions)

# Plot
assembly.plot()