-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from GazzolaLab/update-0.2.2
Release 0.2.2
- Loading branch information
Showing
59 changed files
with
1,555 additions
and
553 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Elastica Documentation | ||
|
||
We use [`Sphinx`](https://www.sphinx-doc.org/en/master/) and [`ReadtheDocs`](https://readthedocs.org/) to organize our [documentation page](https://docs.cosseratrods.org/en/latest/). | ||
|
||
In addition, we utilize the following extensions to enhance the documentation :coffee: | ||
- `numpydoc`: We favor [numpy documentation style](https://numpydoc.readthedocs.io/en/latest/format.html) for API documentation. | ||
- `myst_parser`: We like to write documentation and guidelines in `markdown` format. | ||
|
||
## Build documentation | ||
|
||
The `sphinx` is already initialized in `docs` directory. In order to build the documentation, you will need additional packages listed in `docs/requirements.txt`. | ||
|
||
```bash | ||
pip install sphinx sphinx_rtd_theme myst-parser numpydoc | ||
cd docs | ||
make clean | ||
make html | ||
``` | ||
|
||
Once the documentation building is done, open `docs/_build/html/index.html` to view. | ||
|
||
Use `make help` for other options. | ||
|
||
# Contribution | ||
|
||
The documentation-related commits will be collected in the branch `doc_**` separate from `master` branch, and merged into `master` collectively. Ideally, the updates in the documentation branch will seek upcoming version update (i.e. `update-**` branch) and merged shortly after the version release. If an update is critical and urgent, create PR directly to `master` branch. | ||
|
||
## User Guide | ||
|
||
User guidelines and tutorials are written in `.rst` or `.md` format. | ||
These files will be managed in `docs` directory. | ||
|
||
> In the future, a separate `asset` branch will be created to keep images and other binary files. | ||
## API documentation | ||
|
||
The docstring for function or modules are automatically parsed using `sphinx`+`numpydoc`. | ||
Any inline function description, such as | ||
|
||
```py | ||
""" This is the form of a docstring. | ||
... description | ||
Attributes | ||
---------- | ||
x : type | ||
x description | ||
y : type | ||
y description | ||
""" | ||
``` | ||
|
||
will be parsed and displayed in API documentation. See `numpydoc` for more details. | ||
|
||
## ReadtheDocs | ||
|
||
`ReadtheDocs` runs `sphinx` internally and maintain the documentation website. We will always activate the `stable` and `latest` version, and few past-documentations will also be available for the support. | ||
|
||
@nmnaughton and @skim449 has access to the `ReadtheDocs` account. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* To resize and re-factor the design parameters for logo | ||
* https://stackoverflow.com/questions/59215996/how-to-add-a-logo-to-my-readthedocs-logo-rendering-at-0px-wide | ||
* */ | ||
.wy-side-nav-search .wy-dropdown > a img.logo, .wy-side-nav-search > a img.logo { | ||
width: 175px; | ||
height: 80px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Localized Force and Torque | ||
|
||
> Originated by the investigation in the [issue #39](https://github.com/GazzolaLab/PyElastica/issues/39) | ||
## Discussion | ||
|
||
In elastica, __a force is applied on a node__ while __a torque is applied on an element__. | ||
For example, a localized force `EndpointForce` is applied only on a node. However, we found that adding additional torque on a neighboring elements, such that the torque represent a local moment induced by the point-force, could yield better convergence. | ||
We haven't found any evidence (yet) that this actually changes the steady-state configuration and kinematics, since it is two different implementation of the same point-load. | ||
We suspect the improvement by adding additional torque is due to explicitly giving the force-boundary condition that match the final internal-stress state. | ||
|
||
## Comparison | ||
|
||
Factoring the additional-torque on a neighboring element leads to slightly better error estimates for the Timoshenko beam example. The results are condensed here. | ||
With new implementation, we achieved the same error with less number of discretization, but it also requires additional torque computation. | ||
|
||
![image](https://github.com/GazzolaLab/PyElastica/blob/assets/docs/assets/plot/error_EndpointForcesWithTorques.png?raw=true) | ||
|
||
## Modified Implementation | ||
|
||
```py | ||
class EndpointForcesWithTorques(NoForces): | ||
""" | ||
This class applies constant forces on the endpoint nodes. | ||
""" | ||
|
||
def __init__(self, end_force, ramp_up_time=0.0): | ||
""" | ||
Parameters | ||
---------- | ||
start_force: numpy.ndarray | ||
2D (dim, 1) array containing data with 'float' type. | ||
Force applied to first node of the rod-like object. | ||
end_force: numpy.ndarray | ||
2D (dim, 1) array containing data with 'float' type. | ||
Force applied to last node of the rod-like object. | ||
ramp_up_time: float | ||
Applied forces are ramped up until ramp up time. | ||
""" | ||
self.end_force = end_force | ||
assert ramp_up_time >= 0.0 | ||
self.ramp_up_time = ramp_up_time | ||
|
||
def apply_forces(self, system, time=0.0): | ||
factor = min(1.0, time / self.ramp_up_time) | ||
self.external_forces[..., -1] += self.end_force * factor | ||
|
||
def apply_torques(self, system, time: np.float64 = 0.0): | ||
factor = min(1.0, time / self.ramp_up_time) | ||
arm_length = system.lengths[...,-1] | ||
director = system.director_collection[..., -1] | ||
self.external_torques[..., -1] += np.cross( | ||
[0.0, 0.0, 0.5 * arm_length], director @ self.end_force | ||
) | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Code Design: Mixin and Composition | ||
|
||
Elastica package follows Mixin and composition design patterns that may be unfamiliar to users. Here is a collection of references that introduce the package design. | ||
|
||
## References | ||
|
||
- [stackoverflow discussion on Mixin](https://stackoverflow.com/questions/533631/what-is-a-mixin-and-why-are-they-useful) | ||
- [example of Mixin: python collections](https://docs.python.org/dev/library/collections.abc.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Callback Functions | ||
=================== | ||
|
||
.. _constraints: | ||
|
||
.. automodule:: elastica.callback_functions | ||
|
||
Description | ||
----------- | ||
|
||
The frequency at which you have your callback function save data will depend on what information you need from the simulation. Excessive call backs can cause performance penalties, however, it is rarely necessary to make call backs at a frequency that this becomes a problem. We have found that making a call back roughly every 100 iterations has a negligible performance penalty. | ||
|
||
Currently, all data saved from call back functions is saved in memory. If you have many rods or are running for a long time, you may want to consider editing the call back function to write the saved data to disk so you do not run out of memory during the simulation. | ||
|
||
.. autosummary:: | ||
:nosignatures: | ||
|
||
CallBackBaseClass | ||
ExportCallBack | ||
MyCallBack | ||
|
||
Built-in Constraints | ||
-------------------- | ||
|
||
.. autoclass:: CallBackBaseClass | ||
:special-members: __init__ | ||
|
||
.. autoclass:: ExportCallBack | ||
:special-members: __init__ | ||
|
||
.. autoclass:: MyCallBack | ||
:special-members: __init__ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
Connections / Contact / Joints | ||
============================== | ||
|
||
.. _connections: | ||
|
||
.. automodule:: elastica.joint | ||
|
||
Description | ||
----------- | ||
|
||
.. rubric:: Available Connection/Contact/Joints | ||
|
||
.. autosummary:: | ||
:nosignatures: | ||
|
||
FreeJoint | ||
ExternalContact | ||
FixedJoint | ||
HingeJoint | ||
SelfContact | ||
|
||
Compatibility | ||
~~~~~~~~~~~~~ | ||
|
||
=============================== ==== =========== | ||
Connection / Contact / Joints Rod Rigid Body | ||
=============================== ==== =========== | ||
FreeJoint ✅ ✅ | ||
ExternalContact ✅ ❌ | ||
FixedJoint ✅ ✅ | ||
HingeJoint ✅ ❌ | ||
SelfContact ✅ ❌ | ||
=============================== ==== =========== | ||
|
||
Built-in Connection / Contact / Joint | ||
------------------------------------- | ||
|
||
.. autoclass:: FreeJoint | ||
:special-members: __init__ | ||
|
||
.. autoclass:: ExternalContact | ||
:special-members: __init__ | ||
|
||
.. autoclass:: FixedJoint | ||
:special-members: __init__ | ||
|
||
.. autoclass:: HingeJoint | ||
:special-members: __init__ | ||
|
||
.. autoclass:: SelfContact | ||
:special-members: __init__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
Constraints | ||
=========== | ||
|
||
.. _constraints: | ||
|
||
.. automodule:: elastica.boundary_conditions | ||
|
||
Description | ||
----------- | ||
|
||
Constraints are equivalent to displacement boundary condition. | ||
|
||
.. rubric:: Available Constraint | ||
|
||
.. autosummary:: | ||
:nosignatures: | ||
|
||
ConstraintBase | ||
FreeBC | ||
OneEndFixedBC | ||
FixedConstraint | ||
HelicalBucklingBC | ||
FreeRod | ||
OneEndFixedRod | ||
|
||
Compatibility | ||
~~~~~~~~~~~~~ | ||
|
||
=============================== ==== =========== | ||
Constraint / Boundary Condition Rod Rigid Body | ||
=============================== ==== =========== | ||
FreeBC ✅ ✅ | ||
OneEndFixedBC ✅ ✅ | ||
FixedConstraint ✅ ✅ | ||
HelicalBucklingBC ✅ ❌ | ||
=============================== ==== =========== | ||
|
||
Examples | ||
-------- | ||
|
||
.. note:: | ||
PyElastica package provides basic built-in constraints, and we expect use to adapt their own boundary condition from our examples. | ||
|
||
Customizing boundary condition examples: | ||
|
||
- `Flexible Swinging Pendulum <https://github.com/GazzolaLab/PyElastica/tree/master/examples/FlexibleSwingingPendulumCase>`_ | ||
- `Plectonemes <https://github.com/GazzolaLab/PyElastica/tree/master/examples/RodContactCase/RodSelfContact/PlectonemesCase>`_ | ||
- `Solenoids <https://github.com/GazzolaLab/PyElastica/tree/master/examples/RodContactCase/RodSelfContact/SolenoidsCase>`_ | ||
|
||
|
||
Built-in Constraints | ||
-------------------- | ||
|
||
.. autoclass:: ConstraintBase | ||
:inherited-members: | ||
:undoc-members: | ||
:exclude-members: | ||
:show-inheritance: | ||
|
||
.. autoclass:: FreeBC | ||
|
||
.. autoclass:: OneEndFixedBC | ||
:special-members: __init__ | ||
|
||
.. autoclass:: FixedConstraint | ||
:special-members: __init__ | ||
|
||
.. autoclass:: HelicalBucklingBC | ||
:special-members: __init__ | ||
|
||
.. autoclass:: FreeRod | ||
|
||
.. autoclass:: OneEndFixedRod |
Oops, something went wrong.