[MUSIC] Finally I will introduce you to real example that is an application of this simulation to investigate as our link to volcano eruption. So when people think about volcano eruption and as of, usually they think about lava and magma, lava flowing but is not the most dangerous problem from human being because lava flows are really slow. There are lots of more dangerous phenomena and one of them being ballistic, that is to say huge chucks of magma or rocks that were inside the conduit of the volcano that fragments and is ejected with characteristic parabolic curve. And those chunk of magma are most of the time small, but they can be big or really big. For example, here you can see a night picture of an eruption at the north of Sicily. And you can see the lava flowing on the side of the vent of the volcano. But you also see that kind of plume made of particles of a chunk of magma that are glowing red and yellow. And you can see that they follow trajectory really close to parabolas. You have kind of a bundle of parabola together getting out of the volcano. In this eruption that is pictured here you can see that the bombs, we call usually bombs these ballistic particle, but the bombs are not going very far away from the volcano. But in fact, they can, they can land several hundred meters far away. For example, that is a field on the side of a volcano in Hawaii, and you can see that you have particle of different size that were deposited to the ground covering a large space. Here for example you can see two huge example of volcano ballistic or volcano bombs that landed, that's another volcano in Sicily, it's the volcano. And you can see that this bomb can be pretty big in size. Here you can see in the right picture the [INAUDIBLE] who was the main researcher. She did her PhD on the subject. And this bomb are not only huge and really heavy, they can weigh several towns, but also they are really hot and yeah they can be more than 700 degrees. So if they fall in houses they will probably destroy the roofs and start fire everywhere. So trying to predict what are the zone around the volcano where this bomb can land is important step in order to predict all the results that can affect people living around volcanoes. If we assume that bombs are sphere and we neglect the friction with the air, we neglect the direct force. We can really easily describe the motion of bomb by giving it's position a velocity, a radius, and a mass. And the bomb will follow a simple, uniformly accelerated motion. Again, that's clearly pre-college physics that allow us to predict the location of the bomb at each timestamp in the future or since it's a parabola even in the past. And we can also use this really simple motion equation to detect when the bomb will land on the ground, when the bomb will deposit is simply when. For example, if we consider volcanic islands, where the only terrain, the most significant terrain is the volcano cone itself. So, we can consider that the rest of the island is close to the sea level, zero. So, when the altitude of the bomb reaches zero we can say that at that time it will deposit. But, we could also try to use this approach to detect the collisions between bombs because some scientists have published data where a trajectory of the bomb are deflected during their airborne time. And so it can arise from collisions between bombs. So in our research, we wanted to investigate how these collision are able to spread and how much they are able to spread the location of a bomb in the ground. Where the bomb will impact due to collision. And it's quite easy to detect them because again, it's a simple parabola, so we could use the following condition to detect collision. So first simply the distance square between two bombs at a given time is the subtraction of the position vectors, and then we multiply it by itself to get the square of the num. And if this number is equal to the sum of the radius of both bombs square, it means if the bomb barley touch they are in collision. So we could also solve this new quadratic equation to try to find the point in the time where the bomb will collide. Of course a quadratic equation, so it can have zero solution, means that the bomb will not collide, just one, or even two. Because the two prabolas can cross in two points. Again, here if we take into account all the possible collision there's no way to have an analytic solution. And we could have a continuous time solution by moving every air bomb by slight delta t, slight time step, and then check all the possible collision by all pairs of particles to see if they are colliding. Or perhaps using some more interesting data structure for that to try to use up that you have seen in molecular dynamics. But in that case, again collision will be quite uncommon because the space is large, and the bomb, even big they are not so big. So collision will be uncommon, most of the time, the bombs will follow a simple parabola and deposit. So here, discrete events simulation seems, really, a good candidate for that, and that's how we used to model that kind of problem. Again, the states is really easy. For each bomb we keep it's velocity, it's position, the radius and the mass. If we go in time we simply follow the parabola given by the equation to find it's new position. And then we keep two lists, first a list with all the airborne particles, that is to say the particle resting in air and that will be deposited later. And we keep a list with all the bombs that are already deposited because that's what we are interested in too. At the end of the simulation we want to have a map and to understand where the bomb would be deposited. In that case, we want to compare what is the role of the collisions. In the events, we have three kind of events. First of all, the eruption every time there's an eruption there's an explosion. We can generate one or more bombs. So we associate every eruption event with a distribution. There are lots of volcano with, when they erupt in fact they have several bursts which can be really close in time and they will, I don't know, during one minute have a hundred of such burst and every burst they are, bombs which are ejected. So every one of these bursts, in that case, will be an eruption event. So, eruption can create one or more bomb. It is associated to a statistical distribution that will allow us to draw a new bomb according to empirical observation of ejection of bombs. And this distribution will allow us to draw the size of the bombs, its mass and density, the initial velocity and so on. But the two other event that we're interested in is collision first. Collision between two bombs, between b1 and b2. So this event means a time(t). b1 will collide with b2. The last event is ground, it means at time t, the bomb b1 will hit the ground. It's interesting to see that each event is related to zero, one, or two bombs. So eruption to zero bomb because it still don't exist when the event occurs, that will exist right after. Collision is related to two bombs, because and ground to one. We will use that to clean the queue as far as we simulate the system. So the old code here, all the interesting part of the code is hidden inside the action of the events. And in fact, that's the more important thing to define when you are running your own DS simulation is to be sure to understand exactly what most actions should do. And ideally you should put all the possible logic there, because then you know exactly where to find it. And it's quite easy to debug, because every action will have an effect which is perhaps not deterministic but is predictable on a part of the state. So you can debug and think about your action events separately and that make your queue code easier. So using the same formalism that I've showed you with traffic simulation, I will present you each event. So first their eruption, so what we do when there's an eruption? First of all, we make each air bomb advance to the time of the event. So, at the given time or the state, we have a list of airborne particle and they all out of position and velocity. So you can imagine that they are in air, they have a direction, etc., but they are frozen. So, as soon as we have an event, we know that nothing did appear before, nothing significant, so we can make all the particle jump to the next time. So all the bombs will advance at the same time. And then we could process the event. So the first thing to do is this loop here. For any bomb, for each bomb in the list of air bomb, we jump to the time, we make this bomb update its stated position to correspond to the time of the event. Then we can generate the new bombs using the distribution, this bs variable. And then for every bomb in bs, first of all we can compute is the position time with the function, the position time, simply solving the quadratic equation. And we insert in the queue a new event which is the bomb, b1, will hit the ground at time td. And then for every bomb already in the air, we will try to compute the collision time between b1 and b2. So here perhaps they will never collide. So perhaps that in fact tc will not be a number, so in that case we have to ignore it. And if there are two possible collision time because again we are considering the intersection between two quadratic equations so we can have two different solution in that case. Simply you will take the next one in the order of time, which is not in the past, but we will take it. And we insert all of that. So the idea is that first of all, for every new bomb, we know exactly when it will fall to the ground and then we will know when it will collide with other particles. Of course, those are assumptions because the other particles could collide before and then change all the trajectory, but we consider that, for the given picture, that's what could happen in the future. So, we can then do the same kind of process for the other events. So for a collision between bombs b1 and b2. So first of all again, we have a loop to be sure that all the particles reach this point in time, since we know that nothing was significant before. And we can clean the queue. It means that since the particle b1 and b2, the bomb of b1 and b2 will collide, it means that they will change trajectory. So all the events related to b1 or to b2 in the future should be invalidated, because they will change trajectory and thus we would have to recompute when after this trajectory change when they will hit the ground and if they will collide with other bombs. So in that case, if b1 and b2 they collide, first of all we have to make the jump to the correct moment to clean the queue as I told you. And then we have to recompute everything about this particle because they will change trajectory, so new deposition time. And for each one of these particles we also have to, again, compare them to all the airborne particles to find the next possible collision. It's the same thing for the ground events. So when a particle hit the ground, we know that all the particle can jump in time to that point because nothing was significant before. And we can simply remove from the queue all the other event particles because it hit the ground, so it won't move again. And finally, we update the air bomb list. We remove the particle deposited from the air bomb and add it to the list of deposited particles. So events were pretty simple. Here is an example of evolution. So here we have three, four events represented by red circles. The first one is at the vent of the volcano it did happen in time before in the eruption. So let's pretend that we are at this stage of evolution and when the eruption take place, we have to compute possible collisions and ground deposition events. Of course they cannot happen all of them. But we can generate all of of them, put them in the queue, simply the first one will be selected. So here of course, they will collide before they hit the ground. So we know that we can jump the simulation time up to this point and it will change the trajectory, for example like that, and we could compute a new ground, a new collision for these two particular. The other particle will fall far away from the island, so we won't compute its ground. But doing like that we can just have a speculative list of possible events and since we jumped to the next one then we will ignore all the other by cleaning up the queue every time a trajectory is modified. That's worked really well, so that's first the traces of the moving particles. So at left you can see an example of eruption without collision and at right exactly the same parameter but taking into account the collision. And it's interesting to see how the bundle of parabola but some of them seems more spread. And if we try to analyze what happens with and without collisions. So, without collisions the simulation corresponding to the left image in the previous slides. Every impact here is represented by a green dot, and the simulation with collision every impact is represented with a red or a blue dot. Red dots are bombs which indeed collided and blue are bomb that could have collided but they did not. And what is interesting to see is that in fact most of the bombs are not affected by collision but when they are there's a chance that the radius will increase. That means that simple analysis of just the initial velocity of bombs and their angle cannot explain us exactly what's the critical radius where such is possible. And collision could effect the results. If you're interested in that example, I recommend you to read this nice paper from Tsunematsu et al., that was published recently in Computers Geosciences. And finally I would like to thank these two authors to the picture that I showed you in my introduction. That ends this seventh week lecture about discrete event simulation. Thank you for your attention, I hope you enjoyed this subject. [MUSIC]