SkillAgentSearch skills...

Sibernetic

This is a C++/OpenCL implementation of the PCISPH algorithm supplemented with a set of biomechanics related features applied to C. elegans locomotion

Install / Use

/learn @openworm/Sibernetic
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Sibernetic

Sibernetic is physical simulator of biomechanical matter (membranes, elastic matter, contractile matter) and environments (liquids, solids and elastic matter with variable physical properties) developed for simulations of C. elegans physical body dynamics within the OpenWorm project by Andrey Palyanov, Sergey Khayrulin and Mike Vella (development of a Python module for external muscle activating signals generation and input) as part of the OpenWorm team. At its core, Sibernetic is built as an extension to Predictive-Corrective Incompressible Smoothed Particle Hydrodynamics (PCISPH). It is primarily written in C++ and OpenCL, which makes possible to run simulations on CPUs or GPUs, and has 3D visualization support built on top of OpenGL.

There is a separate effort lead by Giovanni Idili and Sergey Khayrulin to port this code to Java, as part of the Geppetto simulation framework.

Compiling / running (Linux/mac)

Join the chat at https://gitter.im/openworm/sibernetic

Linux Install OpenCL on Ubuntu. We suggest you initially go with AMD OpenCL drivers as we have found these to be the most stable and complete. You can also try Intel's drivers. This step often causes problems, contact the openworm-discuss mailing list if you encounter issues. The AMD drivers include samples in /opt/AMDAPP/samples/opencl/bin which you can use to verify your OpenCL support is working.

You'll also need a variety of libraries. In ubuntu, install the dependencies with:

sudo apt-get install g++ python-dev freeglut3-dev nvidia-opencl-dev libglu1-mesa-dev libglew-dev python-numpy

Next, from the sibernetic/ directory run:

make clean
make all

Also you may need to set some enviromat variables like path to OpenCL lib or header for to do this you can fix your LD_LIBRARY_PATH as this:

export LD_LIBRARY_PATH=/path/to/opencl_lib/folder/:$LD_LIBRARY_PATH
e.g.
export LD_LIBRARY_PATH=/usr/local/cuda/lib64/:$LD_LIBRARY_PATH

You can find OpenCL lib in CUDA folder if you're using NVIDIA (/usr/local/cuda/lib64/) or run this command.

ldconfig -p | grep opencl

Also you may need to give compiler path to OpenCL header files usually you can find them in /usr/include/CL if they there than you don't need do anything. In othe case you can edit makefile directly and add directory to OpenCL headers by adding options -I/path/to/opencl_includes/ or you can copy folder with header into /usr/include/ but you should have root permission for doing that.

Mac: stay in the top-level folder. You need before run export several environment variables:

export PYTHONHEADERDIR=/usr/local/Cellar/python/<version_of_installed_pythonFramework>/Python.framework/Headers/
export PYTHONLIBDIR=/usr/local/lib/python2...
export PYTHONFRAMEWORKDIR=/usr/local/Frameworks/

Then

make clean -f makefile.OSX
make all -f makefile.OSX

You should see an output which looks something like this:

Building file: ../src/PyramidalSimulation.cpp
Invoking: GCC C++ Compiler

....
more stuff...
....

Building target: Sibernetic
Invoking: GCC C++ Linker
g++ -L/usr/lib -L/usr/lib/python2.7 -o "Sibernetic"  ./src/PyramidalSimulation.o ./src/main.o ./src/owHelper.o ./src/owOpenCLSolver.o ./src/owPhysicsFluidSimulator.o ./src/owWorldSimulation.o   -lOpenCL -lpython2.7 -lrt -lglut -lGL -lGLU
Finished building target:Sibernetic

Then navigate to the top-level folder in the hierarchy (e.g Sibernetic) and set your PYTHONPATH:

export PYTHONPATH=$PYTHONPATH:.

Finally, to run, run the command:

Linux:

./Release/Sibernetic

Mac:

./Release/Sibernetic

You may need to make ./Release/Sibernetic executable like so:

chmod +x ./Release/Sibernetic

If you do not run from the top-level folder you will see an error which looks something like this:

Compilation failed:
"/tmp/OCLQ1BaOw.cl", line 8: catastrophic error: cannot open source file
"src//owOpenCLConstant.h"
#include "src//owOpenCLConstant.h"

What's inside

Physical Algorithms:

  • PCI SPH - simulation incompressible liquid [1]
  • Simulation elastic matter
  • Simulation liquid-impermeable membranes
  • Boundary handling [2]
  • Surface tension [3]

There are two demo scenes generated for Sibernetic. The first one contains an elastic cube covered with liquid-impermeable membranes and liquid inside. The second one contains two elastic membranes attached to a boundary (one of them has liquid-impermeable membranes covering them and the other one doesn't).

To switch between demos you need to press the 1 or 2 keys respectively. To pause simulation you may press space bar.

References

  1. B. Solenthaler, Predictive-Corrective Incompressible SPH. ACM Transactions on Graphics (Proceedings of SIGGRAPH), 28(3), 2009.
  2. M. Ihmsen, N. Akinci, M. Gissler, M. Teschner, Boundary Handling and Adaptive Time-stepping for PCISPH Proc. VRIPHYS, Copenhagen, Denmark, pp. 79-88, Nov 11-12, 2010.
  3. M. Becker, M. Teschner. Weakly compressible SPH for free surface flows // Proceedings of the 2007 ACM SIGGRAPH/Eurographics symposium on Computer animation, pages 209-217.

Main command options

To start Sibernetic with argument print in command prompt next `./Release/Sibernetic -whatever Available options:

 -no_g                 Run without graphics
 -l_to                 Save simulation results to disk.
 -export_vtk           Save simulation results to VTK files.
     logstep=<value>   Log every <value> steps
 -l_from               Load simulation results from disk.
     lpath=<value>     Indicates path to the directory (not the file) where result of simulation will be stored.  
                       This option work only for -l_to and -l_from options
 -test                 Run some physical tests.
 -f <filename>         Load configuration from file <filename>.
 device=<device_type>  Trying to init OpenCL on device <type> it could be cpu or gpu
                       default-ALL (it will try to init most powerful available device).
 timestep=<value>      Start simulation with time step = <value> in seconds.
 timelimit=<value>     Run simulation until <value> will be reached in seconds.
 leapfrog              Use for integration LeapFrog method
 oclsourcepath=<value> You can indicate path to you'r OpenCL program just using this option
 -nrn <value>          Indicates that you plan run simulation with NEURON simulation = <value> value should be a file which
                       can be run by NEURON simulator and also you should have installed neuron and sibernetic_neuron bridge.
 -help                 Print this information on screen.

LeapFrog integration

Leapfrog is second order method insted of Semi-implicid Euler which we are using as default method for integration. For run simulation with Leapfro integration medhod print run command

./Release/Sibernetic leapfrog

Run simulation from configuration file

All configuration is stored in the configuration folder. There are two demo configurations demo1 and demo2 (demo1 is the default configuration). You can switch between two demo configurations directly inside the working Sibernetic - just push button '1' or '2' respectively. To run your configuration put your configuration file into the configuration folder and run Sibernetic using:

./Release/Sibernetic -f <configuration_file_name>.

To run the worm body simulation you need run Sibernetic with key:

./Release/Sibernetic -f worm

It loads the worm body configuration and initialises and runs the Python module which is responsible for muscle signal updating. For run simulation with crawling worm on carpet like surface or swimming in deep water you need run sibenretic with next command arguments:

./Release/Sibernetic -f worm_crawling oclsourcepath=src/sphFluid_crawling.cl
./Release/Sibernetic -f worm_deep_water oclsourcepath=src/sphFluid_crawling.cl

Control in graphical mode

If you run Sibernetic with graphics you can work with scene rotation and scaling using the mouse. There are also several control button options available:

'Space' - pause the simulation
's'     - save current configuration into file
          ./configuration/snapshot/configuration_name_current_time_and_date you can run this
than (./Release/Sibernetic -f ./configuration/snapshot/configuration_default).
'q' or 'Esc'     - quit the sibernetic
'1'     - run demo1 configuration
'2'     - run demo2 configuration
'r'     - reset current configuration and start from begining

Configuration file format

The configuration file consists of: First block is an optional if you didn't indicate this block then sibernetic will init consts by default value which you can find in owPhysicsConstant.h .

[physical parameters]
mass: 5.4e-14
timeStep: 5.0e-06
simulationScale: 2.46e-06
viscosity: 5.0e-05
surfTensCoeff: 1.21948e+27
elasticityCoefficient: 5.55556e+08

Next 6 lines is a spatial description of boundary box

[simula

Related Skills

View on GitHub
GitHub Stars385
CategoryDevelopment
Updated7h ago
Forks109

Languages

C

Security Score

80/100

Audited on Apr 4, 2026

No findings