Gas Lab
Contrary to popular belief, GagsEngine is designed for all types of programs, not just games! One of my teachers tasked me with creating a new version of a virtual gas lab for Chemistry class.
Gas Lab 6: Bug Fixes
Same as Gas Lab version 5 but with a few bug fixes to make more accurate calculations.
|
Gas Lab 5: Gas Lab Revisited
Recently I came across the CreateJS code library. I decided to revisit the gas lab to test the graphics library. I went for a simplistic design, but added additional gauges to track each variable.
Among other changes, I also made the values for each variable more realistic. For example, the temperature starts at room temperature and goes to a little above boiling. |
Demo 4: Almost Done
Now that we have many more of the images, this demo is looking pretty nice!
This program is almost complete. These are the final steps Seung and I have to complete:
This program is almost complete. These are the final steps Seung and I have to complete:
- Add an easter egg to the program
- Animate the main gas chamber as variables change
- Check the formulas and fix any problems
Demo 3: Graphics
Same demo, new graphics. Still quite a ways to go to make it look more visually appealing.
Demo 2: Canvas User Interface
Since the last demo, I made an HTML5 canvas interface for the program. It's ugly, since the images are not complete yet, but it works.
Controls:
Mouse: Click screen elements
Buttons:
Red Square: Temperature Up
Blue Square: Temperature Down
Cyan Rectangle: Add Gas
Lime Square: Gas Release
Grey Rectangles: Weights (can be added or removed)
White Rectangle: Reset
Controls:
Mouse: Click screen elements
Buttons:
Red Square: Temperature Up
Blue Square: Temperature Down
Cyan Rectangle: Add Gas
Lime Square: Gas Release
Grey Rectangles: Weights (can be added or removed)
White Rectangle: Reset
Now in HTML5!
Due to a Java security issue with Java 1.7, I decided to try making the gas lab simulation in HTML5. It turns out it actually easier to work with for what I am doing.
This demo is just the math behind the gas lab program before I create a visual interface. The buttons change the variables as follows:
- Temperature Buttons: Change Temperature (T). Affects Volume (V) and/or Pressure (P)
- Weight Buttons: Change Pressure (P). Affects Volume(V)
- Gas Buttons: Change moles of gas (n). Affects Volume(V) and/or Pressure (P)
This demo is just the math behind the gas lab program before I create a visual interface. The buttons change the variables as follows:
- Temperature Buttons: Change Temperature (T). Affects Volume (V) and/or Pressure (P)
- Weight Buttons: Change Pressure (P). Affects Volume(V)
- Gas Buttons: Change moles of gas (n). Affects Volume(V) and/or Pressure (P)
AdditionThis is the first test of addition of ScienceDecimals.
So far the demo only supports addition of positive numbers. The next demo will handle rounding to the least number of decimal places and possibly subtraction. Controls: Up Arrow Key - Increase decimal a by 0.01 Shift + Up Arrow Key - Increase decimal b by 0.01 R - Reset demo Note how on the right side of the demo, the numbers quickly become slightly inaccurate. This is the reason why I am taking the time to create a ScienceDecimal class |
Artithmetic
The first challenge in emulating a chemistry program is the rounding of decimals. in Java and other programming languages, some floating point (decimal) numbers cannot be stored exactly in binary, only approximated. For example, 11.4 is stored as 11.3999999999999. While floating point numbers are efficient in terms of memory, I would prefer a fixed-precision representation of a floating point number. I am working on a ScienceDecimal class that uses two integers to represent the whole and fractional part of a decimal. While not the most efficient way of handling arithmetic, it allows me to control rounding, whether by number of decimal places or by number of significant figures. Since the numbers in the problem set are small, I can trade some efficiency for greater accuracy.