
A 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 in pigs. ”
Folklore
“You will call it a perversion. But who said that perversion is bad? ”
One associate professor of our department
The idea of the experiment described below arose after a series of heard and overheard statements 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 entertaining purposes. Also, as you should expect, and as a recent post shows , the tablet is an excellent mobile tool when working with "office" applications. However, the hardware characteristics of the existing equipment allow us to think - and how effective the tablet will become in the field that is initially for computers.
TeXeT TM-7025, with a 1 GHz processor, 512 MB of RAM and Android 4.0 on board, became an experimental one. My first computer, purchased 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, having throttled Fortran over the course of his life and, later, paired with an HP 550 laptop - for two diplomas, ensuring the successful completion of school, bachelor's and master's degrees in theoretical physics with a specialization in computational fluid dynamics.
It is worth saying that the experimental tablet has a 7-inch screen, which severely limits the convenience 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.
Due to occupation, I was not going to mess with porting available software even in the extreme case of parsing a task. Therefore, if this were not found, then there would be no experiment. However, a review of Google Play showed that it has the Octave port on Android. In addition to it, of course, there is a very wide range of simpler programs, but with their computational capabilities there is no clarity, but Octave is a well-known program and there is already little experience with it. Therefore, there was nothing to choose from, but the ability to deal with this system at the same time in more detail became an additional incentive to work. To draw graphs, the existing package requires the installation of the droidplot graphic package - a version of gnuplot ported by the same author.
Naturally, the program code is easier to write in separate text and just load it into the Octave console. As an editor, he took the first one that turned up by the arm, that is, the free version of DroidEdit.
Test runs were made on systems of differential equations. We simply drive the system and draw a graph on the output, all with the built-in Octave features. Uninteresting, fast. But it works, which is encouraging.
The well-known Lorenz system, which originates, as is known, from the convection equations in the Boussinesq approximation, became a test.

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

r = 4:

r = 16:

r = 25:

r = 28:

This is all wonderful, but what computational fluid dynamics without finite-difference methods? The next step in proving that the tablet can not only consume content was modeling a completely standard problem of convection of fluid in a closed cavity. Within the framework of one of the courses, each student of our departments is required to implement it. The wording is as follows: calculate the velocity and temperature field of an incompressible viscous fluid in a square cavity heated from the side. According to the mind, of course, it would be wise to first look at something simpler, for example, the problem of thermal conductivity, but it was decided not to be petty.

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

To simplify, 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 wealth of content, but at the same time a completely different level in terms of resource requirements, because their numerical modeling began to develop widely only in the last couple of decades. The two-dimensional approach, however, makes it possible to identify primarily the basic, universal properties of hydrodynamic systems, with much less effort. First of all, this is connected with the peculiarities of two-dimensional fluid flow - instead of the Navier-Stokes vector equations, we can go on to describe the velocity in two scalar quantities (the so-called two-field method) - the stream function (it is also the z-component of the velocity vector potential) and vorticity ( z-component of the speed rotor). They are notable for the fact that,
Equations of the two-field method:

The program is straightforward, and is the simplest explicit finite-difference scheme. Therefore, there is no need to dwell on it in detail. Just give the source. Even not particularly optimized, although taking into account the tablet's performance, questions of code optimality become extremely significant.
Well, and the most interesting. The speed and temperature of the liquid at different intensities of heating, that is, different Gr. The solutions are obtained on a grid of 10x10 nodes. Of course, this is also not much, however, when computers were large, calculations were also normal on 4x4, 5x5 grids.
With the values of the main 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, taking into account the lack of memory, the need Android can perform other system functions and recapture system resources, as well as the potential slowness of the Octave system itself as an interpreter.
At 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 stationary, but a steady-state oscillatory process - the vortices either amplify or weaken, simultaneously changing their sizes over a rather wide range. For example, Gr = 120,000 on a tablet is considered about an hour and a half or two, but on a regular machine the process is not very joyful compared to weak heating. Yes, and fly to NaN in this mode is already easier than easy, you need to significantly reduce the time step. Acceleration of the algorithm in this situation is a special issue, and requires a review of the method for solving difference equations.
So, the received pictures. Simple and clear - it is clear that there is a steady vortex flow in the cavity and a pronounced heat transfer primarily due to the movement of the liquid - floating up at the heated boundary and immersion at the cold one. With an increase in the heating intensity, the flow concentrates in the boundary layer and passes into a two-vortex mode. The color scale was not drawn, but it was standard - growth from purple to brown through green (as on geographical maps).
The current function and temperature at Gr = 2000:

at Gr = 20,000:

and at Gr = 120,000:

A tablet is a truly complete computing machine. Weak but persistent. And to make simple calculations on it, say, to test a fresh idea or to 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.
Folklore
“You will call it a perversion. But who said that perversion is bad? ”
One associate professor of our department
The idea of the experiment described below arose after a series of heard and overheard statements 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 entertaining purposes. Also, as you should expect, and as a recent post shows , the tablet is an excellent mobile tool when working with "office" applications. However, the hardware characteristics of the existing equipment allow us to think - and how effective the tablet will become in the field that is initially for computers.
Equipment
TeXeT TM-7025, with a 1 GHz processor, 512 MB of RAM and Android 4.0 on board, became an experimental one. My first computer, purchased 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, having throttled Fortran over the course of his life and, later, paired with an HP 550 laptop - for two diplomas, ensuring the successful completion of school, bachelor's and master's degrees in theoretical physics with a specialization in computational fluid dynamics.
It is worth saying that the experimental tablet has a 7-inch screen, which severely limits the convenience 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.
Software
Due to occupation, I was not going to mess with porting available software even in the extreme case of parsing a task. Therefore, if this were not found, then there would be no experiment. However, a review of Google Play showed that it has the Octave port on Android. In addition to it, of course, there is a very wide range of simpler programs, but with their computational capabilities there is no clarity, but Octave is a well-known program and there is already little experience with it. Therefore, there was nothing to choose from, but the ability to deal with this system at the same time in more detail became an additional incentive to work. To draw graphs, the existing package requires the installation of the droidplot graphic package - a version of gnuplot ported by the same author.
Naturally, the program code is easier to write in separate text and just load it into the Octave console. As an editor, he took the first one that turned up by the arm, that is, the free version of DroidEdit.
Task
Test runs were made on systems of differential equations. We simply drive the system and draw a graph on the output, all with the built-in Octave features. Uninteresting, fast. But it works, which is encouraging.
The well-known Lorenz system, which originates, as is known, from the convection equations in the Boussinesq approximation, became a test.

Source code for integrating the Lorentz 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);
# график аттрактора в плоскости x-z
plot(y(:,1),y(:,3));
Depending on the control parameter (normalized Rayleigh number), this system goes through a series of stable states from complete equilibrium at zero to the chaotic regime. The pictures generated on the tablet clearly demonstrate them. When r = 0.5:

r = 4:

r = 16:

r = 25:

r = 28:

This is all wonderful, but what computational fluid dynamics without finite-difference methods? The next step in proving that the tablet can not only consume content was modeling a completely standard problem of convection of fluid in a closed cavity. Within the framework of one of the courses, each student of our departments is required to implement it. The wording is as follows: calculate the velocity and temperature field of an incompressible viscous fluid in a square cavity heated from the side. According to the mind, of course, it would be wise to first look at something simpler, for example, the problem of thermal conductivity, but it was decided not to be petty.

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

To simplify, 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 wealth of content, but at the same time a completely different level in terms of resource requirements, because their numerical modeling began to develop widely only in the last couple of decades. The two-dimensional approach, however, makes it possible to identify primarily the basic, universal properties of hydrodynamic systems, with much less effort. First of all, this is connected with the peculiarities of two-dimensional fluid flow - instead of the Navier-Stokes vector equations, we can go on to describe the velocity in two scalar quantities (the so-called two-field method) - the stream function (it is also the z-component of the velocity vector potential) and vorticity ( z-component of the speed rotor). They are notable for the fact that,
Equations of the two-field method:

Program
The program is straightforward, and is the simplest explicit finite-difference scheme. Therefore, there is no need to dwell on it in detail. Just give the source. Even not particularly optimized, although taking into account the tablet's performance, questions 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, and the most interesting. The speed and temperature of the liquid at different intensities of heating, that is, different Gr. The solutions are obtained on a grid of 10x10 nodes. Of course, this is also not much, however, when computers were large, calculations were also normal on 4x4, 5x5 grids.
With the values of the main 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, taking into account the lack of memory, the need Android can perform other system functions and recapture system resources, as well as the potential slowness of the Octave system itself as an interpreter.
At 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 stationary, but a steady-state oscillatory process - the vortices either amplify or weaken, simultaneously changing their sizes over a rather wide range. For example, Gr = 120,000 on a tablet is considered about an hour and a half or two, but on a regular machine the process is not very joyful compared to weak heating. Yes, and fly to NaN in this mode is already easier than easy, you need to significantly reduce the time step. Acceleration of the algorithm in this situation is a special issue, and requires a review of the method for solving difference equations.
So, the received pictures. Simple and clear - it is clear that there is a steady vortex flow in the cavity and a pronounced heat transfer primarily due to the movement of the liquid - floating up at the heated boundary and immersion at the cold one. With an increase in the heating intensity, the flow concentrates in the boundary layer and passes into a two-vortex mode. The color scale was not drawn, but it was standard - growth from purple to brown through green (as on geographical maps).
The current function and temperature at Gr = 2000:

at Gr = 20,000:

and at Gr = 120,000:

Conclusion
A tablet is a truly complete computing machine. Weak but persistent. And to make simple calculations on it, say, to test a fresh idea or to 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.