3D Simulation of N Particles Randomly Dispersed
3D Simulation of N Particles Randomly Dispersed
3D Simulation of N Particles Randomly Dispersed
Jos e Carlos Garc a Reyes Facultad de Ingenie a El ectrica Universidad Michoacana de San Nicolas de Hidalgo Morelia Michoacan, M exico August 28, 2013
Abstract We present a sequential programming for a 3D simulation of N particles randomly dispersed. The mathematical model for this kind of particles can be used in a great number of physical phenomenons, however one of the most important applications is the simulation of uids. In these approach the uid is considered as a collection of millions of particles interacting between them and in some cases with the surroundings, nowadays to carry out the calculation of such kind of models represents a challenge. In order to get the information of each particle in the most ecient way a computer algorithm is used . The present work is a simulation of a simplied model of N particles dispersed randomly, however the features of the dynamic system of particles shows an interesting behavior that resembles a nonlinear dynamical system in the theory of chaos, a detailed discussion of the issues and interpretation of the simulation is presented. Keywords Particles, Simulation, threedimensional. Phenomenons, Dynamic System.
1 Introduction
In its most basic form a computer is any device which aids humans in performing various kinds of computations or calculations. Every computer supports some form of input, processing, and output. So, we input information, the computer processes it according to its basic logic or the program currently running, and put out the result. The rst generation (1940s -1950s) of electronic computers contains vacuum tubes, and they were so big that 1
a large room can be lled by a single computer and so complex that many people were concerned for their operation. The second generation (1955-1960) of computer came true thanks to the invention of the transistor that replaced the vacuum tubes in the computer design. The transistor computer consumed less power, produce less heat, and were much smaller compared to the rst generation. The third generation (1960s) were characterized with the invention of the integrated circuits (ICs) also known as microchips, that dene the computer as we know them today; it was a big step for the next generation. The fourth generation (1971-Present), started with the rst microchips-based central processing unit based on a set of multiple microchips for dierent CPU components. The rst single-chip CPU, or a microprocessor, was the Intel 4004. Today there is a great variety of processors of lager speeds compared to its predecessors. At the beginning of 1990, the animation 3D was a thing far away even from imagination. But was the great opportunity for the Graphics Cards, since they where devices dedicated to the 3D graphic [1]. In this context nowadays the 3D simulation of the natural phenomena is an interesting subject. One of the most important applications is the simulation of uids that can represent any type of uid as a collection of millions of particles that interact in many ways that depends on the physical conditions of the system. In this models the calculations made for each particle are long and the computer algorithms are needed for obtaining information in the shortest possible time and in the most precise way[?]. This is one of the important motivations of this project, develop an ecient simulation of such models. However, this work is a small step in a long road, at the end of the road we hope to be closer develop models as complex as those we see in real life. In this article we will discuss the problems that
can arise in sequential programming for a 3D simulation with a number N of randomly dispersed particles. In the present work we use a simplied situation in which the particles moves in one single direction, and the system of particles is restricted to a 3D box. The results of the simulations were strange but interesting, it turns out that the evolution depend on the initial condition for the localization of the point in which the evolution started, and even more interesting the simulation seems to behave like the lines of a magnetic eld. The interpretation of the simulation, became dicult until we look at the a theory of chaos. The theory of chaos is a proposal to explain dynamical nonlinear systems, in which the initial conditions leads to a dierent nal state. The nal interpretation for the 3D simulation presented is that it resembles a nonlinear dynamical system.
3D cube and related to the position vector (1) by the following equation Wi = M i + V i . The vector Mi is dened by the equation Mi = Mx0 , My0 , Mz 0 xi , yi , zi , (5) (4)
where the vector M0 = Mx0 , My0 , Mz 0 can be any vector located in the 3D cube, and it can be interpreted as an initial condition for the model in the context of chaos theory. Taking into account that if |Mi | 500 the vector Mi will be replaced by Mi = Mi . | Mi | These equations give the specic information for one of the N particles, in our work we intend to obtain the information for the entire system of particles. The calculations are large, repetitive and inefcient by hand and is precisely in this point where the computer algorithms are needed for obtaining information in the shortest possible time and in the most precise way.
3 Technical Specications
The tool used for the development of the simulation was a framewoks. The frameworks is an open source in C + +, this has a kit of tools designed to assist the creative process by providing a simple and intuitive framework for experimentation, it use libraries to support in building source code. The libraries used in the development of the code are [4]:
1. OpenGL, The evolution of the point particles starts with a movement from top to bottom, and we consider 2. GLEW, the 3D space divided into two sections, each section with M particles that are limited in such a way 3. GLUT. that when a particle reaches the limit it returns to the starting point at the beginning of the section, These are the most important libraries in graphin other words, the movement takes place from top ics programming used by openFrameworks. to bottom in the upper section and viceversa in the lower section. This movement can be described with 3.1 Structure frameworks the speed vector equation (2) with a single constant Its structure comprises three main sections: component in the y direction. Now let us focus in the dynamics and randomness 1. Setup of the particles, for the 3D simulation the following relation gives the new position of the particle (a) This function is the soul of the code. In this part are loaded with all the features Xi+1 = xi , yi , zi + Wxi , Wyi , Wzi t. (3) of the program to run. where Wi is a new velocity vector of each particle. This new velocity depends on a vector M inside the 2. Update 2
(a) update is a function begin a loop that continues until your program ends. Its function is update the variables that changing with time.
3. Draw
void testApp::update() for (int i=0; i points.size(); i++) speeds[i].y += 0.1; points[i] +=speeds[i]; speeds[i] *= 0.98; ofVec3f M = ofVec3f(incX, incY, incZ) points[i]; if ( M.lenght 500) M.normalize(); ; speeds[i] += M
(a) Its function is to draw the shapes that are set in the code.
Dene a pair of vectors, these vectors contains the position points and speed speed of each particle. In order to get the position and speed of each particle we start a cycle from 0 to i. Where the initial value for speed is a random vector and then the cycle start with speeds[i].y = speed[i].y + 0.1 then points[i] = points[i] + speed[i] and get the new value for speed speed[i] = speed[i] * t where t is the time of the simulation. Dene a vector M the initial condition is given by L/2, L/2, 0 M = M - points[i] if |M | 500 then = M M |M | This value is added to get the new speed vector speeds[i] = speeds[i] + M
The seudocode in the programming language Initial conditions C++, reduces to the following lines 1. points.size = 10,000 particles 3
Figure 1: 20,000 particles to 277 FPS The rst simulation starts with 20,000 particles in space with a radius of attraction of 500 units. At a time of 1.05 sec after onset. Look at Figure 1. Figure 5: 54,000 Particules, t = 2.01 sec, Figure Formation
Initial conditions 1. points.size = 9,000 particles Figure 3: 20,000 particles, Vertical formation 2. t = 0.98sec 3. M = ( 633 , 434 , 0 ) 4
small change in the initial position of the vector is the translated in a change of the initial conditions of a dynamical system in chaos theory. The rare behavior of the system of particles can be tted in the chaos theory, but for obtain a truly nonlinear dynamical system in chaos theory some modications of the mathematical model must be carefully made. On the other hand the model presented here is very simple, but can be extended to a more realistic model for a specic phenomena present in nature; for example a uid in the uniFigure 7: Formacion a 2 seg despues de iniciado verse or cosmic expansion among many others; and new algorithms can be implemented in order to get 4. speeds = (Random(-1,1),Random(- the information in a more ecient way. 1,1),Random(-1,1)) El caso tres, podemos observar que al cambiar las condiciones iniciales, la formacion de guras puede variar. Este se vuelve dicil de predecir, ya que por cada nueva condicion inicial se puede se puede obtener una gura distinta. Podemos ver la formacion de anillos de rerentes tama nos al rededor de una comulacion de puntos que aun siguen en movimiento. En el comienzo de la simulacion, observamos la acomulacion y movimiento de las particulas. Vease Figura 6, La gura 7 se nota ya la formacion de los anillos al rededor de un punto. Y en la parte superior se asemeja al comportamiento de los casos 1 y 2. La gura 8 la formacion de los anillos esta completa y las particulas en la parte superior estan tan juntas que se pierden de vista.
References
[1] David Luebke, Greg Humphreys, How GPUs Work, IEEE Computer, USA, February 2007 [2] Galileo 1638 Discorsi e Dimostrazioni Matematiche, intorno a due nuoue scienze , published by Lowys Elzevir (Louis Elsevier) [3] Raymond A. Serway, John W. Jewett Jr. , Principles of Physics A Calculus Based Text, 4th Edition, 2005, pp 260 - 262. [4] openFrameworks, About,http://www.openframeworks.cc/about/. [5] openFrameworks,tutorials, http://www.openframeworks.cc/tutorials/introduction/. [6] Aqui hay que poner todos los articulos de chaos
4 Conclusion
The present work shows a 3D simulation N particles randomly dispersed, the results shown in the simulation resembles a dynamical nonlinear system in chaos theory. The vector Mi , can be interpreted as an initial condition for the set of equations, a 5