Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Documentation] Rework for v0.2.2 #65

Merged
merged 57 commits into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
9ab2c77
change header levels to be consecutive
skim0119 Feb 7, 2022
abe70f0
switch to myst parser
skim0119 Feb 7, 2022
0fe694b
add numpydoc
skim0119 Feb 7, 2022
2053d4b
rework docs/readme as documentation guideline
skim0119 Feb 7, 2022
5c0fdd5
doc format change for MyST
skim0119 Feb 7, 2022
c4a4aee
add expected date for e++
skim0119 Feb 7, 2022
253641c
rearrange directory
skim0119 Feb 7, 2022
2b41f19
distinguish attributes from methods
skim0119 Feb 7, 2022
81b99e8
Update doc/README.md
skim0119 Feb 7, 2022
78506ca
Update CONTRIBUTING.md
skim0119 Feb 7, 2022
0527d80
update README.md: typo
skim0119 Feb 7, 2022
e894fd0
Merge pull request #53 from skim0119/docs_myst
skim0119 Feb 7, 2022
4296115
Update requirements.txt
skim0119 Feb 8, 2022
f709d12
Merge branch 'wip_constraint' of https://github.com/GazzolaLab/PyElas…
skim0119 Feb 10, 2022
91ae939
add typing documentation extension
skim0119 Feb 11, 2022
c00133c
update e++ info; update index page
skim0119 Feb 11, 2022
92f2f55
refactor constraint documentation page
skim0119 Feb 11, 2022
1f680fe
wip constraints api
skim0119 Feb 12, 2022
3d217b6
Merge branch 'update-0.2.2' of https://github.com/GazzolaLab/PyElasti…
skim0119 Feb 12, 2022
694cc59
update coveragerc
skim0119 Feb 12, 2022
8504ec9
Updating docs with getting started guide from website
nmnaughton Feb 13, 2022
91267e2
Update welcome_page.rst
nmnaughton Feb 13, 2022
0b10955
Merge pull request #58 from nmnaughton/docs_port_getting_started_guide
skim0119 Feb 13, 2022
07fa69a
Merge branch 'update-0.2.2' into doc_update_skim449
skim0119 Feb 13, 2022
996ce45
Merge branch 'doc_patch' of https://github.com/GazzolaLab/PyElastica …
skim0119 Feb 16, 2022
004a4af
prepare logo
skim0119 Feb 16, 2022
4b4d80b
rename headers
skim0119 Feb 16, 2022
9e76789
add logo; add css for logo
skim0119 Feb 16, 2022
a531542
remove old docs
skim0119 Feb 16, 2022
a59b040
add rigid body
skim0119 Feb 16, 2022
4f1443c
update index and toc
skim0119 Feb 16, 2022
2a4ea09
add advanced note
skim0119 Feb 16, 2022
2a4b8b7
add localized force and torque discussion
skim0119 Feb 16, 2022
e57af9a
update requirements
skim0119 Feb 16, 2022
2874fac
Doc update skim449 (#63)
skim0119 Feb 28, 2022
4dd8712
update
skim0119 Mar 4, 2022
b3c6994
add code design discussion
skim0119 Mar 5, 2022
601ba16
update: user guide clean up, redirect example link to the correct dir…
skim0119 Mar 6, 2022
07e49dc
fix documentation build warnings
skim0119 Mar 6, 2022
311950a
update: rod documentation
skim0119 Mar 6, 2022
d013437
doc: organize rigid body
skim0119 Mar 6, 2022
7b41831
update: external force and interaction doc page
skim0119 Mar 6, 2022
e290595
update: joint/connection doc page
skim0119 Mar 6, 2022
6f7d6f3
update: callback doc page
skim0119 Mar 6, 2022
809ade3
update: utility doc page
skim0119 Mar 6, 2022
f5e5df7
fix: notes in workflow page
skim0119 Mar 6, 2022
5b3a89b
remove np.typing: too bleeding np feature
skim0119 Mar 6, 2022
59b83f2
archive Hackathon readme
skim0119 Mar 6, 2022
5b5f21a
fix image url for raw format
skim0119 Mar 6, 2022
185515c
update doc: Helical buckling BC doc updated.
armantekinalp Mar 7, 2022
2f4fc31
update doc: SelfContact documentation updated.
armantekinalp Mar 7, 2022
8db4b7e
update doc: calculus functions docs are updated.
armantekinalp Mar 7, 2022
c379356
add autolabel for documentation
skim0119 Mar 7, 2022
14cee1f
fix link in example_cases page
skim0119 Mar 7, 2022
ea9c239
Merge branch 'doc_patch' of https://github.com/GazzolaLab/PyElastica …
skim0119 Mar 7, 2022
a697a2f
update doc: change blocksize to n_nodes, n_elems, and n_voronoi
skim0119 Mar 7, 2022
e7df9a8
add rod parameter table
skim0119 Mar 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ omit =
elastica/systems/analytical.py
# omit deprecation warning message
elastica/_elastica_numpy.py
# omit experimental
# omit experimental modules
elastica/experimental/*
setup.py
8 changes: 6 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Once you find the issue that you are interested in, please leave a comment that
If you leave some questions in the comment, we will provide more detailed descriptions.

You are also welcomed to help us pushing this project further.
Please don't hesitate improving documentation or code-coverage.
Please don't hesitate improving [documentation](https://github.com/GazzolaLab/PyElastica/tree/master/docs) or code-coverage.

### Side projects

Expand Down Expand Up @@ -155,7 +155,11 @@ In order to format the code:

### Documentation styleguide

We follow [NumPy documentation guidelines](https://numpydoc.readthedocs.io/en/latest/format.html) for PyElastica documentation.
We follow [NumPy documentation guidelines][numpydoc-guideline] for PyElastica documentation.
If you are interested in contributing or modifying the documentation, please refer to the [docs-readme][docs-readme] file.

[beginner]: https://github.com/GazzolaLab/PyElastica/labels/good%20first%20issue
[help-wanted]: https://github.com/GazzolaLab/PyElastica/labels/help%20wanted

[numpydoc-guideline]: https://numpydoc.readthedocs.io/en/latest/format.html
[docs-readme]: https://github.com/GazzolaLab/PyElastica/blob/master/docs/README.md
61 changes: 61 additions & 0 deletions docs/README.md
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.
29 changes: 0 additions & 29 deletions docs/README.rst

This file was deleted.

8 changes: 8 additions & 0 deletions docs/_static/css/logo.css
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;
}
58 changes: 58 additions & 0 deletions docs/advanced/LocalizedForceTorque.md
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
)

```
8 changes: 8 additions & 0 deletions docs/advanced/PackageDesign.md
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)
33 changes: 33 additions & 0 deletions docs/api/callback.rst
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__

51 changes: 51 additions & 0 deletions docs/api/connections.rst
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__
67 changes: 67 additions & 0 deletions docs/api/constraints.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
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.


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
Loading