Giter VIP home page Giter VIP logo

bcerjan / simplefdtd Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 3.83 MB

An embeddable 2D FDTD simulation for approximate results in the visible region. Uses leapfrog alternating-direction implicit update equations.

Home Page: https://simplefdtd.waldocorp.com

License: GNU Affero General Public License v3.0

CMake 0.22% C++ 0.74% C 8.58% HTML 7.49% Makefile 0.22% JavaScript 39.80% Objective-C 17.41% MATLAB 0.71% Mathematica 24.83%
fdtd wasm emscripten c webapp

simplefdtd's Introduction

simpleFDTD

An embeddable 2D electromagnetic FDTD simulation for approximate results in the visible region. Uses the leapfrog alternating-direction implicit FDTD (LADI-FDTD) method.

The goal of this project is to make a simple, user-friendly, and embeddable 2D FDTD simulation using emscripten to compile to WebAssembly. This allows the computation to be run in the user's browser, rather than on the server hosting the page allowing the server to run smoothly and serve simulations even under high load.

To see an example of the generated web page, see here.

Embedding On Your Site:

To use on your site (subject to the license) just download the three files in the website directory and then adjust them as you see fit for your site. It is strongly recommended that you only edit the .html file directly unless you know what you are doing.

Compiling:

To compile, a (perhaps inelegant) combination of make and cmake is used. CMake is used for compiling to executables to run for testing / debugging, while make is used to generate the final .wasm, .html, and .js files.

Specifically, clone the git repo (git clone https://github.com/bcerjan/simpleFDTD) then cd simpleFDTD/c_code, mkdir build, cd build, and cmake ... From there, you can now use make empty or make structure to create executables for testing without compiling all the way to .wasm. Note that if you change any parameters, you need to first run ./empty before compiling make structure as ./structure needs the header files (re)generated by running ./empty.

To make the .wasm (and associated ephemera) enter the c_code directory, and run make. This compiles to WebAssembly. When you edit things, it can be helpful to

  1. use make clean_html to remove the previous version of the .wasm, .html, and .js files
  2. before running make.

simplefdtd's People

Contributors

bcerjan avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

simplefdtd's Issues

Reduce Size of Empty Run Data

It appears (and I believe it should be) that every point in the stored fields for the empty run are the same for a given frequency (i.e. Ey(0,yPos) == const for all yPos). Re-using the same data point for each position will save memory and make the stored files significantly more legible.

Simplify Material Fitting Process

As it stands coming up with material fits is at best sort of confusing. It uses both Matlab and Mathematica and can still produce fits that cause the simulation to become unstable.

  • Update to include Levy estimation of initial parameters in Mathematica (or do the advanced fitting in Matlab, either way works).

  • Try to establish criteria that ensure stability of a material model in the simulation. This might be an entire PhD though, so don't get too caught up on it.

Add "Normalize Data" Button

Output can be hard to interpret when R -> 0 and T -> 1 due to the scale, so it would be handy to scale the chart based on the max value of each dataset.

Improve Metal Dielectric Functions

Right now it seems like all the metals are basically the same (in terms of results). There are slight differences, but by and large they aren't particularly meaningful. Adjust the modelling to use Lorentz-Drude model instead of just Drude approximation to try and get more physical results.

Add Adaptive Timing

Currently number of steps in the simulation is hard-coded -- now that users can input high dielectric values for the object it is possible that the number of steps will not be enough for the energy to sufficiently dissipate (particularly when on-resonance). Can use ArrayMax to find current field strength and wait for it to decay to a sufficiently low value before terminating in these conditions.

Improve chart design and functionality

  • Add figure heading and axes labels
  • Add checkbox so users can store data from previous runs to overlay with new data (this will require auto-renaming the Chart.js datasets so they can be distinguished properly...)
  • Option to download datasets shown on the chart (and / or raw e-field strength as a function of time?)

Rendering without requestAnimationFrame

Sometime last night the error:
Looks like you are rendering without using requestAnimationFrame for the main loop. You should use 0 for the frame rate in emscripten_set_main_loop in order to use requestAnimationFrame, as that can greatly improve your frame rates!

started showing up. It didn't use to, so it must be something that I changed somewhere along the way. Not sure if it's technically an issue as everything still works, but I'm not happy that it's so unhappy.

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.