All Projects → ABRG-Models → morphologica

ABRG-Models / morphologica

Licence: Apache-2.0 license
A library of supporting code for numerical modelling (JSON config, HDF5 data, Modern OpenGL visualization)

Programming Languages

C++
36643 projects - #6 most used programming language
c
50402 projects - #5 most used programming language
HTML
75241 projects
CMake
9771 projects
GLSL
2045 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to morphologica

cpp-tutor
Code examples for tutoring modern C++
Stars: ✭ 52 (-55.93%)
Mutual labels:  cplusplus-17
Cut The Rope Replica
A "Cut the Rope" game replica, 2D fun mobile game about helping the frog get the candy.
Stars: ✭ 26 (-77.97%)
Mutual labels:  2d
JScad2d
Javascript Library for CAD 2D drawing from json file
Stars: ✭ 25 (-78.81%)
Mutual labels:  2d
SchrodingerWellPython
2D 3D Time independent FDM Schrodinger equation solver for arbitrary shape of well
Stars: ✭ 21 (-82.2%)
Mutual labels:  2d
nautilus
another graphics engine
Stars: ✭ 16 (-86.44%)
Mutual labels:  graphics-engine
graph-transformer-pytorch
Implementation of Graph Transformer in Pytorch, for potential use in replicating Alphafold2
Stars: ✭ 81 (-31.36%)
Mutual labels:  graphs
Neural-Plot-Development
A Library for visualizing Neural Networks of the TensorFlow/Keras models.
Stars: ✭ 16 (-86.44%)
Mutual labels:  graphs
graph datasets
A Repository of Benchmark Graph Datasets for Graph Classification (31 Graph Datasets In Total).
Stars: ✭ 227 (+92.37%)
Mutual labels:  graphs
beapi-bench
Tool for benchmarking apis. Uses ApacheBench(ab) to generate data and gnuplot for graphing. Adding new features almost daily
Stars: ✭ 16 (-86.44%)
Mutual labels:  graphs
any invocable
Сonservative, move-only equivalent of std::function
Stars: ✭ 14 (-88.14%)
Mutual labels:  cplusplus-17
magnum-singles
Single-header libraries from the Magnum engine
Stars: ✭ 96 (-18.64%)
Mutual labels:  graphics-engine
ntds 2018
Material for the EPFL master course "A Network Tour of Data Science", edition 2018.
Stars: ✭ 59 (-50%)
Mutual labels:  graphs
gnn-lspe
Source code for GNN-LSPE (Graph Neural Networks with Learnable Structural and Positional Representations), ICLR 2022
Stars: ✭ 165 (+39.83%)
Mutual labels:  graphs
topometry
A comprehensive dimensional reduction framework to recover the latent topology from high-dimensional data.
Stars: ✭ 64 (-45.76%)
Mutual labels:  graphs
lifish
A game inspired by Factor Software's "BOOM". Also the repo for BOOM Remake.
Stars: ✭ 38 (-67.8%)
Mutual labels:  2d
kglib
TypeDB-ML is the Machine Learning integrations library for TypeDB
Stars: ✭ 523 (+343.22%)
Mutual labels:  graphs
visual-heatmap
Open source javascript module for high performance, large scale heatmap rendering.
Stars: ✭ 21 (-82.2%)
Mutual labels:  2d
combatris
A "perfect" implementation of an old classic
Stars: ✭ 20 (-83.05%)
Mutual labels:  cplusplus-17
shaper
A C++ tool for 3D reconstruction from parallel 2D sections
Stars: ✭ 69 (-41.53%)
Mutual labels:  2d
SwiftCharts
Easy to use and highly customizable charts library for iOS
Stars: ✭ 2,405 (+1938.14%)
Mutual labels:  graphs

morphologica

A banner image of a hexgrid surface plot

Header-only library code to visualize C++ numerical simulations using fast, modern OpenGL.

You'll find all in the code in the morph directory. For example code and screenshots, see this page.

morphologica has some demo/tutorial content on YouTube: https://www.youtube.com/playlist?list=PLwiQ_IuTOr_Us9_tBde96VLYQlRWOYeAP

Quick Start

This quick start shows dependency installation for Linux, because on this platform, it's a single call to apt (or your favourite package manager). If you're using a Mac, see README.build.mac for help getting dependencies in place. It's README.build.windows for Windows users.

# Install dependencies for building graph1.cpp (assuming Debian-like OS)
sudo apt install build-essential cmake git wget  \
                 freeglut3-dev libglu1-mesa-dev libxmu-dev libxi-dev \
                 libglfw3-dev libfreetype-dev

git clone [email protected]:ABRG-Models/morphologica   # Get your copy of the morphologica code
cd morphologica
mkdir build         # Create a build directory
cd build
cmake ..            # Call cmake to generate the makefiles
make graph1         # Compile a single one of the examples. Add VERBOSE=1 to see the compiler commands.
./examples/graph1   # Run the program. You should see a graph of a cubic function.
# After closing the graph1 program, open its source code and modify something (see examples/graph2.cpp for ideas)
gedit ../examples/graph1.cpp

The program graph1.cpp is:

// Visualize a graph. Minimal example showing how a default graph appears
#include <morph/Visual.h>
#include <morph/GraphVisual.h>
#include <morph/vVector.h>

int main()
{
    // Set up a morph::Visual 'scene environment'.
    morph::Visual v(1024, 768, "Made with morph::GraphVisual");
    // Create a new GraphVisual with offset within the scene of 0,0,0
    auto gv = new morph::GraphVisual<double> (v.shaderprog, v.tshaderprog, {0,0,0});
    // Data for the x axis. A vVector is like std::vector, but with built-in maths methods
    morph::vVector<double> x;
    // This works like numpy's linspace() (the 3 args are "start", "end" and "num"):
    x.linspace (-0.5, 0.8, 14);
    // Set a graph up of y = x^3
    gv->setdata (x, x.pow(3));
    // finalize() makes the GraphVisual compute the vertices of the OpenGL model
    gv->finalize();
    // Add the GraphVisual OpenGL model to the Visual scene
    v.addVisualModel (gv);
    // Render the scene on the screen until user quits with 'x'
    v.keepOpen();
    // When v goes out of scope, gv will be deallocated
    return 0;
}

The program generates a clean looking graph...

Screenshot of graph1.cpp output showing a cubic function

...and the code compares favourably (in terms of amount of boilerplate code) with the equivalent Python, graph1.py:

# Visualize the graph from graph1.cpp in Python
import matplotlib.pyplot as plt
import numpy as np

# Create some data for the x axis
x = np.linspace(-0.5, 0.8, 14)
# Set a graph up of y = x^3
plt.plot(x, np.power(x,3), '-o')
# Add labels
plt.title('Made with Python/numpy/matplotlib')
plt.xlabel('x')
plt.ylabel('y')
# Render the graph on the screen until user quits with 'q'
plt.show()

See the coding README for a description of some of the main classes that morphologica provides.

What is morphologica?

This header-only C++ code provides simulation support facilities for simulations of dynamical systems, agent-based models or, in fact, any program that needs dynamic, runtime visualization.

It helps with:

  • Visualizing your model while it runs. A modern OpenGL visualization scheme called morph::Visual provides the ability to visualise 2D and 3D graphs of surfaces, lines, bars, scatter plots and quiver plots with minimal processing overhead. Here's a morph::Visual helloworld and a more complete example. It's almost as easy to draw a graph in C++ with morphologica as it is to do so in Python.

  • Configuration: morphologica allows you to easily set up a simulation parameter configuration system, using the JSON reading and writing abilities of morph::Config. (morph::Config Example)

  • Saving data from your simulation. morphologica provides a set of easy-to-use convenience wrappers (morph::HdfData) around the HDF5 C API. By saving data in a standard format, it is easy to access simulation data in python, MATLAB or Octave for analysis and graphing. (HdfData Example)

It keeps out of the way of what kind of simulation you write. Our programs typically start with some kind of preamble, in which we use morph::Config to load up a JSON parameter file defining the values of the parameters for the simulation run. We might also use morph::HdfData to retrieve some data (e.g. the state) from an earlier simulation and then set up a morph::Visual object for the visualization. We then might call a function, or create a class object which defines the simulation. This may or may not access features from the morphologica headers.

As the simulation progresses, we update the data in the morph::Visual scene; save images from the scene for movie making and record data as often as we want it using morph::HdfData. At the end of the program, as well as saving any final data, we use morph::Config to save out a 'version of record' of the parameters that were used, along with git information which morph::Config can extract so that we could find the exact version of the simulation for future reproduction of the result.

Shows a variety of visualisations created with morphologica

A selection of visualisations made with morphologica. A 2D graphs. B A self-organising map simulation (orientation preference maps). C Three dimensional quiver plot. D gene driven reaction diffusion model. E Debugging a large model.

Although it need not be incorporated into your actual simulation, morphologica does also provide classes that you might find useful. Examples include:

morphologica is a way of storing our 'group knowledge' for posterity.

Some existing projects which use morphologica are:

Code documentation

See README.coding.md for a guide to the main classes.

morphologica code is enclosed in the morph namespace. If README.coding.md doesn't coverit, then the header files (They're all in morph/) contain code documentation.

You can find example programs which are compiled when you do the standard cmake-driven build of morphologica in both the tests/ subdirectory and the examples/ subdirectory. The readme in examples/ has some nice screenshots.

For full, compilable, standalone examples of the code, see the standalone_examples/ subdirectory. You can use these as templates for creating your own projects that use morphologica library code.

For more info on how to set up CMake files to build a program using morphologica (and some hints as to what you'll need to do with an alternative directed build system), see README.cmake.md.

Credits

Authorship of morphologica code is given in each file. Copyright in the software is owned by the authors.

morphologica is made possible by a number of third party projects whose source code is included in this repository. These include nlohmann::json, lodepng, rapidxml and incbin. Thanks to the authors of these projects!

morphologica is distributed under the terms of the Apache License, version 2 (see LICENSE.txt).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].