# Patent

## Title
Method for calculating force acting on interface between immiscible fluids in fluid simulation

## Abstract

A method for calculating a force acting on an interface between immiscible fluids in an SPH (Smoothed Particle Hydrodynamics) based fluid simulation includes: calculating a force caused by viscosities of the fluids; calculating a force caused by pressures of the fluids; calculating an external force applied to the fluids from outside; and calculating an interactive force caused by interaction between the fluids. The force acting on the interface between the immiscible fluids are obtained by using sum of the force caused by the viscosities, the force caused by the pressures, the external force and the interactive force. The interactive force is a surface tensional force calculated based on a pressure acting on the interface between the fluids.

## Background
CROSS-REFERENCE(S) TO RELATED APPLICATION(S)
The present invention claims priority of Korean Patent Application No. 10-2008-0131367, filed on Dec. 22, 2008, which is incorporated herein by reference.
FIELD OF THE INVENTION
The present invention relates to a particle-based fluid simulation; and, more particularly, to a method for calculating a force acting on an interface between immiscible fluids in an SPH (Smoothed Particle Hydrodynamics) based fluid simulation.
BACKGROUND OF THE INVENTION
There are many methods relating to interaction between immiscible fluids in a smoothed particle hydrodynamics (hereinafter, simply referred to as “SPH”) based fluid simulation. Particularly, there are two methods showing good visualization results in a graphics animation field: a first method using surface tension and a second method of changing velocities and positions of particles.
The first method uses property in which particles on a surface do not have a force maintaining balance with an inwardly acting force so that the particles on a surface are unstable than particles in the fluids and tend to form a sphere having the smallest surface. In this method, a force in proportion to magnitude of curvature acts in the normal direction of the particles. That is, the first method relates to a shape of a group of fluid particles.
However, in case of setting the surface tension to be weak in the first method, it is difficult to control mixing and scattering of the particles due to differences in velocities and pressures thereof occurring when the fluids collide. In case of setting the surface tension to be strong, the fluids shrink to overall form a sphere and stability of a system is damaged.
The second method of changing velocities and positions of particles detects collisions between the particles and changes the velocities and positions of the particles to prevent the particles from colliding with each other. This method shows a good result in simulating fluids which are not mingled with each other at all.
However, the collision detection as shown in FIG. 1A required to be performed in every simulation steps in the second method takes a considerably long calculation time. Further, in the second method, the collisions are prevented by instantly changing the calculated positions of the particles as shown in FIG. 1B to those as shown in FIG. 1C. However, distances between the particles are too short in FIG. 1C, which damages stability of a system in the next simulation step.
SUMMARY OF THE INVENTION
In view of the above, the present invention provides a method for calculating a force acting on an interface between immiscible fluids in an SPH based fluid simulation, which adds a surface tensional force based on a pressure acting as a major factor in scattering and mixing of the fluids during the collisions therebetween, thereby shortening calculation time and maintaining stability of a system.
In accordance with an aspect of the present invention, there is provided a method for calculating a force acting on an interface between immiscible fluids in an SPH (Smoothed Particle Hydrodynamics) based fluid simulation, the method including:
calculating a force caused by viscosities of the fluids;
calculating a force caused by pressures of the fluids;
calculating an external force applied to the fluids from outside; and
calculating an interactive force caused by interaction between the fluids,
wherein the force acting on the interface between the immiscible fluids are obtained by using sum of the force caused by the viscosities, the force caused by the pressures, the external force and the interactive force.
Preferably, the interactive force is a surface tensional force calculated based on a pressure acting on the interface between the fluids.
Preferably, the interactive force is calculated by using parameters representing scattering properties of the fluids, normal vectors of particles in the fluids, a magnitude of the a force caused by the pressure acting on the interface between the fluids and an angle between a direction of the force caused by the pressure acting on the interface between the fluids and the interface of the fluids.
Preferably, the angle between the direction of the force caused by the pressure acting on the interface between the fluids and the interface of the fluids is calculated by using the normal vectors of the particles.
Preferably, the normal vectors of the particles are calculated by using variations of color fields assigned to the particles.
Preferably, each of the parameters representing the scattering properties has a value in a range from 0 to 0.5.
Preferably, a magnitude of the interactive force is determined by the magnitude of the force caused by the pressure acting on the interface between the fluids and a difference between the direction of the force caused by the pressure acting on the interface between the fluids and a direction of an average normal vector of the normal vectors of the particles.
In accordance with another aspect of the present invention, there is provided a computer-readable storage medium for storing therein computer-readable programs to execute on a computer the method of claim 1.
According to the present invention, only by adding to an SPH based fluid simulation an interactive force, calculated based on a pressure acting on an interface between fluids, acting on an interface between immiscible fluids, realistic and excellent visualization results can be obtained. The method of the present invention can be applied to an interaction between fluids following different fluid equations as well as fluids following identical fluid equations.
Further, since the interactive force can be calculated by using normal vectors of particles in the fluids and a magnitude of a force caused by a pressure acting on an interface between fluids only, simulation time for the fluid simulation can be shortened.
Furthermore, since the SPH based fluid simulation is used without changing a position and velocity of a specific particle, stability of a simulation system can be improved.



BRIEF DESCRIPTION OF THE DRAWINGS
The above features of the present invention will become apparent from the following description of embodiments, given in conjunction with the accompanying drawings, in which:
FIGS. 1A to 1C illustrate explanatory views of a conventional fluid simulation method;
FIG. 2 illustrates a group of particles for explaining a method for calculating a force acting on an interface between immiscible fluids in a fluid simulation in accordance with the present invention; and
FIG. 3 illustrates an average normal vector of the particles in FIG. 2.



DETAILED DESCRIPTION OF THE EMBODIMENTS
Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings, which form a part hereof.
FIG. 2 illustrates a group of particles for explaining a method for calculating a force acting on an interface between immiscible fluids in a fluid simulation in accordance with the present invention. Fluids A and B in FIG. 2 are immiscible fluids. The fluid A has a particle i and the fluid B has a particle k, respectively. Here, the first fluid A is assumed as a Newtonian fluid and the second fluid B is assumed as a non-Newtonian fluid, which means that the particles i and k belong to different particle systems.
In general, movement of a fluid is represented by a continuity equation and a momentum equation. The continuity equation and the momentum equation are as in Equation 1 and Equation 2, respectively:




  
    
      
        
          
            
              D
              ⁢
              
                
              
              ⁢
              ρ
            
            
              D
              ⁢
              
                
              
              ⁢
              t
            
          
          =
          
            -
            
              ρ
              ⁡
              
                (
                
                  ∇
                  
                    ·
                    V
                  
                
                )
              
            
          
        
        ,
      
    
    
      
        Equation
        ⁢
        
          
        
        ⁢
        1
      
    
  
  
    
      
        
          
            ρ
            ⁢
            
              Dv
              Dt
            
          
          =
          
            
              -
              
                ∇
                P
              
            
            -
            
              [
              
                ∇
                
                  ·
                  τ
                
              
              ]
            
            +
            
              ρ
              ⁢
              
                
              
              ⁢
              g
            
          
        
        ,
      
    
    
      
        Equation
        ⁢
        
          
        
        ⁢
        2
      
    
  




wherein, V, ρ, P, g and τ respectively denote a velocity of a fluid, a density of the fluid, a pressure of the fluid, an external force acting on the fluid and a shear stress acting on the fluid.

Among the above-described two equations, the present invention relates to the momentum equation. Hereinafter, calculating forces acting on the particle i in the fluid A will be described. However, it should be noted that forces acting on the particle k in the fluid B can be calculated in a same manner as that for the particle i, except for features depending on the particle system to which it belongs.
From Equation 2, an acceleration ai varying a velocity of the particle i can be derived as in Equation 3:




  
    
      
        
          a
          i
        
        =
        
          
            
              Dv
              i
            
            Dt
          
          =
          
            
              1
              
                ρ
                i
              
            
            ⁢
            
              
                (
                
                  
                    -
                    
                      ∇
                      
                        P
                        i
                      
                    
                  
                  -
                  
                    [
                    
                      ∇
                      
                        ·
                        
                          τ
                          i
                        
                      
                    
                    ]
                  
                  +
                  
                    ρ
                    ⁢
                    
                      
                    
                    ⁢
                    
                      g
                      i
                    
                  
                
                )
              
              .
            
          
        
      
    
    
      
        Equation
        ⁢
        
          
        
        ⁢
        3
      
    
  




Assuming that the acceleration ai be a force fi acting on the particle i, the force fi includes three terms as in Equation 4:




  
    
      
        
          f
          i
        
        =
        
          
            a
            i
          
          =
          
            
              1
              
                ρ
                i
              
            
            ⁢
            
              
                (
                
                  
                    f
                    i
                    viscosity
                  
                  +
                  
                    f
                    i
                    pressure
                  
                  +
                  
                    f
                    i
                    external
                  
                
                )
              
              .
            
          
        
      
    
    
      
        Equation
        ⁢
        
          
        
        ⁢
        4
      
    
  




In Equation 4, the term of fiviscosity corresponds to the term of −[∇·τi] in Equation 3, which is a force relating to a viscosity because a viscosity of the fluid A involves in calculating τi. The term of fipressure corresponds to the term of −∇Pi in Equation 3, which is a force related to the pressure. The term of fiexternal corresponds to the term of ρgi in Equation 3, which is a force applied from outside, e.g., the gravity.
Considering an interactive force acting on an interface between immiscible fluids A and B, the force fi can be rewritten as in Equation 5:




  
    
      
        
          
            f
            i
          
          =
          
            
              1
              
                ρ
                i
              
            
            ⁢
            
              (
              
                
                  f
                  i
                  viscosity
                
                +
                
                  f
                  i
                  pressure
                
                +
                
                  f
                  i
                  interface
                
                +
                
                  f
                  i
                  external
                
              
              )
            
          
        
        ,
      
    
    
      
        Equation
        ⁢
        
          
        
        ⁢
        5
      
    
  




wherein the newly added term of fiinterface is a surface tensional force interactively acting on the interface between the fluids A and B, i.e., the interactive force.

In Equation 5, the forces fiviscosity and fipressure are as in Equations 6 and 7:




  
    
      
        
          
            f
            i
            viscosity
          
          =
          
            
              ∑
              k
            
            ⁢
            
              [
              
                
                  
                    V
                    ⁡
                    
                      (
                      i
                      )
                    
                  
                  +
                  
                    V
                    ⁡
                    
                      (
                      k
                      )
                    
                  
                
                2
              
              ]
            
          
        
        ,
      
    
    
      
        Equation
        ⁢
        
          
        
        ⁢
        6
      
    
  
  
    
      
        
          
            f
            i
            pressure
          
          =
          
            
              ∑
              k
            
            ⁢
            
              [
              
                
                  
                    P
                    ⁡
                    
                      (
                      i
                      )
                    
                  
                  +
                  
                    P
                    ⁡
                    
                      (
                      k
                      )
                    
                  
                
                2
              
              ]
            
          
        
        ,
      
    
    
      
        Equation
        ⁢
        
          
        
        ⁢
        7
      
    
  




wherein the terms of V(i) and V(k) in Equation 6 are forces respectively caused by viscosities of the fluids A and B, while the terms of P(i) and P(k) in Equation 7 are forces respectively caused by pressures of the fluids A and B. The forces V(i) and P(i) are calculated based on the particle system of fluid A, while the forces V(k) and P(k) are calculated based on the particle system of fluid B.

Referring back to Equation 5, the interactive force fiinterface can be calculated by using normal vectors of the particles i and k and an average normal vector of the particles i and k FIG. 3 illustrates a normal vector n(i) of the particle i, a normal vector n(k) of the particle k and an average normal vector Nik of the particles i and k. The average normal vector Nik determines the interface of the particles i and k. The interactive force fiinterface is as in Equation 8:




  
    
      
        
          
            f
            i
            interface
          
          =
          
            
              ∑
              k
            
            ⁢
            
              
                (
                
                  
                    
                      a
                      i
                    
                    +
                    
                      a
                      k
                    
                  
                  2
                
                )
              
              ×
              
                (
                
                  1
                  -
                  
                    cos
                    ⁢
                    
                      
                    
                    ⁢
                    
                      θ
                      ik
                    
                  
                
                )
              
              ×
              
                
                
                  f
                  ik
                  pressure
                
                
              
              ×
              
                
                  N
                  ik
                
                _
              
            
          
        
        ,
      
    
    
      
        Equation
        ⁢
        
          
        
        ⁢
        8
      
    
  




wherein the term of Nik denotes a unit vector of the average normal vector Nik, and the term of fikpressure denotes a force caused by a pressure acting on the interface between the fluids A and B. Further, the terms of ai and ak denote parameters depending on the respective particle systems of the fluids A and B, and represent immiscibility properties, i.e., degrees of being scattered (scattering properties), of the particles i and k, respectively. The term of θik denotes an angle between the force fikpressure and the average normal vector Nik, i.e., an angle between the force fikpressure and the surface of the fluid A.

The normal vectors n(i) and n(k) can be easily obtained by assigning the particles i and k with respective color fields. For example, a color field having a value of one may be assigned to the particles of the fluid A and a color field having a value of zero may be assigned to the particles of the fluid B. Then, the normal vectors n(i) and n(k) can be obtained by calculating variations of the respective color fields, as in Equations 9 and 10:

n(i)=∇Ci,  Equation 9

n(k)=∇Ck,  Equation 10

wherein the terms of Ci and Ck are color fields assigned to the particles i and k, respectively.

Referring back to Equation 8, the term of cos θik is defined as in Equation 11:




  
    
      
        
          cos
          ⁢
          
            
          
          ⁢
          
            θ
            ik
          
        
        =
        
          
            
              f
              ik
              pressure
            
            ·
            
              
                N
                ik
              
              _
            
          
          
            
            
              f
              ik
              pressure
            
            
          
        
      
    
    
      
        Equation
        ⁢
        
          
        
        ⁢
        11
      
    
  




As shown in Equations 8 and 11, a magnitude of the interactive force fiinterface depends on a difference between a direction of the force fkpressure and a direction of the average normal vector Nik. If the two directions are identical, the term of (1−cos θik) in Equation 8 becomes one so that the magnitude of the force fiinterface becomes zero. Accordingly, if the direction of the force fikpressure is identical to that of the average normal vector Nik, it is not necessary to apply an additional tension to stabilize the particles on the surface of the fluid A. If the direction of the force fikpressure is in reverse to that of the average normal vector Nik, the term of (1−cos θik) in Equation 8 becomes two so that the magnitude of the force fiinterface becomes its maximum value.
As for the parameters ai and ak in Equation 8, since the forces fiinterface and fipressure need to meet a condition as defined in Equation 12 due to the angle between the force fipressure and the average normal vector Nik, the parameters ai and ak are set within a range from zero to 0.5:

|fiinterface|≦|fipressure|.  Equation 12

Particles on a surface of a fluid are more unstable than those in the fluid because they cannot maintain balance with inwardly acting forces. Such unstability increases in a simulation for an interaction between fluids following different fluid equations. This is because the particles on the surface are brought into contact with particles belonging to a different particle system which follows different fluid equations. Thus, when a pressure is applied to the immiscible fluids due to the collision, stronger attractions need to be applied to stabilize the particles on the surfaces. Accordingly, a major factor of the interactive force fiinterface in scattering and mixing of the fluids during the collision therebetween is a pressure acting on the interface between fluids, i.e., the force fikpressure in Equation 8.
In the present invention, instead of making the magnitude of the force fikpressure be in proportion to the magnitude of a curvature, the force fiinterface is adjusted according to the magnitude and direction of the force fikpressure as shown in Equation 8. Hence, the fluids can be prevented from being unrealistically scattered.
The method for calculating a force acting on an interface between immiscible fluids in an SPH based fluid simulation can be implemented by computer-readable codes stored in a computer-readable storage media. The computer-readable storage media may include all kind of storage media to which data read by a computer or the like is stored. The computer-readable storage media includes ROM, RAM, CD-ROM, a magnetic tape, a hard disk, a floppy disk, a flash memory, an optical data storage and a type implemented in the form of a carrier wave (e.g., transmission through internet). Moreover, the computer-readable storage media may be a distributed storage media distributed to computer systems interconnected to each other through a computer communications network, and the computer-readable codes are stored to be executed in the distributed storage media in a form of distributed codes.
While the invention has been shown and described with respect to the embodiments, it will be understood by those skilled in the art that various changes and modification may be made without departing from the scope of the invention as defined in the following claims.

## Claims

1. A method for calculating a force acting on an interface between immiscible fluids in an SPH (Smoothed Particle Hydrodynamics) based fluid simulation, the method comprising:
calculating a force caused by viscosities of the fluids;
calculating a force caused by pressures of the fluids;
calculating an external force applied to the fluids from outside; and calculating an interactive force caused by interaction between the fluids,
wherein the force acting on the interface between the immiscible fluids are obtained by a computer by using a sum of the force caused by the viscosities, the force caused by the pressures, the external force and the interactive force,
wherein the interactive force is a surface tensional force calculated based on a pressure acting on the interface between the fluids at a contact surface of the fluids, and
wherein the interactive force is calculated by using parameters representing scattering properties of the fluids, normal vectors of particles in the fluids, a magnitude of the force caused by the pressure acting on the interface between the fluids and an angle between a direction of the force caused by the pressure acting on the interface between the fluids and the interface of the fluids,
wherein the interactive force is calculated by using the following formula:





  
    
      ∑
      k
    
    ⁢
    
      
    
    ⁢
    
      
        (
        
          
            
              a
              i
            
            +
            
              a
              k
            
          
          2
        
        )
      
      ×
      
        (
        
          1
          -
          
            cos
            ⁢
            
              
            
            ⁢
            
              θ
              ik
            
          
        
        )
      
      ×
      
        
        
          f
          ik
          pressure
        
        
      
      ×
      
        
          N
          ik
        
        _
      
    
  
  ,




wherein Nik denotes an average normal vector of particles of i and k; Nik denotes a unit vector of Nik; fikpressure the force caused by the pressure acting on the interface between the fluids; ai and ak denote the scattering properties of the particles of i and k, respectively; and θik denotes the angle between the force fikpressure and the interface of the fluids.

2. The method of claim 1, wherein the angle between the direction of the force caused by the pressure acting on the interface between the fluids and the interface of the fluids is calculated by using the normal vectors of the particles.

3. The method of claim 1, wherein the normal vectors' of the particles are calculated by using variations of color fields assigned to the particles.

4. The method of claim 1, wherein each of the parameters representing the scattering properties has a value in a range from 0 to 0.5.

5. The method of claim 1, wherein a magnitude of the interactive force is determined by the magnitude of the force caused by the pressure acting on
the interface between the fluids and a difference between the direction of the force caused by the pressure acting on the interface between the fluids and a direction of an average normal vector of the normal vectors of the particles.

6. A non-transitory computer-readable storage medium for storing therein computer-readable programs to execute on a computer the method of claim 1.

7. A method for calculating a force acting on an interface between immiscible fluids in an SPH (Smoothed Particle Hydrodynamics) based fluid simulation, the method comprising:
calculating a force caused by viscosities of the fluids;
calculating a force caused by pressures of the fluids;
calculating an external force applied to the fluids from outside; and calculating an interactive force caused by interaction between the fluids,
wherein the force acting on the interface between the immiscible fluids are obtained by a computer by using a sum of the force caused by the viscosities, the force caused by the pressures, the external force and the interactive force,
wherein the interactive force is a surface tensional force calculated based on a pressure acting on the interface between the fluids, and
wherein the interactive force is calculated by using parameters representing scattering properties of the fluids, normal vectors of particles in the fluids, a magnitude of the force caused by the pressure acting on the interface between the fluids and an angle between a direction of the force caused by the pressure acting on the interface between the fluids and the interface of the fluids,
wherein the interactive force is calculated by using the following formula:





  
    
      ∑
      k
    
    ⁢
    
      
    
    ⁢
    
      
        (
        
          
            
              a
              i
            
            +
            
              a
              k
            
          
          2
        
        )
      
      ×
      
        (
        
          1
          -
          
            cos
            ⁢
            
              
            
            ⁢
            
              θ
              ik
            
          
        
        )
      
      ×
      
        
        
          f
          ik
          pressure
        
        
      
      ×
      
        
          N
          ik
        
        _
      
    
  
  ,




wherein Nik denotes an average normal vector of particles of i and k; Nik denotes a unit vector of Nik; fikpressure denotes the force caused by the pressure acting on the interface between the fluids; ai and ak denote the scattering properties of the particles of i and k, respectively; and θik denotes the angle between the force fikpressure and the interface of the fluids.