Cacatoo - FitzHugh Nagumo
by bramvandijk88
March 05, 2025
HTML
<!--
###########################################################################################
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>
<head>
<title>Cacatoo examples</title>
</head>
<script>
/*-------------------------End user-defined code ---------------------*/
</script>
<body onload="cacatoo()">
<div class="", id="all_holder">
<div class="content" id="canvas_holder"> </div>
<div class="content" id="graph_holder"> </div>
<div class="content" id="form_holder">Druk op 'b' om de blokkade aan/uit te schakelen</div>
</div>
</body>
</html>
CSS
body {
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
background-color: #f0f0f0;
margin: 10px;
font-size: 13px;
}
/* Style the header */
.header {
background-color: rgb(111, 146, 170);
display: block;
border: 0px solid #f0f0f0;
box-shadow: 3px 1px 0px #24242444;
border-radius: 15px 15px 0px 0px;
padding: 10px;
text-align: center;
font-size: 20px;
font-weight: 900;
color: #ffffff;
}
.logos {
z-index: -1;
vertical-align: middle;
display: inline-block;
padding-left: 10px;
padding-top: 10px;
}
.example_card {
width: 220px;
height: 220px;
background-color: rgb(151, 183, 204);
box-shadow: rgba(100, 100, 111, 0.1) 20px 7px 29px 0px;
/* font-weight: bold; */
color: rgb(229, 239, 245);
font-size: 12px;
line-height: 25px;
margin: 25px;
padding: 20px;
padding-bottom: 40px;
padding-top: 10px;
border-radius: 0px 0px 0px 0px;
display: inline-block;
transition: all 100ms ease-out 200ms;
transition-delay: 0s;
}
.example_card_img {
width: 100%;
height: 100%;
border-radius: 0px 0px 0px 0px;
background-position: 45% 50%;
background-repeat: no-repeat;
background-size: cover;
}
.example_card:hover {
background-color: rgb(151, 183, 204);
font-size: 12px;
color: black;
border-radius: 30px 0px 30px 0px;
box-shadow: rgba(100, 100, 111, 0.3) 0px 0px 29px 0px;
}
.example_card:active {
background-color: rgb(151, 183, 204);
font-size: 12px;
padding-top: 11px;
height: 199px;
color: black;
box-shadow: rgba(100, 100, 111, 0.3) 0px 0px 29px 0px;
}
/* Content (grid, graphs, sliders) */
.content {
text-align: center;
/*border-bottom: 1px dashed #88888844;*/
/*background-color: #000000;*/
padding: 5px;
}
/* Output div */
.output {
border-radius: 8px 8px 8px 8px;
margin: 30px;
height: 300px;
overflow-y: scroll;
font-size: 11px;
text-align: left;
/*background-color: #000000;*/
color: #00FF00;
...
JavaScript
/*-----------------------Start user-defined code ---------------------*/
let sim;
var a = 0.05
var e = 0.005
var b = 3
var dt = 3
var disruption = 0.3
var block = true
window.onkeyup = function(e) { console.log(e.keyCode);
if(e.keyCode == 66) {
block = !block
}
};
function cacatoo() {
let config = {
title: "Fitzhugh Nagumo PDE",
description: "",
maxtime: 1000000,
ncol: 150,
nrow: 62, // dimensions of the grid to build
wrap: [false, false], // Wrap boundary [COLS, ROWS]
scale: 2, // scale of the grid (nxn pixels per grid cell
bgcolour:'white',
graph_interval: 5,
graph_update: 25
}
sim = new Simulation(config)
sim.makeGridmodel("Fitz");
sim.Fitz.colourGradient('W', 100, [255, 255, 255], [0, 0, 255]) // Will contain the ODEs, and show the abundance of PREDATORS
sim.Fitz.colourGradient('V', 100, [255, 255, 255], [255, 0, 0]) // Will contain the ODEs, and show the abundance of PREDATORS
sim.createDisplay_continuous({model:"Fitz", property:"V", label:"Actiepotentiaal", minval:0, maxval:1, decimals:3, nticks:3})
sim.createDisplay_continuous({model:"Fitz", property:"W", label:"Refractair weefsel (met blokade)", minval:0, maxval:0.3, decimals:3, nticks:3})
sim.reset = function(all=true){
sim.time=0
if(all)sim.Fitz.resetPlots()
for (let i = 0; i < sim.Fitz.nc; i++)
{
for (let j = 0; j < sim.Fitz.nr; j++)
{
if(all){
sim.Fitz.grid[i][j].V = i == 0 ? 1 : 0.0
sim.Fitz.grid[i][j].W = 0.0
}
else{
if(i==0) sim.Fitz.grid[i][j].V = 1
}
}
}
}
sim.reset()
sim.Fitz.nextState = function (i, j) // Define the next-state function.
...