really-simple-dispersion-wasm

module
v0.0.0-...-61a586d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2021 License: MIT

README

Really Simple Dispersion (Wasm)

Introduction

An interactive atmospheric dispersion model for simulation and visualisation of industrial plant emissions. Written in Go, compiled to WebAssembly (Wasm), runs fully in the browser.

LIVE EXAMPLE served from GitHub repo: https://joshuanunn.github.io/really-simple-dispersion-wasm/example

In the live example above, the properties of the industrial source and the weather conditions can be tweaked to see the effect on dispersion. Each change will plot average concentrations for a single hour. The Simulate button can be used to run a simulation for the specified number of hours of random weather conditions, which builds up a picture of how concentrations may look time-averaged over a longer period with varied conditions.

Comparison to pure JavaScript version

This project has also been implemented fully in JavaScript in order to compare performance. Both codebases have fully working live demos, but remain a work in progress. The code and live demo can be found at https://github.com/joshuanunn/really-simple-dispersion.

At present the JavaScript implementation is approximately twice as fast as the Wasm one (in Chrome). To test for yourself, load the live demos, select 100 hours and click the Simulate button.

Background

This is Gaussian based dispersion model, which is a mathematical simulation of how air pollution disperses in the atmosphere. The form of the plume exiting a stack at a given height is derived from the overall Gaussian plume equation below, which describes the pollutant concentration at a single position (x,y,z) in a plume referenced coordinate system. The sigma plume formulas σy and σz are power-law or logarithmic functions which vary with meteorological conditions. Briggs plume rise formulas are used to add an additional plume rise due to the buoyancy or momentum of the plume. A typical schematic of a plume is shown below (centre).

Gaussian Equation

The plume is visualised by mapping concentrations onto a regular gridded areas, which are effectively 2D slices through a 3D plume. Typical outputs showing simulated ground level emissions over a 5km x 5km area centred on an industrial facility time-averaged over 20 hours is shown below (left). The corresponding side elevation profile of the plume average cross-section with height up to 1km altitude (right). These are contoured on a log scale (each contour is 10x lower/higher than the next).

Gaussian Views Image

NOTE that while this simulation can help with understanding and visualising how Gaussian plume dispersion models work, the ISC-3 model on which it is based has long-since been replaced by modern atmospheric dispersion models such as AERMOD (US) and ADMS (UK).

Technical Details and Wasm Compilation

Most of the core functionality and program state is encapsulated in an RSDM struct. The concentration maps are held in two internal [][]float64 slices for each plot - one to hold running raw concentrations and another to build a contour map. The default "High" image quality is based on a 500 x 500 element array for the plan view (5km @ 10m pixel spacing) and a 500 x 200 element array for the height profile (5 km @ 10m horizontal spacing and 1km @ 5m vertical spacing). These are converted to png images and returned to the browser on each call.

To compile any changes, run the following from the base project directory:

$ GOOS=js GOARCH=wasm go build -o main.wasm ./cmd/rsdm/
$ mv main.wasm ./example/

Note that the wasm_exec.js JavaScript file included in this repo is provided by Go and is needed to support the loading of the Wasm. If a different version is needed, it can be found inside the local Go installation:

$ cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" ./example/

If serving locally, make sure that the server can support the mimetype 'application/wasm' for .wasm files.

Tests

Prior to running tests, Node must be installed and /path/to/go/misc/wasm added to your $PATH. Unit tests can then be run by executing the following from the base project directory:

$ GOOS=js GOARCH=wasm go test ./internal/rsdm/

License

This software is released under the MIT license MIT.

This software is based upon equations derived from the Industrial Source Complex (ISC-3) atmospheric dispersion model developed by the US EPA. More details can be found in the ISC-3 user guide: http://www.epa.gov/scram001/userg/regmod/isc3v2.pdf.

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL