# Gravitational field of thin 2D ring - numerical simulation

I'm aware of Newton's Shell Theorem, which states that inside of a thin ring of uniform density, the gravitational force exerted on a point mass should be zero.

I wrote a quick field simulation to demonstrate this, but am getting a force inside the ring. The potential (-GM/r) is zero, but the force on a test mass (-GM/r^2) is non-zero.

I'll post the relevant segments of my code below and a few screenshots. Any ideas what's going on?

Each point in the field accumulates the felt gravitational force from all masses comprising the ring (which is a large set of very closely spaced point masses):

void accumulateForce(Mass m){
//Vector from test point towards individual ring mass
double dx = m.x-x;
double dy = m.y-y;

double lenSqd = dx*dx + dy*dy;
double len = Math.sqrt(lenSqd);

//Normalized direction of gravitational force
double nx = dx/len;
double ny = dy/len;

//These variables accumulate the force from all ring masses
fxAccum += nx*bigG*m.m/lenSqd;
fyAccum += ny*bigG*m.m/lenSqd;
}


After this function has been executed for each point mass in the ring, the felt force at that location in the gravitational field is visualized.

Here's what the above code looks like:

When I change the last 2 lines of code to:

fxAccum += nx*bigG*m.m/len;
fyAccum += ny*bigG*m.m/len;


The result is zero potential inside the ring, as expected:

Am I misinterpreting something here? A test mass inside of the ring will be pulled towards the edge. I thought Newton's shell method described zero gravitational force inside of the ring.

• A ring is not a shell. Dec 16, 2015 at 0:54

Newton's shell theorem relies on Gauss's law, which in $d$ spatial dimensions implies a $r^{1-d}$ force law. Since $d=2$, the force should fall off as $1/r$.
This explains why OP's first plot (with an $1/r^2$ code) fails to produce a vanishing interior force, while OP's second plot (with an $1/r$ code) produces a vanishing interior force.