Friday, September 16, 2011

Build a numerical simulation in medicine and biology. Part One.

my simple boids simulation
                Every problem can be described using the language of mathematics, but the question at what level we wish to remain. The ideal is to take account of fundamental rights, which show all the rest. Then we create a very realistic simulation, where everything occurs spontaneously. The downside is the cost of computing and often quite complicated boundary conditions. Because the lower level we choose, the more calculations we have to do (although often these calculations are simpler). 
               An example of a simple idea is to calculate the propagation of inviscid fluid through network of connected vessels. These vessels form a circulatory system of man for example.  The problem is identical with the calculation of resistance of replacement network of interconnected resistors, or current flow in electrical networks. You can use the method of nodal potentials, delta-Wye solution, rely on Kirchhoff's law. This requires usage of equations systems and solve it one of the available methods, for example, by Gauss. Otherwise, you can try to apply the transform of the delta-wye (delta - y), to transcribe entire network of resistors (communicating vessels), as a series-parallel arrangement. Then simply use the already familiar with the primary method used to calculate. Beautiful ideas, but still quite complicated and difficult to implement. The algorithms necessary for the calculations are quite complicated and write, debug them, may take a very long time. 
               But if you think you can come up with a simpler idea, offering a solution less accurate, the convergence (to determine the final solution), which often have to wait a bit. Method based on the idea at once banal and beautiful. Well, for every  network node the same amount of fluid comes in, than comes out. Whether we talk about electric current, or a liquid. As the resistance of connections, we cannot modify, we affect only the pressure in each step. In each step of the simulation, modifying the pressure in the network nodes to balance the quantities of liquid entering and leaving was zero - which is an equivalent of lack of accumulation (non compressibility condition). 
               But everything depends on the use of simulation. Programs for electronics design, based on complicated mathematical apparatus, can’t wait to determine the numerical solution of the assumed error. This would be impossible and unprofessional. In this case, we put more work and create a reliable and fast algorithm, giving instant and accurate solution. 
               Another problem is choosing the method of calculation. Do you peel the analytical methods or numerical? If the boundary conditions for known already established analytical solution exists, you can try to use it. For example, the heat loss by a man at rest. Someone measured it, set the coefficients for each of the methods of heat loss and posted a solution. Does it make sense to model the skin perfusion, each of the ways of heat loss, including the account convection in the atmosphere? You can, but it borders on insanity. It requires a lot of knowledge (fluid mechanics, etc.), computational power, and the same number can be achieved using a simple formula. 

               In practice, it often turns out that the solution of the model differs significantly from the observations (the worse for observation!). In fact, you have to deal with it. Each simulation is simplification of the real world. If the results are significantly different from each other, it probably means that one of the important factors wasn’t included. This is important in nonlinear problems. An example here would be forecasting the weather. Models can be perfect, but a small measurement error, or not quite dense network of meteorological stations, makes the forecast misses the truth after a few days. 
               No less important is the presentation of data listed. How many dimensions we are able to fit on the surface of 2D? It appears that up to 2, You can, however do much more. Coding of color, shape characters and symbols allow you to place a few times more data. The problem is readability. 
               Graphics and animation much more speaks to the audience's imagination, than the pillars of graphs, but charts and bars much more than tables of figures or just plain numbers. Although the animation is often unavailable to the needs of education, such as most bars charts. Always avoid numerical data in raw form. Spare no graphics and charts. 
               Choosing a programming language, unfortunately, is often a choice of lesser evil, between 'how fast can write "and" how fast will work".  At least in the case of numerical simulations where speed od calculations is critical. Please be aware of computing power it’s available for you to use. Most problems can be resolved quickly enough even using relatively slow FLASH. The advantage is its portability between platforms and availability for your browser. Similarly, the situation is with Java, except that Java  is much faster. Jobs once said that "if something uses flash, it is certainly possible to fry an egg on it" and had a little wrong. Since then, one will not find a flash player installed on devices from Apple. The speed of calculation provides a C + +, especially if you use accelerated computing on the GPU nVidia CUDA. Alone with this technology still did not use, but I know that not every calculation can be accelerated. Acceleration is greatest when large amounts of simple calculations, the best on grids, which can easily be divided into individual units spreadsheets. With this, amount of transfers between RAM  and GPU should be as small as possible. If we care about time, good, if a programming language provides us with ease of presentation of the data in graphical form, or interactive. Operation using the command line, not the most user-friendly.  
               Everything should be considered before we start the project. In the middle it is difficult to change the design of the project, and if decide so, we lose a lot of valuable time and workhours. 

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...