Giter VIP home page Giter VIP logo

gazzolalab / pyelastica Goto Github PK

View Code? Open in Web Editor NEW
203.0 203.0 107.0 25.45 MB

Python implementation of Elastica, an open-source software for the simulation of assemblies of slender, one-dimensional structures using Cosserat Rod theory.

Home Page: https://www.cosseratrods.org

License: MIT License

Makefile 0.28% Python 99.72%
cosserat-rod-theory cosserat-rods elastica mechanics python simulation

pyelastica's People

Contributors

armantekinalp avatar asadnizami avatar bhosale2 avatar chshih2 avatar dependabot[bot] avatar erfanhamdi avatar gitter-badger avatar ilianasiriziba avatar jbwasse2 avatar mstoelzle avatar nmnaughton avatar parthas1 avatar rahul-joon avatar skim0119 avatar sy-cui avatar tp5uiuc avatar zhidou2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyelastica's Issues

Static Analysis of the Rod

Hello PyElastica,

In my project, I do a static analysis of 3 rods in parallel. So far, two examples that I have seen are that of timoshenko and the snake, but both are dynamic models.

To do this, I thought of setting the force ramp time close to zero compared to the final time and "nu" large enough to "dissipate" the energy and converge as fast as possible. Despite reaching the desired final configuration, the simulation is still dynamic and I would like to only get the configuration for a given force, for example. Is there a way to make a static model?

I hope I have been clear enough and thank you in advance for all the technical support.

Code in getting started guide doesn't work

Hi all,

Thanks for writing the package! I'm just getting started and trying to test a few things out but the code from the getting started guide doesn't run. The code in the guide has a few syntactical errors (missing equals signs) but more importantly it seems that the API has changed a bit and isn't reflected in the docs.
Screen Shot 2021-10-14 at 3 22 20 PM
.

#GSoC Project 5: Debugger/logger of simulation instabilities

Hi PyElastica Team,

I am interested in GSoC 2022 and specifically Project 5: Debugger/logger of simulation instabilities.

I want to clarify a few things:

  • is the task to create a logger which binds to the simulation?
  • should the crash/unstable log be a textfile or based on HTML UI

Thank you! I am looking forward to what I can contribute.

Instability when Simulating Suture Thread

Hello,

I am using PyElastica to simulate surgical suture thread. To test if my simulation works, I am applying a small velocity to a single node at the middle of the simulated thread until the node reaches a goal point, which is a small distance away from the node’s rest position. Both ends of the simulated suture are held in place. However, often when I run the simulation, the PyElastica rod’s velocities and internal forces become incredibly large very quickly and generate NaN values that destroy the simulation. The suture thread I’m simulating is mostly made of collagen and has the following properties:

Length: 10 cm
Radius: 0.2 mm
Density: 3e-3 g/cm^3
Young’s Modulus: 750 MPa
Poisson Ratio: 2

I ran multiple simulations using different units (g and mm, g and dm, g and cm) and timesteps (1e-4 * dl, 1e-6 * dl, 1e-8 *dl), and most became unstable within the first few iterations. However, in the following simulation, the rod seems to be stable. Unfortunately, this simulation requires an incredibly small timestep (1e-8 * dl), resulting in the simulation taking several dozen hours to complete 2 seconds of simulation time.

import numpy as np

from elastica.wrappers import BaseSystemCollection, Connections, Constraints, Forcing, CallBacks
from elastica.rod.cosserat_rod import CosseratRod
from elastica.boundary_conditions import FreeRod
from elastica.timestepper.symplectic_steppers import PositionVerlet
from elastica.timestepper import integrate

# Make simulator
class SutureSimulator(BaseSystemCollection, Connections, Constraints, Forcing, CallBacks):
    pass

# Make constraint to apply velocity to rod midpoint while both ends are held in place
class SutureTest(FreeRod):
    def __init__(self):
        pass
    
    def constrain_values(self, system, time: np.float = 0.0):
        # Anchor both rod ends
        system.position_collection[..., 0] = np.zeros(3)
        system.position_collection[..., -1] = [10.0, 0.0, 0.0] # This position is in cm units
        return
    
    def constrain_rates(self, system, time: np.float = 0.0):
        # Calculate displacement from goal position (offset from midpoint by 8 mm in y direction)
        displacement = (
            np.array([5.0, 0.0, 0.8]) # Goal point, in cm units
            - system.position_collection[..., n_elem//2] # Rod midpoint
        )
        # Move at low speed in direction of displacement
        # Stop movement if control node is close enought to goal position
        if (np.linalg.norm(displacement) > 1e-6):
            system.velocity_collection[..., n_elem//2] = displacement / 2 # arbitrarily scale displacement to reduce speed
        else:
            system.velocity_collection[..., n_elem//2] *= 0
        
        # Anchor both rod ends
        system.velocity_collection[..., 0] *= 0
        system.velocity_collection[..., -1] *= 0

suture_sim = SutureSimulator()

#initialize all relevant rod and time variables
n_elem = 50
start = np.array([0.0, 0.0, 0.0])
direction = np.array([1.0, 0.0, 0.0])
normal = np.array([0.0, 1.0, 0.0])
# Below values are in units of centimeters (cm) and grams (g)
base_length = 10  # cm
base_radius = 0.02 # cm
density = 3e-3 # g/cm^3
nu = 0.1 # g/s
E = 7.5e9 # g/(cm * s^2)
poisson_ratio = 2

final_time = 2.0
dl = base_length / n_elem
dt = 1e-8 * dl
total_steps = int(final_time / dt)

timestepper = PositionVerlet()

suture_thread = CosseratRod.straight_rod(
    n_elem,
    start,
    direction,
    normal,
    base_length,
    base_radius,
    density,
    nu,
    E,
    poisson_ratio
)
suture_sim.append(suture_thread)

suture_sim.constrain(suture_thread).using(
    SutureTest
)

suture_sim.finalize()
integrate(timestepper, suture_sim, final_time, total_steps)

What is the best way to make the simulation more stable while keeping its timestep at a reasonable size? Ideally, I want the simulation to complete in at most a few minutes. Thank you for your help!

Sincerely,
Neelay Joglekar

paralleled rod connection setting

Dear PyElastica,

thank you in advance.
While using powerful PyElastica to model a soft robot, which is consisted of 3 parallel rods connected from each other. Luckily, I found a similar one from your paper: Topology, Geometry, and Mechanics of Strongly Stretched and Twisted Filaments: Solenoids, Plectonemes, and Artificial Muscle Fibers, but i can not find any reference code.
So could you share the modeling code like boundary condition or how the bilateral rods connected to the centeral one.
Thank you for your time and help.

BR
Daphne

Google Summer of Code 2022 - Project 4: Saving and restart framework for simulations

Hi PyElastica Team,
I am interested in applying for the GSoC 2022. The topic that interests me the most is Project 4: Saving and restart framework for simulations.
I have seen how the jupyter notebook checkpoints work and have been interested in working towards a project such as this. I have a particularly strong will to learn and been a fast learner because of it.

I look forward to work for this project and finish it.

Thank you! I am looking forward to what I can contribute!!

Experimental features

Some features are implemented but disabled due to a lack of testing and validation. For example, AnisotropicFrictionalPlaneRigidBody is disabled. We should consider enabling the functionality under the module elastica.experimental or elastica.contrib. In this way, people can tell why the implementation is in the file but not available.

Pyelastica API changes

Issue by armantekinalp
Monday Apr 13, 2020 at 16:07 GMT
Originally opened as https://github.com/GazzolaLab/elastica-python/issues/73


These comments are from @tp5uiuc regarding the API of Elastica. I think they are good comments and we should try to accomplish these changes. @tp5uiuc and @nmnaughton please go over the below list and add your comments. Then after we finalize our discussion, I will start making changes.

  • #168
  • Changing OneEndFixedRod to OneEndFixedBC . (#55)
  • Changing callback functions to observer functions
  • Changing CallBackBaseClass to AbstractObserver or ObserverBaser.
    • @skim449: I'm scratching this out, because I think Base class is a somewhat common trend in many Python packages I'm seeing. There is really no community standard for this other than OOP languages. The word abstract could be too restrictive.
  • Reducing import statements, we can do
    -- from elastica.timesteppers import integrate, PositionVerlet
    -- from elastica.wrappers import Connections, Constraints
    -- from elastica import *

Other Refactor Request

-- Dissipation constant name to include mass

  • ExponentialDamping -> AnalyticalLinearDamping #163

Current-step passed to callback is determined by floating point division.

Issue by skim0119
Friday Dec 31, 2021 at 21:31 GMT
Originally opened as https://github.com/GazzolaLab/elastica-python/issues/116


SystemCollection.apply_callbacks(time, int(time / dt))

During the operation int(time/dt), we loose up to 1 step error. If user write the callback such that the data is recorded every 100 steps, some of the data will be recorded either 99 steps.

Applying non-constant torques and forces

Hello,
Is there a way to apply non-constant forces / torques to a rod? For example, I am trying to apply torque to a rod for a certain duration of time, rather than to have the torque act on the rod for the whole duration of the simulation.

Create a pre-curved rod

Hello PyElastica,

I am a student and I am trying to apply the library 'PyElastica' in my project for a rod with a pre-curvature. But I could only create a straight rod. Could you please advise me if there is a way to make a pre-curved rod?

Thank you in advance for your help and congratulations for this beautiful work !

Émerson

Release 0.2.3 Checklist

Release Checklist

  • Update RELEASE.md - It should be in based on milestone description.
  • Commit the changes:
git add RELEASE.md
git commit -m "Changelog for upcoming release <version>"
  • Final check README and CONTRIBUTING.
  • Bump LICENSE year
  • Bump version

Test

  • Run the tests
  • Run the formatting
  • CI Check
python -m pytest
make all

Setup.py

  • Update version number in setup.py (or version.py) (can also be minor or major)
  • Check if we need to upgrade REQUIRES_PYTHON or REQUIRED dependencies.
  • Check if local installation can be done.
  • Update download_url in setup
conda create --name temp
conda activate temp
conda install python==<version>
which pip
pip install .

Documentation and Website

  • Check all documentations are updated
  • Update version label on documentation
    • docs/conf.py
    • Python version
  • Update version label on website
    • Python version
- BEYOND THIS, EACH STEP SHOULD BE DONE IN SERIAL (STEP_BY_STEPS). -

Last Edit

  • Rebase the commit history (should be done by only one person) right before the PR. (Not required)

Update

  1. Merge the branch to master
  2. Release on PyPI by uploading python setup.py upload (make sure twine is installed)
  3. Release on github (v) "include v in front"

Final Check

  • Test that it pip installs
  • Check the PyPI listing page to make sure that the README, release notes, and roadmap display properly.
  • Edit the release-page on GitHub. Paste the release notes with a title for the release.
  • Check Codcov ID and make sure they are running.
  • Make mirror branch in private repo.

Inconsistent Numpy dependency version for Numba

Problem description
Currently, the requirements.txt in PyElastica states the required version of numpy as >=1.19.2 and numba as ==0.51.0. However this seems to be inconsistent with numba release notes, which state that even the latest version of numba i.e. 0.55.0 doesnt support numpy latest release 1.22.1 and only has support till numpy version 1.21. While numba installs its own compatible numpy during installation, an update to numpy by the user can lead to dependency issues with numba.

Suggested solution
An upper limit on installation version of numpy i.e. >=1.19.2,<1.22 in requirements.txt and other related locations (setup.py). An additional suggestion is to update the numba dependency to 0.55.0, since all tests pass in PyElastica, with the latest numba version installed (on my Mac).

@armantekinalp please confirm the above, after which I can take this issue.

Point Force Class

Hello,
Is there a way to apply a force to the Rod (for example in the middle)? how can i implement it?

Any help would be of great assistance.
Thank you

Unit tests for contact module

Is your feature request related to a problem? Please describe.
Although we have tested contact module through different simulations, there is no unit tests for contact module. This can cause vulnerability in development process as well as reduces code coverage.

Describe the solution you'd like
Implement unit tests for contact module.

Issues defining compute_and_plot_velocity(plot_params: dict, period) function

I've been trying to write a plotting function for different rod systems just to get a feel for this software. I have based my code on the compute_and_plot_velocity function defined in the Slithering Snake tutorial. I have also imported all the wrappers mentioned.

However I run into the same error every time: "from analysis_functions import compute_projected_velocity
ModuleNotFoundError: No module named 'analysis_functions'". I tried looking for analysis_functions through documentation but to no avail. What am I missing?

The definition of the function here attached:

    def compute_and_plot_velocity(plot_params: dict, period):
        from matplotlib import pyplot as plt
        from analysis_functions import compute_projected_velocity

        time_per_period = np.array(plot_params["time"]) / period
        avg_velocity = np.array(plot_params["avg_velocity"])

        [velocity_in_direction_of_rod,
         velocity_in_rod_roll_dir,
         avg_forward,
         avg_lateral] = compute_projected_velocity(plot_params, period)

        print("average forward velocity:", avg_forward)
        print("average forward lateral:", avg_lateral)

        fig = plt.figure(figsize=(5, 4), frameon=True, dpi=150)
        ax = fig.add_subplot(111)
        ax.grid(b=True, which="major", color="grey", linestyle="-", linewidth=0.25)
        ax.plot(time_per_period[:], velocity_in_direction_of_rod[:, 2], "r-", label="forward")
        ax.plot(time_per_period[:], velocity_in_rod_roll_dir[:, 0], "b-", label="lateral", )
        ax.plot(time_per_period[:], avg_velocity[:, 1], "g-", label="normal")
        ax.legend(prop={"size": 12})
        ax.set_ylabel('Velocity (m/s)', fontsize=12)
        ax.set_xlabel('Time (s)', fontsize=12)
        plt.show()


Any help would be of great assistance.
Thank you

Path Error

The examples/Visualization/ContinuumSnakeVisualisation/continuum_snake_render.py file cannot run correctly. The error is: ModuleNotFoundError: No module named 'examples'.
I think it may be be path error.

Issue with varying radius of filament

Hi all,

I'm trying to simulate a system where the radius should decrease linearly from the base to the tip of the rod. I can add forces and set the environment without any issues but when I run the integrator I can see that all of the radii are NaNs. There is no failure indicated during integration but on post processing the problem is apparent (screenshot + video below).
var_rad_code

testing_traveling_var_rad_tanh.mp4

I'm pretty sure it's not an issue with my implementation of forces/torques on the system as I am able to run the code with no problem in the uniform radius case (screenshot and video below).

const_rad_code

testing_traveling_const_rad_tanh.mp4

The allocation of rod properties seems to allow for a varying radius and nothing else jumped out to me as the issue. Do you all have any idea what could be going on here?

Visualization

Hi,

What is the class or commands for the octopus visualization? does Elastica (PyElastica) have an environment for the visualization part? I could not find anything in your examples providing the same outputs as in the case studies.

Thanks,

Errors with the notebooks

Hello,

I was running the code in the notebook for the Timoshenko beam (https://hub.gke2.mybinder.org/user/gazzolalab-pyelastica-0ttn23rh/notebooks/examples/Binder/1_Timoshenko_Beam.ipynb). I got an error in the last notebook cell, and it said the following "AttributeError: 'PositionVerlet' object has no attribute 'do_step'". How do I fix this error?

In the slithering snake tutorial, I got an error saying "TypeError: init() missing 1 required positional argument: 'rest_lengths'". I found there is a mistake in the code in the cell under the heading "Muscle Torques", there should be an additional argument to the function snake_sim.add_forcing_to(shearable_rod).using(). It is missing the argument 'rest_lengths=shearable_rod.rest_lengths'. Adding this argument fixed it. I would recommend updating the code.

Kind regards,
Rohit K. John

how to load a custom model and apply this rod algorithm

Very impressive Jobs! I am attempt to use this library in vascular intervention simulation platform. I want to load vascular model and apply this rod as catheter. But I don't know how to load my model(a STL file) and make the rod have collision and friction. Could you give me some demo ? Thanks!

Pre-commit

Is your feature request related to a problem? Please describe.
We should consider adding pre-commit configuration script, including black, flake8, and mypy. It also provide some out-of-the-box features that are useful. I think they are easy to use/install, and will reduce the number of formatting commits.

pre-commit

Recommonmark is deprecated: We should switch to MyST

Context

We are currently using sphinx and ReadtheDocs to keep our documentation clean and organized. Natively, sphinx uses reStructuredText (or .rst extension), and the module recommonmark has been used to parse markdown format. I ​recently found that the module recommonmark is no longer maintained, and the developer (and community) shifted to MyST parser.

Suggestion

I don't think the issue is imminent and we can probably handle the problem in the back, but I can definitely see the community and the supports for the markdown + sphinx are shifting to MyST. It appears to me that MyST is now officially supported markdown extension for sphinx, and we should change our environment as well.

Change

It looks like MyST is fairly easy to use just like recommonmark. Most of the change will be done on conf.py, and everything should be compatible.

Notes

Deprecation note from recommonmark

Simulating Soft Arm in Pyelastica

Hello all,

I have a task in my project to simulate a soft robotics arm that is actuated by 12 cables connected to 3 discs with four cables connected to each disc. The three discs are distributed over the arm with one close to the base, one in the middle and the last close to the end of the arm. I would like to ask if it's possible to use pyelastica to simulate the arm as while I was going through the website, I could not find a way to attach any cables to the arm, If so, can you please give me some advice how to simulate it.

New release (v0.2.0) breaks on import

I updated to the new v0.2.0 and am unable to import elastica. v0.1.0.post5 and before work fine. I have verified this occurs on both mac and linux. It also occurs if I directly use the main branch. Shouldn't CI have caught this?

mechse-mgazzola-grp:docs naughton$ python3
Python 3.8.5 (default, Jul 21 2020, 10:48:26) 
[Clang 11.0.3 (clang-1103.0.32.62)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import elastica
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/elastica/__init__.py", line 5, in <module>
    from elastica.wrappers import *
  File "/usr/local/lib/python3.8/site-packages/elastica/wrappers/__init__.py", line 8, in <module>
    from .base_system import BaseSystemCollection
  File "/usr/local/lib/python3.8/site-packages/elastica/wrappers/base_system.py", line 13, in <module>
    from elastica.wrappers.memory_block import construct_memory_block_structures
  File "/usr/local/lib/python3.8/site-packages/elastica/wrappers/memory_block.py", line 8, in <module>
    from elastica.memory_block import MemoryBlockCosseratRod, MemoryBlockRigidBody
  File "/usr/local/lib/python3.8/site-packages/elastica/memory_block/__init__.py", line 8, in <module>
    from elastica.reset_functions_for_block_structure._reset_ghost_vector_or_scalar import (
ModuleNotFoundError: No module named 'elastica.reset_functions_for_block_structure'
>>> 

Faster than real-time simulation?

Hi @nmnaughton , does the PyElastica simulator provides faster than real time simulation. If yes/no, then to what extent the speed can be optimised right now for the current version of the software?

P.S. Found the answer

GSoC 2022 - Project 4: Saving and restart framework for simulations

Hi PyElastica Team,
I am interested in applying for the GSoC 2022. The topic that interests me the most is Project 4: Saving and restart framework for simulations.
I have seen how the jupyter notebook checkpoints work and have been interested in working towards a project such as this. I have a particularly strong will to learn and been a fast learner because of it.

I look forward to work for this project and finish it.

Thank you! I am looking forward to what I can contribute!!

Applying a constant torque in one direction

Hello!
Is there any way to apply torque( at the end of the rod) in the same direction as rod is fixed. For example I have a rod in y direction and I would like to apply a torque in this direction. I have created a calss called "OnedirectionTorque"

class OnedirectionTorque(NoForces):
def init(self,torque_end,direction):
super(EndPointTorques, self).init()
self.torque_end= (torque_end * direction).reshape(3, 1) # defined in global frame, shape(3,1)
def apply_torques(self, system, time: np.float = 0.0):
system.external_torques[..., -1] += system.director_collection[..., -1]@self.torque_end

I also have add it this piece of lines in examples/TimoshenkoBeamCase/timoshenko.py
direction = np.array([0.0, 1.0, 0.0])
toque_end = -10
timoshenko_sim.add_forcing_to(shearable_rod).using(
UniformTorques,toque_end,direction)

Is it implemented correctly

Thanks in advance

[Fixed] Install failure on Windows

Describe the bug
When install the package on Windows, the installation failed by providing the info:

 ERROR: Command errored out with exit status 1:
     command: 'c:\users\xarthur\source\tmprepo\pyelastica\scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\xarthur\\AppData\\Local\\Temp\\pip-install-c20v04d_\\llvmlite_f3ca8c63d35f47e895df5b42bc8946cb\\setup.py'"'"'; __file__='"'"'C:\\Users\\xarthur\\AppData\\Local\\Temp\\pip-install-c20v04d_\\llvmlite_f3ca8c63d35f47e895df5b42bc8946cb\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\xarthur\AppData\Local\Temp\pip-record-jwqs25f2\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\xarthur\source\tmprepo\pyelastica\include\site\python3.9\llvmlite'
         cwd: C:\Users\xarthur\AppData\Local\Temp\pip-install-c20v04d_\llvmlite_f3ca8c63d35f47e895df5b42bc8946cb\
    Complete output (28 lines):
    running install
    running build
    got version from file C:\Users\xarthur\AppData\Local\Temp\pip-install-c20v04d_\llvmlite_f3ca8c63d35f47e895df5b42bc8946cb\llvmlite/_version.py {'version': '0.34.0', 'full': 'c5889c9e98c6b19d5d85ebdd982d64a03931f8e2'}
    running build_ext
    c:\users\xarthur\source\tmprepo\pyelastica\scripts\python.exe C:\Users\xarthur\AppData\Local\Temp\pip-install-c20v04d_\llvmlite_f3ca8c63d35f47e895df5b42bc8946cb\ffi\build.py
    CMake Error at CMakeLists.txt:3 (project):
      Generator

        Visual Studio 15 2017 Win64

      could not find any instance of Visual Studio.



    -- Configuring incomplete, errors occurred!
    See also "C:/Users/xarthur/AppData/Local/Temp/tmpvduc6zx7/CMakeFiles/CMakeOutput.log".
    Trying generator 'Visual Studio 15 2017 Win64'
    Traceback (most recent call last):
      File "C:\Users\xarthur\AppData\Local\Temp\pip-install-c20v04d_\llvmlite_f3ca8c63d35f47e895df5b42bc8946cb\ffi\build.py", line 191, in <module>
        main()
      File "C:\Users\xarthur\AppData\Local\Temp\pip-install-c20v04d_\llvmlite_f3ca8c63d35f47e895df5b42bc8946cb\ffi\build.py", line 179, in main
        main_win32()
      File "C:\Users\xarthur\AppData\Local\Temp\pip-install-c20v04d_\llvmlite_f3ca8c63d35f47e895df5b42bc8946cb\ffi\build.py", line 88, in main_win32
        generator = find_win32_generator()
      File "C:\Users\xarthur\AppData\Local\Temp\pip-install-c20v04d_\llvmlite_f3ca8c63d35f47e895df5b42bc8946cb\ffi\build.py", line 84, in find_win32_generator
        raise RuntimeError("No compatible cmake generator installed on this machine")
    RuntimeError: No compatible cmake generator installed on this machine
    error: command 'c:\\users\\xarthur\\source\\tmprepo\\pyelastica\\scripts\\python.exe' failed with exit code 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\xarthur\source\tmprepo\pyelastica\scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\xarthur\\AppData\\Local\\Temp\\pip-install-c20v04d_\\llvmlite_f3ca8c63d35f47e895df5b42bc8946cb\\setup.py'"'"'; __file__='"'"'C:\\Users\\xarthur\\AppData\\Local\\Temp\\pip-install-c20v04d_\\llvmlite_f3ca8c63d35f47e895df5b42bc8946cb\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\xarthur\AppData\Local\Temp\pip-record-jwqs25f2\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\xarthur\source\tmprepo\pyelastica\include\site\python3.9\llvmlite' Check the logs for full command output.

To Reproduce

Environment

  • Python/pip: 3.9/21.3.1
  • OS, Device: Windows

Expected behavior
package successfully installed.

Additional context
It seems the installation requires a Visual Studio 15 2017 compiler.
Since VS 2022 has been released already, it would be helpful to add at least Visual Studio 2019 into the list...

Release 0.2.2 Checklist

Release Checklist

  • Update RELEASE.md - It should be in based on milestone description.
  • Commit the changes:
git add RELEASE.md
git commit -m "Changelog for upcoming release <version>"
  • Final check README and CONTRIBUTING.
  • Bump LICENSE year
  • Bump version

Test

  • Run the tests
  • Run the formatting
  • CI Check
python -m pytest
make all

Setup.py

  • Update version number in setup.py (or version.py) (can also be minor or major)
  • Check if we need to upgrade REQUIRES_PYTHON or REQUIRED dependencies.
  • Check if local installation can be done.
  • Update download_url in setup
conda create --name temp
conda activate temp
conda install python==<version>
which pip
pip install .

Documentation and Website

  • Check all documentations are updated
  • Update version label on documentation
    • docs/conf.py
    • Python version
  • Update version label on website
    • Python version
- BEYOND THIS, EACH STEP SHOULD BE DONE IN SERIAL (STEP_BY_STEPS). -

Last Edit

  • Rebase the commit history (should be done by only one person) right before the PR.

Update

  1. Merge the branch to master
  2. Release on github (v) "include v in front"
  3. Release on PyPI by uploading both sdist and wheel:
python setup.py sdist
twine upload dist/*
python setup.py bdist_wheel

Final Check

  • Test that it pip installs
  • Check the PyPI listing page to make sure that the README, release notes, and roadmap display properly.
  • Edit the release-page on GitHub. Paste the release notes with a title for the release.
  • Check Codcov ID and make sure they are running.
  • Make mirror branch in private repo.

[Dev Note] Boundary condition issues.

Boundary condition model

Follow from #54. We are going to patch some patches to the current boundary condition implementation.

  • Enable boundary condition to be available at any specified node.
  • Expose system in each wrapper
  • Refactor names #36

How to simulate the gravity of cable being applied forces?

Hi PyElasitica teams,

I want to simulate the process of cable operation. I set one end of the cable fixed, applied an upward force in the middle of the cable, and applied gravity to the whole cable.
image

The unfixed end of the real cable will sag naturally under the influence of gravity, as shown in above figure, but in my simulation results, the unfixed end is still lifting until the whole cable is straightened, as shown in below figure.
image

Here is my code:

Is there a cpp version of this library?

Hi, I'm developing a research project and found this library.
However, I'm doing mainly cpp and need a lib to be able to integrate it into the current system.

After checking the code, it seems the main lib is written in python?
Or do you have another version that is written in C/C++ elsewhere?

Thank you

Apply torques to elements for localized forces

Issue by tp5uiuc
Friday Dec 24, 2021 at 22:36 GMT
Originally opened as https://github.com/GazzolaLab/elastica-python/issues/101


Currently, when localized forces (say on one node) are added to pyelastica rods, we don't add torques (of torque arm x force) to the neighboring elements.
Factoring this torque in leads to slightly better error estimates, at least in the Timoshenko Beam example. The results are condensed here:
timoshenko 001

The code for reproducing these plots can be found in my fork here.

Reorganizing examples, tutorial, and webpage

We should rearrange where we place information that introduces pyelastica to newcomers. The problem is that we shouldn't assume people know the structure of pyelastica, especially because pyelastica is not so intuitive to native-python style. Here is the suggestion we came up with. Leave a comment if you have other ideas.

Suggestion

  • example codes should be placed in an external repository, and we can make it as a submodule. We want people to install pyelastica using pip, which means the example scripts will not be exposed to users. We should expose examples (with proper description) on the website, such that it serves as a template for beginners.
  • Remove binder (jupyter notebook) as a tutorial, instead clean up the tutorial on the website. Juptyer notebook can be linked at the bottom of the tutorial as run-cases. The idea is that tutorial should teach very basics of how to use pyelastica modules. Whether or not they can run the script is probably not important (and maybe cumbersome).

Dissipation constant should be scaled with mass instead of lengths

Describe the bug
In Elastica dissipation constant (nu) is defined as per unit length and its unit is kg/(m.s). However, this assumes that rods are uniform. However, in the case of tapered rods dissipation constant should also be scaled with the area. Otherwise for two elements that have same velocity but different mass we apply same dissipation force.

How to fix

  1. Define the dissipation constant as 1/s .
  2. In allocate function, scale the user defined nu with element mass and store it.
  3. Remove multiplication by lengths while computing the dissipation forces and torques.

Interface for Environment and Control

Issue by skim0119
Sunday Dec 12, 2021 at 19:05 GMT
Originally opened as https://github.com/GazzolaLab/elastica-python/issues/86


From @tp5uiuc

I'm porting only the Environment and Controller interfaces here, as the rest are already in-place. An additional reason is that its not quite clear what needs to go into the Environment (slender-body theory is one, friction is another...), and what the interface for a Controller is going to be.

This is a WIP, so feel free to propose any changes as you see fit. Things yet to do:

  • Environment mixin interface : add environment effects (fluids, friction etc, needs PR from some other branch, I'll only provide the interface)
  • tests forEnvironment
  • Controller mixin interface : interface for attaching arbitrary controllers (once again needs a different PR)
  • tests forController

It'll be nice to eventually have a time-varying environment, itself governed by an independent system (say, governed by a PDE). The example I have in mind is a chemical source placed at some position in the free-space—it releases chemical concentration based on some simple diffusion law. We can make our arms "sense" this concentration.

Converting nodal velocities to element velocities

In PyElastica we store velocity on nodes and for some computations (i.e. rod damping, plane damping or stokes flow) we have to convert velocity from nodes to elements. Currently we are averaging the neigboring node velocity to compute element velocity using the following function.

def node_to_element_pos_or_vel(vector_in_node_frame):
"""
This function computes the velocity of the elements.
Here we define a separate function because benchmark results
showed that using Numba, we get more than 3 times faster calculation.
Parameters
----------
vector_in_node_frame: numpy.ndarray
2D (dim, blocksize) array containing data with 'float' type.
Returns
-------
vector_in_element_frame: numpy.ndarray
2D (dim, blocksize) array containing data with 'float' type.
"""
"""
Developer Notes
-----
Benchmark results, for a blocksize of 100,
Python version: 3.5 µs ± 149 ns per loop
This version: 729 ns ± 14.3 ns per loop
"""
n_elem = vector_in_node_frame.shape[1] - 1
vector_in_element_frame = np.empty((3, n_elem))
for k in range(n_elem):
vector_in_element_frame[0, k] = 0.5 * (
vector_in_node_frame[0, k + 1] + vector_in_node_frame[0, k]
)
vector_in_element_frame[1, k] = 0.5 * (
vector_in_node_frame[1, k + 1] + vector_in_node_frame[1, k]
)
vector_in_element_frame[2, k] = 0.5 * (
vector_in_node_frame[2, k + 1] + vector_in_node_frame[2, k]
)
return vector_in_element_frame

Although this function is correct for uniform rods (uniform cross-section, element length and density) for tapered rods, momentum is not conserved since neighboring node masses are not the same. Thus, we have to first compute the total momentum of element and divide by the element mass to compute element velocity.

How to fix :

  1. Use the following function to compute element velocities
def node_to_element_velocity(mass, velocity_collection):
    """
    """
    n_elem = velocity_collection.shape[1] - 1
    element_velocity = np.empty((3, n_elem))
    for k in range(n_elem):
        element_velocity[0, k] = (
            mass[k+1] * velocity_collection[0, k + 1] + mass[k] * velocity_collection[0, k]
        )
        element_velocity[1, k] = (
            mass[k+1] * velocity_collection[1, k + 1] + mass[k] * velocity_collection[1, k]
        )
        element_velocity[2, k] =(
            mass[k+1] * velocity_collection[2, k + 1] + mass[k] * velocity_collection[2, k]
        )
        element_velocity[:,k] /= (mass[k+1] + mass[k])


    return element_velocity
  1. Rename the function node_to_element_pos_or_vel as node_to_element_position, since this will be only used to compute the element positions.

Visualization

Hello,

I just want to ask what software you used to visualize the results as done in your papers. Is it Blender?

Visualization bug of lacking Povray

Describe the bug
I want to run the example of snake visualization, the scripting process is running correctly.
However, when the rendering process begin, Some error occured.
File "G:\study\pyelastica\PyElastica-master\examples\Visualization\ContinuumSnakeVisualization_povmacros.py", line 138, in render
+ stderr.decode("ascii",'ignore')
OSError: POVRay rendering failed with the following error: 'povray'
By checking the codel, i found that the subprocess is calling povray here, but the povray does not installed in my PC.
I try to install the newest version of povray, but it still can have same error to run the code.
The question is: How I install povray correctly, is any special library i need to install?
please give me a instruction. thank you so much!!

To Reproduce

from line 127 to 139
<script>
    process = subprocess.Popen(
        cmds, stderr=subprocess.PIPE, stdin=subprocess.PIPE, stdout=subprocess.PIPE
    )
    _, stderr = process.communicate()

    # # Check execution error
    if process.returncode:
        print(type(stderr), stderr)
        raise IOError(
            "POVRay rendering failed with the following error: "
            + stderr.decode("ascii",'ignore')

        )
<error>

Environment

  • Python/pip version 3.6
  • Numpy/numba version 1.19
  • PyElastica version 0.1.0 post5
  • OS, Device, Window 10

Expected behavior
I hope to run the visualization correctly. And I would like to simulation the manipulation of deformable linear objects(cable)
by the pyelastca, would you please give me some advice?

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Timoshenko example throws an error on the current `master`

Running the Timoshenko example, from examples/TimoshenkoBeamCase/timoshenko.py throws the following error.

Traceback (most recent call last):
  File "/Users/tp5/code/PyElasticaPublic/examples/TimoshenkoBeamCase/timoshenko.py", line 41, in <module>
    shearable_rod = CosseratRod.straight_rod(
TypeError: straight_rod() missing 1 required positional argument: 'poisson_ratio'

Simulation save/restart module

Issue by skim0119
Wednesday Dec 29, 2021 at 05:00 GMT
Originally opened as https://github.com/GazzolaLab/elastica-python/issues/111


Partially provide a way to save and load rod. We need more robust simulator-wise callback to save the module. (restart.py)

Things to keep in mind

  • Some data is serializable, which we can use pickle or json, but some other modules must be handled separately.
  • We should account for customized forces/connection/etc. If they have state variables (such as ramp-up rate, etc), we need to save them as well.
  • The interaction between finalize() is somewhat contradicting restart/reloading data in the middle of a simulation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.