📜 ⬆️ ⬇️

Tablet is not a luxury

“Modern mobile phones have the same computing power as NASA computers in the 60s. And at that time it was enough to launch a man into space, and today only to launch birds into pigs. ”
Folklore

“You call it a perversion. But who said that perversion is bad? ”
One assistant professor of our department

The idea of ​​the experiment described below arose after a series of statements heard and overheard that modern tablets cannot act as instruments of serious research activity. Indeed, for many users, working with the tablet comes down to web surfing, email correspondence and various protocol messengers, reading books, watching videos and other mostly entertainment purposes. Also, as it should be expected and as the recent post shows, the tablet is an excellent mobile tool when working with "office" applications. However, the hardware characteristics of the existing technology allow us to think - how effective will the tablet be in the original field for computers.
')

Equipment



TeXeT TM-7025, with a 1 GHz processor, 512 MB of RAM and Android 4.0 on board, became the experimental one. My first computer, acquired in 2004, was a bit more powerful (Athlon XP 1.66 GHz, 256 MB of memory before and 1 GB after the upgrade), but it was replaced only in March 2012, it took Foreran to make course calculations for his life, and then paired with a laptop HP 550 - for two degrees, ensuring a successful graduation from school, undergraduate and graduate in the direction of theoretical physics with a specialization in computational fluid dynamics.

It is worth saying that the experimental tablet has a 7-inch screen, which sharply limits the ease of editing the source code, but an external computer was used for these purposes to a minimum. This article has already been written by third-party tools, although, to be honest, the introduction and this section are typed on a smartphone.

Soft



By virtue of occupation, I did not intend to tinker with porting available software, even in the limiting case of parsing the problem. Therefore, if this were not found, then there would be no experiment. However, a Google Play review showed that it has the Octave port on Android. Besides him, of course, there is also a very wide range of simpler programs, but there is no clarity with their computational capabilities, but Octave is a well-known program and there is already little experience with it. Therefore, there was nothing to choose from, but the opportunity to figure it out at the same time and with this system in more detail became an additional incentive to work. To draw graphs, the existing package requires the installation of a graphical droidplot package - a version of gnuplot ported by the same author.

Naturally, the program code is easier to write with separate text and simply load it into the Octave console. As an editor, I took the first one that came to hand, I mean the free version of DroidEdit.

Task



Trial launches were made on systems of differential equations. Just pound the system and draw a graph at the exit, all with built-in functions Octave. Uninteresting, fast. But it works that inspires.

The well-known Lorentz system, which originated, as is well known, from the convection equations in the Boussinesq approximation, became a test one.



Source code for integrating the Lorenz system
function xdot=f(x,t) r=28.; s=10.; b=8./3.; #    xdot(1)=s*(x(2)-x(1)); xdot(2)=r*x(1)-x(2)-x(1)*x(3); xdot(3)=x(1)*x(2)-b*x(3); endfunction #  ,   t=linspace(0.,10.,250); x0=[7.;10.;5.]; lsode_options("integration method","non-stiff"); y=lsode("f",x0,t); #     xz plot(y(:,1),y(:,3)); 



Depending on the control parameter (the normalized Rayleigh number), this system passes a series of stable states from complete equilibrium at zero to a chaotic regime. The images generated on the tablet clearly demonstrate them. When r = 0.5:



r = 4:



r = 16:



r = 25:



r = 28:



This is all great, but what computational fluid dynamics without finite difference methods? The next stage of proving that the tablet can not only consume content, was the simulation of a completely standard problem of convection of fluid in a closed cavity. As part of one of the courses, every student of our departments must implement it. The wording is as follows: calculate the velocity and temperature fields of an incompressible viscous fluid in a square cavity heated from the side. According to the mind, of course, it would be reasonable to first see what is simpler, for example, the problem of heat conduction, but it was decided not to waste time on trifles.



The equations are immediately given in a dimensionless form, reducing the whole variety of the physical parameters of the problem to two — the Grashof number Gr and the Prandtl number Pr. At all boundaries, the speed, and therefore, the current function, is zero (the sticking condition for a viscous fluid), the temperature on the left is 0, on the right is 1, and at the upper and lower boundaries it grows linearly.



For simplicity, the problem is considered as two-dimensional - the cavity is represented by an infinitely extended channel of square section. Three-dimensional tasks are a much wider richness of content, but at the same time a completely different level in terms of resource requirements, therefore their numerical modeling has developed widely only in the last couple of decades. The two-dimensional approach allows us to identify first of all the basic, universal properties of hydrodynamic systems, with much less effort. First of all, this is due to the peculiarities of the two-dimensional fluid flow - instead of the Navier-Stokes vector equations, we can proceed to the description of the velocity through two scalar quantities (the so-called two-field method) - the current function (it is the z-component of the vector potential of the velocity) and the vorticity ( z-component of the rotor speed). They are remarkable by the fact that, first, when passing to the current function, the condition of incompressibility is automatically and precisely satisfied (which is the main problem of modeling in natural variables velocity-pressure), and, secondly, it is extremely convenient to represent the field using the current function speeds - its contours correspond to streamlines, the main thing is to understand the direction of the flow.

Equations of the two-field method:



Program



The program is simple, and is the simplest explicit finite-difference scheme. Therefore, there is no need to dwell on it in detail. Just bring the source. Even not very optimized, although taking into account the performance of the tablet, the issues of code optimality become extremely significant.

Source code of the finite difference method
 a = 8.0; ap = 8.0; maxp = 100; Nx = 10; Ny = 10; tmax = 10.; Gr = 20000.; Pr = 1.; eps = 1.0e-2; #   o1id = fopen("/sdcard/Octave/Convection/psi(t)_Gr=20000.txt","w"); o2id = fopen("/sdcard/Octave/Convection/field_Gr=20000.txt","w"); # / #  phi0 = zeros(Nx+1,Ny+1,"single"); phi1 = zeros(Nx+1,Ny+1,"single"); #   psi0 = zeros(Nx+1,Ny+1,"single"); psi1 = zeros(Nx+1,Ny+1,"single"); #  T0 = zeros(Nx+1,Ny+1,"single"); T1 = zeros(Nx+1,Ny+1,"single"); # -  hx = 1.0 / Nx; hy = 1.0 / Ny; hxi = 1.0 / hx; hyi = 1.0 / hy; ht = hy**2/ a; htp = hy**2 / ap; htx2 = ht*hxi**2; hty2 = ht*hyi**2; htxy = 0.25*ht*hxi*hyi; htpx2 = htp*hxi**2; htpy2 = htp*hyi**2; htpxy = 0.25*htp*hxi*hyi; Pri = 1.0 / Pr; #   x = linspace(0.,1.,Nx+1); y = linspace(0.,1.,Ny+1); axis("xy"); #   for i = 1:Nx+1 for j = 1:Ny+1 psi0(i,j) = 1.0e-1*(1.0d0 - (i-1)*hx)*(i-1)*hx*(1.0d0 - (j-1)*hy)*(j-1)*hy; T0(i,j) = (i-1)*hx; phi0(i,j) = 0.0; endfor endfor ct = 0.; q = 0; #    while(ct <= tmax) #   phi, T for i = 2:Nx for j = 2:Ny dpsidx = psi0(i+1,j) - psi0(i-1,j); dpsidy = psi0(i,j+1) - psi0(i,j-1); phi1(i,j) = phi0(i,j) + ... (phi0(i+1,j) - 2.*phi0(i,j) + phi0(i-1,j))*htx2 + ... (phi0(i,j+1) - 2.*phi0(i,j) + phi0(i,j-1))*hty2 + ... htxy*( dpsidx*(phi0(i,j+1) - phi0(i,j-1)) - dpsidy*(phi0(i+1,j) - phi0(i-1,j)) ) + ... 0.5*ht*hxi*Gr*(T0(i+1,j) - T0(i-1,j)); T1(i,j) = T0(i,j) + Pri*( (T0(i+1,j) - 2.*T0(i,j) + T0(i-1,j))*htx2 + ... (T0(i,j+1) - 2.*T0(i,j) + T0(i,j-1))*hty2 ) + ... htxy*( dpsidx*(T0(i,j+1) - T0(i,j-1)) - dpsidy*(T0(i+1,j) - T0(i-1,j)) ); endfor endfor #   for i = 1:Nx+1 T1(i,1) = (i-1)*hx; T1(i,Ny+1) = (i-1)*hx; phi1(i,1) = -2.*Nx*Nx*psi1(i,2); phi1(i,Ny+1) = -2.*Nx*Nx*psi1(i,Ny); endfor for j = 1:Ny+1 T1(1,j) = 0.; T1(Nx+1,j) = 1.; phi1(1,j) = -2.*Ny*Ny*psi1(2,j); phi1(Nx+1,j) = -2.*Ny*Ny*psi1(Nx,j); endfor #      p = 0; ppp0 = 0; ppp1 = 0; do for i = 1:Nx+1 for j = 1:Ny+1 psi1(i,j) = 0.; endfor endfor for i = 2:Nx for j = 2:Ny psi1(i,j) = psi0(i,j) + htp*phi1(i,j) + ... (psi0(i+1,j) - 2.*psi0(i,j) + psi0(i-1,j))*htpx2 + ... (psi0(i,j+1) - 2.*psi0(i,j) + psi0(i,j-1))*htpy2; ppp0=ppp0 + abs(psi0(i,j)); ppp1=ppp1 + abs(psi1(i,j)); endfor endfor for i = 1:Nx+1 psi1(i,1) = 0.; psi1(i,Ny+1) = 0.; endfor for j = 1:Ny+1 psi1(1,j) = 0.; psi1(Ny+1,j) = 0.; endfor for i = 1:Nx+1 for j = 1:Ny+1 psi0(i,j) = psi1(i,j); endfor endfor p = p++; until(p > maxp || abs(ppp1 - ppp0)/(ppp0+ppp1) < eps) for i = 1:Nx+1 for j = 1:Ny+1 phi0(i,j) = phi1(i,j); psi0(i,j) = psi1(i,j); T0(i,j) = T1(i,j); endfor endfor #     if(q == 1000) fprintf(o1id,"%f %f\n",ct,max(max(psi0))); q = 0; endif ct = ct + ht q++; endwhile #   for i = 1:Nx+1 for j = 1:Ny+1 fprintf(o2id,"%f %f %f %f %f\n",(i-1)*hx,(j-1)*hy,psi0(i,j),T0(i,j),phi0(i,j)); endfor endfor fclose(o1id); fclose(o2id); #     #         #  ,    eps- # ,  Octave       #    gnuplot / droidplot figure(1); contourf(x,y,T0'); title("T, Gr = 2000"); xlabel("x"); ylabel("y"); saveas(1,"/sdcard/Octave/Convection/T_20000.eps"); figure(1); contourf(x,y,psi0'); title("Psi, Gr = 2000"); xlabel("x"); ylabel("y"); saveas(1,"/sdcard/Octave/Convection/psi_20000.eps"); 



results



Well, the most interesting. The speed and temperature of the liquid at different intensity of heating, I mean - different Gr. Solutions are obtained on a 10x10 grid. Of course, this is also a bit, however, when computers were large, calculations on 4x4, 5x5 grids were also the norm.

With the values ​​of the basic parameters Gr ~ 10 000, Pr = 1, eps = 0.01 and the code above, the tablet processes one unit of dimensionless time for about three to five minutes, which is not so slow at all, given the lack of memory, the need Android will perform other system functions and win back the system resources, as well as the potential slowness of the Octave system itself as an interpreter.

For large Gr, the calculation of the two-vortex flow regime takes much longer due to a significant deterioration in the convergence of the iterative process. This deterioration is caused by the fact that the two-vortex flow is not a stationary, but a steady-state oscillatory process — the eddies either amplify or weaken, simultaneously changing their dimensions in a rather wide range. For example, Gr = 120,000 on the tablet is considered about an hour and a half to two, but the process on a regular car is not very pleasant compared to a weak heating. And to fly to NaN in this mode is already easier than the easy one, it is required to significantly reduce the time step. Acceleration of the algorithm in this situation is a special question, and requires a revision of the method for solving difference equations.

So, the resulting pictures. Simply and clearly - it is clear that in the cavity there is a steady vortex flow and pronounced heat transfer primarily due to the movement of the fluid - floating up near the heated boundary and immersing near the cold. With an increase in the intensity of heating, the flow concentrates in the boundary layer and goes into a two-vortex regime. The color scale was not drawn, but it is standard - growth from purple to brown through green (as on geographical maps).

Current function and temperature at Gr = 2000:



at Gr = 20,000:



and at Gr = 120000:



Conclusion



The tablet is really a full-fledged computing machine. Weak, but stubborn. And to make simple calculations on it, say, to check a fresh idea or estimate the main directions of further search, is absolutely realistic.

Do not forget that any computer always remains a computer in the original sense of the word.

Source: https://habr.com/ru/post/168411/


All Articles