Giter Club home page Giter Club logo

wavesimulator2d's Introduction

2D Wave Simulation on the GPU

This repository contains a lightweight 2D wave simulator running on the GPU using CuPy library (probably requires a NVIDIA GPU). It can be used for 2D light and sound simulations. A simple visualizer shows the field and its intensity on the screen and writes a movie file for each to disks. The goal is to provide a fast, easy to use but still felxible wave simulator.

Example Image 1 Example Image 2

Update 01.04.2024

  • Refactored the code to support a more flexible scene description. A simulation scene now consists of a list of objects that add their contribution to the fields. They can be combined to build complex and time dependent simulations. The refactoring also made the core simulation code even simpler.
  • Added a few new custom colormaps that work well for wave simulations.
  • Added new examples, which should make it easier to understand the usage of the program and how you can setup your own simulations: examples.
Example Image 3 Example Image 4

The old image based scene description is still available as a scene object. You can continue to use the convenience of an image editing software and create simulations without much programming.

Image Scene Decsription Usage

When using the 'StaticImageScene' class the simulation scenes can given as an 8Bit RGB image with the following channel semantics:

  • Red: The Refractive index times 100 (for refractive index 1.5 you would use value 150)
  • Green: Each pixel with a green value above 0 is a sinusoidal wave source. The green value defines its frequency.
  • Blue: Absorbtion field. Larger values correspond to higher dampening of the waves, use graduated transitions to avoid reflections

WARNING: Do not use anti-aliasing for the green channel ! The shades produced are interpreted as different source frequencies, which yields weird results.

Example Image 5

Recommended Installation

  1. Go here and install miniforge/mamba, which is a python package manager.
  2. Start the mamba command prompt (under windows type 'Miniforge Prompt' in the start menu and you should find it).
  3. install the dependencies by running:
    • mamba install numpy, opencv, matplotlib, cupy
  4. Run the program directly from the miniforge prompt (cd into the directory where you downloaded the Wave Simulator first): python main.py
  5. Alternatively, you can run the program from an IDE like PyCharm (don't forget to configure the IDE to use the python interpreter from the mamba/miniforge install directory)

wavesimulator2d's People

Contributors

0x23 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.