All posts by johnmick

WebGL Lake Simulation

lake

This numerical simulation explores how Zooplankton and Algae populations are impacted by a variety of factors describing the conditions of a lake. Also examined is the oxygen concentration and amount of organic carbon present within the lake.

The user is able to modify oxygen, light, temperature, wind speed, nitrogen, phosphorus, and other simulation factors to observe different scenarios.

The application also serves as an experiment with Three.JS, Flot, and running numerical simulations entirely in JavaScript.

The complete source for the application is unminified in a single file and available:
Source Code

A list of the simulation parameters has been provided below:

(Hovering over the parameter labels in the display will also show this information)
Gmax (day) Max Algae Growth Rate at Optimal Light & Nutrients per Day
T (C) Temperature of Lake
f CONSTANT Used in Determining Light
Ke (m^-1) Light Extinction Coefficient
H (m) Lake Depth
Ia (Ly/day) Maximum Light Intensity per Day
Is (Ly/day) Saturating Light Intensity per Day
N (µg/L) Nitrogen Concentration
KmN (µg/L) Nitrogen Half-Saturation Constant
P (µg/L) Phosphorus Concentration
KmP (µg/L) Phosphorus Half-Saturation Constant
uR Algae Endogenous Respiration CONSTANT
Cg Grazing Rate per Unit Mass of Zooplankton
Dz Death Rate of Zooplankton
k (day) Organic Carbon Growth CONSTANT
rog Complex Organic Molecule
u (m/s) Wind Speed
A (µgChl/L) Initial Algae Population
Z (mgC/L) Initial Zooplankton Population
OC (mgOC/L) Initial Organic Carbon
O (mgDO/L) Initial Dissolved Oxygen
days (day) Days to Simulate

Exploring an Agent Based Model

In the default model, the team which maintains a higher population tends to be the team which begins the simulation with more strength among its agents. Due to the psuedorandom nature of the simulation, this is not always the case, regardless a typical run may look something like:

Default Run – Strength Matters A Whole Bunch:

***

Placing the blue team agents closer to each other at initialization does not offer the team any leverage over the red team. Winning is still purely determined by the encountering agents’ strength.

Default Rules – Place Blue Together – Strength Still Significant:

***

Now say that if a battle occurs where blue has 2 neighbors within a certain distance, the red agent will become outnumbered and lose the fight. We see here that blue does substantially better.

2 Neighbors Needed to Win – Blue in Center:

***

Re-exploring strength, we now increase the initial strength of all the red team’s agents. Also changed in this run is that we now say blue must have 5 neighbors to guarantee overpowering a red agent. Here we find the red team outperforming blue.

Neighbor Minimum 5 – Blue in Center – Much Stronger Red:

***

The blue team is not sticking close enough together! This next run confines blue agent’s initial position and delta movements more than in the previous runs. Now the blue team is working together and defeating red again.

Neighbor Minimum 5 – Tighter Blue in Center – Much Stronger Red:

***

Having the blue team remain even closer together reduces their population loss. When the team sticks together the individuals are less likely to lose the fights.

Neighbor Minimum 5 – Tightest Blue in Center – Much Stronger Red:

***

Removing the restrictions on the blue team’s positions and delta movements causes the team to lose all their members nearly immediately.

Neighbor Minimum 5 – Much Stronger Red – Neighbors Matter: