springable


Namespringable JSON
Version 0.0.2 PyPI version JSON
download
home_pageNone
SummaryNonlinear spring assembly solver and visualization
upload_time2024-06-13 14:23:18
maintainerNone
docs_urlNone
authorPaul Ducarme
requires_python>=3.11
licenseNone
keywords nonlinear spring simulation animation instability snap-through
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # springable


The Python package `springable` allows you to simulate how assemblies of springs deform under loads.
By accounting for any geometrical changes (as large as they may be), the simulation allows you to explore the richness
of nonlinear mechanics, beyond the (boring) linear regime.

The implementation of the package is geared towards understanding how spring assemblies lead to mechanical behaviors
ranging from simple monotonic responses to complex, highly-nonlinear ones, such as snapping instabilities, sequencing,
buckling, symmetry-breaking or restabilization.

In its core, `springable` deals with **springs**, that we define as any entity that can store [elastic energy](https://en.wikipedia.org/wiki/Elastic_energy). **Springs** therefore include longitudinal springs (compression and extension), rotation springs (bending), area springs (useful to model fluids and pneumatic loading) and more (*see gallery*).
## Installation

Use [pip](https://pypi.org/project/springable/) to install. In the terminal simply enter

    pip install springable

and you are good to go!

It is supported on **Python 3.11 and above**.
## How to use


### Running a simulation
To start a simulation, create a Python file named - let's say - `my_first_simulation.py`, then run it.

```python
"""
my_first_simulation.py
Example to learn how to use the package springable
"""
import springable.simulation as ss

ss.simulate_model(model_path='my_spring_model.csv', save_dir='my_simulation_result')
```

The function `ss.simulate_model()` takes in two necessary arguments:
* The `model_path` argument is the path leading to the [CSV file](https://en.wikipedia.org/wiki/Comma-separated_values)
that describes the model you want to simulate.
How to create such a file is described in the section **Creating a CSV file describing the spring model**.
* The `save_dir` argument is simply the name of the folder under which the simulation results will be saved.

CSV file examples that describe spring assemblies are already available
[here on GitHub](https://github.com/ducarme/springable/tree/main/examples) for inspiration or to download.

A simple linear spring under a tensile load can be described as follows.
```csv
# my_simple_spring_model.csv

PARAMETERS
stiffness, 1.0
NODES
0, 0.0, 0.0, 1, 1
1, 1.0, 0.0, 0, 1
SPRINGS
0-1, stiffness
LOADING
1, X, 2.0
```

Many settings can be tuned before running a simulation. See section **Configuring simulation settings** for more details.




### Creating a CSV file describing the spring model


The CSV file describing a valid spring model is specified as follows:

~~~~
PARAMETERS
<parameter name>, <parameter value>
<parameter name>, <parameter value>
...
NODES
<node index>, <x>, <y>, <constrained x>, <constrained y>
<node index>, <x>, <y>, <constrained x>, <constrained y>
...
SPRINGS
<node index>-<node index>, <mechanical behavior>, [natural length]
<node index>-<node index>, <mechanical behavior>, [natural length]
...
ROTATION SPRINGS
<node index>-<node index>-<node index>, <mechanical behavior>, [natural angle]
<node index>-<node index>-<node index>, <mechanical behavior>, [natural angle]
...
AREA SPRINGS
<node index>-<node index>-<node index>-..., <mechanical behavior>, [natural area]
<node index>-<node index>-<node index>-..., <mechanical behavior>, [natural area]
...
LOADING
<node index>, <direction>, <force>, [max displacement]
<node index>, <direction>, <force>, [max displacement]
...
~~~~
NB:
* `<...>`: required field
* `[...]`: optional field
#### The `PARAMETERS` section
The `PARAMETERS` section serves to define some parameters that can be used to in the next sections. To define a parameter, a line with the following structure is added to the section `PARAMETERS`:\
`<parameter name>, <parameter value>`.
* `<parameter name>` is the name of the parameter (character string **without** quotes).
* `<parameter value>` is the value of the parameter. It can be either a float or a string (**with** simple quotes)

Example:
```csv
PARAMETERS
width, 2.0
height, 1.0
stiffness, 7.3
```
*Three parameters - `width`, `height` and `stiffness` - are defined and set to values `2.0`, `1.0` and `7.3` respectively.*

#### The `NODES` section
The `NODES` section serves to define the nodes composing the spring assembly, by specifying their index,
their coordinates and the fact they are constrained or not. To define a node, a line with the following structure is added to the section `NODES`:\
`<node index>, <x>, <y>, <constrained x>, <constrained y>`.
* `<node index>` is a positive integer (`0`, `1`, `2`, ...) representing the index of the node being defined. Two nodes cannot have the same index.
When nodes are defined, indices cannot be skipped (if there are four nodes in total, the indices must be `0`, `1`, `2` and `3`). The order in which the nodes are defined does not matter.
* `<x>` is the horizontal coordinate of the node (float).
* `<y>` is the vertical coordinate of the node (float).
* `<constrained x>` is either
  * `1` if the node cannot move horizontally,
  * `0` if the node is free to move horizontally.
* `<constrained y>` is either
  * `1` if the node cannot move vertically,
  * `0` if the node is free to move vertically.

Example:
```csv
NODES
0, -width/2, 0.0, 1, 1
1, +width/2, 0.0, 1, 1
2, 0.0, height, 1, 0
```
*Three nodes labelled `0`, `1` and `2` are defined at coordinates `(-width/2, 0.0)`, `(+width/2, 0.0)`, `(0.0, height)`
respectively. Nodes `0` and `1` are constrained horizontally and vertically, while node `2` is constrained horizontally
but free to move vertically.*

#### The `SPRINGS` section
The `SPRINGS` section serves to define **longitudinal springs**. Each longitudinal spring is defined by the
**two nodes** it connects, a **mechanical behavior**, and optionally its **natural length**,
that is the length it has if not constrained nor loaded. If no natural length is provided, the natural length is
automatically set to the distance between the nodes connected by the spring.

The mechanical behavior describes its intrinsic axial force-displacement relation. It can be a linear behavior
(the spring follows [the Hooke's law](https://en.wikipedia.org/wiki/Hooke%27s_law)) or a nonlinear one
(see section **Specifying a Nonlinear Mechanical Behavior**).

To define a longitudinal spring, a line with the following structure is added to the section `SPRINGS`:\
`<node index>-<node index>, <mechanical behavior>, [natural length]`.
* `<node index>` is the index of one of the node connected to the spring.
* `<node index>` is the index of the other node connected to the spring.
* `<mechanical behavior>` is the axial mechanical behavior of the spring. To specify a **linear** longitudinal spring,
the mechanical behavior is simply the **spring constant** (positive float).
* `[natural length]` is the natural length of the spring connecting both nodes (positive float). 
It is an optional parameter; if not provided the natural length of the spring element will automatically be set to the
distance between both nodes as created in the `NODES` section.

Example:
```csv
SPRINGS
0-2, stiffness
1-2, stiffness
```
*Two linear longitudinal springs are defined. Both are characterized by the spring constant value `stiffness`.
No natural length was provided, so their natural length will be automatically set to the distance between nodes `0`
and `2`, and between nodes `1` and `2` as defined in the section `NODES`, respectively.*

#### The `ROTATION SPRINGS` section
The `ROTATION SPRINGS` section serves to define **rotation springs**
(also known as [torsion springs](https://en.wikipedia.org/wiki/Torsion_spring)), by specifying **three nodes** A, B and C,
which together, define the angle ABC (B is the vertex of the angle). More precisely, the angle ABC is the angle by which
the segment BA must rotate counterclockwise (about B) to align with segment BC. The angle is always between 0 and 2π.
Along with its three nodes, the **mechanical behavior** must be specified, and optionally the natural angle of the rotation
spring (in radians). If no natural angle is provided, the natural angle is automatically set to the angle defined by the
three specified nodes.
To define a rotation spring, a line with the following structure is added to the section `ROTATION SPRINGS`:\
`<node index>-<node index>-<node index>, <nechanical behavior>, [natural angle]`.
* `<node index>` is the index of node A.
* `<node index>` is the index of node B.
* `<node index>` is the index of node C.
* `<mechanical behavior>` is the angular mechanical behavior of the rotation spring. To specify a **linear** rotation spring,
the mechanical behavior is simply the **spring constant** (positive float), that is the slope of its (torque)-(angle-change) curve.
* `[natural angle]` is the natural angle of the rotation spring in radians (float in [0, 2π[). 
It is an optional parameter; if not provided the natural angle of the rotation spring will automatically be set to the
angle defined by nodes A, B and C as created in the `NODES` section.

Example:
```csv
ROTATION SPRINGS
0-2-1, 1.5, PI/2
```
*A linear rotation spring is defined. The torque it creates will be determined by the difference between the angle 021
(vertex at node `2`) and its natural angle `PI/2` (90 deg). The angle-difference versus torque relation is defined
by the spring constant set to `1.5`.
Note that if no natural angle was specified, the natural angle would have been automatically set to the angle defined by
the nodes `0`, `1` and `2` as defined in the section `NODES`.*

#### The `LOADING` section
The `LOADING` section serves to set the forces applied on some specific nodes along a specific direction (horizontal or vertical).
To define a horizontal or vertical force on a node, a line with the following structure is added to the section `LOADING`:\
`<node index>, <direction>, <force>, [max displacement]`.
* `<node index>` is the index of the node on which the force is applied.
* `<direction>` is either:
  * `X` for a horizontal force,
  * `Y` for a vertical force.
* `<force>` the signed amplitude of the force (negative or positive float)
* `[max displacement]` is the maximum displacement of the specified node along the specified direction (positive float).
Beyond this value, the simulation will finish (even if the force has not been reached yet).
It is an optional parameter; if not provided, there is no maximum displacement at which the simulation can finish
prematurely (it is the same as setting the maximum displacement to a value close to infinity).

Example:
```csv
LOADING
2, Y, -10.0, -3.0
```
*A force is applied on node `2`, along the `Y`-direction (vertical).
The magnitude of the force is `-10` (it is a negative value, so the force points downwards).
The maximum displacement is set to `-3.0`, meaning that if node `2` is displaced downward by more that `3.0`,
the simulation is assumed to have completed.*


Complete example
```csv
# spring model example (this is a comment)

PARAMETERS
width, 2.0
height, 1.0
stiffness, 7.3

NODES
0, -width/2, 0.0, 1, 1
1, +width/2, 0.0, 1, 1
2, 0.0, height, 1, 0

SPRINGS
0-2, stiffness
1-2, stiffness
ROTATION SPRINGS
0-2-1, 1.5, PI/2

LOADING
2, Y, -10.0, -3.0
```

#### Additional notes
* Empty lines have no semantic meaning. Adding/removing some will not change the spring model.
* `#` is used to indicate a line comment. Each line starting with `#` will be ignored when reading the file.
* Parameters can be combined in mathematical expression in all sections but `PARAMETERS`. Supported operations include
`(...)`, `+`, `-`, `*`, `/`, `SIN(...)` (sine), `COS(...)` (cosine), `TAN(...)` (tangent), `SQRT(...)` (square root). 
Value π can be used without defining it in the section `PARAMETERS` with the keyword `PI`.
* If your spring assembly does not include a certain type of spring, feel free to leave the corresponding section empty (header only)
or to omit it completely (no header and no content).


### Configuring simulation settings
Many settings can be tuned before running a simulation. They fall into two categories: **solver settings**
or **graphics settings**.

Solver settings only affect the solver (that is the part responsible to solve the nonlinear equations,
by computing all the equilibrium points), while graphics settings determines what is generated to visualize a result
(previously computed by the solver), and how it is going to look like.

All default solver and graphics settings along with useful documentation are listed in the files
`default_solver_settings.toml` and `default_graphics_settings.toml` respectively. They are available
[here on GitHub](https://github.com/ducarme/springable).


When you wish to change a setting (let's say a solver setting),
create a [TOML file](https://toml.io/en/), that is a text file saved with extension *.toml*. You can use the NotePad (Windows)
or TextEdit (MacOS) to do that, for example. The file will look similar to this:
```toml
# custom_solver_settings.toml
radius = 0.01
reference_load_parameter = 0.01
```
*Low values for `radius` and `reference_load_parameters` can be used to refine the solution,
at the cost of increasing the solving duration. Default values are 0.05 and 0.05, respectively.*

To use these custom solver settings, use the path to `custom_solver_settings.toml`
as an extra argument of the `ss.simulate_model()` function, as follows:

```python
"""
my_first_simulation.py
Example to learn how to use the package springable
"""
import springable.simulation as ss

ss.simulate_model(model_path='my_spring_model.csv',
                  save_dir='my_simulation_result',
                  solver_settings_path='custom_solver_settings.toml')
```


Similarly, when you wish to modify a graphics setting, create another TOML file and include the settings you wish to modify
```toml
# custom_graphics_settings.toml
[animation_options]
nb_frames = 240
fps = 60

[plot_options]
show_snapping_arrows = true
drive_mode = "force"
```
*Animation settings `nb_frames` and `fps` determine the number of frames and the frame rate (in frame per second) of the animation showing
the spring assembly deforming. Plot settings `show_snapping_arrows = true` combined with `drive_mode = "force"` means that
you want to indicate with arrows the (potential) snapping transitions under controlled force in the force-displacement plot.
To indicate, snapping transitions under controlled displacement use `show_snapping_arrows = true` combined with `drive_mode = "displacement"`
instead.*

To use these custom graphics settings, use the path to `custom_graphics_settings.toml`
as an extra argument of the `ss.simulate_model()` function, as follows:

```python
"""
my_first_simulation.py
Example to learn how to use the package springable
"""
import springable.simulation as ss

ss.simulate_model(model_path='my_spring_model.csv',
                  save_dir='my_simulation_result',
                  solver_settings_path='custom_solver_settings.toml',
                  graphics_settings_path='custom_graphics_settings.toml')
```




#### Additional notes
* A custom settings file does not need to contain all the possible settings; just include the one you wish to modify.
* Graphics settings are divided into 4 sections of settings (indicated by `[...]` in TOML files):
  * general options (determines _what_ should be generated and directly shown (drawing, animation, plot))
  * plot options (determines _how_ plots will look like)
  * animation options (determines _how_ animations will look like)
  * assembly appearance (determines _how_ the spring assembly will be depicted)





            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "springable",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "nonlinear, spring, simulation, animation, instability, snap-through",
    "author": "Paul Ducarme",
    "author_email": "paulducarme@hotmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e3/4e/d145d89b9c1f4f0161461612a021f452636c3428a6b58f718842ae81f53e/springable-0.0.2.tar.gz",
    "platform": null,
    "description": "# springable\r\n\r\n\r\nThe Python package `springable` allows you to simulate how assemblies of springs deform under loads.\r\nBy accounting for any geometrical changes (as large as they may be), the simulation allows you to explore the richness\r\nof nonlinear mechanics, beyond the (boring) linear regime.\r\n\r\nThe implementation of the package is geared towards understanding how spring assemblies lead to mechanical behaviors\r\nranging from simple monotonic responses to complex, highly-nonlinear ones, such as snapping instabilities, sequencing,\r\nbuckling, symmetry-breaking or restabilization.\r\n\r\nIn its core, `springable` deals with **springs**, that we define as any entity that can store [elastic energy](https://en.wikipedia.org/wiki/Elastic_energy). **Springs** therefore include longitudinal springs (compression and extension), rotation springs (bending), area springs (useful to model fluids and pneumatic loading) and more (*see gallery*).\r\n## Installation\r\n\r\nUse [pip](https://pypi.org/project/springable/) to install. In the terminal simply enter\r\n\r\n    pip install springable\r\n\r\nand you are good to go!\r\n\r\nIt is supported on **Python 3.11 and above**.\r\n## How to use\r\n\r\n\r\n### Running a simulation\r\nTo start a simulation, create a Python file named - let's say - `my_first_simulation.py`, then run it.\r\n\r\n```python\r\n\"\"\"\r\nmy_first_simulation.py\r\nExample to learn how to use the package springable\r\n\"\"\"\r\nimport springable.simulation as ss\r\n\r\nss.simulate_model(model_path='my_spring_model.csv', save_dir='my_simulation_result')\r\n```\r\n\r\nThe function `ss.simulate_model()` takes in two necessary arguments:\r\n* The `model_path` argument is the path leading to the [CSV file](https://en.wikipedia.org/wiki/Comma-separated_values)\r\nthat describes the model you want to simulate.\r\nHow to create such a file is described in the section **Creating a CSV file describing the spring model**.\r\n* The `save_dir` argument is simply the name of the folder under which the simulation results will be saved.\r\n\r\nCSV file examples that describe spring assemblies are already available\r\n[here on GitHub](https://github.com/ducarme/springable/tree/main/examples) for inspiration or to download.\r\n\r\nA simple linear spring under a tensile load can be described as follows.\r\n```csv\r\n# my_simple_spring_model.csv\r\n\r\nPARAMETERS\r\nstiffness, 1.0\r\nNODES\r\n0, 0.0, 0.0, 1, 1\r\n1, 1.0, 0.0, 0, 1\r\nSPRINGS\r\n0-1, stiffness\r\nLOADING\r\n1, X, 2.0\r\n```\r\n\r\nMany settings can be tuned before running a simulation. See section **Configuring simulation settings** for more details.\r\n\r\n\r\n\r\n\r\n### Creating a CSV file describing the spring model\r\n\r\n\r\nThe CSV file describing a valid spring model is specified as follows:\r\n\r\n~~~~\r\nPARAMETERS\r\n<parameter name>, <parameter value>\r\n<parameter name>, <parameter value>\r\n...\r\nNODES\r\n<node index>, <x>, <y>, <constrained x>, <constrained y>\r\n<node index>, <x>, <y>, <constrained x>, <constrained y>\r\n...\r\nSPRINGS\r\n<node index>-<node index>, <mechanical behavior>, [natural length]\r\n<node index>-<node index>, <mechanical behavior>, [natural length]\r\n...\r\nROTATION SPRINGS\r\n<node index>-<node index>-<node index>, <mechanical behavior>, [natural angle]\r\n<node index>-<node index>-<node index>, <mechanical behavior>, [natural angle]\r\n...\r\nAREA SPRINGS\r\n<node index>-<node index>-<node index>-..., <mechanical behavior>, [natural area]\r\n<node index>-<node index>-<node index>-..., <mechanical behavior>, [natural area]\r\n...\r\nLOADING\r\n<node index>, <direction>, <force>, [max displacement]\r\n<node index>, <direction>, <force>, [max displacement]\r\n...\r\n~~~~\r\nNB:\r\n* `<...>`: required field\r\n* `[...]`: optional field\r\n#### The `PARAMETERS` section\r\nThe `PARAMETERS` section serves to define some parameters that can be used to in the next sections. To define a parameter, a line with the following structure is added to the section `PARAMETERS`:\\\r\n`<parameter name>, <parameter value>`.\r\n* `<parameter name>` is the name of the parameter (character string **without** quotes).\r\n* `<parameter value>` is the value of the parameter. It can be either a float or a string (**with** simple quotes)\r\n\r\nExample:\r\n```csv\r\nPARAMETERS\r\nwidth, 2.0\r\nheight, 1.0\r\nstiffness, 7.3\r\n```\r\n*Three parameters - `width`, `height` and `stiffness` - are defined and set to values `2.0`, `1.0` and `7.3` respectively.*\r\n\r\n#### The `NODES` section\r\nThe `NODES` section serves to define the nodes composing the spring assembly, by specifying their index,\r\ntheir coordinates and the fact they are constrained or not. To define a node, a line with the following structure is added to the section `NODES`:\\\r\n`<node index>, <x>, <y>, <constrained x>, <constrained y>`.\r\n* `<node index>` is a positive integer (`0`, `1`, `2`, ...) representing the index of the node being defined. Two nodes cannot have the same index.\r\nWhen nodes are defined, indices cannot be skipped (if there are four nodes in total, the indices must be `0`, `1`, `2` and `3`). The order in which the nodes are defined does not matter.\r\n* `<x>` is the horizontal coordinate of the node (float).\r\n* `<y>` is the vertical coordinate of the node (float).\r\n* `<constrained x>` is either\r\n  * `1` if the node cannot move horizontally,\r\n  * `0` if the node is free to move horizontally.\r\n* `<constrained y>` is either\r\n  * `1` if the node cannot move vertically,\r\n  * `0` if the node is free to move vertically.\r\n\r\nExample:\r\n```csv\r\nNODES\r\n0, -width/2, 0.0, 1, 1\r\n1, +width/2, 0.0, 1, 1\r\n2, 0.0, height, 1, 0\r\n```\r\n*Three nodes labelled `0`, `1` and `2` are defined at coordinates `(-width/2, 0.0)`, `(+width/2, 0.0)`, `(0.0, height)`\r\nrespectively. Nodes `0` and `1` are constrained horizontally and vertically, while node `2` is constrained horizontally\r\nbut free to move vertically.*\r\n\r\n#### The `SPRINGS` section\r\nThe `SPRINGS` section serves to define **longitudinal springs**. Each longitudinal spring is defined by the\r\n**two nodes** it connects, a **mechanical behavior**, and optionally its **natural length**,\r\nthat is the length it has if not constrained nor loaded. If no natural length is provided, the natural length is\r\nautomatically set to the distance between the nodes connected by the spring.\r\n\r\nThe mechanical behavior describes its intrinsic axial force-displacement relation. It can be a linear behavior\r\n(the spring follows [the Hooke's law](https://en.wikipedia.org/wiki/Hooke%27s_law)) or a nonlinear one\r\n(see section **Specifying a Nonlinear Mechanical Behavior**).\r\n\r\nTo define a longitudinal spring, a line with the following structure is added to the section `SPRINGS`:\\\r\n`<node index>-<node index>, <mechanical behavior>, [natural length]`.\r\n* `<node index>` is the index of one of the node connected to the spring.\r\n* `<node index>` is the index of the other node connected to the spring.\r\n* `<mechanical behavior>` is the axial mechanical behavior of the spring. To specify a **linear** longitudinal spring,\r\nthe mechanical behavior is simply the **spring constant** (positive float).\r\n* `[natural length]` is the natural length of the spring connecting both nodes (positive float). \r\nIt is an optional parameter; if not provided the natural length of the spring element will automatically be set to the\r\ndistance between both nodes as created in the `NODES` section.\r\n\r\nExample:\r\n```csv\r\nSPRINGS\r\n0-2, stiffness\r\n1-2, stiffness\r\n```\r\n*Two linear longitudinal springs are defined. Both are characterized by the spring constant value `stiffness`.\r\nNo natural length was provided, so their natural length will be automatically set to the distance between nodes `0`\r\nand `2`, and between nodes `1` and `2` as defined in the section `NODES`, respectively.*\r\n\r\n#### The `ROTATION SPRINGS` section\r\nThe `ROTATION SPRINGS` section serves to define **rotation springs**\r\n(also known as [torsion springs](https://en.wikipedia.org/wiki/Torsion_spring)), by specifying **three nodes** A, B and C,\r\nwhich together, define the angle ABC (B is the vertex of the angle). More precisely, the angle ABC is the angle by which\r\nthe segment BA must rotate counterclockwise (about B) to align with segment BC. The angle is always between 0 and 2\u03c0.\r\nAlong with its three nodes, the **mechanical behavior** must be specified, and optionally the natural angle of the rotation\r\nspring (in radians). If no natural angle is provided, the natural angle is automatically set to the angle defined by the\r\nthree specified nodes.\r\nTo define a rotation spring, a line with the following structure is added to the section `ROTATION SPRINGS`:\\\r\n`<node index>-<node index>-<node index>, <nechanical behavior>, [natural angle]`.\r\n* `<node index>` is the index of node A.\r\n* `<node index>` is the index of node B.\r\n* `<node index>` is the index of node C.\r\n* `<mechanical behavior>` is the angular mechanical behavior of the rotation spring. To specify a **linear** rotation spring,\r\nthe mechanical behavior is simply the **spring constant** (positive float), that is the slope of its (torque)-(angle-change) curve.\r\n* `[natural angle]` is the natural angle of the rotation spring in radians (float in [0, 2\u03c0[). \r\nIt is an optional parameter; if not provided the natural angle of the rotation spring will automatically be set to the\r\nangle defined by nodes A, B and C as created in the `NODES` section.\r\n\r\nExample:\r\n```csv\r\nROTATION SPRINGS\r\n0-2-1, 1.5, PI/2\r\n```\r\n*A linear rotation spring is defined. The torque it creates will be determined by the difference between the angle 021\r\n(vertex at node `2`) and its natural angle `PI/2` (90 deg). The angle-difference versus torque relation is defined\r\nby the spring constant set to `1.5`.\r\nNote that if no natural angle was specified, the natural angle would have been automatically set to the angle defined by\r\nthe nodes `0`, `1` and `2` as defined in the section `NODES`.*\r\n\r\n#### The `LOADING` section\r\nThe `LOADING` section serves to set the forces applied on some specific nodes along a specific direction (horizontal or vertical).\r\nTo define a horizontal or vertical force on a node, a line with the following structure is added to the section `LOADING`:\\\r\n`<node index>, <direction>, <force>, [max displacement]`.\r\n* `<node index>` is the index of the node on which the force is applied.\r\n* `<direction>` is either:\r\n  * `X` for a horizontal force,\r\n  * `Y` for a vertical force.\r\n* `<force>` the signed amplitude of the force (negative or positive float)\r\n* `[max displacement]` is the maximum displacement of the specified node along the specified direction (positive float).\r\nBeyond this value, the simulation will finish (even if the force has not been reached yet).\r\nIt is an optional parameter; if not provided, there is no maximum displacement at which the simulation can finish\r\nprematurely (it is the same as setting the maximum displacement to a value close to infinity).\r\n\r\nExample:\r\n```csv\r\nLOADING\r\n2, Y, -10.0, -3.0\r\n```\r\n*A force is applied on node `2`, along the `Y`-direction (vertical).\r\nThe magnitude of the force is `-10` (it is a negative value, so the force points downwards).\r\nThe maximum displacement is set to `-3.0`, meaning that if node `2` is displaced downward by more that `3.0`,\r\nthe simulation is assumed to have completed.*\r\n\r\n\r\nComplete example\r\n```csv\r\n# spring model example (this is a comment)\r\n\r\nPARAMETERS\r\nwidth, 2.0\r\nheight, 1.0\r\nstiffness, 7.3\r\n\r\nNODES\r\n0, -width/2, 0.0, 1, 1\r\n1, +width/2, 0.0, 1, 1\r\n2, 0.0, height, 1, 0\r\n\r\nSPRINGS\r\n0-2, stiffness\r\n1-2, stiffness\r\nROTATION SPRINGS\r\n0-2-1, 1.5, PI/2\r\n\r\nLOADING\r\n2, Y, -10.0, -3.0\r\n```\r\n\r\n#### Additional notes\r\n* Empty lines have no semantic meaning. Adding/removing some will not change the spring model.\r\n* `#` is used to indicate a line comment. Each line starting with `#` will be ignored when reading the file.\r\n* Parameters can be combined in mathematical expression in all sections but `PARAMETERS`. Supported operations include\r\n`(...)`, `+`, `-`, `*`, `/`, `SIN(...)` (sine), `COS(...)` (cosine), `TAN(...)` (tangent), `SQRT(...)` (square root). \r\nValue \u03c0 can be used without defining it in the section `PARAMETERS` with the keyword `PI`.\r\n* If your spring assembly does not include a certain type of spring, feel free to leave the corresponding section empty (header only)\r\nor to omit it completely (no header and no content).\r\n\r\n\r\n### Configuring simulation settings\r\nMany settings can be tuned before running a simulation. They fall into two categories: **solver settings**\r\nor **graphics settings**.\r\n\r\nSolver settings only affect the solver (that is the part responsible to solve the nonlinear equations,\r\nby computing all the equilibrium points), while graphics settings determines what is generated to visualize a result\r\n(previously computed by the solver), and how it is going to look like.\r\n\r\nAll default solver and graphics settings along with useful documentation are listed in the files\r\n`default_solver_settings.toml` and `default_graphics_settings.toml` respectively. They are available\r\n[here on GitHub](https://github.com/ducarme/springable).\r\n\r\n\r\nWhen you wish to change a setting (let's say a solver setting),\r\ncreate a [TOML file](https://toml.io/en/), that is a text file saved with extension *.toml*. You can use the NotePad (Windows)\r\nor TextEdit (MacOS) to do that, for example. The file will look similar to this:\r\n```toml\r\n# custom_solver_settings.toml\r\nradius = 0.01\r\nreference_load_parameter = 0.01\r\n```\r\n*Low values for `radius` and `reference_load_parameters` can be used to refine the solution,\r\nat the cost of increasing the solving duration. Default values are 0.05 and 0.05, respectively.*\r\n\r\nTo use these custom solver settings, use the path to `custom_solver_settings.toml`\r\nas an extra argument of the `ss.simulate_model()` function, as follows:\r\n\r\n```python\r\n\"\"\"\r\nmy_first_simulation.py\r\nExample to learn how to use the package springable\r\n\"\"\"\r\nimport springable.simulation as ss\r\n\r\nss.simulate_model(model_path='my_spring_model.csv',\r\n                  save_dir='my_simulation_result',\r\n                  solver_settings_path='custom_solver_settings.toml')\r\n```\r\n\r\n\r\nSimilarly, when you wish to modify a graphics setting, create another TOML file and include the settings you wish to modify\r\n```toml\r\n# custom_graphics_settings.toml\r\n[animation_options]\r\nnb_frames = 240\r\nfps = 60\r\n\r\n[plot_options]\r\nshow_snapping_arrows = true\r\ndrive_mode = \"force\"\r\n```\r\n*Animation settings `nb_frames` and `fps` determine the number of frames and the frame rate (in frame per second) of the animation showing\r\nthe spring assembly deforming. Plot settings `show_snapping_arrows = true` combined with `drive_mode = \"force\"` means that\r\nyou want to indicate with arrows the (potential) snapping transitions under controlled force in the force-displacement plot.\r\nTo indicate, snapping transitions under controlled displacement use `show_snapping_arrows = true` combined with `drive_mode = \"displacement\"`\r\ninstead.*\r\n\r\nTo use these custom graphics settings, use the path to `custom_graphics_settings.toml`\r\nas an extra argument of the `ss.simulate_model()` function, as follows:\r\n\r\n```python\r\n\"\"\"\r\nmy_first_simulation.py\r\nExample to learn how to use the package springable\r\n\"\"\"\r\nimport springable.simulation as ss\r\n\r\nss.simulate_model(model_path='my_spring_model.csv',\r\n                  save_dir='my_simulation_result',\r\n                  solver_settings_path='custom_solver_settings.toml',\r\n                  graphics_settings_path='custom_graphics_settings.toml')\r\n```\r\n\r\n\r\n\r\n\r\n#### Additional notes\r\n* A custom settings file does not need to contain all the possible settings; just include the one you wish to modify.\r\n* Graphics settings are divided into 4 sections of settings (indicated by `[...]` in TOML files):\r\n  * general options (determines _what_ should be generated and directly shown (drawing, animation, plot))\r\n  * plot options (determines _how_ plots will look like)\r\n  * animation options (determines _how_ animations will look like)\r\n  * assembly appearance (determines _how_ the spring assembly will be depicted)\r\n\r\n\r\n\r\n\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Nonlinear spring assembly solver and visualization",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/ducarme/springable",
        "Issues": "https://github.com/ducarme/springable/issues"
    },
    "split_keywords": [
        "nonlinear",
        " spring",
        " simulation",
        " animation",
        " instability",
        " snap-through"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "47e851b6a7ebd3b2d3050e7e13ab14a2ae90ef9491fccabce4d29c3d8cdecb8f",
                "md5": "fa4bb66141388ebf2c9dde84a6907aa4",
                "sha256": "431e09f9909a2b7d058608053dd81bc9029f0da20d0a897a18a76e463d8be8f1"
            },
            "downloads": -1,
            "filename": "springable-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fa4bb66141388ebf2c9dde84a6907aa4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 72602,
            "upload_time": "2024-06-13T14:23:16",
            "upload_time_iso_8601": "2024-06-13T14:23:16.727546Z",
            "url": "https://files.pythonhosted.org/packages/47/e8/51b6a7ebd3b2d3050e7e13ab14a2ae90ef9491fccabce4d29c3d8cdecb8f/springable-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e34ed145d89b9c1f4f0161461612a021f452636c3428a6b58f718842ae81f53e",
                "md5": "d79024629212284ce21f5fda7bcfffa9",
                "sha256": "3c76e1b00173d653def240fe7198170c08fb78d716b917d03daf009a710c96e0"
            },
            "downloads": -1,
            "filename": "springable-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "d79024629212284ce21f5fda7bcfffa9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 69789,
            "upload_time": "2024-06-13T14:23:18",
            "upload_time_iso_8601": "2024-06-13T14:23:18.287247Z",
            "url": "https://files.pythonhosted.org/packages/e3/4e/d145d89b9c1f4f0161461612a021f452636c3428a6b58f718842ae81f53e/springable-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-13 14:23:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ducarme",
    "github_project": "springable",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "springable"
}
        
Elapsed time: 0.57577s