# Optimization Efficiency of Monte Carlo Simulation Tool for Evanescent Wave Spectroscopy Fiber-Optic Probe

Authors: Daniel Khankin; Shaul Mordechai; Shlomo Mark
Journal: Advances in Optical Technologies
 (2012)

---

## Abstract

In a previous work, we described the simulation tool (FOPS 3D) (Khankin et al., 2001) which can simulate the full three-dimensional geometrical structure of a fiber and the propagation of a light beam sent through it. In this paper we are focusing on three major points: the first concerns the improvements made with respect to the simulation tool and the second, optimizations implemented with respect to the calculations' efficiency. Finally, the major research improvement from our previous works is the simulation results of the optimal absorbance value, as a function of bending angle for a given uncladded part diameter, that are presented; it is suggested that fiber-bending may improve the efficiency of recording the relevant measurements. This is the third iteration of the FOPS development process (Mann et al., 2009) which was significantly optimized by decreasing memory usage and increasing CPU utilization.


---

## Body

## 1. Introduction

The evanescent wave spectroscopy technique, generally used in the IR range, is useful for inspecting materials and examining their properties, as well as for establishing biomedical diagnoses [1]. The diagnosis technique is based on a phenomenon called Attenuated Total Reflection (ATR) [2], in which incident rays are completely reflected within the medium, leaving evanescent waves on the interface between the medium and the adjacent sample. As the number of reflections occurring in the sensing fiber increases, a greater number of evanescent waves are created. Consequently, use of this spectroscopic method requires detailed planning, since fiber wave spectroscopy intensifies as fiber absorbance increases.Two primary methods can be used, the first involves tapering the untapped part of the fiber and the second, bending the fiber about its untapped part. These two actions make it more difficult for the light beam to propagate, causing more hits in the untapped part and thus creating additional evanescent waves, which in turn increase the absorption intensity. The first method was investigated experimentally by [3] and by [1]; these papers provided correlations between the absorbance and the thickness of the untapped fiber section, [1] the optimal width d of the untapped part. In our previous work [4], we computed and investigated the relation between the diameter of the uncladded part and the resultant absorption value, using an in-house Monte Carlo simulation tool. In this work, we investigate an additional method of determining the optimal bending angle of a fiber with a constant width.In a previous work, the Monte Carlo simulation tool (FOPS 3D) was described [5]; this tool can simulate the full three-dimensional geometrical structure of the fiber and the propagation of a light beam through it. Evanescent waves are formed when waves travelling through a medium undergo total internal reflections, on which the Attenuated Total Reflectance (ATR) sampling technique is based [1, 6]. In fact, evanescent waves decrease exponentially as they propagate further into the sample, and optical fibers, which are transparent in the mid-IR range, are used as the ATR elements. As the number of reflections causing the evanescent fields increases, the measurement becomes more efficient. Thus, the curvature of the fiber and the diameter of its uncladded part, which is in contact with the sample, both contribute to the efficiency of the measurement.


## 2. System Description

The user may define several properties for the simulation system, including the simulated fiber’s length, radius, the radius of the uncladded part, reflection coefficients, and bending angle (see Figure1). Next, the simulated light beam is propagated through the fiber, undergoes an emission process, and hits the fiber medium. The emission source, which emits rays according to a radial Gaussian distribution (which is both uniform and isotropous), is simulated with Monte Carlo techniques.Figure 1
The simulated fiber.The simulation history is defined by a light beam that hits the uncladded part and successfully travels through the fiber up to the light sensor. The number of successful histories is an estimator of the efficiency of the simulated fiber shape. The unbiased mean value of hits in successful histories is used for calculating the Fresnel transmission coefficient [6], which is the absorption property of the simulated shape.The simulation tool, as it is virtual, has the flexibility of freely bending the fiber, thus providing the possibility of creating a fiber folded in any possible curvature. In turn, folding the fiber increases the number of beam hits in the uncladded part by slowing down the beam’s propagation. A second feature of the simulation tool is the possibility of adjusting the radius of the uncladded part alone, specifically decreasing its radius relative to the rest of the fiber’s radius; this affects the number of beam hits in the uncladded section. In addition, the fiber maybe deformed and clay modeled, providing the possibility of creating alternative geometrical shapes and inspecting their efficiency as ATR elements [1, 3, 4].The Monte Carlo approach of simulating physical phenomena is based on the creation of a large sample of random occurrences, used in order to reconstruct the dynamics of a particular system. The simulation tool can then provide, as a system output, the utilization of a certain geometrical fiber configuration. The simulation results include estimates of the probability of rays successfully passing through a fiber in a particular, user-defined geometry.


## 3. Physical Background

Fiber evanescent wave spectroscopy, primarily used with an IR light source, consists of emitting rays into a flexible optical fiber. The emitted energy is passed on to the distal end of the fiber and into a Fourier transform infrared spectroscopy (FTIR) detector. In this section, we will briefly define the main physical phenomena modeled by the simulation algorithm.The Gaussian distribution for a beam waist is given by [7]:(1)I(r)=I0e-8r2r02,
where r0 is the radius of the laser aperture and I0 is the irradiance at the center of the aperture.The incidence angles of the rays must be less thanθcl=sin-1(n12-ncl2), where θcl is the critical angle of the cladded section,n1 is the refractive index of the fiber core, and ncl is the refractive index of the cladding, and is sampled from the angular distribution given by [8](2)p(θ)∝f(x)={sin⁡⁡θcos⁡3⁡θ,θ<θcri,0,θ≥θcri.
According to the Beer-Lambert Law, the transmitted power P(z) along a fiber is given by(3)P(z)=p0e-γz,
where p0 is the power at the input face of the fiber, and γ is the effective evanescent absorption coefficient (which varies for different orientations of the ray) [9].In the Monte Carlo approach applied in the simulation, Ruddy’s equation [9] is used:(4)γ=NT,
where N is the number of reflections per unit length, and T is the Fresnel transmission coefficient for an evanescent wave, defined for any angle θz relative to the core axis.In the Monte Carlo simulation, rays are fired into the fiber according to the radial and angular distributions of (1) and (2), respectively.


## 4. Development Process

The current simulation tool belongs to the family of scientific software [10, 11], softwares that require a knowledgeable user, that appreciates both its input and its output. In addition, successful scientific software development requires a knowledgeable tester, who should understand the mathematical as well as the scientific models used in the software. In third iteration the simulation tool had to be transferred from a 32-bit environment to a 64-bit operating system and, correspondingly, a 64-bit Java environment. Though from an API perspective the environments are similar, this transfer required taking some aspects into account. For instance, the data structures in a 64-bit environment require more memory than required in the 32-bit environment. Taking the above specifications into account, the Agile [12, 13] software development methodology was chosen, as it is suited for small teams with constantly changing requirements. However, the changes and optimizations to the software are not trivial and should be carefully considered before implementation. Therefore, test-driven development (TDD) methodology should be integrated into the software development process.Test-driven development is a software development approach based on “test-first development”, according to which tests should be written before coding. Since the development process is broken into small units, it is very easy to adapt it to black-box testing. This approach tests all possible combinations of end-user actions. Black-box testing does not require knowledge of code and is intended to simulate the end-user experience of the final product. These tests determine appropriately correct output for valid or invalid input. The Java platform was chosen for development since it is efficient time wise with regards to the development of existing data structures and helps avoid memory management issues.The simulation tool was initially modeled and designed by Unified Modeling Language (UML). The simulation’s architectural blueprints were visualized by UML elements. Objects were described by object modeling techniques and information flow by data flow diagrams and entity relationship diagrams. Entity relationship diagrams represent abstract and conceptual data elements; for example, the simulation tool uses the fiber structure as the conceptual data. In order to describe the data flow between object entities, as well as modifications on data structures, data flow diagrams were created. Data flow diagrams help visualize data processing in an information system. FOPS 3D is computation-intensive software, and for this reason, more tests were conducted to ensure high level of reliability. Finally, it was verified that the results were in accordance with previous experiments and simulations.


## 5. Optimization

Extensive optimization of the tool was performed. The main aspect optimized was memory usage, which was especially high after the transfer to a 64-bit JVM. As the system was first ported to the new architecture, memory usage was extensive, (around 600 MB). In previous versions, memory cleaning was mostly performed by the JVM garbage collector. However, with the advances in CPU speed and architecture, the JVM’s garbage collector was too slow to keep memory usage at a consistent level. Data structure objects were not deleted quickly enough and memory was not retrieved at a sufficient pace, while the simulation continued to run and demand memory space allocations. To solve this problem, an inner agent was introduced, with its own cleaning policy. The agent’s primary concern was to clear data structures by clearing all references to it and marking it for garbage collection. Meanwhile, the agent replaced the existing data structures with new, smaller sized structures, since in Java clearing only the data structure will not reduce its memory size. Furthermore, the size of data objects was reduced as much as possible. In addition, some redundancy was found with respect to data objects, especially in data structures regarding animation of recurring shapes, like rays (consisting of points). Such data structures were adapted to a limit of containing data objects, so they will not hold too many objects.After implementing the above-mentioned changes, memory usage declined to 230 MB. Of course, there is always a tradeoff between resource usage and accuracy of calculation. In this case, reducing memory usage allowed for an increase in calculation accuracy. The latter depends on the number of fiber parts constituting a single fiber, where a greater number of fiber parts results in increased accuracy. Thus, the reduction in memory usage allowed for a significant increase in the number of fiber parts represented. Moreover, simplifying the data objects led to significant improvement in the overall simulation runtime. The simulation engine is now able to process both the fiber data structures and ray beam structures more quickly. In other words, calculations of the ray beam’s advancement and its collision with the fiber medium are more accurate, and the error tolerance of the calculations is of a much smaller order The running time for the previous version, at 1,000,000 histories, was days, while the running time for the new version (at the same number of histories) was around hours. Overall, there was an approximate 43% improvement in running time and 62% improvement of memory usage.


## 6. Results and Discussion

The verification phase in the software development process of the new version of the FOPS 3D simulation tool consisted of comparing the compatibility of its results with those of a previous work [5]. The verification case was a fiber (indices of refraction: n1=1.46, n2=1.34, and ncl=1.45) 100 mm long and 0.9 mm thick, with a flattened section of 35 mm and conical tapered sections with a 6° slope, where the thickness of the flattened section varied between 0.32 mm to 0.19 mm. The results showed an exact match between the old and new results [5], which allowed for validating the new version of FOPS 3D so that other conditions could be investigated.As in the previous study, in order to seek the optimal width of the uncladded section, the relative absorbance was simulated with respect to the following fiber properties: fiber length 100 mm, diameter 0.9 mm, and refractive indicesn1=1.457 and n2=1.357. As opposed to the previous simulation, where the midsection was a flattened section, in this simulation the midsection was a circular section with a diameter of 0.2–0.36 mm, length of 50 mm, and conical tapered sections with a 6° slope.In Figure2, the simulation results for the given fiber properties (in the case of no bending angle) are shown. These results were presented in our previous works [4, 5] and were actually used to validate all three versions of FOPS 3D and were also used as acceptance tests.Figure 2
Average relative absorbance for a flattened fiber with a narrowed midsection.As seen in Figure2, the results agree with those presented earlier [4] (where a tapped midsection was used), with a slight difference, probably because of the different midsections used in the simulation. As shown in Figure 2, the absorbance increases as thickness of the narrowed section decreases, due to the larger number of reflections that takes place within the narrower section. In other words, these results clearly indicate that even for a circular midsection, using thinner tapered midsection radii may increase the absorbance intensity dramatically and improve the spectral signal-to-noise ratio.In this work, the goal was to explore the effect of fiber bending on the fiber effectiveness. Accordingly, the bending angles for the untapped midsection were changed, while the midsection itself was kept constant, in order to see determine the optimal absorbance value. In other words, the relative absorbance for different bending angles was measured, while defining the uncladded section at the constant that was shown in Figure2.The results of the simulation are shown in Figure3. Clearly, as the fiber is bent, the relative absorbance increases, for the reasons mentioned earlier regarding fiber bending, which enables the light beam to hit the uncladded section more often. In Figure 3, the results for four different cases are shown. The first case is the optimal one, as was found in Figure 2, that is, a circular midsection with a diameter of 0.2 mm; the other three cases show results for additional (arbitrary) diameter values (d=0.3, 0.32, 0.34 mm). For the optimal case, this goes on as far as a certain optimal bending angle (around 45°), where the efficiency increases almost 20% over that of the comparable unbent case, after which the relative absorbance decreases by 20% as the bending angle grows. Other widths below the optimal value were tested as well, and the same pattern was observed: an increase until the optimal angle (around 45°) and a decrease following it; however, the difference in the efficiency of the optimal angle is no more than 5%. Figure 3 reveals the most dramatic changes in efficiency that soccur when the fiber bending occurs mostly in the optimal diameter. Thus, both thickness and bending angle are two complementary parameters with which optimal efficiency can be achieved.Figure 3
Average relative absorbance of bending angle for a given uncladded part diameter.


## 7. Conclusions

As predicted, it indeed is beneficial to bend the fiber so that the ray beam advances more slowly and hits the fiber medium a greater number of times, in order to increase the efficiency of spectroscopy with fiber optics. More hits on the fiber medium transfer additional energy into the tissue or sample tested, thus increasing the accuracy of the method. The most significant finding of this work is that there are two complementary parameters determining optimal fiber efficiency: the thickness of the midsection and the bending angle, which is optimally around 45°. The relation between these two parameters is that the efficiency achieved by bending at the optimal angle is much more significant when the midsection is at its optimal width.The simulation tool still requires further optimization at the algorithmic level. With the recent advances of multicore processors and parallel programming languages, FOPS 3D may be adapted for parallel execution in order to increase the simulation processing speed. This, along with the use of grids or genetic algorithms, can further improve the simulation tool, enabling it to find the optimal bending level once the optimal width for given fiber properties is determined.



---

*Source: 187678-2012-05-31.xml*