4
Computer Physics Communications 183 (2012) 26–29 Contents lists available at ScienceDirect Computer Physics Communications www.elsevier.com/locate/cpc Mobile phone as a platform for numerical simulation Filip A. Sala Faculty of Physics, Warsaw University of Technology, Koszykowa 75, 00-662 Warsaw, Poland article info abstract Article history: Received 20 February 2011 Received in revised form 31 May 2011 Accepted 12 August 2011 Available online 19 August 2011 Keywords: Numerical simulation Embedded system Mobile device JAVA ME Light propagation Cholesterics In this work numerical simulations performed on mobile devices equipped with ARM microprocessors are shown. Calculations include: light propagation in linear and nonlinear media based on one-dimensional Schrödinger equation and molecules reorientation in nematic liquid crystals. The purpose of this publication is to show advantages and disadvantages of using mobile devices as a platform for education and research. Discussion about software development is provided. © 2011 Elsevier B.V. All rights reserved. 1. Introduction The first handheld mobile phone was demonstrated in 1973 by Motorola. Since then mobile devices and their software have been actively improved especially when it comes to multimedia, enter- tainment and security. However there are very few applications of such devices in numerical simulations [30]. In the recent years mo- bile devices have processors clocked at the speeds similar to those of PCs from the late 90s. There are nearly 5 billion cell phones in the world which gives enormous computational power. Even us- ing a small fraction of it is worth a try. Such simulations could be used not only for educational purposes but also for research. In this work some calculations performed on mobile devices are shown. The purpose of this publication is to present possibilities, advantages and disadvantages of using mobile devices in numeri- cal simulations. 2. Theoretical bases Simulations were performed for two different physical models: light propagation using BPM 1 and reorientation of molecules in cholesteric liquid crystals. BPM is one of the easiest and widely known method for simulating electromagnetic field propagation proposed in the 1976 by Fleck and Feit [5] and thoroughly inves- tigated since then [4,25]. There are many types of BPM optimized for particular issues including full-vector BPM [26,10,33,29]. The * Tel.: +48 22 234 7277. E-mail address: [email protected]. 1 Beam Propagation Method. most common approach is to use finite differences, finite elements or FFT for solving Helmholtz equation. For the simulations I have used one-dimensional Schrödinger equation (1) assuming the am- plitude is complex and slowly varying. 2i β e A z = 2 A x 2 + ( k 2 0 n 2 (x) β 2 e ) A (1) where β e = ω c n eff and n eff = const. – effective refractive index, n(x)-refractive index distribution. BPM is an initial value problem. The solution depends on the input beam profile and the ana- lyzed structure. Light is propagated along the z-axis. The equation was rewritten using finite differences and solved with Runge–Kutta 4th order method. The problem arises at the edge of the system where it is impossible to calculate second derivative. Many so- lutions have been proposed to date including TBC 2 [9,10,6] and PML 3 [2,6]. I have used TBC which assumes the amplitude expo- nentially vanishes at the boundary. Moreover, to take into account nonlinearity, Kerr-type nonlinearity has been implemented in the following form: n(x) = n 0 (x) + n 2 | A| 2 (2) where n 2 – nonlinear coefficient. The second analyzed model describes the reorientation of molecules in cholesterics i.e. chiral nematic liquid crystals. The first records about liquid crystals come from 1888 by Reinitzer [24], further studies were made in the 20s and 30s by Friedel [8] 2 Transparent Boundary Conditions. 3 Perfectly Matched Layer. 0010-4655/$ – see front matter © 2011 Elsevier B.V. All rights reserved. doi:10.1016/j.cpc.2011.08.008

Mobile phone as a platform for numerical simulation

Embed Size (px)

Citation preview

Computer Physics Communications 183 (2012) 26–29

Contents lists available at ScienceDirect

Computer Physics Communications

www.elsevier.com/locate/cpc

Mobile phone as a platform for numerical simulation

Filip A. Sala ∗

Faculty of Physics, Warsaw University of Technology, Koszykowa 75, 00-662 Warsaw, Poland

a r t i c l e i n f o a b s t r a c t

Article history:Received 20 February 2011Received in revised form 31 May 2011Accepted 12 August 2011Available online 19 August 2011

Keywords:Numerical simulationEmbedded systemMobile deviceJAVA MELight propagationCholesterics

In this work numerical simulations performed on mobile devices equipped with ARM microprocessors areshown. Calculations include: light propagation in linear and nonlinear media based on one-dimensionalSchrödinger equation and molecules reorientation in nematic liquid crystals. The purpose of thispublication is to show advantages and disadvantages of using mobile devices as a platform for educationand research. Discussion about software development is provided.

© 2011 Elsevier B.V. All rights reserved.

1. Introduction

The first handheld mobile phone was demonstrated in 1973 byMotorola. Since then mobile devices and their software have beenactively improved especially when it comes to multimedia, enter-tainment and security. However there are very few applications ofsuch devices in numerical simulations [30]. In the recent years mo-bile devices have processors clocked at the speeds similar to thoseof PCs from the late 90s. There are nearly 5 billion cell phones inthe world which gives enormous computational power. Even us-ing a small fraction of it is worth a try. Such simulations couldbe used not only for educational purposes but also for research.In this work some calculations performed on mobile devices areshown. The purpose of this publication is to present possibilities,advantages and disadvantages of using mobile devices in numeri-cal simulations.

2. Theoretical bases

Simulations were performed for two different physical models:light propagation using BPM1 and reorientation of molecules incholesteric liquid crystals. BPM is one of the easiest and widelyknown method for simulating electromagnetic field propagationproposed in the 1976 by Fleck and Feit [5] and thoroughly inves-tigated since then [4,25]. There are many types of BPM optimizedfor particular issues including full-vector BPM [26,10,33,29]. The

* Tel.: +48 22 234 7277.E-mail address: [email protected].

1 Beam Propagation Method.

0010-4655/$ – see front matter © 2011 Elsevier B.V. All rights reserved.doi:10.1016/j.cpc.2011.08.008

most common approach is to use finite differences, finite elementsor FFT for solving Helmholtz equation. For the simulations I haveused one-dimensional Schrödinger equation (1) assuming the am-plitude is complex and slowly varying.

2iβe∂ A

∂z= ∂2 A

∂x2+ (

k20n2(x) − β2

e

)A (1)

where βe = ωc neff and neff = const. – effective refractive index,

n(x)-refractive index distribution. BPM is an initial value problem.The solution depends on the input beam profile and the ana-lyzed structure. Light is propagated along the z-axis. The equationwas rewritten using finite differences and solved with Runge–Kutta4th order method. The problem arises at the edge of the systemwhere it is impossible to calculate second derivative. Many so-lutions have been proposed to date including TBC2 [9,10,6] andPML3 [2,6]. I have used TBC which assumes the amplitude expo-nentially vanishes at the boundary. Moreover, to take into accountnonlinearity, Kerr-type nonlinearity has been implemented in thefollowing form:

n(x) = n0(x) + n2|A|2 (2)

where n2 – nonlinear coefficient.The second analyzed model describes the reorientation of

molecules in cholesterics i.e. chiral nematic liquid crystals. Thefirst records about liquid crystals come from 1888 by Reinitzer[24], further studies were made in the 20s and 30s by Friedel [8]

2 Transparent Boundary Conditions.3 Perfectly Matched Layer.

F.A. Sala / Computer Physics Communications 183 (2012) 26–29 27

Fig. 1. Light propagation solutions for three different structures: (a) linear propagation in a free space, (b) linear propagation in a waveguide array, (c) interaction of twosolitons of the same phase propagated in a nonlinear Kerr-type media (n2 �= 0). Graphs below present light power distribution at the input (red) and at the output (blue)of the system. In the last row more detailed descriptions of the analyzed structures are provided. (For interpretation of the references to color in this figure, the reader isreferred to the web version of this article.)

and Oseen [21] and in the 50 s by Frank [7]. To date, a lot ofwork has been done and still liquid crystals remain interestingmedium for many purposes. Cholesteric phase is made of nematicmolecules rotated along the axis to obtain helicoid. Molecules ori-entation at the boundaries is fixed. Initial conditions are linear(θ = 2Π

P x, P -pitch of a cholesteric). Reorientation can be inducedby external electric field or the light beam. Such reorientation in-duces optical nonlinearity and can be used to form solitons i.e.non-diffractive light beams in nematic phase called nematicons[11]. For recent years soliton formation in liquid crystals have beeninvestigated by Karpierz [14,26,13] and Assanto [11,1]. Most defor-mations of cholesterics can be explained with three Frank elasticconstants i.e. K11 (splay), K22 (twist) and K33 (bend). In a simpleone-dimensional case only twist deformation K22 �= 0 can be takeninto account, as assuming K11 = K33 leads to the equation:

∂2θ

∂x2+ ε0 · �ε

2K22

[|E y|2 sin(2θ)] = 0 (3)

where E y – electric field component, θ – reorientation angle, �ε –anisotropy. It is an example of a boundary value problem. The solu-tion depends on the boundary conditions and the electric field pro-file. In the analyzed problem electric field was applied only alongthe y-axis (Ex = 0, Ez = 0). Eq. (3) was rewritten using finite dif-ferences and solved using successive over-relaxation method [31].

3. Test platform

The experiments were carried out on two mobile devicesequipped with ARM9 and ARM11, 32-bit RISC4 microprocessors.The ARM9 is a previous generation, in my case clocked at 235 MHz

4 Reduced Instruction Set Computing.

and ARM11 is a newer architecture supporting speeds up to 1 GHz,in my case clocked at 600 MHz. Both devices are equipped withJAVA Micro Edition and CLDC 1.1 framework [19] which allowedme to utilize floating point operations unlike the previous version(CLDC 1.0) which supported only fixed point operations. Although,there are many translators from different programming languages,like Cibyl (C language) [3], Fnattlab (Matlab), Jasymca (Matlab,Scilab, Octave, GNU-Maxima) [12], Mobile BASIC [17], MIDletPascal[16] and others, my software was written directly in JAVA ME. Pro-grams were also tested on the JAVA Platform Micro Edition SDK 3.0emulator run on Intel Pentium IV 2.66 GHz with 1.5 GB of RAM.Software was written using NetBeans 6.9.1 IDE [18].

4. Numerical results

Light propagation simulations were carried out on a grid of 50points along the x-axis with resolution �x = 1 μm. Propagationstep was set to �z = 0.1 μm. Gaussian beam of a few microns inFWHM was launched into the system. At first linear light propa-gation in a free space was analyzed (Fig. 1(a)). Then, simulationswere made for linear propagation in a waveguide array (Fig. 1(b)).Such system was proposed and analyzed in the 70s by Yariv [28]and Snyder [27,15] and is still under research [22,23,32]. As an ex-ample of nonlinear propagation two parallel interacting solitons ofthe same phase were simulated (Fig. 1(c)).

Afterwards computation time and speed have been measured(Fig. 2). It is clearly visible that the computation speed increasesand saturates in time. It is caused by the optimization algorithmsbuilt into CLDC HotSpot [20] virtual machine. One of them is JIT5

compilation. Frequently used parts of the sourcecode are compiledinto the bytecode. Moreover HotSpot has optimized interpreter for

5 Just-In-Time.

28 F.A. Sala / Computer Physics Communications 183 (2012) 26–29

Fig. 2. BPM computation time (left) and speed (right) versus distance.

Fig. 3. Molecules deformation solutions for two different twist angles: 360◦ (a)–(b) and 180◦ (c)–(d). Linear initial conditions (no field applied) are shown on (a) and (c).Solutions for the electric field corresponding to a Gaussian beam profile are shown on (b) and (d). Below each graph visualization of molecules orientation along the x-axisis shown.

Fig. 4. Computation time (for modeling molecules reorientation) versus number of iterations are shown on the left and versus twist angle (anchoring condition) on the right.Two different architectures ARM9 and ARM11 were tested. The Sine2 is a custom sine function implemented for a comparison with the built-in JAVA ME sine function.

two architectures: x86 and ARM. By measuring difference betweeninput and output energy relative computation error was calculatedand was of the order 10−19. As an example of a second model,describing molecules reorientation, cholesterics deformation withthe following anchoring conditions θmax = π and θmax = 2π wheresimulated (Fig. 3). To obtain convergence relaxation parameter wasset to ω = 0.01 so in fact under-relaxation was used. Calculationswere made on a grid of 100 points with at least 500 iterations.Computation time versus iterations were also measured (Fig. 4).Surprisingly, computation time depends also on the anchoring con-dition. Although, at a glance the number of arithmetic operationsseems to be the same, in fact it is not. The answer lies in the im-plementation of JAVA ME built-in sine function which is optimizedespecially for low angle values. To verify this hypothesis the cus-tom sine function was implemented, based on the first 7 elementsof the Taylor series. The results are shown in Fig. 4.

5. Development process details

During writing the software some issues emerged. First of allthere are still lack of important mathematical functions such as ex-ponent or inverse trigonometrical functions. Math library in JAVAME contains only a few methods. Also making interface mightbe arduous but hopefully NetBeans supports WYSIWYG graphicaluser interface development. Obfuscating the code with NetBeansbuild-in tool also might be very useful. In my case it gave nearly35–40% lower file sizes and made execution 2–4% faster, how-ever these values strongly depend on the programming style. For acomparison molecules reorientation model were also implementedin FreePascal and JAVA (Oracle HotSpot, JDK 1.6) and run on IntelPentium IV 2.66 GHz and Intel Pentium III 500 MHz. Exactly thesame algorithms were used. JAVA ME execution time on ARM11was approximately 24 times longer than FreePascal and 16 times

F.A. Sala / Computer Physics Communications 183 (2012) 26–29 29

longer than JAVA on Pentium IV and nearly 5–6 times longer thanFreePascal and JAVA on Pentium III.

6. Conclusions

Calculations of light propagation in linear and nonlinear mediahave been performed on a mobile platform. Computation time wasless than a few minutes, so even for larger numerical grids it willbe acceptable. It has been proved that it is possible to simulatelight propagation on even a few millimeters. Also molecules reori-entation calculations have been performed in reasonable time of afew seconds. The user interface was easily made using NetBeans.Despite lack of appropriate numerical libraries JAVA ME and mo-bile devices seem to be a good platform for numerical simulations.However, when we are thinking of using it not only in educa-tion but also in research, further studies and software developmentshould be done especially in the field of parallel computing.

Acknowledgement

I would like to acknowledge helpful discussions with Prof. Mi-rosław Karpierz.

References

[1] G. Assanto, M. Peccianti, C. Conti, Nematicons: Optical spatial solitons in ne-matic liquid crystals, Opt. Photon. News 14 (2003) 44–48.

[2] J.P. Berenger, A perfectly matched layer for the absorption of electromagneticwaves, J. Comp. Phys. 114 (1994) 185–200.

[3] Cibyl, C language translator, http://code.google.com/p/cibyl/, 2010.[4] M.D. Feit, J.A. Fleck Jr., Light propagation in graded-index optical fibers, Appl.

Opt. 17 (1978) 3990–3998.[5] J.A. Fleck Jr., J.R. Morris, M.D. Feit, Time-dependent propagation of high energy

laser beams through the atmosphere, Appl. Phys. 10 (1976) 129–160.[6] F. Fogli, G. Bellanca, P. Bassi, TBC and PML conditions for 2D and 3D BPM a

comparison, Opt. Quantum Electron. 30 (1998) 443–456.[7] F.C. Frank, I. Liquid crystals. On the theory of liquid crystals, Discuss. Faraday

Soc. 25 (1958) 19–28.[8] G. Friedel, The mesomorphic states of matter, Ann. Phys. 18 (1922) 273–474.[9] G.R. Hadley, Transparent boundary condition for the beam propagation

method, IEEE J. Quantum Electron. 28 (1992) 363–370.[10] G.R. Hadley, Full-vector waveguide modeling using an iterative finite-difference

method with transparent boundary conditions, J. Lightwave Technol. 13 (1995)465–469.

[11] Y.V. Izdebskaya, A.S. Desyatnikov, G. Assanto, Y.S. Kivshar, Multimode nemati-con waveguides, Opt. Lett. 36 (2011) 184–186.

[12] Jasymca and FnattLabME, Clones of Matlab Octave, GNU-Maxima, Scilab envi-ronments for mobile devices, http://webuser.hs-furtwangen.de/~dersch/, 2010.

[13] U.A. Laudyn, M. Kwasny, M.A. Karpierz, Nematicons in chiral nematic liquidcrystals, Appl. Phys. Lett. 94 (2009) 091110.

[14] U.A. Laudyn, M. Kwasny, M.A. Karpierz, Properties of spatial solitons in chiralnematic liquid crystal cells, Phot. Lett. Poland 1 (2009) 157–159.

[15] P.D. McIntyre, A.W. Snyder, Power transfer between optical fibers, J. Opt. Soc.Am. 63 (1973) 1518–1527.

[16] MIDletPascal, Pascal translator, http://sourceforge.net/projects/midletpascal/,2010.

[17] Mobile BASIC, Basic translator, http://www.mobilebasic.com/, 2010.[18] NetBeans, Integrated development environment, http://netbeans.org/, 2010.[19] Oracle, Connected limited device configuration (CLDC) JSR-139 documentation,

http://www.oracle.com/technetwork/java/cldc-141990.html, 2005.[20] Oracle, CLDC HotSpot implementation architecture guide v.2.2, http://down

load.oracle.com/javame/config/cldc/cldc-opt-impl/cldc-hi-2.2/doc/architecture/html/, 2008.

[21] C.W. Oseen, The theory of liquid crystals, Trans. Faraday Soc. 29 (1933) 883–899.

[22] U. Peschel, F. Lederer, Oscillation and decay of discrete solitons in modulatedwaveguide arrays, J. Opt. Soc. Am. B 19 (2002) 544–549.

[23] U. Peschel, R. Morandotti, J.M. Arnold, J.S. Aitchison, H.S. Eisenberg, Y. Silber-berg, T. Pertsch, F. Lederer, Optical discrete solitons in waveguide arrays. 2.Dynamic properties, J. Opt. Soc. Am. B 19 (2002) 2637–2644.

[24] F. Reinitzer, Beiträge zur kenntniss des cholesterins, Monatsh Chem. Chem.Mon. 9 (1888) 421–441.

[25] J.V. Roey, J. van der Donk, P.E. Lagasse, Beam-propagation method: analysis andassessment, J. Opt. Soc. Am. 71 (1981) 803–810.

[26] F.A. Sala, M.A. Karpierz, Numerical simulation of beam propagation in a layerfilled with chiral nematic liquid crystals, Phot. Lett. Poland 1 (2009) 163–165.

[27] A.W. Snyder, Coupled-mode theory for optical fibers, J. Opt. Soc. Am. 62 (1972)1267–1277.

[28] S. Somekh, E. Garmire, A. Yariv, H. Garvin, R. Hunsperger, Channel opticalwaveguide directional couplers, Appl. Phys. Lett. 22 (1973) 46–47.

[29] P.J.M. Vanbrabant, J. Beeckman, K. Neyts, R. James, F.A. Fernandez, A finite el-ement beam propagation method for simulation of liquid crystal devices, Opt.Express 17 (2009) 10895–10909.

[30] T. Wriedt, Mie theory 1908, on the mobile phone 2008, J. Quant. Spectrosc.Radiat. 109 (2008) 1543–1548.

[31] D.M. Young, Iterative methods for solving partial difference equations of ellip-tical type, PhD thesis, Harvard University, 1950.

[32] K.B. Zegadlo, M.A. Karpierz, Analysis of beam propagation in optical fiber struc-tures with a high step index, Phot. Lett. Poland 1 (2009) 175–177.

[33] G.D. Ziogos, E.E. Kriezis, Modeling light propagation in liquid crystal deviceswith a 3-D full-vector finite-element beam propagation method, Opt. Quant.Electron 40 (2008) 733–748.