## Monday, November 4, 2013

### Basic Gravity Equations for a Sphere with a Hole in it

For a solid sphere, expressions for the gravity inside and outside of this body are fairly easy to find online.  That is (4/3) G Pi rho r within it, and G M / r^2 outside of it.  Now cut out a sphere in the center of this sphere, and replace it with empty space.  The gravity in this case will not be linearly increasing, and this result took some work for me to figure out.  The most simple correct approach is to subtract gravity from the removed sphere, which is using the principle of superposition.  This is straightforward algebra, so I've put that in the following equation, and a comprehensive roundup of the gravitational field forms inside the hole, in the shell, and outside it all.
• solid: the entire sphere without the hole cut out
• hole: the spherical region in the center that is cut out
• shell: the points within the solid sphere that is not in the cut out region
• R: the radius of the inner sphere cut out
• t: the difference between the original sphere's radius and the hole radius

Gravitational Field for Solid Sphere with Hole in Center

Since it's what I'm interested in, I derive the pressure of the center cavity due to hydrostatic force from the shell's weight.  The principle is that height time field equals gravitational potential.  Since the field is constantly changing here, we integrate that, but only do it in the shell region because it's the only area that has a non-zero density.

Getting Pressure from the Field

This is the most important equation related to a gravity balloon, since it quantifies the pressure with respect to the other physical parameters.  However, this form isn't necessarily the most useful possible combination.  For any given body, we would like to presume that we're starting out with the mass value because there's only so much matter in that place to work with.  That makes the task a little more computationally difficult.  To do this, we introduce a mass balance equation.  This is nothing more than a geometric statement, with calculation of the volume of the shell.

Pressure and Mass Equations

These give two equations with 5 variables.  In any case, we're probably going to know the density.  That leaves 4 variables and 2 equations, for 2 degrees of freedom.  For instance, these could be satisfied by specifying what mass you start with and then how much of an inner radius you excavate.  That will then return a pressure.  Alternatively, maybe we query what radius we can get with a given asteroid, assuming that we want Earth sea level pressure.  That case can present some difficulty since there is no answer when the mass is below a certain value.

I've addressed several combinations of values.  The governing equations can be rearranged quite simply for several cases to get an explicit function.  This is done in a simple form for the pressure and mass equations individually, and then in combination between them.  Two functions are then left which can't be found except for with a cubic formula application (or worse), so these are left as implicit functions.

Function Set

All of the above about directly implimentable, except for the fact that the implicit functions need a solver in order to work.  I found Newton's method to be the ideal option for this.  The challenge is keeping the convergence in check, but that's workable since these functions are relatively simple.  Implicit solves are often somewhat of an art form.

The thickness of the shell (variable t) demonstrates a behavior where it remains in a definable range for the small and large cases.  This is useful to set a guess at the start of Newton's method, as a simple average of those two limit cases are used.  For the guess of the radius (looked up by pressure and mass), a similar type of trick is used.  A limit case of thickness is put into the equation for radius, and that gives a value.  We want to over-estimate the radius because we don't want it to ever go negative.

Guesses for Variables in the Implicit Solves

In my formulation, the functions don't start out as a root find, so the objective value (for instance, of pressure) is subtracted from the listed function, which doesn't affect the derivative.  The derivates can be found algebraically fairly easily, but there's a complication in the case of R_MP.  That is a root find on a function which takes the output of another function as an argument.  That requires application of the chain rule for differentiation, but the exact way it plays out is a little bit complicated.

Multivariate Chain Rule with Composite Function

That pretty well covers everything needed to get correct and efficient implimentation of lookups for a gravity balloon.  The total list of functions are:
• dPdR_RM (R , M , rho )
• dPdR_Rt (R , t , rho )
• dPdt_Rt (R , t , rho )
• dtdR_RM (R , M , rho )
• M_RP (R , P , rho )
• M_Rt (R , t , rho )
• P_RM (R , M , rho )
• P_Rt (R , t , rho )
• R_MP (M , P , rho )
• R_Mt (M , t , rho )
• R_Pt (P , t , rho )
• t_RM (R , M , rho )
• t_RP (R , P , rho )

As a side note, you need functions for the gravitational constant, G.  Also pi.  I implimented all of this, and put the code here:

The Visual Basic (for Excel) code link on Pastebin

This post covers the basic mathematics that underpin the entire idea.  I wanted to make this one technical post in extreme detail because I had these equations wrong before, so this is a correction of some of the things posted in this blog, although not everything.  I had made the wrong assumption that gravity within the shell would be linear, and this is demonstrably false by a couple of arguments.  I have good confidence in the equations here, and the functions seem to perform rather well to the extent of my testing so far.  It's good to have this documented well, because it forms the starting point for all of the rest of the discussions.