Simulation-Based Analysis of Hydrometallurgical Processes. Case Study: Small-Scale Gold Mining in Ecuador

In this work, two hydrometallurgical processes for gold recovery are explored for a smallscale gold mining case study located at Ponce Enriquez, Azuay, Ecuador. The hydrometallurgical systems consider the use of sodium cyanide and sodium thiosulfate as leaching agents, with and without the incorporation of a subsystem for residual mercury removal. The proposed processes are modelled using the commercial simulator PRO/II interconnected with a Python scientific computing environment for performing stochastic simulations. Monte Carlo simulations, in which the conversion of the main units and the prices of gold vary following a random uniform distribution, permit observing the effects of these uncertainties on key recovery and economic indicators. The results facilitate the correlation between the inputs and outputs of interest as well as the visualization of the outputs variability for an adequate assessment of the systems under study by following a technical and social responsibility approach.


Introduction
The COVID-19 outbreak during 2020-2021 has placed Latin America as one of the most affected regions, because of not only the casualties, but also the economic impact [1]. In this context, Ecuador has faced a GDP contraction along with the drop of oil prices worldwide, requiring foreseeing medium-and long-term economic recovery alternatives. Gold mining appears to be a reasonable path to follow with the intention of improving the economy of the country. On 15 October 2020, Ecuador was accepted as a member of the Extractive Industries Transparency Initiative (EITI), which paves the path in the direction of improving transparency and accountability in the extractive sector [2]. In the case of gold mining, it is imperative to promote its technification, particularly for the artisanal and small-scale gold mining (ASGM) sector of the country. From exploration to commercialization, the ASGM operations influence the perspective of the public opinion towards the mining industry [3]. Ecuador has been promoting its modernization to increase tax collection and to reduce the associated environmental impact [4]. Even though there are some unresolved issues, this sector has exposed benefits for rural citizens and the government along with activating local networks and economic activities [5]. Therefore, the development of technically oriented frameworks for decision-making in small-scale gold mining operations has relevant importance.
ASGM processors are important actors in the extraction and processing of gold ores. Indeed, they contribute with 85% of the total gold produced in Ecuador. Small operations The stream coming from the hydro-separator TK-102 has a set point of 50% (w/w) water. This stream is referred to as a pulp and passes through two stirred tanks in series R-101 and R-102, where the leaching process included in Section 2 takes place. Here, the pulp is conditioned by adding calcium hydroxide to increase its pH to 11. Sodium cyanide is then added as a complexing agent, until it reaches a concentration of 0.15 M. Together with gold, it forms a soluble and recoverable compound. Air is injected into the reactors keeping the oxygen concentration at 8.2 mg/L to ensure slightly oxidizing conditions required for leaching. The leaching reaction that takes place inside the tanks is denoted as Equation (1) [20]: Section 3 corresponds to an adsorption system that uses activated carbon with a ratio of 20 kg per ton of mineral [20]. The system works in a counter current arrangement and includes three stages represented by TK-103, TK-104, and TK-105. Here, the gold complex is retained. It is assumed that the carbon adsorbs the complex until it reaches TK-103 and that in TK-105 the solution no longer contains gold. Thus, it is sent to a treatment system. The stream coming from the hydro-separator TK-102 has a set point of 50% (w/w) water. This stream is referred to as a pulp and passes through two stirred tanks in series R-101 and R-102, where the leaching process included in Section 2 takes place. Here, the pulp is conditioned by adding calcium hydroxide to increase its pH to 11. Sodium cyanide is then added as a complexing agent, until it reaches a concentration of 0.15 M. Together with gold, it forms a soluble and recoverable compound. Air is injected into the reactors keeping the oxygen concentration at 8.2 mg/L to ensure slightly oxidizing conditions required for leaching. The leaching reaction that takes place inside the tanks is denoted as Equation (1) [20]: Section 3 corresponds to an adsorption system that uses activated carbon with a ratio of 20 kg per ton of mineral [20]. The system works in a counter current arrangement and includes three stages represented by TK-103, TK-104, and TK-105. Here, the gold complex is retained. It is assumed that the carbon adsorbs the complex until it reaches TK-103 and that in TK-105 the solution no longer contains gold. Thus, it is sent to a treatment system.
The carbon loaded with gold is retained due to its particle size in TK-103 with filters. Thereafter, it is sent to the elution column T-101 in Section 4. In this column, a solution composed of sodium cyanide, ethanol, and sodium hydroxide is fed at a rate of 2 the bed's volume. The mixture, known as the elution solution, is heated up to 353 K in E-101. When the loaded carbon is put in contact with the solution, it causes the release of the gold complex by diluting it. The resultant electrolytic solution is sent to the electroplating unit to obtain the final gold product, while the utilized carbon is regenerated.

Via Sodium Thiosulfate
In the case of using sodium thiosulfate as the leaching agent, some modifications are included as observed in Figure 2. This system is analogous the one presented in Figure 1. However, in R-101, sodium thiosulfate is added as the leaching agent, and the ammonia dose is adjusted for reaching a 10.5 pH value. The reactor uses copper sulfate as catalyst at a concentration of 1.5 g/L. Later, it is regenerated by reducing the dissolved oxygen.
The carbon loaded with gold is retained due to its particle size in TK-103 with filters. Thereafter, it is sent to the elution column T-101 in Section 4. In this column, a solution composed of sodium cyanide, ethanol, and sodium hydroxide is fed at a rate of 2 the bed's volume. The mixture, known as the elution solution, is heated up to 353 K in E-101. When the loaded carbon is put in contact with the solution, it causes the release of the gold complex by diluting it. The resultant electrolytic solution is sent to the electroplating unit to obtain the final gold product, while the utilized carbon is regenerated.

Via Sodium Thiosulfate
In the case of using sodium thiosulfate as the leaching agent, some modifications are included as observed in Figure 2. This system is analogous the one presented in Figure 1. However, in R-101, sodium thiosulfate is added as the leaching agent, and the ammonia dose is adjusted for reaching a 10.5 pH value. The reactor uses copper sulfate as catalyst at a concentration of 1.5 g/L. Later, it is regenerated by reducing the dissolved oxygen. The leaching reaction for the dissolution of gold [7,21] is represented as Equation (2): Section 3 represents the carbon absorption system. It consists of three parallel tanks TK-103, TK-104, and TK-105. This arrangement provides a prolonged contact between the gold ion and the contact surface. Finally, in Section 4, a mixture of ammonia and sodium thiosulfate is used as an elution solution for T-101.

Hydrometallurgical Process Simulation
All the simulations follow a similar methodology. The components are added using the PRO/II OLILIB library, which allows working with pure electrolytes and minerals, as those found in the studied systems. For simulating the raw mineral, samples processed in a small-scale mining plant located at Ponce Enriquez, Azuay, Ecuador were considered. Different physical and chemical analyses were performed to determine the mineral properties and its composition. Such analyses are important to understand the ore's behavior during its processing. Physical techniques such as natural humidity and apparent and real density were carried out. In addition, the samples were analyzed using a Flame Atomic Absorption Spectrophotometer (210VGP, Buck Scientific Inc., East Norwalk, CT, USA). The mineralogical composition of the raw material was evaluated by an X-ray The leaching reaction for the dissolution of gold [7,21] is represented as Equation (2): Section 3 represents the carbon absorption system. It consists of three parallel tanks TK-103, TK-104, and TK-105. This arrangement provides a prolonged contact between the gold ion and the contact surface. Finally, in Section 4, a mixture of ammonia and sodium thiosulfate is used as an elution solution for T-101.

Hydrometallurgical Process Simulation
All the simulations follow a similar methodology. The components are added using the PRO/II OLILIB library, which allows working with pure electrolytes and minerals, as those found in the studied systems. For simulating the raw mineral, samples processed in a small-scale mining plant located at Ponce Enriquez, Azuay, Ecuador were considered. Different physical and chemical analyses were performed to determine the mineral properties and its composition. Such analyses are important to understand the ore's behavior during its processing. Physical techniques such as natural humidity and apparent and real density were carried out. In addition, the samples were analyzed using a Flame Atomic Absorption Spectrophotometer (210VGP, Buck Scientific Inc., East Norwalk, CT, USA). The mineralogical composition of the raw material was evaluated by an X-ray diffractometer instrument (X'Pert Pro, PANalytical, Almelo, The Netherlands). Finally, the granulometric analyses of the material to be leached took place using a laser scattering particle size distribution analyzer (LA-300, HORIBA Scientific, Austin, TX, USA). The information regarding the mineral composition of the studied material can be found in Table 1. The chemicals that are not available in the databank were formulated and incorporated into the simulation through the functional groups of each compound. Solid ionic compounds were defined as UNIFAC structures including their molecular weight, density, entropy, and enthalpy. The simulations were built using two equations of state (EOS). The Soave-Redlich-Kwong (SRK) thermodynamic package was implemented for the mercury removal (System 1) because of its applicability in these processes [22]. The EOS for the leaching system and subsequent stages was the non-random two-liquid (NRTL) model, because it allows working with polar and electrolytic streams. The solution under study was assumed to be polar because it was composed of complexes soluble in water and of electrolytic nature due to the presence and formation of ions [20]. The modeling of the equipment required the use of different units available in PRO/II. The main assumptions and thinking process for selecting the unit operations are described in Table 2. Table 2. Unit operations incorporated into the process simulations in PRO/II.

Unit Operations Description
Conversion reactor This reactor is a preliminary approximation of the equipment during conceptual design stages.
Counter-current decanter It models the recovery of components in the liquid phase of a stream with a defined solvent.

Flash
It resembles the separation of the components in a stream due to volatility differences.

Stream calculator
It allows the separation of streams based on mass balances determined by the user.

Simple heat exchanger
It is used to heat up or cool down a stream by specifying certain conditions or by exchanging heat between two fluids.

Controller
It allows regulating a parameter/variable of interest of a process stream or equipment by varying a certain input. It also permits modifying the specification of another unit.

Calculator
It performs any calculation through mathematical equations. This information can be used by other units within the simulation environment.
For modelling Section 1, TK-101 and TK-102 were simulated together. For the amalgam formation, a conversion reactor with a fixed value of the reaction yield was utilized. Afterwards, a counter-current decanter was incorporated. No pressure drop and a liquid recovery fraction of 0.9 were assumed. The upper outlet stream of the decanter was connected to a flash separator. This unit operated at atmospheric temperature and pressure, and it represented the separation of mercury from water. The lower stream of the decanter was connected to a stream calculator that represented the separation of the amalgam from the rest of the minerals for later mixing it with the mercury stream downstream the flash separator. This stream was connected to a retort system using a conversion reactor where the thermal decomposition of the amalgam on H-101 was simulated followed by a flash that separated gold and mercury in the vapor phase. E-101 was a heat exchanger in which the outlet temperature was specified at 298 K, ensuring a total condensation of the mercury.
The process parameters and variables of the system using sodium cyanide as a leaching agent are enlisted in Table 3. The parameters and the variables that corresponded to the system using sodium thiosulfate as a leaching agent are enlisted in Table 4. In both cases, the process variables were obtained from the literature. Table 3. Hydrometallurgical process simulation conditions when the leaching agent is sodium cyanide.

Section
Operating To simulate the leaching reactors R-101 and R-102 (Section 2), the perfect mixing of the components was assumed by implementing mixers to add the required reagent streams. The controllers implemented in the simulation regulated the flow of the required reagents, guaranteeing that the needed conditions were accomplished inside the reactor. The calculators were implemented to estimate the pH inside the reactors by using the concentration of the bases. The calculator was connected to a controller which regulated the amount of base added to attain certain desired pH.
The counter-current adsorption tank system in Section 3 was simulated using a conversion reactor and a molar equivalency of the ion attached to the carbon. In this case, the adsorption yield was utilized as a conversion value. A stream calculator was responsible for separating the activated carbon from the rest of the components, once the adsorption finished. The three adsorption stages, established in TK-103, TK-104, and TK-105, were simulated as one, considering the overall performance of the process. Equation (3) represents the absorption equivalence reaction for the sodium cyanide system: For the T-101 elution tower, a heat exchanger adjusted the elution solution to a desired temperature, followed by a conversion reactor that used the same base in adsorption but this time with the elution yield. Likewise, a stream calculator was implemented for the deactivated carbon separated from the electrolytic current. Equation (4) represents the molar equivalency for the elution of the sodium cyanide system [20]:

Problem Formulation
The literature reports that the conversions in all the stages of gold recovery could vary within a range. Due to the margin of variability of the yields in the leaching, adsorption, and elution stages, their direct impact on the process is notorious, influencing the amount of gold recovered and the economy of the business. These conversions are associated with the consumption of different amounts of reagents and utilities. In addition, the market, mainly driven by the prices of gold and its associated volatility, influences the business economy.
The reliability of a process could be evaluated by studying its uncertainties [23,24]. In this context, a stochastic analysis for evaluating the uncertain nature of the process was studied along with the influence of varying the prices of gold. The incidence of the conversion and income variations were evaluated in terms of the cash flow and profitability of the evaluated hydrometallurgical alternatives, particularized for a small-scale gold mining case study located in Ecuador.
A generic mathematical expression for analyzing the variability of outputs y k when including uncertainty is reported as Equation (5): subject to: where θ represents an uncertainty matrix of i generated samples and j parameters. This matrix is considered as the source of uncertainty for the high-resolution model; the outputs are composed of a deterministic term denoted by c T , which corresponds to a constant vector of unchanged parameters; the term E f θ ij represents the expected value of the outputs of interest. It considers the uncertainties, and it is a function of the uncertain parameters, θ ij ; the equality constraints, denoted by h(θ), resemble the mass and energy balances of the process simulation as well as the cost estimation equations; the inequality constraints, represented by g(θ), correspond to the equipment and other process design constraints. Each generated sample θ i is restricted between an upper and lower bound, represented by θ LB i and θ UB i , respectively. In this work, both process and economic indicators were considered. The main equations studied are displayed as following: where where Au recovered represents the percentage of gold recovered from the procces and it is the ratio between the amount of gold recovered in the process (AGR) and the amount of gold with the mineral (AG) multiplied by 100; CF is the cash flow, and it is the difference between the sales revenues and obtained by multiplying the AGR, the price of gold c Au , and the annualized operational expenditures (OPEX); Pro f it a represents the annualized profit, and it is the difference between the sales revenues and the total annualized cost (TAC), which is the sum between the capital expenditures (CAPEX) and the OPEX; the CAPEX is annualized when multiplied by the annualization factor (AF); the OPEX includes the raw material costs (RMC) and the utility costs (CUt). In this work, the CUt included the electricity, water, carbon reactivation, and tailings treatment. The RMC considered a total of R raw materials with an individual mass flow of F j . The CAPEX was expressed as the sum of the cost bare modules (C BM ) of a total of E equipment required by each process. It was multiplied by the relationship between the chemical plant cost index (CEPCI) of 2019 and the base year (2001 in this work). The factor AF considered an annual interest rate (i) and the life span of the mineral processing plant (t). In this work, the values of 0.1 and 10 years were applied for both parameters, respectively [25]. Table 5 enlists the lower and upper bounds of the uncertain parameters. The operational uncertainties bounds were obtained from [17,26,27], and the range for the gold prices was defined based on the prices of this commodity between August and October 2020. Notice that the system considering sodium cyanide as the leaching agent has four process parameters and the system that uses sodium thiosulfate as the leaching agent has three process parameters. The costs of the raw materials and utilities are listed in Table 6 [25], and the prices of the reagents are detailed in Table 7. These prices were obtained from local vendors (in Ecuador).

Framework for Economic Evaluation under Uncertainty
Uncertainty can influence decision-making in every process, and typically, it is not accounted when modelling or designing a system. However, it can impact on the efficiency and the profitability of a project. To visualize and quantify the influence of uncertainties in metal recovery facilities, it is essential to consider the variability of certain exogenous parameters. In our practice, the process simulator PRO/II was connected to a Python environment through the Python COM interface [28] for evaluating the variability of three outputs from different hydrometallurgical alternatives.

Market uncertainty
Price of gold 60 65 USD/g A schematic of the framework is included in Figure 3. The proposed approach adopts a simulation-based paradigm that exploits the accuracy of the high-resolution model, and it is based on the methodology proposed in [29]. The benefits of the process simulator include the reliability of internal mass and energy balances as well as internally built-in computations. The interface with Python was set as an external evaluator tool.
The connection between Python and PRO/II was established through the Component Object Model (COM) command which allows a bi-directional communication between Python and PRO/II. PyWin32, an extension package for Windows available in Python, allows accessing the COM to manipulate other applications while using the Python programming interpreter. Once the communication between both platforms is established, the PRO/II COM server allows access to the process simulation model to read and write values on the simulation's objects and streams. This promotes a continuous and iterative interaction between the process simulation and Python.  The connection between Python and PRO/II was established through the Component Object Model (COM) command which allows a bi-directional communication between Python and PRO/II. PyWin32, an extension package for Windows available in Python, allows accessing the COM to manipulate other applications while using the Python programming interpreter. Once the communication between both platforms is established, the PRO/II COM server allows access to the process simulation model to read and write values on the simulation's objects and streams. This promotes a continuous and iterative interaction between the process simulation and Python.

Results
In terms of computational time, the simulations that used sodium cyanide as the leaching agent required 5.62 and 7.32 h for the cases that excluded and included Hg treatment, respectively. The simulations that used sodium thiosulfate as the leaching agent required 5.60 and 9.98 h for the cases that excluded and included Hg treatment, respectively.
Figures 4 and 5 illustrate the resultant probability density functions for ( ) and ( ), respectively. The blue distributions correspond to sodium thiosulfate, and the black distributions correspond to sodium cyanide. The Y-axis is the probability of the density function. This function describes the relative probability at which the output variable will take certain value within a probable region limited by the area under the curve. The dashed lines correspond to the cases that do not include the mercury removal section, while the continuous lines are the systems that include the mercury removal section. It is important to mention that the cases that do not include these removal units include an additional cost for treating the generated contaminated tailings. On the other hand, the systems that include the mercury removal section have the advantage of recovering additional gold, which otherwise would be discarded into the disposal tailings.
When analyzing the probability density function in Figures 4 and 5, it was observed that the greatest existing risk fell in the processes that used sodium thiosulfate. This observation showed a greater degree of variability/dispersion through the widening of its distributions when compared to the processes using sodium cyanide, in which the potential risk was lower.

Results
In terms of computational time, the simulations that used sodium cyanide as the leaching agent required 5.62 and 7.32 h for the cases that excluded and included Hg treatment, respectively. The simulations that used sodium thiosulfate as the leaching agent required 5.60 and 9.98 h for the cases that excluded and included Hg treatment, respectively. Figures 4 and 5 illustrate the resultant probability density functions for Au recovered (θ) and Pro f it a (θ), respectively. The blue distributions correspond to sodium thiosulfate, and the black distributions correspond to sodium cyanide. The Y-axis is the probability of the density function. This function describes the relative probability at which the output variable will take certain value within a probable region limited by the area under the curve. The dashed lines correspond to the cases that do not include the mercury removal section, while the continuous lines are the systems that include the mercury removal section. It is important to mention that the cases that do not include these removal units include an additional cost for treating the generated contaminated tailings. On the other hand, the systems that include the mercury removal section have the advantage of recovering additional gold, which otherwise would be discarded into the disposal tailings.     Table 8 displays a summary statistic of the three studied outputs ( ), and ( ). The included statistics in this work are the mean or e value, standard deviation of the outputs (σ ), and minimum and maximum achieved in the evaluated simulations. Case 1 and case 2 corresponded to the ca used sodium cyanide as the leaching agent excluding and including the mercury r section, respectively. Case 3 and case 4 were the cases that used sodium thiosulfat leaching agent excluding and including the mercury removal section, respective tice that the cases that used sodium cyanide had the highest annualized prof which was a consequence of a higher gold recovery. In addition, these cases sh higher cash flow, which represents a good indicator for the business. A particul pelling factor was observed in terms of the process reliability. The systems using cyanide showed a smaller σ in all results, implying that this leaching agent lea configuration less sensitive to the process and market uncertainties. On the othe we can observe the benefit of including the mercury removal system, because go When analyzing the probability density function in Figures 4 and 5, it was observed that the greatest existing risk fell in the processes that used sodium thiosulfate. This observation showed a greater degree of variability/dispersion through the widening of its distributions when compared to the processes using sodium cyanide, in which the potential risk was lower. Table 8 displays a summary statistic of the three studied outputs Au recovered (θ), CF(θ), and Pro f it a (θ). The included statistics in this work are the mean or expected value, standard deviation of the outputs (σ y ), and minimum and maximum values achieved in the evaluated simulations. Case 1 and case 2 corresponded to the cases that used sodium cyanide as the leaching agent excluding and including the mercury removal section, respectively. Case 3 and case 4 were the cases that used sodium thiosulfate as the leaching agent excluding and including the mercury removal section, respectively. Notice that the cases that used sodium cyanide had the highest annualized profitability which was a consequence of a higher gold recovery. In addition, these cases showed a higher cash flow, which represents a good indicator for the business. A particular compelling factor was observed in terms of the process reliability. The systems using sodium cyanide showed a smaller σ y in all results, implying that this leaching agent leads to a configuration less sensitive to the process and market uncertainties. On the other hand, we can observe the benefit of including the mercury removal system, because gold was recovered from tailings generating a positive impact on the gold recovery facility. These results could be used as a guidance for decision-making in small-scale mining facilities.

Hydrometallurgy Process Using Sodium Cyanide
In Figure 6, the outputs of the processes using sodium cyanide as the leaching agent are contrasted. The three studied outputs were evaluated for the system excluding (case 1) and the system including (case 2) the mercury removal section. The diagonal illustrates the type of distribution of the output variables. Notice that all cases resembled a normallike distribution. Furthermore, the dispersion points show each possible combination of the outputs for two random variables according to their probabilities of occurrence. The outputs showed a positive relationship among them, meaning that a greater value of one will cause a greater value of the other.

Hydrometallurgy Process Using Sodium Cyanide
In Figure 6, the outputs of the processes using sodium cyanide as the leaching agent are contrasted. The three studied outputs were evaluated for the system excluding (case 1) and the system including (case 2) the mercury removal section. The diagonal illustrates the type of distribution of the output variables. Notice that all cases resembled a normal-like distribution. Furthermore, the dispersion points show each possible combination of the outputs for two random variables according to their probabilities of occurrence. The outputs showed a positive relationship among them, meaning that a greater value of one will cause a greater value of the other. Figure 6. Pairwise bivariate distribution of the outputs for the systems using sodium cyanide as the leaching agent. The blue results correspond to the samples that did not include Hg removal, and the orange results correspond to the samples that included Hg removal. Figure 6. Pairwise bivariate distribution of the outputs for the systems using sodium cyanide as the leaching agent. The blue results correspond to the samples that did not include Hg removal, and the orange results correspond to the samples that included Hg removal.
A Pearson's coefficient matrix permits constructing a visualization, in the form of a heat map and the relationship between the uncertain inputs and the outputs of interest. Such representation permits quickly identifying the incidence patterns and discovering the relationships among inputs and outputs. Depending on the value of the Pearson's coefficient, certain relationship could be deducted. A value of 0 indicates that there is no relationship, while −1 or +1 implies a perfect negative or a perfect positive relationship, respectively. Figure 7 shows the Pearson's coefficients heat map correlations for the systems that used sodium cyanide as the leaching agent. Figure 7a corresponds to case 1, which did not include the mercury removal section, and Figure 7b corresponds to case 2, which included the mercury removal section. The variables denoted as θ 1−5 are the uncertain inputs, in which the last one corresponds to the price of gold as previously introduced in Table 5. The remainder three variables (y 1−3 ) are the outputs of interest in the following order Au recovered (θ), CF(θ), and Pro f it a (θ), respectively. Both cases are essentially similar with some minor differences. Overall, the results showed a strong correlation of the elution process conversion on Au recovered (θ) followed by the adsorption conversion with respect to the same output. In addition, the elution process conversion and the adsorption conversion showed relevant influence on CF(θ) and Pro f it a (θ). Finally, the price variability mainly affected the CF(θ) and the Pro f it a (θ). Based on these results, a key operational variable and unit to pay attention is the elution process, as it influences the overall gold recovery and the economy of the process.
used sodium cyanide as the leaching agent. Figure 7a corresponds to case 1, which did not include the mercury removal section, and Figure 7b corresponds to case 2, which included the mercury removal section. The variables denoted as 1−5 are the uncertain inputs, in which the last one corresponds to the price of gold as previously introduced in Table 5. The remainder three variables ( 1−3 ) are the outputs of interest in the following order ( ), ( ), and ( ), respectively. Both cases are essentially similar with some minor differences. Overall, the results showed a strong correlation of the elution process conversion on ( ) followed by the adsorption conversion with respect to the same output. In addition, the elution process conversion and the adsorption conversion showed relevant influence on ( ) and ( ). Finally, the price variability mainly affected the ( ) and the ( ). Based on these results, a key operational variable and unit to pay attention is the elution process, as it influences the overall gold recovery and the economy of the process.

Hydrometallurgy Process Using Sodium Thiosulfate
In Figure 8, the outputs of the systems using sodium thiosulfate as the leaching agent were evaluated. The three outputs were studied for the proposed alternatives, which exclude the mercury removal section (case 3) and include the mercury removal section (case 4). The diagonal represents the type of distribution for the output variables. Similarly, all cases exhibit a normal-like distribution. The outputs showed a positive relationship among them, meaning that a greater value of one will cause a greater value of the other.

Hydrometallurgy Process Using Sodium Thiosulfate
In Figure 8, the outputs of the systems using sodium thiosulfate as the leaching agent were evaluated. The three outputs were studied for the proposed alternatives, which exclude the mercury removal section (case 3) and include the mercury removal section (case 4). The diagonal represents the type of distribution for the output variables. Similarly, all cases exhibit a normal-like distribution. The outputs showed a positive relationship among them, meaning that a greater value of one will cause a greater value of the other.  Figure 9 shows the Pearson's coefficients heat map correlations for the systems that use sodium thiosulfate as the leaching agent. Figure 9a corresponds to case 3 which did not include the Hg recovery unit, and Figure 9b corresponds to case 4 which included the Figure 8. Pairwise bivariate distribution of the outputs for the systems using sodium thiosulfate as leaching agent. The blue results correspond to the samples that do not include Hg removal, and the orange results correspond to the samples that include Hg removal. Figure 9 shows the Pearson's coefficients heat map correlations for the systems that use sodium thiosulfate as the leaching agent. Figure 9a corresponds to case 3 which did not include the Hg recovery unit, and Figure 9b corresponds to case 4 which included the Hg recovery unit. The variables denoted as θ 1−4 are the uncertain inputs, in which the last one corresponds to the price of gold as previously introduced in Table 5. The remainder three variables (y 1−3 ) are the outputs of interest as already explained in the previous section. For both cases, they were essentially similar with some minor differences. For the sodium thiosulfate systems, the influence of gold prices lost relevance. In fact, the sections that appear to be important and more influential in the economy are the leaching and adsorption processes. Au recovered (θ) showed a strong correlation with the leaching conversion, which implies that the operation and control of this process stage is a key factor in achieving the good economy of the system. Finally, the elution process lost importance in these cases. Figure 8. Pairwise bivariate distribution of the outputs for the systems using sodium thiosulfate as leaching agent. The blue results correspond to the samples that do not include Hg removal, and the orange results correspond to the samples that include Hg removal. Figure 9 shows the Pearson's coefficients heat map correlations for the systems that use sodium thiosulfate as the leaching agent. Figure 9a corresponds to case 3 which did not include the Hg recovery unit, and Figure 9b corresponds to case 4 which included the Hg recovery unit. The variables denoted as 1−4 are the uncertain inputs, in which the last one corresponds to the price of gold as previously introduced in Table 5. The remainder three variables ( 1−3 ) are the outputs of interest as already explained in the previous section. For both cases, they were essentially similar with some minor differences. For the sodium thiosulfate systems, the influence of gold prices lost relevance. In fact, the sections that appear to be important and more influential in the economy are the leaching and adsorption processes.
( ) showed a strong correlation with the leaching conversion, which implies that the operation and control of this process stage is a key factor in achieving the good economy of the system. Finally, the elution process lost importance in these cases.

Social Responsibility
International experiences show that the nature of the ASGM is a major challenge for the implementation of cleaner technologies. The social and cultural context of small-scale gold mining and its informality is a barrier for mercury recovery and elimination, as well as for gold recovery following more sustainable and environmentally friendly pathways. These topics have been addressed by different governmental and corporate programs, with some of them driven by international large-scale mining (LSM) companies for more than two decades in Africa, Latin America, and Asia.
None of the international agreements is better for this concern than the Minamata Convention on mercury elimination, addressed by several governmental and regional programs, such as the UNDP Planet Gold in the Andean countries. Any progress in this direction requires a step-by-step approach to the ASGM actors and an appropriated change management.
In some cases, gradual mercury reduction and mercury-free gold recuperation could be achieved at a greater scale. Important initiatives correspond to technical assistance and learning programs regarding mineral pre-selection (vs. whole ore amalgamation), community-based retorts, and gold recovery with gravimetric methods. Another change approach is local buying platforms for artisanal miners and women minerals selectors to avoid domestic amalgamation or through local trading platforms. For instance, it is the aim of the Ecuadorian Central Bank to buy gold from artisanal-and small-scale miners for a market price in cooperation with area rehabilitation programs of the Ecuadorian National Mining Company (ENAMI) [30,31].
In several parts of the world, small retort equipment has been provided to ASGM groups, but in locations where its operation is not accompanied over time; after finishing the programs, miners tend to re-use amalgamation after project closing. The lesson learnt is that programs should be developed by miners themselves for achieving mercury elimination at a higher scale.
After international and national legislations have been changed to commit to phasing mercury out, the ASGM development programs are focusing more on formalization and organizational development. This offers access to credits, better technologies, and markets and incentives for organizational development. On the other hand, this establishes a clear crossroad, going from formalization (mercury elimination) or falling out of the scope of programs, which might foil the current achievements.
Unfortunately, the pandemic situation increases the risks of a new wave of strong poverty, driving migration into mining areas which might mean that illegal gold mining and mercury use is a bigger challenge than ever before for the eco-systems. The key lesson learnt from all programs is that the lever for change management are economic incentives through commercial platforms for buying gold at a commercial price, and offering further incentives for development as proposed by CSR-systems like Fairtrade [32] and Fairmined [33] certification.
More effective step-by-step programs towards development could be small-scale gold miners located at concessions of LSM companies. In this regard, LSM companies assume the responsibilities for small-scale and artisanal miners in their concessions and surrounding areas. In this context, computer-aided tools, as the proposed framework, could become more accessible for ASGM decision-makers if promoted by LSM companies. These tools could illustrate the bigger picture of different processing techniques as well as the advantages of recovering remanent mercury. Such an approach could encourage more beneficial and sustainable operations in the ASGM sector once applied as a common practice.

Discussion and Conclusions
A simulation-based strategy for evaluating hydrometallurgical alternatives was developed using tailor-made computer-aided tools combined with commercial process simulation software. The framework developed in this work aims to serve as a decision support tool for the mining sector even though the case study focused on small-scale gold mining in Ecuador. Indeed, this sector (ASGM) requires to include more technical, sustainable, and profitable operations.
The high-resolution simulation of different processes for gold recovery was evaluated including uncertainties in the conversion stages and the gold prices. These simulations were interconnected with a Python environment for its stochastic analysis and further statistical assessment. Four different scenarios were simulated using PRO/II. The considered hydrometallurgical processes included the use of sodium cyanide and sodium thiosulfate as the leaching agents and with and without the removal of residual mercury. For the evaluated scenarios, the systems that used sodium cyanide as the leaching agent were the most profitable hydrometallurgical processes, especially the one that included the removal of mercury. In addition, these systems exhibited a higher reliability, because their standard deviations were lower. Such a finding should not undermine the use of more cleaner leaching pathways (e.g., sodium thiosulphate). Indeed, it should encourage the study of applying incentives that promote the use of more sustainable processes.
In terms of the environmental perception, the use of sodium thiosulfate is more competitive when compared with cyanide solutions. In this study, environmental indicators were not included, but the literature highlights that safe and clean reagents are of remarkable importance for public perception [7]. However, small-scale mining operations have the priority of incorporating mercury removal systems. This work concludes that such practices could bring additional economic benefits due to the amalgam recovery and consequent increase of gold recovery and annualized profitability as observed in Figures 4 and 5. These benefits do not exclude the already existing incentives regarding the Fairtrade and the Fairmined certification for gold commercialization. Overall, the combination of better and more sustainable practices, guided by technologically oriented frameworks as the proposed one, have the potential of improving the ASGM sector in Ecuador and to bring benefits for all the actors.