The New Modification of the Approximating Functions Method for Cloud Computing

The approach for building cloud-ready fault-tolerant calculations by approximating functions method, which is an analytical-numerical part of Volterra integral equation method for solving 1D+T nonlinear electromagnetic problems, is presented. The solving process of the original algorithm of the method is modified: it is broken down into the sequential chain of stages with a fixed number of sequential or parallel steps, each of which is built in a fault-tolerant manner and saves execution results in fault-tolerant storage for high availability. This economizes RAM and other computer resources and does not damage the calculated results in the case of a failure, and allows stopping and starting the calculations easily after manual or accidental shutdown. Also, the proposed algorithm has self-healing and data deduplication for cases of corrupted saved results. The presented approach is universal and does not depend on the type of medium or the initial signal. Also, it does not violate the natural description of non-stationary and nonlinear features, the unified definition of the inner and outer problems, as well as the inclusion of the initial and boundary conditions in the same equation as the original approximating functions method. The developed approach stress-tested on the known problems, stability checked and errors compared.


I. INTRODUCTION
The interaction of electromagnetic fields with nonlinear media has fundamental importance for developing laser technologies, technologies of signal processing, optical communications, nanocomputers and others, where electromagnetic wave interacts with nonlinear media in time in bounded spatial regions. Solving process of such problems requires the development of adequate mathematical models involving new methods for solving initial-boundary problems of electrodynamics. The most practical problems are now solved using only numerical or analytical-numerical methods. Currently, methods based on direct digitization of Maxwell equations in differential form for constructing numerical algorithms for solving electrodynamics problems are very popular: FDTD [1], TLM method [2], FVTD [1,3,4]. The method of finite elements remains important in the time as well as in the frequency domains [5,6]. These methods have high universality but often do not take into account particular features of the problem that deteriorates the solution quality.
They also often have a number of essential restrictions when solving problems with non-stationary and nonlinear media such as the lack of difference schemes, the description of the boundary conditions, general stability, the solution accuracy, and high demand for computer resources. Exclusively numerical nature of these methods also hampers the qualitative analysis of the phenomenon under study. An alternative approach to the differential formulation of the problem is based on integral equations equivalent to Maxwell equations [7,8]. Its key features are natural description of non-stationary and nonlinear features, unified definition of the inner and outer problems, and inclusion of initial and boundary conditions in the same equationsthe equations form is the same for various media and does not depend on the initial signal equation. This significantly simplifies the problem statement and its solution process, based on the universal modeling algorithms for a wide range of electrodynamics problems [9,10]. The one of the most promising analytical-numerical approach for obtaining solution in this case is the approximating functions method [11,12]. It is a particular case of the finite elements method that is based on a partitioning the definition region by cells and approximation of the desired function by orthogonal polynomials in each of them. The method reduces the calculation process to the problem of solving a system of nonlinear algebraic equations, for which there are many well-known methods, for example Newton's method. This method in the classical formulation [12] involves constructing and solving a problem at once for the entire space and time domain. Failure at any stage of the solution process: during construction of a system of equations, during its solving, during calculation of the fields outside the inhomogeneity, etc.leads to the need to restart the entire solution process from the beginning. Also, an increase in the size of the domain or a decrease in the simulation step leads to an increase in the size of the system of nonlinear equations and in the dimensions of the Jacobi matrix in Newton method in quadratic proportion. Because of this, the solving process may become too demanding on computational resources or simply impossible due to their limitations. So, all this shows that the original solution scheme is not faulttolerant with respect to either software or hardware failures and so is not could-ready. The construction of a cloud-ready fault-tolerant calculation scheme for approximating functions method for solving nonlinear integral equations that represents electromagnetic problems by Volterra integral equation method is demonstrated in this paper.

II. THE APPROXIMATING FUNCTIONS METHOD
The subject for consideration is the 2D Volterra integral equation of the second kind that describes electromagnetic processes in the space-time domain (1D+T) [9], which in the dimensionless variables [12] can be presented as follows E  is the electric field inside or outside an inhomogeneity located in the spatial interval [0,1]   this integral equation formulates the problem for the inner field, the inner problem. Otherwise, it is the formula for calculation of the outer field through the inner one, the outer problem. Nonlinearity is introduced to Equation (1) by the features of the material inside the inhomogeneity which are described by the polarization where   where h is a square side, a spacing of the mesh. The solution to Equation (1) is constructed approximately as a sum of piecewise-smooth functions , ( , ) ij E  each of which is determined in the corresponding grid cell ij D : These functions are constructed from the four approximating polynomials of the special form [12] that can be written in general as follows: with corresponding weighting coefficients , ij c that in fact are approximated values for the function Ê from Equation boundary and 1 for the right one) is calculated according to [12] after which energy balance is calculated.

III. FORMULATION OF THE APPROACH
To build a cloud-ready scheme of solving process of the problem described above, the following approach is proposed. The actions of the described method of solving the problem must be divided into stages, each of which has only backward dependency. Each stage should be broken down into steps with no dependencies on each other or only with backward dependency on the results of previous steps. Steps can be executed in sequence or, if possible, in parallel mode.
The results of execution of each stage step should be stored in fault-tolerant storage systems. A computational process built on such principles will save its state up to the current step of the current stage, which means that by fact it will be journaling for high-availability, the basic principles of which are described, for example, by the authors of Apache Kafka [13]. This means that if calculations are interrupted and restarted at an arbitrary time, they will automatically resume exactly from the last correctly executed and completely saved stage's step before the moment of interruption. This will happen due to the automatic full restoration of the state of the computational process after a reload of all previously correctly executed stages and their steps from the storage of the results. In case of missing or corrupted saved results, only the results up to the first correct one should be loaded, and the rest should be discarded. Execution will continue as if the discarded results have not yet been obtained. It is also important to keep in mind that in cases of shortterm interruption of the network connection or other reasons, duplicate data may appear in storage due to their repeated sending. To solve this problem, it is necessary to load the calculation results in a way that relies on the unambiguous difference between the results of two arbitrary stages and stage steps, which will provide automatic data deduplication on the client side of the storage system.

IV. APPLICATION OF THE APPROACH TO THE PROBLEM
To apply the approach discussed in the previous section for the approximation functions method let's break down its algorithm into the following stages: 1. Calculating the initial field values at all mesh points necessary for the solving inner and outer problems; 2. Solving inner problem; 3. Solving outer problem; 4. Calculating the energy flow and balance and checking the accuracy of the obtained solution. Stage 1 is trivial. The calculation of the initial field value at one mesh point is a stage step, which, obviously, can be performed in parallel. Also the storage of stage results must allow random or at least sequential access for using the results in the stages 2 and 3.
To solve the inner problem at stage 2 it is necessary to split the whole domain D from Equation (4)    (10) where K is the window size in index units, a multiple of the step h, w is a window number. The size in time domain of each window must be a multiple of the mesh step h, and in spatial domain it must fill the entire area The solving of whole inner problem then is divided into its sequential solving in windows The same applies to the case of restarting interrupted computations of this stage. Stages 3 and 4 are just calculations based on Equation (1) with all known coefficients , ij c . Since the calculation of the external fields can be performed sequentially for each mesh point outside the inhomogeneity, starting from its , such a calculation will be a stage's step. Stage 4 has only one step because its result is a only numberthe problem calculation error.

V. VERIFICATION
For verification of the developed approach for the cloudready fault-tolerant approximation functions method execution and for the error comparison purposes the original paper's [12] problems of interaction of electromagnetic waves with a dielectric layer was used: the problem of reflection and transmission of a plane electromagnetic wave from a dielectric layer and the problem of passing the Gaussian pulse through the layer with the quadratic nonlinear medium. The simulation parameters were chosen the same as the original work. Computational resources were specially limited to create conditions when the problem cannot be solved with saving the results of all stages in RAM and in one window on stage 2. Apache Kafka content delivery platform, formed from three nodes cluster, was used as a storage system that is fault-tolerant to a one node failure. The name of saved result of each step of each stage contained the name of the entity it stores and the coordinates of the mesh point. For example: "E0[i, j]" is the name for a value of initial wave in mesh point (i, j). So, data deduplication was done automatically in the client-side application due of these unique names. The correctness of the loaded results was checked inside the application when loading the results of steps. For the problems under consideration, the following formula was obtained empirically for choosing the optimal window size: where M is the amount of RAM available for the process in GB.
The developed approach was tested according to the following scheme. After the calculation start, at an arbitrary moment of execution of a random step of each stage: at the beginning, in the middle, or during the saving of the result to the storage,an error was artificially introduced that interrupted the execution of the program. After that, damages were added also to the saved results of the random step of the random stage and evaluation process was rerun from the start with reload the state from the storage as described above.
The system built using the developed approach showed good stability in loading data and correct continuation of calculations. The results are the same as in the original paper [12], but the margin of error is different. It increased by 0.07% for a plane electromagnetic wave and by 0.73% for a Gaussian pulse. This happened due to the fact that the first problem is for a layer with a linear medium, and the second one with a quadratic nonlinear medium, and the error in Newton method accumulates in different ways.

VI. CONCLUSION
The approach for building cloud-ready fault-tolerant calculations by approximating functions method, as an analytical-numerical component of the Volterra integral equation method, for solving 1D+T nonlinear electromagnetic problems is developed. The solving process is broken down into the stages, with backward dependency only, with fixed number of steps, each of which is built in fault-tolerant manner and saves execution results in fault-tolerant storage. This allows stopping and starting the algorithm easily after manual or accidental shutdown. The domain for solving the inner problem is divided into disjoint adjacent subdomains, windows. The solving process of the whole problem then is divided into its sequential solving of sub-problems in these windows. The formula for calculating the window size depending on the modeling step and the amount of computer RAM is shown. Due to the fact that the developed algorithm inside inhomogeneity is always working in a window a certain number of values calculated beforehand are used. The rest is stored on outside the RAM that allows making the calculation step smaller. The formula for determining the exact number of windows that must be loaded from storage to calculating the field inside the inhomogeneity in the current window is given. Also the reflected and transmitted fields, as well as energy flow and balance, are calculated after the field inside the structure is calculated and its results are stored. This significantly economizes RAM and other computer resources and does not damage the calculated results in the event of a failure. The original software for computer modeling of the algorithm is developed and the reliability and fault-tolerance of the proposed approach are verified through its stress testing.
Comparison of errors for problems of the transformation of a plane wave and a Gaussian pulse by a layer with nonlinear features is shown. Due to the accumulation of error by Newton method, the presented approach is less accurate than the original one, but shows good results.