Skip to content

A Java port of a high school physics computing project. The original source code was in Processing. Simulations include circular orbits around the sun, general orbits around the Earth and the Doppler effect.

License

Notifications You must be signed in to change notification settings

shermanlo77/physicssim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

physicssim

MIT License

Copyright (c) 2008-2021 Sherman Lo

A Java port of a high school physics/computing project. The original source code was in Processing.

How to use

Download from the .jar file from the release or compile it using the instructions below. Call the .jar file using

java -jar physicssim-1.0.0-jar-with-dependencies.jar -option

where -option can be one of the following options below.

-orbit Planetary Orbit

This simulation simulates planets orbiting the sun and it explains about circular motion and how it is used to derive one of Kepler's law.

-satellite Satellite Manoeuvres

This simulation simulates satellites being affected by the Earth's gravitational field and derives equations for gravitational force, field strength and potential.

-doppler Doppler Shift

This simulation simulates electromagnetic waves being emitted from a moving source and derives equations for the Doppler Shift.

How to compile (Linux recommended)

Maven required.

Clone this repository.

Go to the repository and run

mvn package

and the .jar files are located in target/.

-orbit Planetary Orbit

The simulation simulates planets orbiting a sun.
This simulation assumes that:

  • All planetary orbits are perfectly circular and obeys Kepler's laws
  • Only the orbital speed changes and the radius of the orbit is kept the same when the mass of the sun changes
  • All planets are particles and have no mass or dimensions
  • Planets can pass through each other

Interface

Interface

The interface in this simulation consist of two sides, the left hand side shows the simulation and the right hand side shows the control panel. The status bar on the browser displays the frame rate the simulation is performing, a frame rate of 60 is considered satisfactory.

Simulations functions Diagram
Left click to create an anti-clockwise orbiting planet.
Right click to create a clockwise orbiting planet.

Control panel functions Diagram 1 Diagram 2
Radius

The distance between the mouse and the centre of the sun is displayed as shown in the diagram 1.

Diagram 2 shows how the distance is measured.
Mass of the sun

The mass of the sun is as shown in diagram 1.

It can be edited as shown in diagram 2, click on it and press backspace to delete the variable. Press the number keys to change the variable. Hit enter to return the variable.
Data display

The display data drop down menu, diagram 1, allows selected data of each planet to be shown, diagram 2, from the following:-
  • Radius of orbit
  • Orbit speed
  • Centripetal acceleration
Time scale

The time scale is as shown in diagram 1.

It can be edited as shown in diagram 2, click on it and press backspace to delete the variable. Press the number keys to change the variable. Hit enter to return the variable.
Pause/play button

The pause/play button will pause or unpause the simulation.
Reset button

The reset button will reset the simulation to its initial state.
Change colour button

The change colour button changes the colour scheme of the simulation from a selection of :
  • Black
  • White
  • Blue

Background physics

One of Kepler's laws state that the time of obit squared is directly proportional to the average radius of the orbit cubed, ie . Sir Isaac Newton proved this law by using his equation of circular motion with the equation for gravitational force.

This simulation's algorithm is somewhat based on Kepler's law but it is mainly based on Newton's equation of circular motion to find the angular velocity. The angular velocity is then used to change the angular displacement of each planet.

So using the equation , the angular displacement of each planet is updated.


Scientific FAQ

  • Why can't you change the mass of the planet?
    • The orbital speed does not depend on the mass of the planet, therefore it is not necessary to change the mass of the planet.

  • Can this simulation be used to model the solar system?
    • Yes but only the inner solar system planets can be used in this simulation. This is because the scale of the whole of the solar system is so huge that it is impractical to model this.

  • What should happen if the mass of the sun changes?
    • If the sun gains mass, it will have more gravitational force which will pulls the planets towards the sun. However as the planets are pulled towards the sun, the planets will convert its gravitational potential energy to kinetic energy and so gain velocity therefore will still be in orbit.
    • However if the sun loses mass, each planet will have less gravitational potential energy as a result of the sun having less gravitational force. Each planets' total energy will increase because of this so each planet may either increase the radius of its orbit or speed up.
    • If the mass of the sun suddenly becomes really small, each planet would travel in a straight line tangent to its orbit at that time.
    • The reason why this simulation is to assume the radius of each orbit is fixed is to simplify the simulation and fully focus on circular orbit.

  • Are planetary orbits perfectly circular?
    • No and it doesn't need to be. Most are actually elliptical because planets have orbital speeds slightly different from what is required for a perfect circular orbit.

Technical FAQ

  • Why can't I create a planet close to the sun?
    • This simulation won't let you create a planet with an orbit of radius less than 16x10⁹ m.

  • How do I change the mass of the sun or the time scale?
    • Click on the number box and it should change colour. Press backspace to delete the digits and type in the desired value by typing in the number keys on the keyboard then press enter. If you have made a mistake, press the backspace button.

  • How do you see the data for each planet?
    • The display data drop down menu can be opened by clicking on it. Select the data to be seen by clicking on the options of data.

  • What's the maximum number of planets which can be created?
    • There is no limit to how many planets can be created however the simulation will slow down if too many are created.

-satellite Satellite Manoeuvres

This simulation simulates satellites being effected by the Earth's gravitational field.
This simulation assumes that:

  • Each satellite is treated as a particle and has no mass or dimensions
  • Total energy is not lost when moving in space
  • Satellites can pass through each other

Interface

Interface

The interface in this simulation consist of two sides, the left hand side shows the simulation and the right hand side shows the control panel. The status bar on the browser displays the frame rate the simulation is performing, a frame rate of 60 is considered satisfactory.

Simulations functions Diagram 1
Left click and drag to create the initial velocity vector of the satellite.
Release the mouse after dragging to create the satellite. The satellite will create a trail of white dots during its orbit.

Control panel functions Diagram 1 Diagram 2
Initial velocity vector information

The initial velocity vector is created when the mouse is dragged as shown in Diagram 1.

Diagram 2 shows the information of the initial velocity vector.
Mass of the Earth

The mass of the Earth is shown as shown in diagram 1.

It can be edited as shown in diagram 2, click on it and press the number keys to change the variable. Hit enter to return the variable.
Force lines

Force lines shows the lines of force as displayed in diagram 1.

It can be selected in the drop down menu as shown in diagram 2.
Equipontentials

Equipontentials shows where gravitational potential is the same as shown in diagram 1. Each equipontential shows increments of 1 x10⁶ J.kg¯¹.

It can be selected in the drop down menu as shown in diagram 2.
Time scale

The time scale is shown as shown in diagram 1.

It can be edited as shown in diagram 2, click on it and press the number keys to change the variable. Hit enter to return the variable.
Pause/play button

The pause/play button will pause or unpause the simulation.
Reset button

The reset button will delete all satellites in the simulation.
Change colour button

The change colour button changes the colour scheme of the simulation from a selection of :
  • Black
  • White
  • Blue

Background physics (Gravitational force)

One of Sir Isaac Newton's law is the inverse square law. It says that the force from a source is proportional to one over r squared, ie ; this is because the lines of force spread out and the area it affects increases quadratically.

The image above shows the lines of force being spread out, creating a field. The area which is affected by the force is the distance from the force squared. Also the force decreases as it moves away from the source and hence explains why the proportionally is an inverse.

Gravitational force obeys Newton's inverse square law because the lines of gravitational force also spreads out. From this it is possible to derive an equation for gravitational force, between mass M and m, and acceleration due to gravity if all mass has a gravitational force.

Where G is the gravitational force constant 6.67 x10¯¹¹ N.m².kg¯² and g is the gravitational field strength or the acceleration due to gravity.

This simulation uses this equation but resolves them into vector components to make calculations easier for the computer.

Background physics (Gravitational potential)

Gravitational potential energy is the work done against gravity. Using the equation work = Fx and F = mg, the equation for gravitational potential energy can be derived.

This equation is fine for small changes of the height because the value of g, the gravitational field strength, is almost always constant. However once height has increased so much, the value of g will change a lot at different distances from the Earth so this equation becomes invalid. To derive a new equation by considering the change in the gravitational field strength over large distances, the equation for the gravitational field strength derived from Newton's inverse square law is substituted into the equation for gravitation potential energy.

Objects going through a change in distance from the Earth will have a change in gravitational potential and this change will change the kinetic energy of the object.

Notice there is a slight similarity with the equation for gravitational potential and the gravitational field strength, only the power of r is different. From this, calculus can be used to find the relationship between gravitational potential and gravitational field strength.

From this it is derived that the gravitational field strength is the change in gravitational potential over the change in distance. In other words the gradient of the graph is the gravitational field strength as shown below.

Using integration, more relationships can be derived.

From this the change in gravitational potential is the area between the curve , the x axis and the two values of r as shown below.

Scientific FAQ

  • What are equipontentials?
    • They are lines where the gravitational potential are the same, they can be compared as contour lines in a geographical map. The closer the equipontentials are, the more change in gravitational potential there which means more gravitational field strength hence more acceleration.
    • By drawing the equipontentials, the simulation looks like a 'well' so a cross of it will look like a curve. The steepness of the curve is actually equal to the acceleration due to gravity.

  • How do you make a satellite orbit?
    • For a circular orbit its initial velocity must be perpendicular to the radius of the Earth, ie 90 degrees, and the magnitude must equal to the speed required for circular orbit depending on the mass of the earth and the distance from the centre of the earth.
    • If the initial velocity is slightly different from what is required for circular orbit, its orbit could be elliptical.

Technical FAQ

  • How do I change the mass of the Earth or the time scale?
    • Click on the number box and it should change colour. Type in the desired value by typing in the number keys on the keyboard then press enter. If you have made a mistake, press the backspace button.

  • What's the maximum number of satellites which can be created?
    • There is no limit to how many satellites can be created however the simulation will slow down if too many are created.

  • How do you see the force/equipotential lines?
    • The display lines drop down menu can be opened by clicking on it. Select the lines to be seen by clicking on the type of lines to be displayed.

-doppler Doppler Shift

This simulation models electromagnetic waves being emitted from a moving source. Each wave front is represented as a line. Because this is a model, the frequency of the wave front emitted is not to scale.

Interface

Interface

The interface in this simulation consist of two sides, the left hand side shows the simulation and the right hand side shows the control panel. The status bar on the browser displays the frame rate the simulation is performing, a frame rate of 60 is considered satisfactory.

Simulations functions Diagram 1
The source of radiation is represented as a green spot.
Wave fronts are represented as lines. This is where a part of the wave goes through one full phase rotation.

Control panel functions Diagram 1 Diagram 2
Speed of the source

The speed of the source over the speed of light is as shown in diagram 1.

It can be edited as shown in diagram 2, click on it and press the number keys to change the variable. Hit enter to return the variable.
Wavelength of the magnetic radiation

The wavelength of the magnetic radiation is as shown in diagram 1.

It can be edited as shown in diagram 2, click on it and press the number keys to change the variable. Hit enter to return the variable.
Relativistic factor

The relativistic can be considered or ignored in this simulation by turning it on or off. The value of the relativistic factor is as shown in diagram 1.

It can be turned on or off in the drop down menu as shown in diagram 2.
Stretched wavelength

The length of the stretched wavelength is as shown in diagram 1.
Start/stop button

The start/stop button will start or stop the simulation.
Pause/play button

The pause/play button will pause or unpause the simulation.
Change colour button

The change colour button changes the colour scheme of the simulation from a selection of :
  • Black
  • White
  • Blue

Background physics

The Doppler effect or Doppler shift is the result of a wave emitting source to move causing the wavelength of the wave to stretch or compress. Waves being stretched are known to undergo red shift as their wavelengths has increased towards the red end of the spectrum. The factor of Doppler shift can be derived as shown below.


The equation derived is know as the Doppler shift factor and it is used to work out how much the wavelength has been stretched. Notice v has to be much smaller than c because time dilation happens when approaching the speed of light, this is where the rate of time slows down so the waves rotating phasors rotate slower and so their wavelengths are stretched even more. The Doppler shift factor ignores time dilation so v has to be smaller than c for the factor to work.

To work out how long is the stretched wavelength considering time dilation, the relativistic factor is used and it is to be multiplied to the length of the overall stretched wavelength worked out by using the Doppler shift factor as shown below.

The simulation also uses the same equation as above to work out the length of the stretched wavelength. Try and get the same results using your calculator.

Scientific FAQ

  • What so important about the Doppler Shift?
    • It is important because ALL galaxies emit red shift or waves which are stretched. This means all galaxies are moving away from us and using the Doppler Shift factor enable us to work out how fast they are receding away from us.
    • Because all galaxies are receding away from us it meant all the galaxies came from one place so the Big Bang theory was concluded.

  • Why is time dilated when approaching the speed of light?
    • Time dilation is the result of the speed of light always being constant no matter the velocity of the observer is.

  • What is the point of turning the relativistic factor on and off?
    • It helps you to compare how much the relativistic factor has an effect on the stretched wavelength when approaching the speed of light. By entering v/c = 0.99 into the simulation, the value of γ reaches a magnitude of 7!

Technical FAQ

  • Why won't the simulation start?
    • You need to press the Start/Stop button to start the simulation.

  • How do I change the variables in the control panel?
    • Click on the number box and it should change colour. Type in the desired value by typing in the number keys on the keyboard then press enter. If you have made a mistake, press the backspace button.

  • Why is my calculator result slightly different from the simulation result?
    • Sometimes there will be a rounding error when the simulation converts binary to deanery. If your answer is around the same magnitude, you more or less have the correct answer.

About

A Java port of a high school physics computing project. The original source code was in Processing. Simulations include circular orbits around the sun, general orbits around the Earth and the Doppler effect.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages