/*********************************************************
* Calculate forces balance for ice ball in water
* INPUT:
* r - the ball radius (m)
* h - the height of the cap above the water (m)
* ps - the ball dencity (kg/m^3)
* pf - the seawater's dencity
* RETURN:
* A total force applied to the ball, positive direction is down
*********************************************************/
double ForceBalance(double r, double h, double ps, double pf)
{
const double PI=3.14159265359;
const double G= 9.80665;
double v_ball = 4.0/3.0 * PI * r*r*r; // The volume of the ball
double v_seg = PI*(r*h*h - h*h*h/3); // The volume of the segment above the water
double f = G * (v_ball * (ps-pf) + v_seg*pf);
return f;
}
#ifdef TEST
#include <iostream>
using namespace std;
int main()
{
double r = 1.0;
double h = 0.397;
double ps = 920.0;
double pf = 1025.0;
cout << "The total force applied to the ice ball with radius " << r
<< "m with cape " << h << "m above the water is" << endl;
double force = ForceBalance(r, h, ps, pf);
cout << abs(force) << "N and directed " << (force>0 ? "down" : "up") << endl;
return 0;
}
#endif
Comments
Leave a comment