IP Topics

Radioactive Decay Simulation Created Using ChatGPT 4o


This simulation of radioactive decay was created using ChatGPT4o.

The prompts used are:

  • Create a javascript simulation with a html5 canvas. Show all the codes in one page.
  • Start with grey particles in a 60 by 60 arrangement. Represent the particles using small circles.
  • Upon clicking the start animation button, every second, a number of grey particles will turn red. Randomly select the particles to decay. Assume the half-life to be one second initially. Allow the user to change the half life from one to 200 seconds. The particles that have turned red must remain red.
  • Use plotly.js to create a decay graph. The horizontal axis is time and vertical axis is number of undecayed nuclei.
  • Initialise the graph such that the time axis starts at zero and the vertical axis shows 3600 at first.
  • Refresh the particles and the graph every second.
  • Display the numerical value of time and number of undecayed particles in text as well.
  • Add a button to download the data in csv format.

Radioactive decay is a fundamental process in nuclear physics where unstable atomic nuclei lose energy by emitting radiation. This decay occurs randomly for individual atoms, but when observed in a large sample, it follows a predictable statistical pattern described by the half-life, which is the time required for half of the radioactive nuclei in a sample to decay. The half-life is a constant characteristic of each radioactive isotope and is not affected by physical conditions such as temperature or pressure.

The probability of decay for each nucleus per unit time is constant, leading to an exponential decay law. Mathematically, if $N_O$​ is the initial number of undecayed nuclei, the number remaining at time 𝑡t can be described by $N(t) = N_0 \dot (0.5)^{t/T_{1/2}}$, where $T_{1/2}$​ is the half-life. This exponential relationship explains why, after each half-life, half of the remaining radioactive atoms will have decayed. As a result, the decay process continues until all the radioactive material has transformed into stable isotopes.

In our simulation, we model this stochastic process by randomly determining whether each nucleus decays based on the given half-life. Each second, a fraction of the remaining grey particles (representing undecayed nuclei) turn red (representing decayed nuclei), mimicking the random yet statistically predictable nature of radioactive decay. The simulation and accompanying graph provide a visual and quantitative representation of how radioactive substances diminish over time, illustrating the principles of exponential decay and the role of half-life in nuclear physics.

Manometer Simulation using GeoGebra

After trying to create a javascript simulation for the manometer using ChatGPT, I decided to return to GeoGebra, a platform that I am more used to, to create this interactive with more customisation. It comes with a ruler and a self-assessment feature for students to key in the value of pressure.

https://www.geogebra.org/m/qyuncz3h

A U-tube manometer is a fundamental device used to measure pressure differences in fluid systems with simplicity and precision. It consists of a U-shaped tube typically made from transparent glass or plastic, allowing for clear observation of fluid levels within the tube. The tube is partially filled with a manometric fluid such as mercury or water, chosen based on the expected pressure range and application. The manometer has a graduated scale for measuring the height difference between the fluid levels in the two arms of the U-tube. The device is connected at two points where the pressure difference needs to be assessed, such as in gas pipelines, liquid tanks, or other systems requiring pressure monitoring.

When the manometer is connected to the pressure sources, the fluid within the U-tube will adjust its levels until equilibrium is achieved, with one side rising and the other side falling. The difference in height between the two columns of fluid (h) indicates the pressure difference. This difference is read using the graduated scale and is used to calculate the pressure difference (ΔP) with the formula ΔP = ρgh, where ρ is the density of the manometric fluid, and g is the acceleration due to gravity.

U-tube Manometer – a ChatGPT-Generated Simulation

I wanted a simple manometer simulation for the Sec 3 topic of Pressure and decided to try generating one with ChatGPT3.5. The first attempt, using just words, resulted in many errors such as single lines instead of 2D objects being used to represent the tubes and coloured bars that move in the wrong direction.

However, after I switched to ChatGPT4 and uploaded an image for reference, it was then able to produce a proper design consisting of glass tubes and coloured columns that move up and down with pressure changes in a flask. With a bit of UI changes using further prompts, this was the final product.


Link

The following is the screenshot showing the image that was uploaded as well as the initial prompt.

Analogue Meter Template

This GeoGebra applet (https://www.geogebra.org/m/watavkq8) can serve as a template for an analogue meter.

I added a check for the text input so that users have to key in the correct number of decimal places according to the precision of the instrument. For instance, a reading of 1 V should be recorded as 1.00 V and 1.5 V recorded as 1.50 V. Users need to read to half the smallest division, e.g. if the needle is between 2.4 and 2.5, they should input 2.45 V.

Kinematics Graphs with Variable Initial Velocity and Acceleration

I used ChatGPT to create this simple interactive graph. Including the time taken to make 2 rounds of refinement using more prompts and the time it took to deploy it via Github, it took about 15 minutes from start to end.

The first prompt I used was :

Create a graph using chart.js with vertical axis being “displacement / m” and horizontal axis being “time / s”. There should be a slider for the initial velocity value ranging from 0 to 2 m/s, a slider for the acceleration value ranging from -2 m/s^2 to 2 m/s^2. The displacement will start from zero and will follow a function dependent on the initial velocity and acceleration values from the slider. Draw the line of the displacement on the graph. Update the graph whenever the sliders are moved.

The results of the first attempt is shown above. It is already functional, with the initial velocity and acceleration sliders working together to change the shape of the graph.

The function it used to calculate displacement is based on the kinematics equation $s = ut + \dfrac{1}{2}at^2$, written as

    displacement.push(0.5 * acceleration * t * t + initialVelocity * t);

After the first successful attempt, I gave some refinement prompts like:

Show the values of the velocity and acceleration, along with the units.

Use drop-down list to change the vertical axis to velocity or acceleration, updating the axis each time and the curve as well.

So the second attempt looked like this

ChatGPT got 1 out of 2 requests correct. The values of the velocity and acceleration were intended to be displayed next to the sliders. It must have been because I was not clear enough. Hence, the last refinement I asked for was :

Give the codes to show the values of velocity and acceleration next to the sliders. Just those codes.

I didn’t want to get ChatGPT to generate the entire page of html and javascript again so I targetted the specific codes that I needed to change.

It was helpful in telling me where to update these codes. So at the end of the day, this is what was obtained after I made some manual tweaks to change the way the unit is displayed (e.g. m s-2 instead of m/s2):

It was good enough for my purpose now. The web app can be sent to students as a link (https://physicstjc.github.io/sls/kinematics-graph) or embedded into SLS as a standalone app. For use in SLS, do note the following:

  1. The html file must be named index.html
  2. The chart.js file must be copied and saved in the same zipped file at the same level as the index.html file. Change the path of the Chart JS from <script src=”https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.7.0/chart.min.js”></script> to <script src=”chart.min.js”></script>.
  3. For reference, this is what it looks like when zipped.

Delight – a web-based board game on electricity

I had previously shared about this physical board game that I designed to teach electricity concepts. Now, with ChatGPT’s help, I have managed to produce a simple implementation of the board game so that there is no need to print and cut out the pieces anymore.

However, the game is still unable to detect if the light bulb will light up and automatically change the image colour or add the scores. That will require further complex programming due to the many possible outcomes for this game.

https://physicstjc.github.io/sls/delight/index.html

The rules of the game are as such:

  1. Players will take turns to connect their own bulbs to the terminals while trying to sabotage their opponent’s bulbs.
  2. Players will take turns to place one piece on the 4-by-4 game board by clicking to select the electrical component and clicking on the square on the board to place it.
  3. Upon placing the piece, the player can also turn that piece in any orientation (by clicking on it) within the same turn.
  4. Players can choose to use up to two turns at any point in the game to rotate any piece that had been placed by any player.
  5. In other words, each player has 9 turns: 7 placement turns and 2 rotation turns.

At lower levels, students can compete to see who has the most lit bulbs. However, they will need to be able to identify which light bulbs are lit. Do watch out for short-circuits.

At higher levels, students can compete to see whose light bulbs has the most total electrical power, with some calculations involved.