<!--
###########################################################################################
This is a JSFiddle example of "Cacatoo". This HTML page does not contain the code itself,
but determines where the grids, graphs, buttons, etc are placed. The real code is in the
Javascript Tab. I recommend enabling "Tabs (Columns)" under the settings in the top-right.
###########################################################################################
-->
<html>
<script src="https://bramvandijk88.github.io/cacatoo/scripts/cacatoo.js"></script>
<script src="https://bramvandijk88.github.io/cacatoo/scripts/all.js"></script> <!-- Dependencies
<link rel="stylesheet" href="style.css"> <!-- Set style sheet -->
<head>
<title>Cacatoo examples</title>
</head>
<script>
/*-------------------------End user-defined code ---------------------*/
</script>
<body onload="cacatoo()">
<div class="header" id="header">
<h2>Cacatoo (example project)</h2>
</div>
<div class="content" id="canvas_holder"> </div>
<div class="content" id="graph_holder"> </div>
<div class="content" id="form_holder"></div>
<div class="output" id="output"></div>
<div class="footer" id="footer"></div>
</body>
</html>
/*-----------------------Start user-defined code ---------------------*/
let sim;
function cacatoo() {
let config = {
title: "ODEs in gridpoints",
description: "Diffusion-coupled predator prey system (Lotka-Volterra)<br> <font size=1> A catastrophy kills some predators at time step 50.</font>",
maxtime: 1000000,
ncol: 64,
nrow: 64, // dimensions of the grid to build
wrap: [true, true], // Wrap boundary [COLS, ROWS]
scale: 3, // scale of the grid (nxn pixels per grid cell
}
sim = new Simulation(config)
sim.makeGridmodel("lotka");
sim.lotka.colourGradient('numpred', 100, [0, 0, 0], [240, 200, 0]) // Will contain the ODEs, and show the abundance of PREDATORS
sim.lotka.colourGradient('numprey', 100, [0, 0, 0], [148, 0, 211]) // Will contain the ODEs, and show the abundance of PREDATORS
sim.createDisplay_continuous({model:"lotka", property:"numpred", label:"Local predator density", // Createa a display for a continuous variable (ODE state for external resources)
minval:0, maxval:200})
sim.createDisplay_continuous({model:"lotka", property:"numprey", label:"Local prey density", // Createa a display for a continuous variable (ODE state for external resources)
minval:0, maxval:200})
// Define a basic Lotka Volterra ODE system
// dn/dt = a n - b n p
// dp/dt = c n p - d p
let LotkaVolterra = function (a, b, c, d) {
return function (n, p) {
return [
a * p[0] - b * p[0] * p[1], // p[0] is the prey which replicates with rate a, and gets consumed by the predator with rate b
c * p[0] * p[1] - d * p[1] // p[1] is the predator which consumes prey with rate c,...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.