Category Archives: Web Labs

How can AI be used in education? Some thoughts

Artificial intelligence agents are getting more powerful by the day. For a couple months, I have been using GitHub Copilot in Visual Studio Code to help develop simulations and to learn about concepts in front-end web programming. In Copilot, you can select between a couple different AI agents. Recently, I subscribed to Anthropic’s Claude to use as a standalone app.

There has been concern expressed in media about students using AI to cheat on assignments and exams. I am not so concerned; “blue book” tests and personal interviews can let students show what they understand. (too many students to do that you say, well you need to hire more human instructors to manage your AI)

Rather, I want to spend my time thinking how these tools can help people learn.

One practice I recommend to instructors is to model how you use AI to do your work and to learn new concepts and techniques. This can be done in live or recorded lessons.

I am thinking about how students themselves can use AI agents to help their studies. One idea is that a student could ask an AI agent to make a simulation that demonstrates a concept they are learning about.

That involves a couple different aspects. One learns how to clearly communicate concepts about a subject in the process of crafting a prompt that produces the desired result. And one learns from a well-crafted simulation.

See my experiments at Web Labs, AI experiments.

Please send us a message letting us know what you think at support@reactorlab.net

Intro to Web Labs

This is from the first page of the Web Labs wiki on our Github site:

Web Labs is a project of ReactorLab.net. Our purpose is to provide labs which help people understand physical systems through active participation.

Many of the labs are interactive simulations of the type “continuous simulation” or “system dynamics simulation.” In this type of simulation, the system evolves continuously as simulation time proceeds. The user can change input parameter values during evolution of the system, thus changing the simulation results.

Some labs are not dynamic but provide one set of outputs with each experiment. Labs 13-15 and 16-18 are like this.

A lab is composed of one or more JavaScript objects representing process units. Each process unit object contains data describing its current and past state, and methods which provide for changes in the unit’s state as simulation time proceeds. A process unit may exchange data with other process units.

In Dynamic labs, simulation time proceeds in incremental steps. At each step, all process units update their inputs from other units, then update their own state based on their current state and the state of the other units from which they get inputs. The methods by which units update their state involve algebraic and ordinary differential equations, and also may involve partial differential equations. This method of stepping in time is the Euler method of approximate solution of ordinary differential equations. Web Lab’s approximate solutions should not be used to design actual systems.

Design Philosophy

We are developing the Labs using plain JavaScript, with few or no libraries.

We construct labs using one or more “process units” which are independent objects but which can send and receive data from each other. This independence allows new labs to be constructed by using existing process units from old labs and adding new units. This is an example of modular simulation.

We have tried to make the code easy to read and understand. Because of this reason, relatively many lines are used to specify lab units and plot info.

For example, in process_plot_info.js there are many lines like this to specify a plot:

plotInfo[pnum]['xAxisShow'] = 1; // 0 false, 1 true
plotInfo[pnum]['xAxisMin'] = 0;
plotInfo[pnum]['xAxisMax'] = 1000;
...
etc.

And in a process unit’s initialize method, variables are specified like this:

initialize : function() {
//
let v = 0;
this.dataHeaders[v] = 'k_300';
this.dataInputs[v] = 'input_field_RateConstant';
this.dataUnits[v] = '(units depend on order)';
this.dataMin[v] = 0;
this.dataMax[v] = 1000;
this.dataDefault[v] = 1.0e-7;
//
v = 1;
...
etc.

The specifications could be shortened by loading values as indexed elements into a single array. That, however, would make the code more difficult to read and write.

While our strategy does result in more lines of code, they don’t all have to be typed separately, with use of copy, paste and edit.

Please send us a message letting us know what you think at support@reactorlab.net

Design your own reactor network in Web Labs

The desktop version of Reactor Lab had a lab that allowed you to design a reactor network with units that you selected and placed on a flowsheet. See our Annual report 2005 at the Desktop Lab tab above. That desktop version was built with the development tool LiveCode. If you have a LiveCode subscription, you can run a copy of the desktop Lab you download from our github site.

We are focusing on our Web Labs, now that we no longer support the desktop version. Today we posted our web version of the networks lab at the Web Labs tab, Reactors, Reactor Networks lab.

This web version was built with simple Javascript with no added libraries. It works by inserting and removing html code linked to Javascript objects as units are added and deleted from the flowsheet. This lab is less complex than apps which also build flowsheets, such as Aspen Plus and COCO, but this lab is easy to use to gain basic understanding of reactors and system dynamics.

Below are three screenshots: one from the new Web Lab (top) and two from the desktop Lab. In the bottom screenshot, you can see a reactor network that utilizes both local desktop units and remote units, where the local and remote units exchange messages over the Internet during a dynamic simulation.

Please send us a message letting us know what you think at support@reactorlab.net

Reactor Networks in Reactor Lab's Web Labs
Reactor Networks in Reactor Lab’s Web Labs (2025)
Reactor Networks in the Desktop Reactor Lab, circa 2005
Reactor Networks in the Desktop Reactor Lab (2005)
Reactor Networks in desktop Reactor Lab
Reactor Networks in desktop Reactor Lab exchanging messages with remote unit on Internet during dynamic simulation (2009)

What happened to the desktop Lab?

As of July, 2022, I am no longer providing downloads of the desktop versions of our software.

After retiring from the university eight years ago, I stopped maintaining the desktop (standalone, executable) versions for several reasons.

The main reason is that web technology has developed to the point that interactive web apps can be written once, then distributed and run on all varieties of mobile devices and computers. One important development has been the dramatically increased speed of Javascript in web browsers, which enables fast computation and graphics animation.

Another reason is that I have chosen not to spend the cost in time and money required to update and build desktop executables for multiple operating systems, as the versions of our development tool, LiveCode, and operating systems change.

The source code of our desktop software is posted at our GitHub site.

Please see our Web Labs, for which the source code is also posted at our GitHub site.

Please send us a message letting us know what you think at support@reactorlab.net

Links to external sites open in new browser tabs.

The Web Labs are being used each day

We counted the number of runs in each of the Web Labs for the 13.4 days of Mon, 18 Oct 2021 21:16 to Mon, 1 Nov 2021 11:00

The reactor on the Home Page is seeing an average of 45 runs per day.

Lab 7, the Plug Flow Reactor is seeing an average of 30 runs per day during this period. Every Web Lab has been used.

We are happy the Web Labs are being found useful. Please let us know your thoughts via email to support@reactorlab.net

600 runs, Home Page reactor
406 runs, Lab 7, Plug Flow Reactor, including 7 Quiz for this period
271 runs, Lab 9, Hysteresis and multiple steady states in catalytic CSTRs in series
103 runs, Lab 13, Batch reactor, isothermal, nth order reaction
101 runs, Lab 3, Reactor T control with Tj inlet
83 runs, Lab 1, Water Tank Level Control
63 runs, Lab 14, CSTR, isothermal, nth order reaction
52 runs, Lab 15, PFR reactor, isothermal, nth order reaction
47 runs, Lab 5, Bioreactor Control
35 runs, Lab 18, Teddy Token blockchain
22 runs, Lab 000, Artificial Zoo, with the Dragon most popular
16 runs, Lab 00, Pendulum
10 runs, Lab 17, Cryptographic hash
9 runs, Lab 2, Dynamic diffusion and reaction in a porous solid catalyst
8 runs, Lab 8, Plug Flow Reactor + Heat Exchanger
7 runs, Lab FF, Forest fire
6 runs, Lab 0, Swarm of Objects
6 runs, Lab 16, RSA encryption
2 runs, Lab 1A, Level Control, two tanks in series
2 runs, Lab 4, Reactor T control with Tj
2 runs, Lab 6, Heat Exchanger

Getting started with Javascript

The interaction in our Web Labs is programmed with Javascript. Javascript is not as easy to code as is LiveCode, the language of our desktop app. But Javascript has other advantages: free to use, web browsers have Javascript interpreters built-in which execute Javascript very fast, and you can leverage the Javascript you learn to do many things with web pages.

Quick: How to write Javascript and display in web browser

1) Use a text editor like Apple’s TextEdit to create an .html file, e.g., mytest.html

2) In that file, write starting and ending html “script” tags, <script></script>, then enter your Javascript code between those tags. The script tags separate your Javascript code from the html in the file. Save the file.

3) Open that file using your web browser and see the output of Javascript document.write statements which you have typed between the script tags, e.g., document.write('hello');

4) After each change in your .html file, save the file and reload (refresh) the browser page to see the changes.

5) To view the output of the console.log statements, open the browser’s Javascript console. In Safari, select Develop > Show Javascript Console ( command-option-C ). New output appears at the bottom of the console window in Safari.

6) Example of a minimal .html text file to run Javascript in your web browser. All you need in the .html file is a script tag with your Javascript:

<script>
  // two slashes start a comment to help you remember what you are doing, does not execute
  document.write('hello'); // display output on web page
  // values between ' ' or " " are "strings" of text characters
  let aa = 3; // save value 3 in memory location you declare and label aa (aa is a "variable")
  console.log('minimal JS example, aa = ' + aa); // display in browser's Javascript console
  // now that a value is stored in new variable aa, we can use the value by using aa
  let bb = 2*aa; // multiply 2 times the value in aa and store value in new variable bb
  document.write('<br> bb = ' + bb); // note html line break tag <br> to start new line
</script>

7) console.log and document.write are standard, built-in “functions.” A function is a block of code to which you can supply input information within the parentheses (e.g., ‘hello’) and returns some output. You can write your own functions so that you don’t have to repeat the same code in different places.

8) You can view the html code of any web page in your browser. In Safari, select Develop > Show Page Source ( command-option-U ).

Here is a link to my examples of interactive controls https://richardherz.github.io/example-controls/index.html

The easiest way to view the code for one of these examples is to go to that example’s code at https://github.com/RichardHerz/example-controls

There are many sites that teach Javascript. Javascript.info looks good. W3schools is a great Javascript reference and place to learn other web technologies such as HTML, CSS, and graphics.

Evolution of Reactor Lab

Reactor Lab celebrated its 27th anniversary in March 2020. Starting in 2003, the desktop version was integrated with the Internet, with advanced features for that time.

These advanced features included automatic download and installation of updated files for off-line work, a conference (chat) room for discussions within Reactor Lab, and the ability to run process simulations involving local units and units at other locations in the same system. At that time, one could not assume constant connection to the Internet, as we do now. Once, from San Diego, I had a three-way discussion with a person in Michigan and a person in Turkey in the conference room.

I retired from the University of California at San Diego – UCSD – in 2014. Since then, my interest has shifted from the desktop version, which was constructed with LiveCode, to the HTML5-based Web Labs at this site.

This shift has been for a number of reasons, including omnipresent Internet connection in much of the world, almost everyone has access to the web and a web browser without having to download an application file, and the fast speed of Javascript built into web browsers.

That said, desktop apps have advantages over web pages such as saving data files to disk. In Web Labs, one has to go through an extra step to copy text from a popup window and save to a disk file. There are so many features that were built into the desktop Reactor Lab that duplicating them all in HTML5 might not happen.

I used to post standalone application files for Windows and Macintosh. With the evolution of operating systems and the evolution of LiveCode, I no longer wish to make the revisions necessary to build standalones.

However, one can continue to use the desktop Reactor Lab on Windows, Mac, and Linux. This can be done by opening Reactor Lab in LiveCode, version 8.0 or higher. LiveCode can be obtained at LiveCode.com. Download the free, open-source version of Reactor Lab from my github site at github.com/RichardHerz.

Instructions for how to do this are posted at the Download tab.

Web Lab development update

We now have six web labs posted. The newest is the dynamic heat exchanger simulation, and we recently updated the code structure of the reaction-diffusion lab and first temperature control lab to match the newest version.

In addition to the jquery and flot (plotting) libraries, each web lab is driven by six javascript files: (1) _main which runs the simulation loop, (2) _interface which handles the run-pause and reset buttons and gets and verifies inputs from the input fields, (3) _units which has simulation parameters and the process unit code, (4) _plot_info which contains definitions of the plots, (5) _plotter which makes the profile (static x,y) and strip chart (scrolling x,y) plots, and (6) _spacetime which makes the space-time, color-canvas plots.

Four of the six files are the same for all web labs. The two files specific to an individual web lab are the (3) _units and (4) _plot_info files.

We are amazed with the fast computational speed of javascript! Somewhere recently I read that the speed of javascript in browsers has increased by a factor of ten in the last year and a half. Years ago, computation in LiveCode (as MetaCard) was many times faster than javascript. Now, computation in javascript for our labs is much faster than native LiveCode script, although LiveCode 9 makes coupling to other languages for computation possible.

A feature unique to the heat exchanger lab is a check for attainment of steady state. When no significant changes to the system state are detected, the main simulation loop continues to run but unit computations and display updates cease until a change in input parameters is detected. When steady state is reached, the CPU load of the simulation decreases significantly. We don’t plan to implement this for the reaction-diffusion and temperature control labs because these usually operate under unsteady-state conditions.

The code is developing over time as we follow our usual development practice, which is repeat the following: (1) get something working, (2) notice repetition, (3) reduce repetition by writing functions and common library files.

Web Lab design progress

We have been working on our web page design project, lcCardLayoutToWeb, which is posted at GitHub. Here is a screenshot of a test page.

This project allows one to layout a web page in the LiveCode IDE, then export it to HTML and CSS files. The new work makes the process reversible. Exported pages can be edited to include links to Javascript files and references to Javascript functions in HTML events. Then the edited page can be imported into our LiveCode project for further editing of the layout: moving, adding and deleting elements. Then the revised page can be exported back to HTML and CSS files with the file and event references preserved.

This new work should allow us to make interactive web apps more easily.

See our newest Web Lab, “Dynamic diffusion and reaction in a porous solid catalyst” at the Web Labs tab above, Reactors. See the latest version of this web lab in our open-source projects at GitHub, https://github.com/RichardHerz/.