Development of a comprehensive software application for realization and dissemination of the mass scale

The main features of the RealMass Calibration software, a tool for mass standards calibration developed at the INRiM, are described. It was developed under the Matlab environment and will be distributed as an executable file on the INRiM website for free download. The software tool has a user-friendly graphical interface to be easily applied by final users. The software is capable of perform advanced mass calibrations processing at the state of the art. Although it can be use at the high-test levels for the mass scale realisation, the user-friendly features also make it suitable for routine calibrations for accredited laboratories. The elaboration of the measurements, defined by the weighing designs, can be performed by the weighted least-squares with Lagrange multipliers and the Gauss Markov estimator. It can take into account uncertainties and correlations of the input quantities, as: between the reference standards, air density measurements and between values of mass and volume of the standards. Tolls to check the consistency of the results are also provided. Validation and the applications to a real case studies are also shown.


Introduction
In mass metrology the calibration of mass standards is performed by comparison to known references, with the use of comparators or balances, that is, instruments capable of measuring differences of mass. The easiest method consists in a direct comparison with a mass reference standard having the same nominal value. However, this method is not practicable without the realisation of the mass scale, which can only be * Author to whom any correspondence should be addressed.
Original content from this work may be used under the terms of the Creative Commons Attribution 4.0 licence. Any further distribution of this work must maintain attribution to the author(s) and the title of the work, journal citation and DOI. achieved through the more complex calibration method, which provides the calibration of the entire mass scale, starting from a reference mass standard, normally of 1 kg.
The process of establishing the mass of each single standard in a set is often called multiplication, by reference to multiples of the kilogram or subdivision for submultiples, and it is the latter that is the most challenging part of the procedure in realising the mass scale. The process is based on the determination of the difference in mass between weights, or groups of weights, of equal nominal value [1].
The measurement plan, or weighing design, can also involve additional references, check standards and redundant weighings, so the system of equations to be solved, can take a very complex form.
To estimate the unknown values, least squares methods are used, the most widely used in mass metrology are the weighted least squares by Lagrange multipliers (LM) [2] and the Gauss Markov (GM) approach [3], which are able to provide the results taking into account the different uncertainties of the input quantities. The application of these methods implies the use of matrix calculation.
It is probably this aspect that makes the implementation of the calculation algorithms particularly laborious. The tools used are normally based on spreadsheets, however, their use for this application is complex and tedious and very prone to errors.
In addition, the existing commercial software solutions are very limited, for example, to our knowledge, there is no commercial software capable of handling the GM method. Furthermore, such solutions usually have costs that are not easily accessible for smaller laboratories or government institutes with limited financial resources.
As a result, laboratories have developed customised solutions to meet their needs. However, in doing so, there are major disadvantages in terms of performance, such as complex data management, poor data security and very specific training requirements for the staff.
For these reasons, as part of the EMPIR 19RPT02 Real-Mass project, INRiM has developed a software in the Matlab environment, with a graphical user interface (GUI), dedicated to mass standards calibration. It will be distributed as an executable on the INRiM website for free download in 2023, and it was called RealMass Calibration software.
This software, realised for mass standards calibration activities, and in particular for the realisation of the mass scale, is able to address these main important functions: (1) the capacity to apply to the measurements, all the necessary corrections, depending on the type of balance, and environmental conditions; (2) the calculation of the centre of gravity depending on the stacking method of the standards; (3) the creation of the weighing design matrix; (4) the evaluation of the covariance matrix of the input quantities, considering the possible correlations; (5) the parameters estimation by the GM and LM methods; (6) the analysis of the results using the check standards and the residuals obtained. These functions will be described in detail in the following sections.

Least squares methods applied to the mass standards calibration
In the calibration method by comparison, the weighings are performed by the substitution method, between a standard or a group of standards having sum m A = m k , compared with another standard or group of standards m B = m j , where m A and m B have the same nominal value m. For each comparison a weighing equation is obtain, from which the mass difference ∆m i is derived.
The model applied by the software to determine the difference in mass ∆m i at each weighing is where: • δm is the apparent mass difference; • ρ a is the air density; • ρ mAdj is the density of the balance adjustment weight; • ΣV k and ΣV j are the sum of the volumes of the group m A and m B , respectively; • ∆g/g is the gradient of the acceleration of gravity; • h GA and h GB are the centre of gravity for the group m A and m B , respectively.
Evaluation of equation (1) is performed automatically taking into account corrections and uncertainties evaluation with the most advanced techniques in mass standards calibration. For example, the difference ∆m w determined by the balance can be corrected: • taking into account the correction ∆m E for the position error, due to the weights position on the pan, this function is useful in automatic balances (∆m ′ w = ∆m w + ∆m E ); • according to the sensitivity of the balance, by the value of the sensitivity mass m s and the corresponding value read by the balance ∆m s (δm = ∆m ′ w m s /∆m s ); • for the buoyancy, where the volumes of the standards are corrected to the measurement temperature and the air density can be determined as a function of environmental parameters; • for the difference of the centre of gravity of the weights, which is evaluated automatically according to the grouping method.
In matrix notation, the system of the weighing equations can be conveniently represented using the model: where: • X w is a the design matrix, which entries are +1, −1 or 0, according to the role played by each weight in the formation of the two groups of weights to be compared; • m T = [m 1, m 2 …m p ] is the column vector of the mass values of the weights (the parameters); • y w T = [∆m 1, ∆m 2 …∆m q ] is the column vector of the mass differences between the two groups of standards involved in each equation; • ε is the vector of measurement errors, which is modelled by a normal distribution with zero mean, with associated uncertainties those of the differences ∆m i [3].
In order to solve the system of equation (2), it is not only required that the rank of the matrix X w be adequate, it is necessary to provide the value of at least one reference standard, this additional information modifies the model (2), by changing the matrix X w and the vector y w . The software can deal with this problem in two ways, through the LM and the GM methods.

Analysis of the methods according to GM and LM
In the LM method, the solution of the system of equations is obtained by considering the value of the standards given as references, as constant value (although an uncertainty is associated with them), whereas, in the GM method, the value of the reference standards are considered as random variables. This is a substantial difference when multiple standards are defined as references.
Although multiple reference standards can be considered with the LM method, this approach would only make sense when the relative uncertainties of the chosen reference standards are equivalent. It would be inappropriate to apply the LM method using references with different uncertainties, as the resulting solution would not take into account these different uncertainties.
For this reason, the LM method is normally used by fixing only one reference standard, and this approach was also chosen in the developed software. Whereas, in the GM method, no limitations are imposed on the number of references, as the GM estimator considers both uncertainties and correlation between references.
The other difference between the two methods concerns the determination of the uncertainties of the parameters. In the GM method, the calculation of the uncertainties is part of the problem solution, as the complete covariance matrix of all quantities is given as input, and also allows the direct determination of the correlation between the parameters. For the LM method, the determination of the uncertainties has to be performed applying the uncertainties propagation law and combining the uncertainties of Type A and B [4,5].
The GM method is therefore more multipurpose and comprehensive than the LM method. However, care must be taken with its implementation, which must take correlations into account, otherwise there is a risk of underestimating the uncertainty when using multiple reference standards. For this, the GM method is more complex to implement than the LM method, and it is probably for this reason that the GM method is currently not widely used, even at the level of National Metrological Institutes. The aim of developing this software was also to facilitate the implementation of the GM method, in order to extend its use to a wider community of users.

The GM method
In order to solve the system of equation (2), it is necessary to provide a constraint, which defines the value of at least one reference standard, in the matrix form [3] where A is a matrix which select the reference standards from the vector m, and R T = [m R1 , m R2 …m Rn ] is the vector with the associated values of mass.
In order to consider this information, the model (2) becomes where X is a composition of two matrices and y is a composition of two vectors This matrix construction is performed automatically on the basis of user selection of the reference standards to be used.
The parameters are estimated as Ψ y is the covariance matrix associated to the vector y. The covariance matrix Ψ m for m, from which the uncertainties and the covariance terms between the standards are derived, is given by

Determination of the covariance matrix Ψ y
The vector y is a function of several quantities, the model is given by equation (1), Ψ y can be evaluated as sum of covariance matrices as indicated in the paper by Bich et al [6]: • Ψ δm for the mass differences measured by the balances • Ψ air for the air density • Ψ ∆V for the volume differences • Ψ RS for the reference standards.
These matrices are evaluated by applying the propagation of uncertainties as described in [6], considering the possible correlations, such as those between reference standards, the volumes and those due to the determination of air density, only Ψ δm is diagonal, that is without covariance terms.
In addition to the mentioned covariance matrices, the model used in this software has been improved taking into account the correlations between the values m and V of the reference standards, which leads to correlations between the value of the reference standards and the measured mass differences in which they are involved. For this reason the covariance matrix Ψ m,∆m is evaluated. This contribution is described in the paper by Malengo and Bich [7], and plays an important role in the uncertainty evaluation, as it considers the air buoyancy uncertainty already contained in the uncertainty of the mass reference.
In conclusion, the matrix Ψ y is a composition of matrices

The LM method
As for the GM method, the constraint for the LM method can be given in matrix form as in (3). However, since only one reference standard needs to be defined, the matrix A is a row vector that selects the chosen reference. The reference value m REF is added to the end of the mass differences vector, in addition a formal parameter λ, which is the Lagrange multiplier, is added to the end of the parameters vector m [2]. This method, in order to take into account that the mass differences in the vector y w can have different accuracies, it is necessary for the model equations to be mathematically weighted before the least-squares adjustment. For this purpose, the diagonal weight matrix W, is introduced [2,8].
The terms on the diagonal are evaluated as Where s i is the standard uncertainty associated to the mass difference δm of each weighing equation, that is the terms on the diagonal of the matrix Ψ δm , and σ 0 is the normalisation factor defined by This approach is different from the method in [8], since for s i , not only the standard deviations of the mean values of δm are considered, but also the contributions of uncertainty in terms of resolution, sensitivity, linearity and eccentricity of the balances [9].
So that, the new matrices are X ′ = WX w and y ′ = √ Wy w .
The solution is given by where The associated uncertainties with m are evaluated combining Type A and Type B uncertainties, by applying the uncertainty propagation law to the matrices Ψ δm , Ψ air , Ψ ∆V and to the uncertainty of the [2].

Input data processing
The acquisition of the data is performed by means of Excel files, which are acquired by the software at different stages of the data processing.
A spreadsheet contains the database with all information of the weights, for both reference and under calibration standards: nominal value, mass value (if known), volume and/or density, centre of mass, height, expansion coefficient, their associated uncertainties and information about the traceability for the reference values. The weights are identified by a name (or serial number) and by the set of weights to which they belong.
An additional spreadsheet is dedicated to the balances, which contains a list with the names of the balances, with information on: capacity, resolution, value of adjustment weight, corrections for the position error and all the terms for evaluating uncertainty, as linearity and eccentricity. With these information, the software, depending on the balance in use, is able to make corrections to the measured mass difference and evaluate the uncertainty of each weighing. The user, can however choose to perform the custom uncertainty evaluation.
The processing of a weighing scheme is done through three spreadsheets that describe: • the weighing plan; • the weighing design; • the measurements of each weighing.
The weighing plan consists of the selection of the weights involved, that corresponds to the vector of the parameters m. The weighing design is the matrix X w , which defines the differences between weights or group of weights. The third sheet contains the measurements for each weighing, required to determine the mass difference: difference of balance reading, environmental parameters, air density, balance in use and traceability of the measurements.
Although these data can be provided in files prepared by the user, the software, via the GUI, allows the user friendly creation of these spreadsheets. Figures 1 and 2 show an example of how the user interface appears to create the weighing plan and design matrix, respectively.
Whether data are entered manually by the user, or using the GUI, the software checks the validity of the data input in order to avoid mistakes, as: missing data in the spreadsheets to be processed, sizes of input matrices not consistent with each other, incorrect implementation of the design matrix.
The software is also set up to automatically evaluate corrections due to centre of mass, by choosing the method of grouping the weights on the pan: stacked or side-by-side. However, in cases where the weighing involves special grouping methods, the user can define the method used for each weighing by means of a matrix given in a spreadsheet. In practice, each weight involved in the weighing equation is indicated where it is placed by a letter: 'Z' indicates that it is located on the balance pan, if it is located on another weight, the letter corresponds to the column name of the design matrix in which the weight is located, an example is given in figure 3.   Concerning the correlation between the reference standards, the user can choose the simple way of using one value for all of them, or has the option of introducing a correlation matrix (upper triangular) between the different weights involved, for which he wants to specify the correlation, an example is given in figure 4.

The control panel
The GUI has been designed to facilitate the implementation of the weighing scheme and the setting of the control parameters for solving the system of equations. Figure 5 shows an example of a GUI in its complete form, in which the solution to the problem is provided.
As already mention in section 4, it is possible to establish and subsequently to save new weighing plans by selecting the weights from the database. The user can load common design matrices, already available, but it is also possible to create new ones.
The spreadsheets to elaborate, containing information on the weighing plan, the weighing design and the measurements of each weighing, can be loaded separately or together, loading a complete file.
Since calibrations are very frequently repeated in the same way, such as the calibration of working standards of their own laboratory, but also the calibration of customers' weights, the user will have all the configuration files of the weighing schemes ready to be processed, the only difference between successive calibrations will be the measurements spreadsheet containing the new mass differences and environmental parameters.
In addition, in the table of the results, the user can define the role of each weight, that is: which are the reference standards 'R', which are the check standards 'C' and which are the standards under test 'T'.
Once the data to be processed have been loaded, the user can solve the problem by choosing between the GM or LM methods, the results are shown in the dedicated table. In addition to the estimates and associated uncertainties, differences from previously processed values will also be shown for the references and check standards, as well as the normalized error E n [10]. This helps to check the consistency of reference values in the case of the use of multiple reference standards.
In order to check the goodness of the fit, the control panel shows both the standard deviation of the fit and also the residual r i for each weighing equation, that is the vector This allows the user to validate the results and detect any possible mistakes in the measurements.
As an auxiliary tool, the result of a residual test is also shown, which checks that the residual value for each mass difference r i is less than a limit value Lim. Since the residual is expected to be within the weighing uncertainty, this threshold, is evaluated considering the uncertainty due to the resolution of the balance u res and the weighing uncertainty u δ m given as standard deviation of the mean value δm, provided by the user There is also the possibility of recalculating the estimates, taking into account the residuals obtained. This function increases the uncertainty associated with the mass difference ∆m i as a function of the value of the residual, the user can choose that the additional standard uncertainty u add is equal to the value of the residual, u add = r i or to u add = r i /sqrt (3). He can also decide whether this contribution is attributed only to the weighings with the resulting fault residual test, or to all weighings, independently of the residual value.
All these settings are easily modified by the user, and, by comparing the results obtained with different settings, both in terms of checking the consistency of the check standards and residual values, they provide a useful tool for identifying the best processing method. The elaboration performed can be saved to a file, in which all the information and traceability of the input data and the settings used for the solution are recorded.

Validation of the results
The algorithms used were validated by performing a pointby-point verification of the partial and final results. However, there are not many comprehensive examples available in literature, with which to compare the results. An example that has been used to validate the LM method is given in the book [8], although this example is based on measurements already elaborated, to which no correction should be applied.
It should be noted, that, although this software allows for corrections due to air buoyancy, balance errors, centre of gravity differences, etc, it is also possible to use this software without making any corrections to the input data. In fact, it is sufficient to set the air density value to zero, not to select the balance in use and to set the heights of the weights to zero. In this way it was possible to perform the validation from the data of the example in [8], the results were identical both in terms of parameter estimates, associated uncertainties and residual values, the data shown in figure 5 are related to this validation.
The GM method with one reference was easily validated against the LM method, in fact, in the case of a single reference standard, the results must be equivalent. In the case of multiple references, the GM method was validated with results obtained with softwares developed by the authors.

Applications of the software
The algorithms developed by the software are based on the processing of the weighing equations defined by the design matrix provided by the user. In this way, the application of the software can extend from the most complicated problems of the design matrices used to realise the mass scale, to the simplest calibrations by comparison with the one-to-one method.
As already mentioned, the software can be used considering all the corrections necessary to obtain the most accurate results possible, but it can also be used in a simpler way, if such corrections, considering the uncertainties involved, are not required. Therefore, this software can be used at all levels of accuracy, from mass scale calibrations to routine calibrations.
In the following, some calibration examples are given, with the design matrices used.
• Calibration by multiplication, up to 5 kg, from two references of 1 kg:

Conclusions
The software developed provides an efficient tool to the laboratories for advanced mass calibrations. It allows to perform calibrations for the mass scale realisation, however, its versatility and user-friendly graphical interface make it also appropriate also for the simplest calibrations. At present, it is in the form of beta version and is being tested within the EMPIR 19RPT02 RealMass project. All the main functions have been implemented, although some improvements will have to be finalised, such as the possibil-ity of recording the history of successive calibrations and processing the weighings not only in terms of mass, but also in terms of conventional mass.
It is planned to provide the RealMass Calibration software on the INRiM website for free download in the middle of 2023.

Data availability statement
All data that support the findings of this study are included within the article (and any supplementary files).