Home : Map : Chapter 3 : Java : Tech : Physics :
Object Oriented Programming in Physics
JavaTech
Course Map
Chapter 3

Introduction
Class Definition
Data Fields
Methods
Constructors
Instantiation
  
Demo 1
  Demo 2
Static Members
  Demo 3

Value&Reference
  Demo 4
Overloading
   Demo 5
Wrappers 
  Demo 6
Autobox/Unbox
   Demo 7
Arrays
  Demo 8
Exceptions
Exercises

    Supplements
MoreAboutObjects
Creating Types

Classes,Objs&JVM

Java OOP vs C++
Garbage Collection
     About JavaTech
     Codes List
     Exercises
     Feedback
     References
     Resources
     Tips
     Topic Index
     Course Guide
     What's New

Physics involves the search for the fundamental principles and components of the universe. So it generally follows a reductionist approach that studies a complicated phenomena by breaking it up into its smallest parts and determining how these much simpler entities work. Then from an understanding of these parts comes a better understanding of the collective behavior of large systems.

(Of course, this doesn't lead to accurate predictions of the weather! Emergent properties of highly complex systems are usually best studied at the macroscopic level.)

So the object approach to programming seems quite a good match for physics simulations. Whether we simulate fundamental particles or whole planets, we often deal in physics with both conceptual and tangible objects that possess distinct self-contained properties and interact according to a theoretical description of those properties. We can typically use numerical methods to solve the equations in that theory even when they don't have an analytical solution.

Granularity

A primary issue in designing a physics simulation is the granularity. At what scale will the simulation take place. This obviously affects what objects we seek to describe in our simulation.

For example, in principle a planetary orbit simulator could follow the motions of all the atoms that make up the sun and planets. Of course, that is neither practical or useful. An orbital simulation usually works fine if the planets, moons, and other cosmic bodies are each described as an individual point objects.

However, to study, say, tidal effects, a planet must be described as extended object and perhaps the surface could be approximated with a tilework of objects composing the outer layer of the planet. Then you must decide what width and thickness to make those surface objects.

Similarly, a simulation of a particle detector in a high energy physics experiment could follow a range of scales. At the most coarse level, the whole detector could simply be assigned a single efficiency value (say it detects 95% of the particles that traverse it). But that could ignore big variations in efficiencies between the edges and the center of the detector. Perhaps it has dead spots where support structures are located.

At the other extreme, one could attempt to simulate the details of the interactions of a particle traversing the detector with all the particles that make up the detector. For example, in a proportional counter a charged particle passing through will ionize some of the atoms in a gas. These freed electrons will follow a high voltage electric field to an anode wire, which is attached to a high gain amplifier that detects the small increase in charge on the wire.

All of this might be simulated (and this has in fact been frequently done for such detectors) but it would required considerable computation time for each "event", especially since up to thousands of partiles per collision may traverse the detector. Usually, a detailed simulation is done when designing and testing the detector. Then a coarse simulation, which matches roughly well to the detailed simulation, is used when doing the simulation of the particle experiment so that it can generate large statistics in a short time. This simulated data will produce smooth curves with which to compare the real data.

So when designing the program, you must consider carefully the scale that will be simulated and what parts most naturally fit into object descriptions.

 

Latest update: Dec.15.2003

           Tech
OOP in Tech Apps
Complex Number
Histogram Class
  Demo
More Wrappers

           Physics
OOP in Physics
Particle Class
Root Finding
  Demo 1
Newton Methods
  Demo 2
Exercises

  Part I Part II Part III
Java Core 1  2  3  4  5  6  7  8  9  10  11  12 13 14 15 16 17
18 19 20
21
22 23 24
Supplements

1  2  3  4  5  6  7  8  9  10  11  12

Tech 1  2  3  4  5  6  7  8  9  10  11  12
Physics 1  2  3  4  5  6  7  8  9  10  11  12

Java is a trademark of Sun Microsystems, Inc.