Interactive physics experiments in a virtual laboratory
Author: Jure Repinc, Faculty for mathematics and physics at University of Ljubljana
Mentor: Jason Harris, KDE
KPhysics aims to provide a way to run interactive physics experiments in a virtual laboratory on a computer. For the Google Summer of Code 2006, I will develop the foundation of KPhysics: the engine that performs the simulations and encapsulates of the physical laws. Eventually, I plan to make it easy for users to develop their own experimental setups and plug them into KPhysics. However, in order to work within the time limit of the Summer of Code, I will simply write a few demonstration experiments, as part of the application itself. KPhysics is going to be based on KDE 4 and Trolltech Qt 4 libraries.
Experimentation has always been a crucial part of our understanding of physical science. We are intuitive thinkers, and seeing physical principles in action is often the best way to understand them. However, doing real-world physics experiments can be difficult and expensive. I am proposing to write KPhysics, which will provide an ideal "virtual laboratory" in which students (or teachers) can easily set up and execute a wide variety of physics experiment simulations. The KPhysics simulations will not only be easier to execute than real experiments, they will also be more interactive and tunable. What happens if we double gravity? Or remove friction? The user will be free to explore the parameters of the experiment in a way that reality cannot duplicate.
In order to run simulations a physics engine is needed. The first task is to read the properties of environment in which the experiment takes place and properties of objects involved. Physical laws (in form of several functions) are then applied to the current situation. Parameters, which can be controlled by the user, are also taken into account and a new situation is calculated. These steps are repeated several times with a fixed amount of time between each iteration until a required condition to stop the simulation is met.
To be able to see results from experiments and the engine I will also create a graphical user interface. It will enable users to browse among the available experiments and to run simulations.
My mother language is Slovenian, but I understand English very well too, so the language should not be a problem while communicating with my mentor. So far we have been communicating over the e-mail and I guess we will continue to do so. Maybe we could also use Jabber or something similar in addition.
I plan to work at least 30 hours a week on KPhysics. This is about 4 hours a day. I will try to split this into 2 hours in the morning and 2 hours in the evening. In the mean time I will try to do any non-coding tasks, for example learning.
I will be programming in C++ language and use KDE 4 and Qt 4 libraries. I chose KDE 4 because it will be around for a long time in the future and I would like to learn KDE 4 based programming as much as possible. Another adventage is that it will be available for Windows and Mac OS operating systems for the first time. This means that a lot more people will be able to use KPhysics.
For the physics engine I will try to create several physical objects using , but I understand English very well too, so the language should not be a problem while communicating with my mentor. So far we have been communicating over the e-mail and I guess we will continue to do so. Maybe we could also use Jabber or something similar in addition. There is a 9 hour difference in our local times during the summer so there will not be much opportunity for real-time communication.
I will ask for an account on KDE Subversion server to store the source code for KPhysics. This way my mentor or anyone else will be able to track the progress of development.
I will be programming in C++ language and use KDE 4 and Trolltech Qt 4 libraries. I chose KDE 4 because it will be around for a long time in the future and I would like to learn KDE 4 based programming as much as possible. Another adventage is that it will be available for Windows and Mac OS operating systems for the first time. This means that a lot more people will be able to use KPhysics.
For the physics engine I will try to create several physical objects using classes in C++. For example there would be one superclass named PhysicalObject that would have properties that any other objects have, like position in a coordinate system, mass, speed vector, an array of force vectors acting on the body, and so on. Then I would create subclasses with PhysicalObject as their parent. These subclasses will at first be simple geometrical objects like ElipsoidObject, which would have proprties about their size and orientation that are specific to them.
So basicly I will try to do at least these classes during the summer and use them in sample experiments:
Others will be added if I'll have some time remaning or after the Summer of Code. At first I'll only work with 2D objects in 2D world. And then I will see how it goes and how simple it is to turn this into 3D world (possibly using OpenGL rendering at some later time).
Physical laws will be implemented in form of functions, which I will put in separate files like laws.h and laws.cpp. When the engine will need to calculate new properties for objects it will call these functions (the ones that will be needed) for objects that need to have the properties updated.
This is how I currently imagine the graphical user interface:

![]()

June 1 - start working on the physics engine
June 25 - finish important parts of the physics engine, start working on the user interface
July 25 - finish the rest of the physics engine, finish the user interface, start working on example experiments
August 20 - finish the user interface and example experiments
After Google Summer of Code 2006 is over I would like to make it as simple as possible to create and add experiments. I plan to convert KPhysics into fully framework/plug-in based structure. Another plan is to use XML files or similar way of describing the experiment scene. An application to set up and edit experiment scene description would be nice. Improvements to physics engine are also very important.
I'm a physics student at University of Ljubljana, Slovenia. In addition to physics I've always been interested into computers. That's why I've started learning C++ programming on my own almost three years ago. Now I would like to work on this project that combines programming and physics. I would like to learn more about computer physics simulations. I know physics part very well but I would like very much to learn more about programming with C++, KDE 4 and Qt 4. This is a perfect opurtunity. While working on a project I will also try to use some concepts of extreme programming. I'm especialy interested in using frequent unit testing to maintain quality as high as possible.