Sign in to follow this  
Hybrid

Buoyancy Problem

Recommended Posts

Hybrid    138
I'm not sure the correct way to solve this, but here's the problem. I've got floating, buoyant objects in my little demo. They are rigid bodies and calculate their buoyancy okay. The problem specifically is this... I have an object that is light (little mass) but a large surface area e.g. big cube with little mass. When I drop this into the water from a height, then the cube will obviously go underwater for a short period of time, but because of its size it displaces a large volume and this causes the cube to shoot up out of the water faster than it came down. Pretty much as soon as the cube hits the water its flying upwards into the sky! Do you add some kind of impact force when an object actually hits the water (e.g. goes from air to water) to basically stop/dampen its motion before the buoyancy takes effect or something? In fact, this may make it even worse. I'm not sure what to do. I could spend hours fiddling with the masses, cube sizes etc trying to find one that doesnt either fly up or sink. Getting things to float normally seems a little hard. I'm confused. I'm not calculating air resistance at the moment, but I don't see that affecting the upwards 'shooting' of objects. Any tips would be appreciated. Thanks.

Share this post


Link to post
Share on other sites
Dmytry    1151
i'm not very sure what you do, but it's looks like during your timestep your cube gets deep underwater, to the point where it shouldn't be, so it's pushed up too much and flyes out of water with bigger energy than when it hit.
It's problem with integrating 1st derivative discontinous forces.

Possible solutions: make energy conservation(that is, compute energy before hit, and after hit, scale velocity so energy will be smaller than energy before hit (by some damping). That at each timestep, total kinetic and potential energy is smaller or equal to previous), and/or use better integration method, but it will not eliminate problem completly (i don't know if rk4 is better in that case,but might be). Or handle that discontinuity analitically. (probably hard with arbitrary orientation of box).

Same will happen if you'll try to make a pool game(or pong) where balls have repelling force that depends to distance between balls, if distance is smaller than ball diameter. Like force=k*(ball_diameter-distance_between_balls). Energy will not conserve. So with pool game usual solution is to do collisions analitically.

Share this post


Link to post
Share on other sites
Hybrid    138
Okay I see what you mean. I like the sound of the energy conservation approach and doing things analitically as opposed to just implementing the equations and seeing what happens.

Thanks.

Share this post


Link to post
Share on other sites
Dmytry    1151
And if you want me to be more specific,
Quick and simple solution, should work:
When object touches water, store it's velocity in variable v1

and when after leaving water it have velocity vel, you need to
vel=vel*(length(v1)/length(vel))*damping_constant_less_that_one;

With damping_constant_less_that_one=1 you'll have simple conservation of kinetical movement energy, it will probably bounce forever. With damping_constant_less_that_one=0.2 or so, you'll probably get good enough results.

It's looks like hack, but have some physical meaning - kinetical movement energy after bounce is always scaled by damping_constant_less_that_one2

****************************************************
If you want to apply conservation of energy even if it's partially under water, it's bit harder(and i don't sure necessary at all)... but more funnay.

how you can find energy of system:
It's simple to find energy of object(it's m*g*height + m*velocity_squared/2+rotation_energy), but what's with water? Same as with anything else.

(potential energy of water) = (height of center of mass of water) * (mass of water)

So we need to find height of center of mass of water, when you have floating object. It can be found in way very much like Archimedes law.

Let h0 = height of COM w/o object (COM it's center of mass)
let h1 - height of COM with object.
Let all heights is counted from water level without object.
Let hd = height of COM of "hole in water" created by sunken[sp] volume of object.

Let s it's surface area of water, let it doesn't significantly change when there's object.
Let v it's volume of displaced water. p*v it's mass of displaced water(p it's density). From Archimedes law, p*v*g it's your force to up...

Let M it's mass of all water

So we have
h1=h0+(v*0.5/s)*p*v/M - p*v*hd/M
(can't explain without drawing)

and water have potential energy
e1=M*h0+(v*0.5/s)*p*v - p*v*hd
and before had energy
e0=M*h0

so energy of water with floating object=
e0+(v*0.5/s)*p*v - p*v*hd

If surface is big, first term may be removed.
If object is fully under water, (- p*v*hd) it's center of mass of water in volume of object * depth under water.

edit: fixed typo.

Share this post


Link to post
Share on other sites
Dmytry    1151
Also, as about realism. In reality, when object hits the water, or leaves the water, it causes water to move, and water have inertia, and it's very complex thing, and there's some kind of impact force, of course... but your simulator surely have waay too long timestep to simulate it more-or-less accurately, it can't even do floating. Yes, "some kind of impact force" can make things worse as you think, because timestep is certanly too big.


So to make things be more realistic at impact you can only do that hack:
vel=vel*some_other_damping_constant_less_than_one;
....
v1=vel;//see prev post.


And it will be more realistic than what you do now, as well.

Share this post


Link to post
Share on other sites
Charles B    863
It's basically the same issue as with diverging spring systems. It's because of the retroactions at first or second order. This make the differential equations far more sensible to discretization (time steps).

The only decent solution is to have a much higher update rate for your physics. You need a higher frq. Google canonical game loop. There have been several threads at Gamedev.

You could locally have higher integration frequencies when any damping, spring buoyancy, well retroaction comes into play. AND probably some energy assertions to detect any unstability. But the best would be that your assertions are never triggered : find the right frequency.

Share this post


Link to post
Share on other sites
Hybrid    138
Well at the moment, there is hardly any rendering and I just let both the physics and rendering run as fast as they want... so they must be well over 200 frames a sceond at the moment, though I've yet to check.

Though it may be tricky to keep track of the energy. It would be easy to check if the box was dropped and the energy amount stored before and then after it exits the water... but this is not always the case, the box could be underwater for a whole number of frames and things may have happened under water that also affect the energy - lift, drag and perhaps underwater collisons. Also I'm aiming for this system to be used for some boat physics, so it won't be a simple case of checking the energy before and after as the boat's velocity/direction etc. will be changing all the time, and then there are things like waves that can affect the volume displaced on a per frame basis.

ugh, this is getting confusing. :)

Share this post


Link to post
Share on other sites
Dmytry    1151
But, if there's waves/etc, not only buoyancy, it's whole different problem. If you want to model it accurately you'll have to do fluid dinamics, etc, very hard stuff. What you now do probably already physically have almost nothing to do with real water, except in static conditions.

When real object leaves water there's some suction.
When real object moves in water/enter, it moves water and it works like attached mass.(do you know that submarine accelerates like it's more than 2 times heavier than it is, because water have to move? so any model that doesn't count it will produce at least 2 times wrong results?)
So you should somehow attach mass to your object.... and it's also hard to do correctly.

Soooo.... if as simulation it's *very* inaccurate anyway, why not use hacks that if correctly applied will make it look more realistic?

Also, i think, waves itself can't make object to jump into air. (unless together with some pretty big piece of water)

******************

Another method, probably the most physically correct: when object hit the water, and underwater volume of object is v,
multiply velocity by (mass_of_object)/(mass_of_object+k*v*p)
Then, use (mass_of_object+k*v*p) as mass in all your acceleration calculations. In that formule, p it's density of water in your units.(i mean, 1000 kg/m3 or 1g/cm3 , depending to units)

Where , say , k=1.5 .

Explanation why it isn't very much of a hack, but have physical meaning:
There's water mass "attached" to object.When object hit the water it causes water to move, that is , water gets some of kinetical energy.

Think about what maximal possible acceleration air bubble does have? It have almost zero mass....

This is really used to model boats and other things including bubbles, except that IIRC k depends to speed.

2Charles:
I think, if he'll model water in not so inaccurate way(not as nearly ideal spring), there will be enough damping at impact that will mask all integration problems. Yes, it's needed to increase timestep to model spring better but why assume water is a spring? Even if it's not a water but helium in superliquid state[grin], there will be damping on impact due to turbulent dissipation. There will be attached mass, greater or equal to mass of vater in volume of underwater part of object.
Jump will not be totally elastic because even superliquid will get some of kinetical energy.

Share this post


Link to post
Share on other sites
CombatWombat    673
Maybe model the viscous drag of moving through a fluid as a sort of damper. Then an object (like your low mass/high volume) that can generate high speeds in the fluid will be slowed by higher damping forces, as it is based on the velocity. It could also represent the added force needed to push the mass of water out of the way.

Alternately, somehow find the volume of water (roughly) that also must move when the object displaces (or stops displacing), then you can find the mass of it and accelerate the body as though it had massItself+massWaterMoved. I suppose you could do this if you know the body's velocity and dt between frames, as well as a surface area (probably normal to the velocity). That would create a sort of volume (surface area x distance it will move).

It's a hard thing to model accurately, as even in design of boats/cars/etc engineers end up using a windtunnel and not equations to predict the behavior of fluids around bodies. So as dmytry said, you're probably better off with a few well thought out hacks to make it behave how you want.

Share this post


Link to post
Share on other sites
Hybrid    138
It may help if I explain how I model my objects. I basically model buoyant objects with a low polygon triangle mesh (like a collision mesh). I calculate the area for each triangle as that's needed for the volume, drag and lift calculations, I also store the velocities of the centres of each of those triangles (as each triangle may have a different velocity if the body is rotating).

To calculate the volume a triangle displaces I do this:

1. For each triangle centre get the water height at the x,z coordinate.

2. If the triangle is underwater, then fire a ray from the triangle directly upwards to a distance of t (t = distance from triangle centre to water level).

3. If the ray hits another triangle then it means its displacing water only upto that point (e.g. boat is fully underwater). If the ray does not intersect another triangle then the boat is partially underwater (e.g bottom of the hull only).

4. Use that distance to calculate volume displaced (triangle area * distance below surface or triangle intersection * normal.y)

So it's a pretty good estimate based system for calculating the volume displaced... But something just struck me, based on drag...

At the moment I implement drag by checking triangles that have normals pointing in the relative direction of the triangle (dot product test), but how about if I add 'suction' too, so for triangles that are underwater whose normals are pointing AWAY from the triangle's velocity then use that to create a suction force that sort of represents the water that needs to fill the empty volume that the triangle is leaving behind it. If that makes sense at all? It might counteract this box flying into the air, as the box will be slowed down as it is 'sucked' back down. What do you think?

Share this post


Link to post
Share on other sites
Charles B    863
@Dmytry
Quote:
I think, if he'll model water in not so inaccurate way(not as nearly ideal spring), there will be enough damping at impact that will mask all integration problems.

Problems of integrations depend on the sampling frequency and the modulus of the physical variables. High incoming speeds and high damping is rightly where you have the most chances to create diverging anomalies.

Quote:

Yes, it's needed to increase timestep to model spring better but why assume water is a spring ?

Not water as such. But the equations that model this situation are retoractive at first and second order. This creates decreasing exponentials modulated by sinusoids normally. But if time steps or factors are too big, then discretization creates increasing exponentials, that is artificial cinetic energy.

The volume displaced is proportional to z*dt, and this creates the archimedaen force. So this will exaclty the same situation as for fluid damping : retroaction. I remember my trials to model futurist flying engines with strong aerodynamic brakes. It was very difficult to avoid divergences with high speeds and strong deccelerations.

Quote:

Even if it's not a water but helium in superliquid state[grin], there will be damping on impact due to turbulent dissipation. There will be attached mass, greater or equal to mass of vater in volume of underwater part of object.
Jump will not be totally elastic because even superliquid will get some of kinetical energy.


Approximatively, damping here just operates the same way as archimedean forces. Except it's second order (vz*dt), not first (z*dt), and except sign, it always opposes to movement.

So in the end, it's like a spring, or a spring with damping. Springs often break in simulations at low sampling rates.

@Hybrid
Can you tell us your actual average delta of time ? Are you sure your physical constants : mass, damping, water density are all coherent ?

Now for energy assertions. Don't forget to add cinetic AND potential energies. It always has to decrease, diffused in the water.

I'll also try to detect any potential consequence of the approximations you make by computing the displaced volumes and damping forces. But tonite, late, quite sleepy (and drunk ;).

Share this post


Link to post
Share on other sites
Dmytry    1151
Yes, damping forces will make problem worse...

The only way to do something with big timestep is to not use forces there but use approximation to true solution for that timestep.

1: Use (mass_of_object+k*v*p) ,that is,(mass_of_object + k*mass_of_displaced_water) as mass in your calculations. It's very important. It's approximation of effect of "attached" water.
It will have effect on making your final acceleration due to buoyant forces and gravity to be always smaller by absolute value than g, as it should.
It's not quite correct without that:
2: make a variable for mass_of_object+attached_mass_of_water. Let's name it EM(effective mass). At each timestep scale your velocity by min(1.0 , prev_step_EM/current_step_EM) . It's approximation to impulse conservation during timestep. But *that* will make things less stable, so first try 1 alone, then add 2, and maybe it will still work. Also it's possible to scale velocity as in 2 and then re-calculate object position again from prev. timestep pos.(kinda similar to RK integrator) So, timestep error will work in opposite way.

I just imagine you simulate extremely small mass object(bubble). So you'll have extremely high acceleration when it comes underwater. And it's just *wrong*. With water, in reality, you probably can't get g even if object's mass is zero, because there's attached mass of water.

2Charles: That's what i mean by simulate more accurately. With 1, he will always have smaller accelerations, not like there's damping forces added, but like there's more mass, and it will be more physically correct. Maybe with that correct, waay smaller accelerations, his timestep will be small enough. Maybe it even will be able to handle 2. I'm just imagining situation: he have light (think, almost zero mass) object underwater. Say, hydrogen bubble :). So with his model(if i understand his model correctly) it will have extremely big acceleration, for hydrogen, >1000g (edit: for hydrogen, about 10 000 g !). And it's just plain wrong. It can't have >g upwards, because water have to move down with acceleration not bigger than g. If we model it with 10 000g acceleration of bubble, and will add some damping forces as computational afterthought, it will make things worse.


BTW . I posted formules for potential energy of water. As about kinetic energy of water, it's mostly lost forever(will so-on completely dissipate) just like thermal energy...

BTW2, you can also try to use better integration method such as RK4. I was unable to simulate springs for some project with Euler, and was able to do it using RK4 .

[Edited by - Dmytry on October 17, 2004 6:43:57 AM]

Share this post


Link to post
Share on other sites
Hybrid    138
I will try and get you my average delta time later today, as at the moment I'm rewriting some of it based on what I've read so far.

I'm keeping my units consistent - masses are in kg, lengths in metres, time in seconds.

Share this post


Link to post
Share on other sites
markr    1692
Sounds like there are some complex solutions here.

Personally, I'd try decreasing the timestep (as has already been suggested). Also perhaps increase the damping caused by the water.

Failing that, just increase the mass of your cube a tad...

Your original article referred to the surface area affecting buoyancy, which of course, it doesn't - but I think from reading your subsequent posts that that was just a typo and you meant volume.

Mark

Share this post


Link to post
Share on other sites
Hybrid    138
Quote:
Original post by markr
Failing that, just increase the mass of your cube a tad...

Your original article referred to the surface area affecting buoyancy, which of course, it doesn't - but I think from reading your subsequent posts that that was just a typo and you meant volume.

Thing is, if I tweak the mass of the cube so it works then thats fine... but then I find if I drop it from a different height into the water the problem sometimes returns and the object flies up again.

Yeah I meant volume, but I use surface area to calculate the volume displaced so sometimes I write one instead of the other :)

Share this post


Link to post
Share on other sites
Dmytry    1151
Quote:
Original post by Hybrid
Quote:
Original post by markr
Failing that, just increase the mass of your cube a tad...

Your original article referred to the surface area affecting buoyancy, which of course, it doesn't - but I think from reading your subsequent posts that that was just a typo and you meant volume.

Thing is, if I tweak the mass of the cube so it works then thats fine... but then I find if I drop it from a different height into the water the problem sometimes returns and the object flies up again.

Yeah I meant volume, but I use surface area to calculate the volume displaced so sometimes I write one instead of the other :)

my latest suggestion is exactly about mass of object - if you count "attached water", mass must be OK and must be physically-correct even if object's mass is zero.

BTW. To test n tune i'd write special version that does it in 2d and uses axis-aligned rectangle/square as object. It's in fact possible that your displaced volume calculation is not quite correct, and with 2d aligned box, it's simpler and there's less room for mistake......

Share this post


Link to post
Share on other sites
Hybrid    138
As I'm working out the forces on a per triangle basis, should I also work out the 'attached mass' per triangle, so only add the mass of water the triangle displaces as opposed to the whole object?

At the moment, it's very close to a 2D situation as the box is upright and the water is a flat plane, so there is no rotation at the moment, so I can easily check the volume displaced to see if the calculations are correct.

Share this post


Link to post
Share on other sites
Charles B    863
@Dmytry (and thus Hybrid too :)
Quote:

The only way to do something with big timestep is to not use forces there but use approximation to true solution for that timestep.

I agree that if a well thought hack works, based on physical observations or on a math study of the differential equations, then it should be prefered to very high integration rates. The volume computations will be time consumming. So risk of global computational 'lags'. Also hydrodynamics are in reality quite complex. Still I don't think it's the approximations of the model that 'cause the jumps'.

I am sure what happense is something like that. At t=0, a volume of 10cm radius is above water, comes with 10m/s. So the next step, t=1/100 sec for intance, it has displaced a height of 10 centimeter. Where it should possibly never have been if the simulation was continuous, this depends on the bal density.And surely never with the velocity it will have at the start of the second frame. I mean in any case energy is artificially created, even with your EM/velocity proposal. I think.

So, until Hybrid tests your solution Dmytry, to see if it works. I would rather go for a event based approach. I suppose it's important to know when the object hits the water/air interface, some kind of collision prediction again or time step refinement. Then integration will surely evolve with sounder initial conditions. Then I'd go for a hugely accelerated sampling rate for the first few seconds. But it's hard to tell on paper the object probably rotates, damping acts...

Quote:
Original post by Dmytry
I'm just inagining situation: he have light (think, zero mass) object underwater. Say, hydrogen bubble. So with his model it have extremely big acceleration, >1000g. And it's just plain wrong. It can't have >g upwards, because water have to move down with acceleration not bigger than g. If we model it with 1000g acceleration of bubble, and will add some damping forces as computational afterthought, it will make things worse.

Excuse me if I miss something. It's just that I haven't experienced physic simulations of solids bodies vs liquids. Still I have experienced many other kind of forces. So maybe I miss something crucial in your post.

Still. Zero mass would mean photon to me :). I know that you certainly mean physically infinitesimal (very small but non zero) mass. But your bubble mass is proportional to its volume, which is also proportionnal to a mass of water displaced. So it's all about a ratio of densities (damping left apart), so acceleration is based on it. So your 1000g, OK.

But when you say it's just plain wrong, I think it's because the damping forces lack, not because your EM model lacks. As damping is roughly based on the apparent surface, here the ratio of densities does not count. Thus in results in very high damping, a problem. And there are probably other kinds of forces coming into play for a bubble, all resulting in higher retroaction. Big bubbles do not exist, there is a reason.

So probably the solution is to control artificially and force the evolution towards the limit of the movement that can be studied in theory. Your bubble would quickly reach it's nominal upward velocity. This is roughly what you tried to do with the EM trick, but I am not sure it takes the right params. Where is damping accounted for since it's the main cause of the limit state ? Or I missed something implicit.

Now it would be perfect if this could be done by creating a fake but working force summation. That is force towards the solution at second order. Well near the limit acceleration is null, and you target a speed limit. So more probably, the only stable way is to force control at first order, that is the velocities, with some sort of morphing during the transition between the initial state (for instance a bubble standing still) and the limit state.

Still if you can't change the typical physics interface : user provides forces, only integration modifies velocities and positions, there is a way to do. I remember that to respond to such issues I had a class of tools that helped me to create the forces required to match a given position, orientation, or linear/angular speed. The time to limit was the second argument of the function.. It did so by reversing the physics integrator. This way for instance I could make keyframed animations compatible with the whole physics engine. And keyframed cyclic stuff like elevators, arbitrarilly of infinite mass, interacted perfectly with free physics objects. this worked perfectly.

Quote:

BTW2, you can also try to use better integration method such as RK4. I was unable to simulate springs for some project with Euler, and was able to do it using RK4 .

Yes good advise. I also experienced that.

Share this post


Link to post
Share on other sites
Dmytry    1151
i did some searches...
clickster
Nothing really useful, except that looks like everyone uses concept of "added mass" to model boats, dolphins, submarins, etc.

Yes, added mass it's generally an approximation to part of damping. You'll also need friction damping of course.

It's possible to simulate added mass using damping. But it requirs full liquid simulation.
How simulating may work:
You have a pressure of bubble and pressure of water. At bubble surface, pressure of water is equal to pressure of bubble. For any practical purprose, we can assume air, or hydrogen bubble mass to be zero. So bubble just equates pressure on it's surface, and can accelerate up to equate pressure on surface. Given that, you need to compute flow of water around bubble.
It doesn't go to singularity if mass of bubble is zero....

And, thing is whole lot harder if bubble is "hard" that is, if we will try to work with our 10000g model. It will have 10000g acceleration, it will move a bit, then it will compress water on it's path, and will have opposite direction force due to pressure of water. To simulate this, you need extremely small timestep.

Truing to work out that 10000g accelerations is like attempt to simulate a steel brick with force applied to some small hemisphere : you'll have steel in that hemisphere accelerating, then to move, then to accelerate backward due to springing of steel. Except that for such things, water is harder than steel - if you apply force to some point, steel may break. And water can not.

Also, 10000 g simulation have almost no physical meaning. We simply can't use Archimedes law for accelerating objects, because, this law doesn't take into account acceleration of water.

Imagine bubble/whatever thing is moving in the water. Water around moves in opposite direction. Compute how center of mass of water is moving, and see that it's the same as if you accelerate object upwards and also accelerate water downwards.
Resulting inertia of water is bigger or equal to inertia of mass of water taken in volume of object.

as about size of bubbles, i've found that it's possible to make big bubbles that looks like |) shape. By big i mean with diameter of 10 cm or so.

Share this post


Link to post
Share on other sites
Eelco    301
getting this unconditionally stable, for any mass, isnt easy.

think about it: if you take a very tiny mass, any force generated in the first contact will cause it to blast away, due to a=f/m. no matter how accurate your simulation is, you can always imagine a mass so small it cant handle it.

unless your program is 'aware' it is in a dangerous situation, and can adapt according to that. working with energies is probably a good idea. if a ball hits the water, you can calculate the energy needed for the calculated displacment, and possibliy conclude 1/2mv^2 isnt ever going to be capable of this given the m in question, and based on this condition locally take a smaller timestep for your simulation.

Share this post


Link to post
Share on other sites
Dmytry    1151
got idea how to explain added mass trick:

Imagine you have a complex mechanical system with inertia(say, gearbox connected to ideal torque source).
We can simulate gearbox as system of springs,of course.

But let we can make some assumptions about gearbox:
1:springing in gearbox is almost zero, that is, all springs in gearbox is very hard.
2: the only thing gearbox can "remember" for some time it's rotation speeds.

So, even if we don't know how what's our gearbox and motor have inside, but want to find acceleration of it's "connector" with given torque applied to it, and with given spinning speed, we generally can simulate gearbox as thing with inertia i and some internal friction, and some torque that depends to angular acceleration of "connector" and spinning speed.

Inertia might depend to speed of gearbox (say,if there's masses on that have bigger radius at bigger rotation speeds (that "oldschool" thing used to measure rotation velocity)), etc.

Same with water. For moving object, movuing water around works like moving parts of gearbox, like mechanical system almost without springs. We don't know masses and ratios between gears, but we know that for constant speed 'em is constant...

edit: i mean why not simulate it as thing with friction,force,and inertia, like we would simulate motor?

It's obvious that if you simulate things without even simplest approximation to friction, or without even simplest approximation to buoyance force, you get quite wrong results. Even worse if you simulate water without even simplest approximation to inertia.

Share this post


Link to post
Share on other sites
Aargyle    122
Heh, everyones thinking too hard on this. The real problem is that your ball moves too deep into the water in a single time step, and if you calculate what happens from there, it will of course fly back up (think of dropping a beach ball onto water, it doesn't go 'in' at all!). A much easier solution is whenever you find out something has collided with water, back up to the point of first contact, then figure out how deep it is supposed to go. Then figure out if the 'time of maximum depth' is within the current time step (if it is, you have this special case, if not, then let it go like normal). Then from there you can handle it smarter. If the turnaround point is within the current timestep, just turn it around and make it go the other way.

Anyway, the downside is it makes you treat collisions with water as a special case, but I think preventing it from going too deep in the first place is probably the way to go.

Share this post


Link to post
Share on other sites
Dmytry    1151
Quote:
Original post by Aargyle
Heh, everyones thinking too hard on this. The real problem is that your ball moves too deep into the water in a single time step, and if you calculate what happens from there, it will of course fly back up (think of dropping a beach ball onto water, it doesn't go 'in' at all!). A much easier solution is whenever you find out something has collided with water, back up to the point of first contact, then figure out how deep it is supposed to go. Then figure out if the 'time of maximum depth' is within the current time step (if it is, you have this special case, if not, then let it go like normal). Then from there you can handle it smarter. If the turnaround point is within the current timestep, just turn it around and make it go the other way.

Anyway, the downside is it makes you treat collisions with water as a special case, but I think preventing it from going too deep in the first place is probably the way to go.


no. The dounside why no one there mentioned it yet:
1:Backstepping to contact time gives you practically no benefit.
It's as hard to find how deep it's supposed to go as without knowing where it was at contact time. In fact, where it was at contact time is almost totally irrelevant....

You can only use contact time to try to apply damping forces at contact time, so damping will really dampen it, but it's really pure hack, not a solution.

2:And to find how deep it's supposed to go.... it's not a ball. As i understand, it's arbitrary mesh.

It's possible to find how deep it's supposed to go but with arbitrary mesh it will be expensive in terms of cycles, and more than hard enough not to consider it to be "much easier soution". It's exactly what i meant by "Or handle that discontinuity analitically". That is, find depth h so potential energy of water = kinetic energy of ball before hit. Seen these formules for potential energy of water [grin]?

Share this post


Link to post
Share on other sites
Charles B    863
Quote:
Original post by Aargyle
...A much easier solution is whenever you find out something has collided with water, back up to the point of first contact, then figure out how deep it is supposed to go ...


Already mentionned this track :)
I suppose it's important to know when the object hits the water/air interface, some kind of collision prediction again or time step refinement. Then integration will surely evolve with sounder initial conditions.

Quote:
]Original post by Dmytry
no. The dounside why no one there mentioned it yet:
1:Backstepping to contact time gives you practically no benefit.

It's as hard to find how deep it's supposed to go as without knowing where it was at contact time. In fact, where it was at contact time is almost totally irrelevant....

You can only use contact time to try to apply damping forces at contact time, so damping will really dampen it, but it's really pure hack, not a solution.


A physics/col-det engine has to deal with triggers, so some kind of collision prediction feature might be required anyway. For instant teleports, so not sure it would be such a hack. It would not necessarilly denature the engine.

Evaluating the max depth of rebound, even a big appromaxition based on the gravity center and an average radius/surface, could give a reasonable hint to subdivide time with the appropriate number of slices. For instance, you know that max depth is roughly after 20 msecs. A 1 msec time step will surely give you a quite accurate result, 95% accuracy ensured in time, and surely much more as metrics, because speed is lowest near the point of maximum potential energy.

Else I'll try to understand your expose about EM a bit later Dmytry. Still I am not coding such physics, as the solution is surely very empirical, I am a bit clueless without feedback.

Share this post


Link to post
Share on other sites
Dmytry    1151
Another explanation about "EM" aka mass with added mass. I'll try to explain it in bit more academical way than that thing about gearboxes. It's not entirely empirical thing, in fact. Yes, attached mass for given velocity is empirical function, but entire idea of attached mass isn't.

Assume water is incompressible, there's no significant turbulence, and there's moving sphere/ball.
When ball moves in water at constant velocity U, we have some constant field of velocities in water, let's name it V(U,x,y,z),
and some constant pressure field P(U,x,y,z), looking from ball's system of reference.
To find drag force acting on ball, we need to compute surface integral of -pressure*surface normal.

Velocity field in water somehow depends to velocity of ball, as well.
For small dU, we can assume that this dependence is linear. That is, V(U+dU,x,y,t)=V(U,x,y,t)+M(x,y,z)*dU
where M is some linear scaling thing(tensor field?) ).

Now, if in small timestep dt, dU = A*dt, where A is acceleration of ball, we have
V(U+A*dt,x,y,t)=V(U,x,y,t)+dt*M(x,y,z)*A
That is, at point V, velocity field have acceleration dt*M(x,y,z)*A

Note that pressure = divergence_of_acceleration * density * something_i_don't_really_sure_what + other_things_that_dont depend_to_acceleration.
That is, pressure is proportional to acceleration, and acceleration is proportional to acceleration of ball.
Acceleration field is dt*M(x,y,z)*A

So, pressure have part that is proportional to acceleration of ball. We can split our pressure into

P(U,x,y,z) = somefunction(U) + (dU/dt)*anotherfunction(U)

And our drag force is equal to surface integral of pressure.

We can also split drag force into
Drag(U)=a(U)+(dU/dt)*b(U)
where a(U) is named drag force, and b(U) is a scalar (edit:in fact tensor, but in such simulation may be approximated by scalar) and is named "added mass" because it works like added mass.

I can't really 100% formally prove well that it's correct but i think it gives idea how it should be proved.

This splitting is found to be correct even if there's turbulence,etc.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this