All Projects → OpenPsiMu → ThePhysicsHub

OpenPsiMu / ThePhysicsHub

Licence: GPL-3.0 license
The Physics Hub is an open source physics simulations project that is being developed by physics students worldwide and aims to deliver clear and easy to understand physics simulations free for everyone!

Programming Languages

javascript
184084 projects - #8 most used programming language
EJS
674 projects

Projects that are alternatives of or similar to ThePhysicsHub

Haskell-abinitio
contains a package in Haskell to calculate the electronic structure properties of molecules using the Hartree-Fock method
Stars: ✭ 14 (-87.93%)
Mutual labels:  physics, simulations
verlet
build and animate objects according to verlet physics. pure golang library
Stars: ✭ 26 (-77.59%)
Mutual labels:  physics
Hamiltonian Nn
Code for our paper "Hamiltonian Neural Networks"
Stars: ✭ 229 (+97.41%)
Mutual labels:  physics
BowlerStudio
A Full-Stack Robotics Development Environment
Stars: ✭ 95 (-18.1%)
Mutual labels:  physics
Particulate Medusae
Soft body jellyfish simulation.
Stars: ✭ 239 (+106.03%)
Mutual labels:  physics
use-spring
Hooke's law hook
Stars: ✭ 53 (-54.31%)
Mutual labels:  physics
Mathutilities
A collection of some of the neat math and physics tricks that I've collected over the last few years.
Stars: ✭ 2,815 (+2326.72%)
Mutual labels:  physics
physx-js
PhysX for JavaScript
Stars: ✭ 80 (-31.03%)
Mutual labels:  physics
InterfaceInteraction
Interact your app's interface elements with different effects!
Stars: ✭ 57 (-50.86%)
Mutual labels:  physics
UnitedEngine
Lightweight physic engine designed for massive and fast simulations
Stars: ✭ 133 (+14.66%)
Mutual labels:  physics
MIMS
PyQt application for creating mass interaction models and compiling them into Faust dsp code, or ~gen objects (for Max/MSP)
Stars: ✭ 22 (-81.03%)
Mutual labels:  physics
Haskanoid
A breakout game in Haskell using SDL and FRP, with Wiimote and Kinect support.
Stars: ✭ 242 (+108.62%)
Mutual labels:  physics
cplot
Function plotter
Stars: ✭ 27 (-76.72%)
Mutual labels:  physics
Pydy
Multibody dynamics tool kit.
Stars: ✭ 232 (+100%)
Mutual labels:  physics
masci-tools
Tools, utility, parsers useful in daily material science work
Stars: ✭ 18 (-84.48%)
Mutual labels:  physics
Math Science Video Lectures
List of Science courses with video lectures
Stars: ✭ 219 (+88.79%)
Mutual labels:  physics
Measurements.jl
Error propagation calculator and library for physical measurements. It supports real and complex numbers with uncertainty, arbitrary precision calculations, operations with arrays, and numerical integration.
Stars: ✭ 248 (+113.79%)
Mutual labels:  physics
mechamodlearn
Structured framework for learning mechanical systems in PyTorch
Stars: ✭ 22 (-81.03%)
Mutual labels:  physics
GFDL atmos cubed sphere
The GFDL atmos_cubed_sphere dynamical core code
Stars: ✭ 34 (-70.69%)
Mutual labels:  physics
TimeEvolvingMPO
A Python 3 package to efficiently compute non-Markovian open quantum systems.
Stars: ✭ 43 (-62.93%)
Mutual labels:  physics

The Physics Hub

The Physics Hub is a website built by physics enthusiasts from a range of backgrounds, serving as a place to view high school/undergraduate university-level physics simulations. The simulations are currently written using the javascript library p5.js. Everybody is welcome to contribute, no matter whether you're a beginner or an expert.

Project Setup

The website is based on ExpressJS. The Node Package Manager (npm) will thus install most of the dependencies for you.

  1. Install NodeJS

  2. In a terminal, run npm install to automatically install the necessary node modules

Instructions to add simulations to the website

To simplify the process of adding simulations, we wrote a python script that automates the grunt work. 0. Run npm install in terminal

  1. If any p5.dom elements are being used, add <element>.parent("simwrapper") in your js file (including the main canvas).

  2. Add your simulation file (p5 code) to /public/javascripts/

  3. Add your simulationdata in JSON to /routes/parameters/simulationdata.js

  4. Run python addSimulation.py in a terminal, type in a urlName and a routerName

Naming convention: the urlName should match the name of your simulation file (e.g. single_pendulum)! The routerName must be written in camelCase (e.g. singlePendulumRouter)!

Forking simulations over a single page

Instead of setting up the whole site, there exists an easier way, building over a single HTML page and .js, if one wishes to only build a new simulation forking existing ones.

  1. For simplicity, you may download the source HTML directly from, for example, view-source:https://physicshub.herokuapp.com/simulations/simplePendulum

  2. Download most of the javascript and css from this github ThePhysicsHub/public/... **Caution: Linking to github directly would not work as it is not a CDN (i.e. protected)

  3. If the simulation does not show up locally, you may change the css and the js source link from relative to direct. i.e.

<script src="file:///X:/[some long path]/public/javascripts/libraries/p5.gui.js"></script>

  1. You may wish to change the links in sim.css if formats do not show up fully.

  2. If you have the physics knowledge but not so much in javascript or programming, one can attempt to fork on the simulation simplePendulum.js. It is well documented and it is possible to start simulating something very simple just by imitating the formats.

Adding a simulation's theory section

To give those interested in the simulations on this webpage further insight into the physics and mathematics involved in the observed phenomena, we're aiming to add a theory section to each simulation.

To add a theory section for a simulation, open a new .ejs file in /routes/parameters, and write the HTML displaying your explanations in there. For displaying maths formulas, make use of the package mathjax.

When your theory section is finished, reference it in /routes/parameters by adding a new attribute to the corresponding simulation JSON object using the getFile() method ("explanation": getFile("<yourTheorySectionsName.ejs>") ).

Design template for simulations

This portion provides a general template for the UI to be followed with some flexibility based on the simulation's specifics.

The UI is meant to be clean, with minimal interactive elements visible on startup. The suggested tools to be used for creating input/sliders/buttons are either the p5.gui library or Pedro's custom-built dropdownFunctions.js file.

The UI should look something as given below, with the parameter options available to the right, and the simulation window to the left, following a minimal grey-scale theme.

The general layering of canvas is as follows:

  • bgCanvas: The overall container canvas, holding all other layers, and the dropdown menu on the right.
  • simCanvas: The simulation window on the left, occupying all of bgCanvas except what is occupied by the dropdown menu.
  • plotCanvas: The plotting window inside simCanvas, it can occupy any position and size depending on the simulation. This layer must have a visibility toggle in the menu. Specific to the simulation, simCanvas and plotCanvas can be resized as the user toggles the visibility. Plotting can be done using grafica.js or a custom lightweight plotter if any.
  • Other layers: Further layers can be added over the above mentioned, as per necessity. For instance, the static grid in the image was on a separate buffer, gridCanvas.

The code given below is a sample to recreate the UI shown above. (it uses Pedro's dropdown file, the documentation for which can be found in the same file.)

let W = 1200  //width of bgCanvas
let H = 500  //height of bgCanvas
let Wsim = W * 0.69 
let Hsim = H
let Wplot = 0.25 * W
let Hplot = 0.875 * H 
let bgCanvas, simCanvas, plotCanvas;

function setup() {
  bgCanvas = createCanvas(W, H)
  
  simCanvas = createGraphics(Wsim, Hsim)
  
  plotCanvas = createGraphics(Wplot, Hplot)
  plotCanvas.background(20)
  plotCanvas.stroke(255)
  plotCanvas.strokeWeight(3)
  plotCanvas.noFill()
  plotCanvas.rect(0, 0, Wplot, Hplot)
  ...
}

 function draw(){
  //border of simCanvas
  simCanvas.clear()
  simCanvas.stroke(255)
  simCanvas.strokeWeight(2)
  simCanvas.noFill()
  simCanvas.rect(10, 10, Wsim - 20, Hsim - 20)
  
  //sim canvas
  image(simCanvas, 0, 0);
  
  //plot canvas toggle
  if (plotCheckbox.checked) {
    ...
    image(plotCanvas, Wsim - Wplot - 30, 30)
  }
  ...
} 
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].