Advertisement

buoyant force total madness

Started by July 03, 2015 10:42 PM
27 comments, last by _WeirdCat_ 9 years, 6 months ago

POST ABOVE WAS EDITED

[spoiler]

[/spoiler]

i dont get that completely when i add drag force which is (-normalize(vel) * length(vel)*length(vel)) * (float DynPressure = (0.5*(v*v)*dens*100.0); ) where dens is constant dididnt change almost anything, when applying dens from 1.125 kg/m3 to 999.1026 kg/m^3 when ships volume is submerged just shits up everything and after time (when ship gets wrap speed in opposite direction of initial movement lets say (v = 0.0, 0.0, 12.0)

it goes backward reaches 10000000000 (big number) m/s after second or third call and then NaN so i didint apply it above.

so yes i added drag force with a drag coeff 1.0 as conbstant and density varying if volume is in air or ( if even a little bit submerged ) in water

air 1.125 kg/m^3

water 999.1026 kg/m^3

How large is your delta time? The motion on the video does not seem very smooth, if the dt is very big you might get some error because of that (since you are doing a discrete simulation with no proper integration as far as I can see, which has potentially large error, especially if working with forces whose magnitude changes greatly with space/velocity like dampening or boyancy might)

Especially high drag and large dt will cause velocity to quickly oscillate and energy introduced to the system out of nowhere so it explodes.

Theres probably plenty of material on how to simulate a stable dapmened spring oscillator (similar to what youre doing), but perhaps you can for now try clamping the dampening so it will never be higher than the ship velocity?

So the dampening can never reverse ship direction, only either slow it down, or stop it completely. Not go in opposite direction.

o3o

Advertisement

yeah i did that without any results too tongue.png additionally i found working code where i put my own values that means mass 120 000 kg displacement volume = 1220 m*3

and setting such parameters just kills working simulation lol! moreover it behaves exactly like mine? wtf?

i set dt to 0.033 constant for

hold on that requires 2 videos or more ;p

here

time is a constant

per every frame: time = time + 0.0330;

one without any drag force

here with drag force + manuall velocity dumper (when i click i set vel to 0,0,0 and screen changes) - both linear and angular

after about 50% i didint dump the vel / if i dont tap at all the sim behaves like that in first vid

one question for now do i have to check only 4 boxes that cover whole model area or can i use 8 for calculation of torques and linear acc?

I noticed i have problem with torque and rotations all along with wrong calculated drag

this is what i apply consider 3 forces for each box: buoyancy + drag + gravity;

theres also velocity vector

buoip.png

take a look at the right 'box'

this violet pink arrow pointing down -> velocity vector

green arrows -> gravity vector;

yellow arrows -> buoyant vector

orange arrows -> drag vector; //as you can see i connect it to the same point i connect gravity one

red is submerged vol

(i am watching at right example with 4 boxes) :

ok back to the example the thing is i dont see any angular change like it would never happen so this is what i do

[spoiler]

set resultant_force = 0;

for each box()

{

calculate overall speed for drag calculation for this box; localspeed -> vel + overall_rotation_translation x modelrelative_COG2COB_vector

LocalSpeedVec = vel + cross( angular_translation, vectorAB( CENTER_OF_GRAVITY, BuoyancyBox[n].center) )

//vectorAB( CENTER_OF_GRAVITY, BuoyancyBox[n].center) <- is a constant it never changes .center like CENTER_OF_GRAVITY are in modelspace

now having velocity vector we can compute drag = (-LocalSpeedVec/ length(LocalSpeedVec) * ( length(LocalSpeedVec) * length(LocalSpeedVec) ) * surface_area * drag_coeff; here is strange thing coz i get NaNs here.

box_force[n].FORCE = Gravity + drag; // i am wondering what is the standard unit for sirface area maybe its because i use m^2 as unit

now from this point i go into two new ones:

first: i need to attach gravity + thrust + drag (- > which is box_force[n].FORCE) to BOX center, and apply resulting torque

second:

now whenevers buoyancy (if body is submerged in water) i add to this force (buoyancy) i make a torque wheres Torque = R x F

wheres R = vector from center of gravity to center_of_buoyancy_calculated_earlier

F = buoyancy force;

ofc to get angtranslation from it i need to to sth like:

vec3 ETorque = cog2cob_vec * BuoyancyBox[n].buoyancy_force;

vec3 EAngAcc = ETorque / EMOI;
vec3 EAngVel = EAngAcc*dt;
vec3 EAngMov = EAngVel*dt;

and i dd that to resuklting torque where our resulting_torque is actually angular_trianslation where:

angular_trianslation = angular_trianslation + EAngMov;

}

//gravity pointed 0, -1, 0); buyoyancy force pointed (0, 1, 0); they act in these dirs

now i rotate and translate my object by given data.

[/spoiler]

so i basically need to know if i missed some kind of step i am not aware. or this is totally wrong of toing my thing :P

how i think it works:

its like when you saw first seconds in a first vid below you can see that model is dropped from a height and its a bit rotated)

so box cubes that fall as first to water generate torque = body - box->pos X buoyancy force -> so it should also rotate the object

it should but it isnt even implementing resistance that when entering water density gets almost 1000 times bigger

and that triggers way bigger drag but still nothing

There is alot of 'drag', as going down you have to push water out of the way and coming up there is a suction where water has to flow into the voided space. Rocking motions get dampened alot by the water, which is a viscous fluid.

Shortening the time interval for more incremental corrections will keep the ship from getting into situations where there is (exaggerated) major difference in local displacement.

The hull/ship itself also has mass and leverage, so that when you get sinoidal waves in the waters surface the local shift in depth (and the weight if the water hitting the side of the ship) the proportions of the waves to the size of the ship will either be something that barely moves it or if the boat is tiny and waves big will cause crazy motions (which all calls for a fairly high adjustment/simulation rate to work properly)

--------------------------------------------[size="1"]Ratings are Opinion, not Fact

There is alot of 'drag', as going down you have to push water out of the way and coming up there is a suction where water has to flow into the voided space. Rocking motions get dampened alot by the water, which is a viscous fluid.

well.... ok....

Shortening the time interval for more incremental corrections will keep the ship from getting into situations where there is (exaggerated) major difference in local displacement.

second video demonstrates engine rate at 0.0330s per frame 33 miliseconds 1/30 second

Advertisement
Is this your own physics engine? I think at this point it is really hard to say where the Problem ließ without seeing all the code.

I used physx in the past for bouyancy Simulation with only highschool level equations and a bit of tweeking and it worked like a charm...

hold on let me port that to windows so i remove some garbage from it

i found the problem with shooting the ship to the sky.

The thing was when ship was partially submerged i was applying too much drag ->

that means i had to calc submerged surface area i thought i was calculating it but i was passing a constant 300 m^2 everytime it was submerged so thats fixed...

however

i have still problem with calculating rotations.

so basically for each of 8 boxes i calculate all forces acting on them (except thrust force)

then i try to apply torque around the center of gravity this produces really small rotation.



vec3 vLocalAngularMoment = vec3(0.0, 0.0, 0.0);
for (int i=0; i < 8; i++)
{
vec3 cog2cob_vec = vectorAB(pos + WORLD_MAT * CENTER_OF_GRAVITY, BuoyancyBox[n].WORLDSPACE_COB);
this is a vector from ships center of gravity to box buoyancy center (if box is not submerged then box center) -> everything is in world space
WORLD_MAT is the rotation matrix

float r = VectorLength(cog2cob_vec);
float EMOI = box_mass * r * r; //box_mass = ship_mass / 8.0;

vec3 ETorque = cog2cob_vec * BuoyancyBox[n].ELEMENT_FORCE; //cross product of vector from center of gravity to center of buoyancy * force acting 
vec3 EAngAcc = ETorque / EMOI; 
vec3 EAngVel = EAngAcc*dt; 
vec3 EAngMov = EAngVel*dt;

vLocalAngularMoment = vLocalAngularMoment + EAngMov; // i add this each box then i rotate model by vLocalAngularMoment and apply it to WORLD_MAT  
}

maybe someone will see bug here

like in most of my posts heres a vid of what i get now: (dont worry that you dont see ship hull model submerged -> boxes are too big)

on bottom left corner theres velocity of a ship shown (in m/s) and you can see it somehow floats)

SOLVED

and i believe its fixed... i was watching an online tutorial and guy said angle or the distance of roatation / time => is in radians so i was like omgwtf?!? i changed it and it works... (i mean i initially used degrees and when applying rotation [along with sin cos functions i was putting RADIAN_ANGLE*(pi/180.0) where i should use degree angle)] on the vid below sometimes the water goes above the hull its because the water mass moves like it was a tsunami there thats not really much of concern to watch that and theres nothing special there... just wrong drawing etc.. you have been warned

someone may tell that i still dont calculate everything properly since when water goes down ship looks like doesnt fall down but it does... i dont know i just assume this is the water mass movement fault (too fast)

once again lowfps since i record that on emulator

3 tests first two are the same but from different camera angle the time and forces match so it should be an exact copy, the thrid is a test on stable water plane as you can see ship doesnt sink and rotates..

This topic is closed to new replies.

Advertisement