Vertical tank capacity measurement based on Monte Carlo method

Vertical tanks are commonly used appliances for liquids, and its capacity is very important for quantitative liquid ratio and liquid trade. In order to measure the capacity of vertical tanks more conveniently, this paper proposes a vertical tank capacity measurement method based on Monte Carlo Method. The method arranges a plurality of sensor points on the inner surface of the tank, and then performs Monte Carlo tests by generating a large number of random sample points, and finally calculates the capacity by counting the sample points that meet the criterion. The criterion for whether a sample point is located in the tank, which is the core issue, is established with the coordinates of sensor points and the distance between different sensor points along the surface of the tank. The results show that the absolute error of the measurement results of the proposed method does not exceed ±0.0003[m3], and the absolute error of capacity per unit volume has a linear relationship with the height of the vertical tank, and has little effect with the radial size of the vertical tank.


Introduction
Vertical tank is widely used in the storage, transportation and measurement of liquid substances such as petroleum and chemical materials. Accurate measurement of the vertical tank capacity is directly related to the fairness of liquid substance transactions.
One of the commonly methods used to measure the capacity of a vertical tank is Geometric Measurement Method (GMM). GMM uses steel tape, theodolite or other measuring device to measure tank's geometry, and use dedicated computer software to process the measured data to obtain the tank capacity [1][2][3]. This method is with a low level of automation, requires measuring a range of geometric parameters, such as the height, circumference, and diameter of different rings (vertical tanks are actually composed of many rings), which is of a heavy work load and time-consuming. Due to the need for a lot of manual operations, the measurement efficiency of this method is low, and the measurement results are easily affected by operator errors.
Another commonly used method to measure the capacity of a vertical tank is Volumetric Method (VM). VM compares the capacity difference between a tank with higher precision and the vertical tank being measured [1,4]. During measurement, a fixed volume of water is poured into the storage tank through a standard metal tank (apparatus with a higher level of accuracy), and then the capacity table is calculated by interpolation. This method can be adapted to irregularly shaped tanks, and the capacity can be obtained directly through volume comparison without conversion calculation. VM is with high precision and simple to operate, but requires liquid (usually is water) supply while measurement and the contaminated liquid needs further processing while measurement finish. At present, 5m 3 is already a very large standard metal tank, but the volume range of vertical tanks includes 20m 3~7 00m 3 , even more than 700m 3 , and the height can exceeds 30 meters. To place the standard metal tank higher than the metal tank, this is difficult to achieve. In addition, the standard metal tank is too small compared to the vertical tank, and it takes a lot of time to pour a fixed amount of water many times. If the vertical tank is large, VM is rarely used because it takes a long time and consumes large amounts of water.
With the development of technology, new techniques for measuring vertical tank capacity has emerged. Laser Scanner Method (LSM) reconstructs the internal volume of a vertical tank by emitting laser light to the surroundings [5][6][7]. The principle of LSM is similar to that of GMM. They both obtain the vertical tank capacity by measuring the geometry parameters, but LSM is more automated. In LSM, a laser scanner is used instead of the manual measurement, and the geometric dimensions of the vertical tank are get by fitting the points cloud obtained through multiple scans. LSM includes external scanning and internal scanning. External scanning is to place the laser scanner outside the vertical tank, which requires an open field of view and as few obstructions as possible. Internal scanning is to place the laser scanner in a vertical tank, which requires fewer parts present inside the vertical tank, and the bottom of the vertical tank keeps stable during the measurement. However, when the vertical tank is large, the inspector stepping on the bottom plate may cause the bottom of the vertical tank to undulate and deform, causing the laser scanner to be unstable.
The volumetric method, geometric measurement method, and laser scanner method are used to measure vertical tanks, with a relatively fixed cycle, about once every four years. If you want to monitor the capacity of the vertical tank in real time, it is a more feasible way to arrange sensors in the vertical tank.
Monte Carlo Method (MCM) constructs a probabilistic model that approximates the performance of the system and performs random experiments on a digital computer [8]. It is very common to calculate the solid volume represented by the boundary with MCM [9,10]. Currently when using MCM to measure a volume, the boundary is usually obtained by laser scanning, which can provide the boundary points cloud. And with octrees construction on the points cloud, whether a point is located in the model is classified [11]. How to construct the boundary conditions of Monte Carlo experiment is the core problem of this method. MCM is computationally intensive, and still need environmental stability while laser scanning. If the boundary discrimination condition of MCM can be simplified, the amount of calculation would be greatly reduced. As General Conference of Weights & Measures has redefined SI base units and associated the definition of these basic units with physical constants, measurement standards may be integrated into the chip. That is to say, it is possible to describe the boundary discrimination condition of MCM through inserting the chip into the vertical tank. In the future, vertical tank capacity measurement would develop towards intelligent, real-time online monitoring. Under this background, we propose a vertical tank capacity measurement method based on the Monte Carlo method, hoping to conveniently measure the vertical tank capacity and obtain acceptable results, and do preliminary theoretical research for the future real-time monitoring of the change in vertical tank capacity. This paper is an exploratory study on the mathematical model and experiment of measuring vertical tank capacity by Monte Carlo method. This method focuses on constructing vertical tank boundary and capacity measurements on the premise of knowing the coordinates of certain points on the inner surface of the vertical tank.

Methods
Vertical tank capacity measurement based on Monte Carlo method is to arrange sensor points on the inner surface of the vertical tank. And then, according to the coordinates of the sensor points and the distance between each point along the tank surface, criterion to decide whether a sample point is located in the vertical tank is established. Base on this criterion, the number of sample points falling in different heights is counted, and the capacity value represented by different liquid level is calculated with the number of sample points. Fig 1 shows the main steps of the proposed method.

The distribution of sensor points
where Q k is the vertical tank capacity when the liquid level is h k . Q upper-k is the capacity of upper part when the liquid level is h k . Q bottom is the capacity of bottom part.
The sensor points in Layer−i are numbered as P i,1 , P i,2 , . . ., P i;N mono in the counter clockwise direction, where 1� i � N layer . The coordinates of sensor point P i,j are (

Criterion of the Monte Carlo test
Criterion of the Monte Carlo test is used to decide whether a sample point falls in the vertical tank. As the vertical tank is convex and the sensor points are located on the inner surface of the tank, sample points in the enclosed area formed by all sensor points must be in the tank, shown in  we have a, b and c, make where a+b+c�1, 0�a�1, 0�b�1, 0�c�1. P i1,j1 ,P i2,j2 andP i3,j3 are sensor points, 1� i1 � N layer , ! . If we cannot find a, b and c let P sample satisfies Eq 4, it is still uncertain whether P sample falls in the vertical tank or not. The subsequent calculation will be performed. Fig 5 is the positional relationship of P sample ,P i1,j1 , and P i2,j2 . If P sample is between P i1,j1 , and P i2,j2 (i.e. P sample falls within the shaded area in Fig 4), we have The distance from P sample to Line P i1,j1 P i2,j2 is P i1;j1 P sample ! . Find P i1,j1 and P i2,j2 makes where 1� i1 � N layer , 1� j1 � N mono , 1� i2 � N layer , 1� j2 � N mono , OP i1;j1 ! . After finding out two sensor points making distance is the smallest, for example, P i1,j1 and P i2,j2 satisfy Eqs 5, 6, and 7, we construct an ellipsoid with P i1,j1 and P i2,j2 as the endpoints, ). Then the ellipsoid equation is ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ðx À x A Þ 2 þ ðy À y A Þ 2 þ ðz À z A Þ 2 q þ ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffiffi Once λ is solved out, Eq 8 would be unique. Following will solve the λ value.
In Fig 6, the distance from O to P i1,j1 and P i2,j2 along the surface of the tank are l i1;j1 ¼ The distance from P i1,j1 to P i2,j2 along the surface of the tank is defined as l i1,j1$i2,j2 . Since the surface continuity of the vertical tank, approximate solution to get l i1,j1$i2,j2 is

PLOS ONE
Vertical tank capacity measurement based on Monte Carlo method According to [12], the half circumference of the ellipsoid is where L major is the ellipsoid major axis length, L minor is the ellipsoid minor axis length.
ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi l À l 2 p � L major ¼ ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi l À l 2 p � P i1;j1 P i2;j2 Solving C half = l i1,j1$i2,j2 , we can get λ and the ellipsoid equation, i.e. Eq 8. According to the definition of an ellipsoid, if the sum of the distance from P sample to A and B is shorter than L minor , P sample is in the ellipsoid. That is, if we think that P sample falls in the vertical tank. In summary, if a sample point P sample falls in the vertical tank, we have 1. The coordinates of P sample satisfy Eq 1.
2. If the coordinates of P sample do not satisfy Eq 1, they should satisfy Eq 11.

The vertical tank capacity
When conducting the Monte Carlo tests, sample points are randomly generated in the smallest cuboid that contains the vertical tank. If x min = min{x i,j }, y min = min{y i,j }, z min = min{z i,j }, x max = max{x i,j }, y max = max{y i,j }, z max = max{z i,j }, where 1� i � N layer , 1� j � N mono , x i,j , y i,j and z i,j Similarly, for a certain height h k , if the number of the sample points that satisfy the criterions of the Monte Carlo Test and z � h k is N IN-k , the capacity in upper part at h k is The vertical tank capacity at h k is The tank capacity table can be compiled by counting the number of sample points satisfying the criterions of the Monte Carlo Test at different heights.  The Monte Carlo tests are performed on Matlab, and the sample points are generated with Matlab's built-in random function ─ unifrnd (). Totally N sample = 10 6 sample points are generated in each test. A total of 10 tests were conducted.

The Monte Carlo test
In order to discuss the measurement results of vertical tanks of different volumes, the absolute error of capacity per unit volume is calculated as where Q k is the vertical tank capacity at h k . Q 0 k is the actual capacity of vertical tank at h k ,  To further investigate the relationship between the absolute error of capacity per unit volume and the size of the vertical tank, another sixty tests are carried out for different heights and radii of tank.  Based on the above analysis of the influence of H upper and R on ε k , in the linear relationship between ε k and h k , R has little effect on the slope, and the product of H upper and the slope is a constant, which is 0.214. Therefore, the relationship between ε k and h k can be written as The vertical tank capacity in upper part at h k , which is measured with the Monte Carlo method, can be compensated according to Eq 16. The compensated vertical tank capacity in upper part at h k is Substituting Eq 16 into Eq 17, we have Thus, Vertical tank test and result analysis Fig 11 are devices used for vertical tank testing, including a vertical tank [13] and a metal tank [14]. The inner diameter of the vertical tank is R = 0.299[m]. One hundred sensor point labels are evenly affixed on the inner wall of the vertical tank, a total of 10 layers, each with 10 points.

PLOS ONE
In the Monte Carlo test, a total of 10 tests are performed, and the parameters of each test are shown in Fig 12. Based on the average value of 10 tests, Q _ k À h k is calculated using Eqs 13 and 19. Table 1 is the results of vertical tank tests. Based on the average values, the relationship between the capacity and liquid level of the vertical tank is obtained through linear fitting, shown in Fig 13.  Fig 14 is the absolute error distribution of the measurement results obtained through the Monte Carlo method, e.g. Q _ k À Q 0 k . In Fig 14, the black mark is the average value of the absolute error of the 10 tests. The red area represents the standard deviation of the absolute error of the 10 tests. The maximum absolute error of using Monte Carlo method to measure the vertical tank capacity does not exceed ±0.0003[m 3 ]. Fig 15 is the relative error shrinkage curve, e.g. jQ _ k À Q 0 k j=Q 0 k . The relative error finally converges to less than 0.18%.

Conclusion
A new vertical tank capacity measurement method based on Monte Carlo Method is proposed. Focusing on constructing vertical tank boundary, the method arranges a plurality of sensor points on the inner surface of the vertical tank, and performs Monte Carlo tests by generating a large number of random sample points. The criterions for whether a sample point is located in the vertical tank are established with the coordinates of sensor points and the distance between different sensor points along the surface of the tank. The results show that the absolute error of capacity per unit volume has a linear relationship with the height of the vertical tank, and has little effect with the radial size of the vertical tank. The absolute error of the measurement results of the proposed method does not exceed ±0.0003[m 3 ], and the relative error finally converges to less than 0.18%.
Although the method we proposed can effectively measure the capacity of vertical tank, there are still some limitations that need to be improved. The number of sensor points is large, and the arrangement of the sensor points is relatively neat. We will further explore the influence of the number and location of sensor points on the measurement results in the future, try to reduce the number of sensor points, and more convenient ways to arrange the sensor points, such as scattered random arrangement. In addition, this method is suitable for tanks of various shapes, such as cuboid, cylinder, etc., but the connection between any two sensor points must be inside the tank, and there can be no such connection outside the tank. At this stage, this article mainly discusses the feasibility of the proposed method. In the future application stage, there are still many problems to be solved, such as the selection of sensors and the reaction of sensors with liquids. Regarding the selection of sensors, we have made some guesses. Surface acoustic wave sensors, ultrasonic guided wave sensors, and stress-strain sensors may be suitable.