
Model of the interaction of ships with water in video games: part 2
- Transfer

Welcome to the second part of a series of articles on ship physics in video games. In the first part, I explained the principles of pushing and justified the choice of calculating the hydrostatic forces acting on the vessel. I also pointed out that we are laying an important foundation for calculating not only hydrostatic forces, but also for hydrodynamic forces in our simplified model. I mean, we will calculate the additional forces for each immersed triangle, summarize them and apply them to the ship. Everything really will be so simple.
Or so it might seem at first glance. It turned out that modeling the remaining forces to give the vessel an acceptable dynamic response required much more research and iteration than laying the entire foundation in part 1 and calculating the pushing out. In retrospect, the first part can be compared to a walk in the park. The second part is more like running over rough terrain in a jungle full of pit traps with stakes when hungry wolves (i.e. producers) are chasing you.
If you have not read the first part, then here is a brief conclusion. The ship is modeled as a triangulated mesh. We approximate the surface of the water with a field of heights and, using a fast algorithm for intersecting an approximated triangle with a field of heights, we determine the part of the vessel under water as a list of immersed triangles. Each triangle in the original mesh can create 0, 1, or 2 completely submerged triangles. The algorithm in action is shown in Figure 1.



Figure 2 shows a typical distribution of hydrostatic pressure on a submerged part of a vessel. As a rough approximation, we assumed that pressure is constant over the entire surface of an immersed triangle. The movement of the vessel shown here is not the result of hydrostatic forces alone.

Figure 2- The distribution of hydrostatic pressure obtained in our model. It should be noted that this behavior was obtained for the full model, and not by applying only hydrostatic forces to the vessel. The ship falls from a height of 2 meters and slows down for some time. Then it is teleported 2 meters under water, pushed to the surface and also slows down for some time. The pressure is considered constant for the entire immersed triangle, and can be quite large. The larger the body triangles, the rougher the approximation. However, the model works and it is stable even with fairly low poly mesh.
As can be seen from Figure 3, the application of hydrostatic forces alone is not enough to accurately simulate the behavior of the body in water. In my opinion, this is a great feature of programming and simulation. It gives us the opportunity to check whether a given model is close enough to real physical behavior. While we hopelessly slowly approach to creating good models for physical phenomena, especially in accordance with exact mathematical conditions, our eyes and brain are able to quickly and with high accuracy recognize a simulation that is unlike the real behavior of objects. In our case, the simulation shows us how important the resistance forces are for the ship, and what would happen if they did not exist in some very strange elastic parallel universe.

Figure 3- The dynamic response of the vessel, to which only hydrostatic forces are applied, on a completely flat surface of the water. It will be quite difficult to fish from such a boat. Obviously, resistance forces play a big role in the real world.
In Figure 3, it appears that the boat is attached to a spring, and is not in the water. From our experience we know that a ship thrown into the water from a height will rather quickly stop oscillating up and down. This is called attenuation, a slowdown caused by opposing forces. As a result, the maximum height achieved by moving up and down becomes less and less. In the case of critical attenuation, the forces are large enough to immediately stop the oscillations.
Fun with a patrol boat from Just Cause 3. Water simulation is performed by NVIDIA WaveWorks.
Model stabilization
When I decided to create a simple model of the forces acting on the ship, I had a rather vague plan of what I want to achieve. It was something between “developing a stable boat model that realistically responds to big waves and that is interesting to drive” and “hmm, how difficult will it be?” Having determined the forces that need to be applied to the vessel, we must stabilize them so that it does not jump uncontrollably through the water. In addition, if we introduce too large or unstable forces, we need protection so that the ship does not reach insane speeds. Therefore, the first thing we did was add great damping forces for both linear and angular components to stabilize the vibrations that I spoke of. Attenuation is simply proportional to how much the body is immersed in water. How can you remember

For example, we can introduce a linear attenuation force that looks like this:

or quadratic attenuation:


Before diving: spoiler
In the end, we use 3 different forces arising from the interaction of the vessel and water: the viscosity of the water, the pressure resistance and the impact force of the hull (or the force entering the water). Each of these forces was added to the model, because it somehow correlates with reality, and also because it relates to a specific problem. In the remainder of the article, I will explain what physical realities these forces should represent, and I will also explain what motivated me to add these forces, i.e. What spectrum of problems each power belongs to. Do not forget that this is a simplified model, so some of the forces are rather implicitly related to physical reality. This applies in particular to pressure resistance, which is a huge simplification of what is associated with wave resistance and spray resistance in a more complex hydrodynamic theory.
Resistance equation
Since below we will talk a lot about resistance, I want to stop for a second and consider the equation of resistance. If you know it, you can go to the next section. In fluid dynamics, resistance is
traditionally expressed in the following form:






Triangle components
Before starting the description of our model of hydrodynamic forces, I will introduce the quantities and vectors associated with the immersed triangles of the hull. All forces are calculated with their help.


Figure 5 - Some useful values for each immersed triangle.
Viscous fluid resistance
I will start with the resistance of a viscous fluid, as many texts on hydrodynamics begin. Viscosity resistance
occurs when water flows along the surface. Since there is a strong interaction between the water directly next to the hull and the hull surface, there is a microscopic layer of water that practically “sticks” to the surface and moves with the ship. With increasing distance from the body, the water “sticks” less and less. To simplify the picture a little, each microscopic layer of water at a given distance from the surface interacts with one layer directly in front of it and with one layer immediately after it. The intensity of this interaction is called viscosity. The more fluid the viscous, the more fluid sticks to the surface and stretches behind it. (*) This creates a force called the resistance of a viscous fluid.
Many experiments have been carried out to measure the resistance of a viscous fluid, and there are good empirical formulas for predicting the resistance of a viscous fluid created by a vessel. For example, let's take a smooth flat plate that moves below the surface of the water. If the plate is thin and moves along its length so that it does not collide with the flow, then the measured force almost completely arises due to the resistance of a viscous fluid. Many countries have created special facilities called test pools to measure, among other things, the hydrodynamic forces acting on submerged bodies moving in water. Some countries discuss the findings at the International Experimental Pool Conference (ITTC), which takes place every 3 years, starting in 1933 (only once there was a pass at 9 years old due to World War II). In 1957, ITTC agreed that the formula:

represents a very good approximation of the data obtained. This formula is called the correlation formula for ship models and is not derived analytically from the basic principles, but rather is a regression function, which for practical purposes is fairly close to the data obtained. Strictly speaking, this is not very important for us, we just need some formula that we can apply to each of our triangles to calculate the viscosity friction. But this shows us that the physics of fluid dynamics is so complex that in practice it is limited to measured resistance, and analytical formulas are not used.
The viscosity of a liquid is not the only parameter that affects the magnitude of a force. First, surface roughness is also important. A rougher surface will interact more strongly with a thicker layer of water than a smoother one. Even more important is the turbulence of the flow near the surface. Before the vessel, the flow is considered laminar. It is ordered and layers at an increasing distance from the surface flow parallel to each other, albeit at different speeds, since they affect each other's speeds at the microscopic level due to viscosity (**). But the longer the fluid flows along the surface, the more turbulent it becomes, and the more layers mix with each other. When the various layers are turbulently mixed, the amount of the accelerated surface of the liquid increases, which leads to an increase in resistance. So we should expect more viscous fluid resistance near the stern of the vessel compared to the bow. And finally, the three-dimensional shape of the ship is important. It differs from a flat plate and changes the nature of the flow. Since the vessel is not completely flat, the fluid needs to travel a greater distance and the relative speed of the fluid is usually higher than the speed of the ship. Due to the non-planar shape of the boat, the pressure along the surface changes, and this also affects the resistance.


When a ship moves through calm water, the resistance of a viscous fluid is the only force acting on the ship. It is possible that the vessel protrudes sufficiently from the water and a relatively small surface counteracts the movement, but at the same time most of the bottom is in contact with water. In this case, the pressure resistance, which we will consider below, will be quite small, but we still need a high water resistance. In addition, if we make the vessel two or three times longer without changing the front surface, we need the resistance to increase, and we will achieve this by using the viscosity resistance, since it occurs mainly on the hull triangles located tangential to the speed.

Figure 6- The dynamic behavior of a vessel, which is subject, in addition to buoyancy, to only viscosity resistance. Despite the fact that very good empirical formulas for the resistance of a viscous fluid are used, which are quite convenient to use, they do not at all lead to any attenuation of the vessel's motion. In this case, the vessel is dropped from a height of one meter from the surface of the water. Resistance of a viscous fluid plays an important role, but it is significant only at high speeds.
Pressure resistance forces
Now we move on to the second force: the pressure resistance force. Also here we move away from serious physics, and I will explain why.
In marine hydrodynamics, scientists share the resistance of the wave profile, the resistance to the destruction of waves, the additional resistance during a wave, the spray resistance, vortex-forming forces, etc. They do not always correspond to a certain physical property. Rather, these are simply ways to account for the hydrodynamics of the fact that there is general resistance to a ship moving in water. exceeds viscosity resistance. Observing the vessel and its surrounding water, it can be understood that energy is dissipated not only due to viscosity resistance. For example, the resistance of a wave profile can be estimated by observing the waves generated by the vessel and determining the value of the resistance applied to the vessel of resistance using the Newtonian principle of action and reaction. But most of the time, the slopes of the waves created in this way should be small. This simplifies the calculation and allows you to create a fairly simple formula. However, this assumption is incorrect, therefore, the resistance of the wave profile is only part of the resistance. Near the vessel, the slopes of the waves cannot be considered insignificant, the waves are destroyed, leading to an increase in resistance. This is called wave breaking resistance. Then, if the appropriate model is chosen for calculating the resistance to wave breaking, it may be necessary to isolate one more resistance: spray resistance, it arises when the impact on water is so strong that the water turns into splashes. Of course, all this is excitingly interesting, but too complicated and cannot be applied to our model. However, this assumption is incorrect, therefore, the resistance of the wave profile is only part of the resistance. Near the vessel, the slopes of the waves cannot be considered insignificant, the waves are destroyed, leading to an increase in resistance. This is called wave breaking resistance. Then, if the appropriate model is chosen for calculating the resistance to wave breaking, it may be necessary to isolate one more resistance: spray resistance, it arises when the impact on water is so strong that the water turns into splashes. Of course, all this is excitingly interesting, but too complicated and cannot be applied to our model. However, this assumption is incorrect, therefore, the resistance of the wave profile is only part of the resistance. Near the vessel, the slopes of the waves cannot be considered insignificant, the waves are destroyed, leading to an increase in resistance. This is called wave breaking resistance. Then, if the appropriate model is chosen for calculating the resistance to wave breaking, it may be necessary to isolate one more resistance: spray resistance, it arises when the impact on water is so strong that the water turns into splashes. Of course, all this is excitingly interesting, but too complicated and cannot be applied to our model. This is called wave breaking resistance. Then, if the appropriate model is chosen for calculating the resistance to wave breaking, it may be necessary to isolate one more resistance: spray resistance, it arises when the impact on water is so strong that the water turns into splashes. Of course, all this is excitingly interesting, but too complicated and cannot be applied to our model. This is called wave breaking resistance. Then, if the appropriate model is chosen for calculating the resistance to wave breaking, it may be necessary to isolate one more resistance: spray resistance, it arises when the impact on water is so strong that the water turns into splashes. Of course, all this is excitingly interesting, but too complicated and cannot be applied to our model.
Instead of calculating the various components using their separation and evaluation, as an alternative, we can numerically solve the Navier-Stokes equation. However, as I keep repeating, all this lies beyond our needs in terms of model performance and complexity.


Figure 7- Dynamic reaction taking into account the resistance of viscosity and pressure resistance. Attenuation now works very well. But it is still imperfect. The dynamic reaction is not rigid enough, residual vibrations remain. It is possible to increase the attenuation by choosing a larger value for the pressure resistance coefficient, but this will lead to unrealistic maneuverability of the vessel. For example, a ship will become unrealistically fast to slow down after moving at a given speed, as if the ship was traveling through mud and not through water. We need another force that is responsive to the very non-linear or non-quadratic dynamic response of a vessel interacting with water.
The pressure resistance force acts normal to the surface of the vessel. At speed, it serves as a sliding force: if the vessel has sufficient driving force to overcome the force that counteracts its acceleration, the hydrodynamic pressure rises in the lower part of the vessel, lifting it up. When lifting the vessel by friction and pressure, less resistance is created (except for the bottom of the vessel). That is why planing vessels usually have flatter bottoms so that the horizontal surface on which they rest when sliding does not decrease when lifting, only if they are not completely raised from the water.
Body impact forces
After applying the resistance of a viscous fluid and pressure resistance, the behavior of the model of the vessel became similar to the behavior of the vessel. However, the vessel can still penetrate into the water more than permissible, and the overall reaction lacks rigidity. Instead of changing the pressure forces, which we wanted to carefully adjust for correct turns and sliding forces, we decided to introduce another force, which will mainly monitor the stiffness of the reaction of the fluid to sudden accelerations or penetrations, which are almost similar to collisions of rigid bodies.
Very severe collisions will be difficult to model using a force depending on the penetration depth or displacement when using the discrete integration scheme. An example of this is a very stiff spring. Since the force is proportional to the displacement from the rest position, the higher the stiffness coefficient, the more difficult it is to simulate a spring with a fixed time cycle. There are well-known solutions to this problem, but they make integration more difficult. Instead of choosing this path, we can take another opportunity, because simply calculate the force required to completely stop the movement of the vessel in one frame. Since it is important that the force be arbitrarily rigid, and the theory associated with the impact forces of the body is very complex, we decided to simplify the problem and start with an absolutely harsh reaction and the necessary return of stiffness to a state of equilibrium. We start by calculating the force of collision with water. If it is very large, we can apply a force that completely stops the movement, while the ship stops, as if collided with the ground. On the other hand, if the collision is of small force, we can provide full control of the movement to other forces and not use force to stop the movement. And between these extremes, we can apply various transition functions (more or less spasmodic) to obtain different dynamic results: linear, power functions, sigmoidal, stepwise. the ship will stop, as if colliding with the ground. On the other hand, if the collision is of small force, we can provide full control of the movement to other forces and not use force to stop the movement. And between these extremes, we can apply various transition functions (more or less spasmodic) to obtain different dynamic results: linear, power functions, sigmoidal, stepwise. the ship will stop, as if colliding with the ground. On the other hand, if the collision is of small force, we can provide full control of the movement to other forces and not use force to stop the movement. And between these extremes, we can apply various transition functions (more or less spasmodic) to obtain different dynamic results: linear, power functions, sigmoidal, stepwise.




Figure 8 - Dynamic response taking into account the impact forces of the hull of a vessel falling into water from a height of 2 m
Figure 9 - Medium-wave vessel accelerated to cruising speed when traveling in a straight line. The driving force applied here is very simple, its source is located at the rear and pushes the ship up a bit. The stiffness of the reaction becomes stronger with increasing speed. There is an effect of bouncing (dolphining), which can be avoided by combining finer tuning of forces, optimizing the shape of the body, adjusting the driving force depending on speed, stabilizing aerodynamic forces. In the lower right corner shows the distribution of pressure resistance forces over the housing.
Conclusion
The model of interaction with water that we developed is applicable for a wide range of vessel sizes and shapes, from a two-meter hydrocycle to a 50-meter corvette (see Figure 10), as well as for larger vessels in conditions from calm to storm and without significant adjustment of variable variable forces. A completely new case with previously not tested shape and size can be thrown into the water with some driving force, and immediately begin to show quite the correct behavior. Of course, bringing any vessel into a transportable state will require the correct location and tuning of the engine (or engines), rudders, transom boards and other stabilizing equipment, but a less procedural approach to hydrostatics and hydrodynamics of the hull would take much more time to set up with lower quality results,
The relative simplicity of the model is suitable for our needs. We use Euler integration forward, the calculations of the three forces are separated from each other, and they can be separately configured; we can easily determine if a given force acts too much or little in a given mode. If we took a larger allowable time for calculations (more than 1 ms), we would expand the current model, and not choose a more realistic model that requires a large amount of computation. However, there are opportunities for improvement in the areas that we will discuss below.
One such area is a force called the strength of the attached mass, or the strength of a virtual mass; Wikipedia quote best explains it: “The meaning of the force is that the fluid receives kinetic energy due to the work performed by an accelerating submerged body. (...) For ships, the attached mass can easily reach 1/4 or 1/3 of the mass of the vessel, and thus represents significant inertia in addition to the friction and wave drag forces. ” Virtual mass does not exist as long as the ship's speed is constant. When accelerating the vessel, it should displace and accelerate a certain proportional part of the liquid in front of itself. During deceleration, a certain proportional part of the fluid around the vessel that receives kinetic energy tends to transfer this energy back to the vessel in the opposite direction to deceleration. It would be undesirable to really change the mass of the vessel to realize this effect. Working with a ship whose mass is changing can be very confusing; therefore, it is much preferable to treat the force of the virtual mass in the same way as with any other force, so that you can compare them and evaluate its effect on the ability to maneuver the vessel, as well as for all other forces. We made attempts to realize this force, but did not achieve what we hoped for; perhaps this happened due to lack of time.
Another area where improvements are possible is comparing the forces in the existing model with the forces acting on the body, according to a realistic computational simulation of hydrodynamics(computational fluid dynamics, CFD). There are open source packages for calculating CFDs, such as OpenFOAM [6], which already contain ready-made examples for simulating the behavior of a ship's hull in water. An example is the Wigley hull benchmark. It contains a housing whose shape is fully mathematically determined and can be used to adjust various coefficients. This makes it easy to compare different simulations with each other or with towing tank data, since the hulls can be manufactured with a high degree of accuracy. This approach requires the ability to run CFDs for the chassis in the detailed configurations of interest and extracting force information for comparison. It also requires many hours of calculations on powerful machines to get a few seconds of data.
Also in 1964, Daniel Savitski developed empirical formulas for prismatic planing enclosures (i.e., enclosures with a clearly defined and simple form). These formulas define “buoyancy strength, resistance, wetting area, center of pressure (...) as a function of speed, angle of attack, angle of elevation and load.” These formulas can be used to adjust the forces in our model by testing on a similar case in a simulation. [5]
Figure 10 - A wide variety of vessels that can be simulated in our model. The first vessel in this video is a corvette with a length of about 50 m. The second vessel is a heavy patrol boat, the shape of the hull of which is completely different. The last vessel has several very flat hulls of a small size (something like a catamaran). We have successfully simulated even such small vessels as jet skis. Water simulation is performed by NVIDIA WaveWorks. [9]
Afterword
Remember that when we started calculating the hydrodynamic forces, we first added strong artificial attenuation to stabilize the system. With such a strong attenuation, the buoyancy force worked perfectly, for example, for a floating barrel. Therefore, I was somewhat prematurely delighted. When we switched to the forms of ships, it was not so easy to achieve what we wanted. Even worse, the team and I could not even come to a consensus as to why what we are seeing seems unnatural. This happens when goals are not clearly defined. Now I realize that we could quickly move to the final model by examining in more detail the behavior of the vessel in the water. For example, by determining the frequencies and amplitudes of the motion of the vessel at rest with little disturbance; answering the following questions: how long does the ship need to reach maximum speed with zero? how much time does a ship need to “brake” with, say, cruising speed to zero? how long does it take a full turn? how big is the trim of the ship (how high is its bow) at speed? What is the normal angle of rotation of the vessel when turning? how much does the ship lose speed when turning, if it is started at maximum speed? All of these issues are essentially very complex, since there are many shapes and sizes of ships that we want to deal with. The mass of conventional transport varies within a factor of 1000, from a motorcycle (~ 100 kg) to a huge truck (100 tons), while the mass of ships can vary from the same lower limit (100 kg) to 90,000 tons of an aircraft carrier, that is, with a multiplier of 900,000 There are also many forms of courts, which significantly affects their behavior.
By asking ourselves these questions and answering them, even approximately, we began to move much faster. For example, from [1] and [2] I found that usually the trim of planing vessels is about 4 degrees, the glide angle during a sharp turn is about 20, and the angle when turning is 25 degrees or more. These values were very useful, because for some reason we tried to avoid too wide a glide angle, which caused us to underestimate some constants and confused us with all the cards at the very beginning.
It was thrilling to watch how, when adding realistic forces to the model, we began to face the same engineering problems as ship developers in the real world. I received the following commentary on the first part of this series of articles from a reader named Greg Sheel: “There is such a thought: if you implement a fairly realistic model of a ship on the water, your ship in the game with a certain degree of accuracy should have exactly the same design that the real ship; otherwise his behavior on the water will be terrible. " He was absolutely right, and this led me to an interesting dilemma in the simulation of vehicle physics. The more realistic the simulation, the more it will run into realistic problems. It’s great when the simulation starts acting like in reality, the players really appreciate and feel it, however, only if this does not interfere with the game itself. A sign that we were on the right track - the shape of the hull greatly affects the stability of the vessel at rest. In particular, the elevation angle or the shape of the stern changes everything. But more realism means that it will take us a lot of time from the time of development to fix the problems that have arisen as a result of a more realistic approach. In the case of the ship model, we noticed serious stability problems in some modes. Later we learned that these problems arise in reality and are known as “dolphinization”, cork-screwing, chine walking (translator's note: I did not find Russian-speaking equivalents to these terms), etc. the elevation angle or the shape of the stern changes everything. But more realism means that it will take us a lot of time from the time of development to fix the problems that have arisen as a result of a more realistic approach. In the case of the ship model, we noticed serious stability problems in some modes. Later we learned that these problems arise in reality and are known as “dolphinization”, cork-screwing, chine walking (translator's note: I did not find Russian-speaking equivalents to these terms), etc. the elevation angle or the shape of the stern changes everything. But more realism means that it will take us a lot of time from the time of development to fix the problems that have arisen as a result of a more realistic approach. In the case of the ship model, we noticed serious stability problems in some modes. Later we learned that these problems arise in reality and are known as “dolphinization”, cork-screwing, chine walking (translator's note: I did not find Russian-speaking equivalents to these terms), etc.
Acknowledgments
I want to thank my colleagues from Avalanche Studios: Hamish Young for important insights and feedback, infinite optimism and enthusiasm in the development of the model, as well as for his incomparable skills in setting up ships that made them interesting to manage; Ronald Lesterlin (Roland Lesterlin) on the fact that he saw the potential in our approach and faith in the possibility of implementing the model on time; Chris Glover (Chris Glover) for the embodiment of ships by programming special effects, such as Kelvin waves, which themselves deserve a separate article, as well as filling with water; the extremely talented Omar Shakir, who produced the most exciting moments of the game (I still can't believe they look so good); all the other members of the Just Cause 3 team for creating such an interesting and high-quality game. I thank my father Richard for editing the drafts of both parts of this series of articles and for refreshing my knowledge of physical topics, which he already explained to me 25 years ago. And finally, I fondly say “thank you” to my wife Zoe for her patience and support, and for allowing me to read physics books almost at the Christmas table.
Notes
(*) Different liquids have different viscosities. For example, yogurt is very viscous. The Swedes do not seem to notice this because they continue to sell yogurt in cartons for milk. I learned this by visiting Avalanche Studios in Stockholm for the first time. In the end, half of the contents stick to the walls of the package when you try to pour it. You have to squeeze the yogurt out of the packaging like a toothpaste. And you already think that avoiding the first time you go shopping for food in tubes was a good idea!
(**) The amazing fact about laminar flow is that it is reversible (at the macroscopic level). To illustrate this, one can cite the popular experiment, which consists in pouring a transparent glucose syrup into a cylindrical tank, the outer wall of which can rotate around its axis. The tank also has an inner cylindrical wall that remains stationary. After pouring three drops of corn syrup of different colors into different points of the tank, we begin to slowly rotate the outer wall to create a laminar flow; the three colored dots begin to “smear” into a circle relative to the axis of rotation and look as if they are mixed. But if you start to rotate the outer wall in the opposite direction, you can return to almost the same initial state with three points located exactly where they were at the beginning.Laminar flow reversibility demonstrated at the University of New Mexico.
References
- Hydrodynamics of High-Speed Marine Vehicles. Odd M. Faltinsen
- Stability of a planing craft in turning motion. Y. Ikeda, H. Okumura and T. Katamaya
- International Towing Tank Conference
- Drag equation
- Principles of Yacht Design. Lars Larsson, Rolf E. Eliasson and Michal Orych
- Openfoam
- Hydrodynamic Design of Planing Hulls. Marine Technology , D. Savitsky
- Procedures for Hydrodynamic Evaluation of Planing Hulls in Smooth and Rough Water. D. Savitsky, PW Brown
- NVIDIA WaveWorks