Other force laws

So far in this chapter, we have discussed physical forces that actually exist in nature. But there is no reason why we cannot invent our own. Because our main purpose is to play around with forces and their effects, we don't have to be limited by reality. In the next few sections, we'll introduce different force laws and see what they can do. Feel free to create your own!

Central forces

A central force is one that satisfies the following two conditions:

  • The magnitude of the force depends only on the distance from a given point.
  • The direction of the force is always toward that point.

Newtonian gravity, electrostatic forces, and spring forces are all examples of central forces. Mathematically, the above two conditions can be combined to give the force vector at any point P as follows, where ru is a unit vector of the point P from the force center, r is its distance from that center, and f(r) is a function of r:

Image

As you already know, for gravity and electrostatic forces, f(r) is proportional to 1/r2:

Image

This is usually referred to as an inverse square law. Ever wondered what things would be like if gravity obeyed a different law—for example, an inverse 1/r or an inverse cube 1/r3 law? Well we can easily find out by creating a modified force function for gravity. But rather than create special functions for these different cases, let's create a general central force function that varies according to the following, where both k and n can be positive or negative:

Image

This gives the following vector form:

Image

Or equivalently:

Image

If k is positive, the force is repulsive (because it is in the direction of r); if k is negative, the force is attractive (because it is in the opposite direction from r). If n is positive, the force increases with distance; if n is negative, the force decreases with distance.

Examples include the spring force law, for which k is negative and n is 1; and gravity, for which k is negative and n is –2. The constant k is usually related to some property of the particle (for example, mass or charge).

Let's add a central force function to the Forces class:

static public function central(k:Number,n:Number,r:Vector2D):Vector2D {
        return r.multiply(k*Math.pow(r.length,n-1));
}

The following code, CentralForces.as, sets up a particle that will be subjected to a central force through the CentralForcer() class:

package{
        import flash.display.Sprite;
        import com.physicscodes.math.Vector2D;
        import com.physicscodes.objects.Ball;

        public class CentralForces extends Sprite{
                public function CentralForces():void{
                        init();
                }
                private function init():void{
                        var center:Ball;
                        center = new Ball(2,0x000000);
                        center.pos2D = new Vector2D(400,300);
                        addChild(center);

                        var particle:Ball;
                        particle = new Ball(5,0xff0000,1);
                        particle.pos2D = new Vector2D(300,300);
                        particle.velo2D = new Vector2D(0,-20);
                        addChild(particle);

                        var timeStep:Number = 10;
                        var forcer:CentralForcer=new CentralForcer(particle,center);
                        forcer.startTime(timeStep);
                }
        }
}

And here is the code for CentralForcer.as:

package {
        import com.physicscodes.motion.Forcer;
        import com.physicscodes.motion.Forces;
        import com.physicscodes.objects.Ball;
        import com.physicscodes.math.Vector2D;
        import com.physicscodes.math.Graph;

        public class CentralForcer extends Forcer{

                private var _particle:Ball;
                private var _center:Vector2D;
                private var _graph:Graph;
                private var _stageWidth;
                private var _stageHeight;
                private var _k:Number=-10;
                private var _n:Number=0.5;

                public function CentralForcer(pparticle:Ball,pcenter:Ball):void{
                        _particle = pparticle;
                        _center = pcenter.pos2D;
                        _stageWidth = _particle.stage.stageWidth;
                        _stageHeight = _particle.stage.stageHeight;
                        setupGraph();
                        super(pparticle);
                }

                override protected function calcForce():void{
                        var r:Vector2D = _particle.pos2D.subtract(_center);
                        force = Forces.central(_k,_n,r);
                }

                override protected function moveObject():void{
                        super.moveObject();
                        plotGraph();
                }

                private function setupGraph():void {
                        _graph= new Graph(0, _stageWidth, 0, _stageHeight, 0, 0,Image
_stageWidth, _stageHeight);
                        _particle.stage.addChild(_graph);
                }
                private function plotGraph():void{
                        _graph.plot([_particle.xpos], [-_particle.ypos],0x666666,Image
false, true);
                }

        }
}

Nothing exceptional here. We are applying a central force to the particle in calcForce() and then plotting its resulting trajectory as before. You can experiment with different values for k and n, as well as different initial positions and velocities for the particle.

Can you always make a particle follow a closed orbit with an attractive central force (negative k)? We already know this is possible for a f(r) = k/r2 law (for example, gravity) and a f(r) = kr law (springs). But what about other force laws, such as f(r) = k/r or f(r) = r3? Try it out and see for yourself!

As an example, with the following initial conditions, and with (k = –1, n = 1), a spring-like force, you get an elongated closed orbit:

center.pos2D = new Vector2D(400,300);
particle.pos2D = new Vector2D(200,300);
particle.velo2D = new Vector2D(0,-20);

With (k = –100000, n = –2), a gravity-like law, you also get a closed elliptical orbit. But with (k = –1000, n = –1), a 1/r law, you get a flower-like trajectory that does not close on itself (see Figure 10-8); it is a bound orbit, but not a closed one. And with a 1/r3 law you get trajectories that either spiral in or spiral out, but do not close: they are neither closed nor bound. Note that the magnitude of k needs to be adjusted depending on the value of n to produce displacements of the right magnitude to fit on the stage.

There is actually a mathematical theorem called Bertrand's theorem that says the only central force laws that give closed orbits are f(r) = k/r2 and f(r) = kr laws. Lucky for Earth (and us!) that gravity is a 1/r2 law!

In spite of the last statement, it turns out that closed circular orbits exist, as a special case, for all attractive central forces if you have just the correct tangential velocity. It's easy to work out the velocity needed for that: just equate the force law with the formula for centripetal force, where m is the mass of the particle:

Image

Solving for v gives this:

Image

You can test this formula with the simulation. It should work for any value of n, provided that k is negative.

Image

Figure 10-8. Trajectory traced by a particle in a 1/r force field

Gravity with a spring force law?

Can you imagine what the universe would be like if gravity obeyed a different force law, for instance a spring force law? Well, let's find out!

SpringGravity.as sets up a bunch of particles with random positions and velocities and puts them in an array called particles. It then creates a Ball object called center that will act as a gravitational attractor and gives it a mass of 1 and a charge of 1. Both particles and center are then passed to a SpringGravityForcer instance:

package{
        import flash.display.Sprite;
        import com.physicscodes.math.Vector2D;
        import com.physicscodes.objects.Ball;

        public class SpringGravity extends Sprite{
                public function SpringGravity():void{
                        init();
                }
                private function init():void{
                        var numParticles:Number=100;
                        var vmax:Number=100;
                        var particles:Array = new Array();
                        for (var i:uint=0; i<numParticles; i++){
                                var particle:Ball;
                                particle = new Ball(4,0x000000,1);
                                particle.pos2D = new Vector2D(Math.random()*Image
stage.stageWidth, Math.random()*stage.stageHeight);
                                particle.velo2D = new Vector2D((Math.random()-0.5)*vmax,Image
(Math.random()-0.5)*vmax);
                                addChild(particle);
                                particles.push(particle);
                        }

                        // spring force kr
                        var center:Ball;
                        center = new Ball(20,0xff0000,1,1);
                        center.pos2D = new Vector2D(400,300);
                        addChild(center);

                        var timeStep:Number = 10;
                        var forcer:SpringGravityForcer=new SpringGravityForcer(particles,Image
center);
                        forcer.startTime(timeStep);
                }
        }
}

SpringGravityForcer.as is pretty simple. It extends MultiForcer because there's a bunch of particles to move. The calcForce() method basically computes a central force, using k = –GMm, where the gravitational constant G = 1, M is the mass of the center; and m is the mass of the relevant particle (all 1 here). Note that we've stored the value of n in the charge property of center. There's no reason why we can't do that because we won't use charge here. Now because k is negative and n = 1, we have a spring force. We've created spring-force gravity!

package {
        import com.physicscodes.motion.MultiForcer;
        import com.physicscodes.motion.Forces;
        import com.physicscodes.objects.Particle;
        import com.physicscodes.objects.Ball;
        import com.physicscodes.math.Vector2D;

        public class SpringGravityForcer extends MultiForcer{

                private var _center:Ball;
                private var _G:Number=1;

                public function SpringGravityForcer(pparticles:Array,pcenter:Ball):void{
                        _center = pcenter;
                        super(pparticles);
                }

                override protected function calcForce(pparticle:Particle):void{
                        var k:Number = -_G*_center.mass*pparticle.mass;
                        var n:Number = _center.charge;
                        var r:Vector2D = pparticle.pos2D.subtract(_center.pos2D);
                        force = Forces.central(k,n,r);
                }
        }
}

Run the code to get an interesting insight into what life might be like with gravity obeying the spring force law. You'll see that all the particles are pulled toward the center undergoing some kind of oscillation (see Figure 10-9). If you increase the value of the velocity coefficient vmax, say to 1000, the particles will move about more, but will still be pulled into this oscillatory motion.

Image

Figure 10-9. Modeling gravity with a spring force

Multiple attractors with different laws of gravity

In our final example, FieldForcer.as, we'll combine central forces with different values of k and n to produce a complex force field. This is a universe in which different attractors exert gravity according to different force laws.

Here is the code in FieldForcer.as:

package{
        import flash.display.Sprite;
        import com.physicscodes.math.Vector2D;
        import com.physicscodes.objects.Ball;

        public class ForceFields extends Sprite{
                public function ForceFields():void{
                        init();
                }
                private function init():void{
                        var numParticles:Number=100;
                        var vmax:Number=20;
                        var particles:Array = new Array();
                        for (var i:uint=0; i<numParticles; i++){
                                var particle:Ball = new Ball(4,0x000000,1);
                                particle.pos2D = new Vector2D(Math.random()Image
*stage.stageWidth, Math.random()*stage.stageHeight);
                                particle.velo2D = new Vector2D((Math.random()-0.5)*vmax,Image
(Math.random()-0.5)*vmax);
                                addChild(particle);
                                particles.push(particle);
                        }

                        // k/r force
                        var center1:Ball = new Ball(20,0xff0000,1000,-1);
                        center1.pos2D = new Vector2D(200,500);
                        center1.velo2D = new Vector2D(10,-10);
                        addChild(center1);
                        center1.move();

                        // k/r2 force
                        var center2:Ball = new Ball(20,0x00ff00,100000,-2);
                        center2.pos2D = new Vector2D(500,100);
                        addChild(center2);

                        // k/r3 force
                        var center3:Ball = new Ball(20,0x0000ff,10000000,-3);
                        center3.pos2D = new Vector2D(600,300);
                        addChild(center3);

                        var timeStep:Number = 10;
                        var forcer:FieldForcer=new FieldForcer(particles, [center1, center2,Image
center3]);
                        forcer.startTime(timeStep);
                }
        }
}

As in SpringGravity.as, we set up a bunch of particles and give them random positions and velocities. Then we set up three attractors called center1, center2, and center3 and give them masses of 1000, 100000, and 10000000; and charges of –1, –2, and –3, respectively. As in the last example, the values of the charges are used to store the values of n, the central force law index. This means that the attractors will exert 1/r, 1/r2, and 1/r3 force laws, respectively. We also give center1 a non-zero velocity and make it move by invoking the move() method.

The simulation is driven by a FieldForcer class instance, which looks as follows:

package {
        import com.physicscodes.motion.MultiForcer;
        import com.physicscodes.motion.Forces;
        import com.physicscodes.objects.Particle;
        import com.physicscodes.objects.Ball;
        import com.physicscodes.math.Vector2D;

        public class FieldForcer extends MultiForcer{

                private var _centers:Array=new Array();
                private var _G:Number=1;

                public function FieldForcer(pparticles:Array,pcenters:Array):void{
                        _centers = pcenters;
                        super(pparticles);
                }

                override protected function calcForce(pparticle:Particle):void{
                        var central:Vector2D;
                        force = Forces.zeroForce();
                        for (var i:uint=0; i<_centers.length; i++){
                                var center:Ball=_centers[i];
                                var k:Number = -_G*center.mass*pparticle.mass;
                                var n:Number = center.charge;
                                var r:Vector2D = pparticle.pos2D.subtract(center.pos2D);
                                if (r.lengthSquared > Math.pow(center.radius,2)){
                                        central = Forces.central(k,n,r);
                                }else{
                                        central = Forces.zeroForce();
                                }
                                force = Forces.add([force, central]);
                        }
                }

        }
}

This is similar to the last example, except that we now have an array of attracting centers (see Figure 10-10), so we sum the central force that each exerts in a for loop in calcForce(). Note that we are setting the force to be zero if a particle happens to be within a center. This is to improve the visual effect. After all, it's a universe of our own creation, so we can do whatever we want, can't we?

Image

Figure 10-10. Particles moving in a field composed of different central forces

If you run the code, you'll see that most of the particles gravitate around the center that exerts the 1/r force. As it moves along, it captures more particles. The gravity of this attractor dominates because a 1/r force is a longer-range force than a 1/r2 or a 1/r3 force: it decays less rapidly with distance. The attractor that exerts the 1/r3 force holds onto very few particles: its influence decays very rapidly with distance.

There are tons of other things you could try; for example, make the attractors move in more complicated ways (for example, orbit a center or move around and bounce). You could add more attractors or include antigravity. Your imagination is the limit.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.57.43