Category Archives: Dynamics

Space-time plot added to web lab

Space-time plots are a beautiful way to view dynamic reaction-diffusion systems. We added one to the Web Lab, “Dynamic diffusion and reaction in a porous solid catalyst.” Here is a static screen shot from the lab.

Adding this dynamic plot required learning how to program the HTML5 canvas element with Javascript – an exciting combination!

We prepared static plots of space-time data for our previous research work, e.g., at http://escholarship.org/uc/item/9bc7v3kv. We were inspired to make them dynamically by the fluid dynamics simulations of Oliver Hunt at https://nerget.com/fluidSim/ and Daniel Schroeder at http://physics.weber.edu/schroeder/fluids/. Those pages showed us that this was possible to do in a web page.

Web app experiment 3 posted – control of reactor T

Web app experiment 3 demonstrates feedback control of temperature during reaction in a continuous stirred tank reactor (CSTR). See the Resources tab, Web app experiments. Below is a static screenshot – click to enlarge.

web_app_3_image_4

At default conditions in manual control mode with constant inputs, the system oscillates. Do you know why the system oscillates? See the Resources tab, CRE Notes, 15 – CSTR thermal effects. Then put the system into Auto Control mode.

LiveCode speed of execution

Reactor Lab was built using LiveCode. Get the free Community version at  LiveCode.org. LiveCode is great because it is cross-platform: write once and deploy on many platforms. Another advantage is that the stack model and scripting language are very stable in the sense of supporting past versions: some of the script dates from 1993 and HyperCard.

In most cases in Reactor Lab, the speed of LiveCode is sufficiently fast. The most demanding lab using math computations in LiveCode script is Division 7 Biological Reactions, Lab 3 Immobilized Enzyme Profiles. In that lab, as the user moves a slider to change an input parameter, LiveCode solves a second-order, ordinary differential equation using the iterative shooting method, and then updates the graphics.

Calculations in the dynamic Catalyst Pellet are too demanding to run in LiveCode script. That lab has a detailed, elementary-step simulation of carbon monoxide oxidation over a porous solid catalyst. A function was written in C++ to do finite-difference integration of a set of partial differential equations. The external is then compiled separately on Mac and Windows to make an “external” (.bundle on Mac, .dll on Windows). The LiveCode stack calls this external to do the calculations. The advantage of an external is that it is fast. The disadvantage is that you must compile a separate executable for each platform.

When the Catalyst Pellet external was written in 2008, we used Revolution 4, where Revolution was the earlier name for LiveCode. The Catalyst Pellet and its external ran great when we finished it but it is not compatible with later versions of LiveCode. Therefore we pulled the dynamic Catalyst Pellet out into its own standalone app. The problem presumably is that the interface specification between externals and LiveCode changed. The stack and its external initially appear to run in LiveCode 7, but there appears to be a memory leak and a crash ensues. We haven’t had the time to keep the external up to date. The original version posted in the Download section works well.

The speed at which LiveCode 7 updates the card graphics appears to have slowed from previous versions. This may be related to the addition of resolution independence and higher resolution target displays. To speed things up, we lock the screen before changing many separate elements in the display, then unlock the screen when everything on the card has been updated.