GithubHelp home page GithubHelp logo

zeus360 / smoothed-particle-hydrodynamics Goto Github PK

View Code? Open in Web Editor NEW

This project forked from openworm/sibernetic

0.0 1.0 0.0 8.31 MB

This is a C++ implementation of the Contractile SPH (Electrofluid) algorithm applied to C. elegans locomotion

License: Other

smoothed-particle-hydrodynamics's Introduction

Sibernetic

Sibernetic is a fluid mechanics simulator developed for simulations of C. elegans in the OpenWorm project developed for the OpenWorm project by Andrey Palyanov, Sergey Khayrulin and Mike Vella as part of the OpenWorm team. Sibernetic provides an implementation of the PCISPH contractile matter algorithm for simulating muscle tissue and is applies to C. elegans locomotion.

When driven by Hodgkin Huxley dynamics contractile matter is called Electrofluid.

Sibernetic is primarily written in C++ and OpenCL, it also provides a Python API.

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)

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, navigate to the Release folder and run:

make clean
make all

Mac: stay in the top-level folder and run:

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: Smoothed-Particle-Hydrodynamics
Invoking: GCC C++ Linker
g++ -L/usr/lib -L/usr/lib/python2.7 -o "Smoothed-Particle-Hydrodynamics"  ./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: Smoothed-Particle-Hydrodynamics

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

export PYTHONPATH=$PYTHONPATH:'./src'

Finally, to run, run the command:

Linux:

./Release/Smoothed-Particle-Hydrodynamics

Mac:

./build/Smoothed-Particle-Hydrodynamics

You may need to make ./Release/Smoothed-Particle-Hydrodynamics executable like so:

chmod +x ./Release/Smoothed-Particle-Hydrodynamics

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"

Saving to disk

You may wish to save simulations to disk rather than visualise them (WARNING: This is buggy)

For record configuraton into file you need to run simulation with key -l_to - it create 3 new files at the folder ./buffers:

  • connection_buffers.txt - it need to store information about conection among of elastic partciles
  • membranes_buffer.txt - it need to store information about membranes
  • position_buffer.txt - it need to store information current position all of the non boundary particles it save information to this file every 10 steps of simulation. You shoulld remember that than more info you want to store than bigger output file is.

For view result you should run simulation with key -l_from - it get positions from position_buffer.txt file and draw evolution of system in time

Making videos (*nix)

If you run a simulation you may be interested in recording the graphical output. Making such videos is a bit tricky because they need to be speeded up, so far I have found the following two commands do a decent job (change folder names accordingly) after you have used a screen record program:

#If your video is in OGV  format (if you used recordmydesktop for instance), use the following script to convert to avi:

#!/bin/bash
 # ogv to avi
 # Call this with multiple arguments
 # for example : ls *.{ogv,OGV} | xargs ogv2avi
 N=$#;
 echo "Converting $N files !"
 for ((i=0; i<=(N-1); i++))
 do
 echo "converting" $1
 filename=${1%.*}
 mencoder "$1" -ovc xvid -oac mp3lame -xvidencopts pass=1 -o $filename.avi
 shift 1
 done
#make images from video
ffmpeg -i crawley_6.avi -r 0.05 -f image2 ~/Documents/tmp/output-%06d.jpg
#re-encode into video
ffmpeg -r 100 -i output-%06d.jpg -r 100 -vb 60M speeded_worm.mp4

smoothed-particle-hydrodynamics's People

Contributors

vellamike avatar skhayrulin avatar a-palyanov avatar neurophile avatar credentiality avatar charles-cooper avatar nhdaly avatar slarson avatar ileanaaldama avatar tarelli avatar

Watchers

 avatar

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.