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.