Skip to content

ProkopHapala/SimpleSimulationEngine

Repository files navigation

Simple Simulation Engine

a minimalistic engine for:

  • Physical simulations
  • Numerical math
  • Game development
  • Computer graphics
  • Educational purposes

Table Of Contents

Structure and Dependecies

  • Computational core is written in C/C++11. It should have no dependencies on external libraries. Even C++STL is avoided where possible. Attempt is made to optimize simultanously run-time speed, code length, compilation time, and interal interdependece of modules. In that respect especially tradeoffs for using templates and class hierarchies are considered.
  • C/C++ part is compiled using CMake 2.8 and tested with gcc 5.4.0 on Ubunt 16.04. Code::Blocks project is generated by cmake .. -G "CodeBlocks - Unix Makefiles". There are several CMake projects for different parts which differ in dependencies
  • Standalone apps, games and demos use SDL2 and OpenGL 1.2 and 4.0 for Graphical user interface. Some other dependencies (e.g. SDL2-net, SDL2-image, SDL2-ttf) may be added to particular build target but are not required globaly.
  • There is stand allone set GPU accelerated simulations using OpenCL
  • Some apps use embeded Lua3.2 for scripting, but it is not globally required.
  • Python 2.7 + numpy + matplotlib is used to make convenient science/engineering packeges partialy wrappaing the C/C++ core libraries.
  • In addition there are some documents using iPython (Jupyter) and javascript+WebGL for rendering interactive 3D graphics and editors of glsl shaders on web. These are independent on the rest.

Compilation

  • tested on Ubunu 16.04 64bit)

quickstart

  1. make sure you have installed gcc >=5.4.0, CMake >2.8, libglew-dev, SDL2-dev
  2. got to cpp/Builds/sketches_SDL/ create subdirectory Build
  3. from cpp/Builds/sketches_SDL/Build generate makefiles by cmake .. -G "CodeBlocks - Unix Makefiles"
  4. in the same directory compile the project make. The compiled binaris are stored in cpp/Build

remarks

  • you may also load Code::Blocks project cpp/Builds/sketches_SDL/SimpleSimulationEngine.cbp and compile particular build target from Code::Blocks
  • If cmake or make fails due to some dependencies, you may try compile just part of the project (e.g. cpp/Build/libs) which has less dependencies
  • you may also remove problematic build targets by commenting out particular parts of CMakeFile.txt

optional

  1. If you were able to compile sketches_SDL you may try compile applications and games in cpp/Builds/apps/ or the whole project in the same way just in cpp/Builds/all/ (you will need liblua5.2-dev and libtolua5.2-dev)
  2. You may try compile OpenCL demos in cpp/Build/sketches_OCL in the same way. This will require properly installed GPU drivers and opencl libraris. These are platform dependent. Personally I tested with nvidia-opencl-dev.
    • Note: be very carefull when installing GPU drivers on linux, ou can easily brak the system (I did 3 times). In my case nvidia-opencl-dev installed dependecies libcuda-378 nvidia-378 nvidia-opencl-icd-378 nvidia-prime nvidia-settings opencl-headers. I also added nvidia-modprobe. When you break your system this make help:
      sudo apt-get autoremove --purge nvidia-*
      sudo stop lightdm
      sudo apt-get install xserver-xorg-video-nouveau
      
      there are many guides for installing GPU drivers on linux. I found particularily helpfull and working this one

Content

This is work in progress. Often particular modules of the engine are functional, but they are not put together to build an unified system and work together.

C++ part

C++ Planned or Preliminary or ToDo
  • multipole expansion
  • fast multipole method or FFT for long range interactions
  • Global optimization algorithms for molecular simulation
  • easy to use generic rendering and physical engine for games (with scene graph) which goes together seamlessly

Python

Web

projects using HTML + Javascritp + WebGL + THREE.js and/or Python Jupyter.nb

Aim and Philosophy

Main motivation is to assemble various common algorithma from physics, numerical mathematics, computer graphics and computer science and build minimalistic tools for rapid development of physical simulation programs and games.

It should be:

  • Didactic - user is expected to be able to understand how things works inside ( i.e. it should not be a blackbox ). The code sould document intself (without much comment strings or external doc).
  • Focused on development of small programs ( like sketches/demos )
  • Each particular part of the engine should be illustrated by simplistic example / demo
  • Minimal dependencies on 3rd party libraries.
  • Minimalized inter-dependencies between different modules within the engine. Many modules are designed to work independently, and be easily plugged into other projects
    • often just as header files (.h)
  • No compicated instalation procedures required
  • It is rather a set of tools and pre-programed code samples rather than enclosed package
  • It does not follow rigorous Object Oriented Programing paradigma and other good practices of software enginering common in large projects. Especially encapsulation resp. information hiding is avoided (everything is public), since otherwise it would lead to huge boiler-plate code (.get() and .set()) and limited or tedious user extensions.
  • User is expected and ecouraged to modify the code (including core parts) to match requirements of his particular project. It should be more a starting point of further development rather than final product.
  • C++11 is used in pragmatic way, not ideologically.
    • E.g. pass by reference, templates and lambda expressions are used for programming convenience and computational performance.
    • At the same time old-schoop C is often prefered:
      • printf is used instead of std:iostrem
      • char* instead of string
      • raw pointers double* for arrays instead of std:vector or smart pointers

About

minimalistic engine for physical simulations, numerical math and games in C++ ( python, lua ) using SDL2 and OpenGL for visualization

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published