Data-driven optimisation of variation of residual concentration to estimate the hydrogen diffusion coefficient and uptake via MATLAB
Luca Gritti, Denny Coffetti, Marina Cabrini, Tommaso Pastore

TL;DR
This paper describes a method to estimate hydrogen diffusion and uptake in metals using experimental data and MATLAB optimization.
Contribution
A novel data-driven MATLAB approach is introduced to calculate hydrogen diffusion parameters from experimental solubility tests.
Findings
A two-step electrochemical process was used to charge and discharge hydrogen in metallic samples.
MATLAB optimization successfully estimated hydrogen diffusion coefficients and uptake parameters.
The method can be adapted to different geometries through simulation.
Abstract
This article presents the data collected during experimental solubility tests in University of Bergamo lab and the developed code to estimate the principal parameters for hydrogen uptake. The experimental approach proposed involves in two-step process: the first phase consists of electrochemical charging to saturate the metallic sample via cathodic polarization at potentials lower than the equilibrium potential for hydrogen evolution, followed by a second phase of discharging under anodic polarization at potentials higher than the equilibrium potential. During the discharging phase, the time-dependent anodic current is influenced by the flux of diffusible hydrogen exiting the sample. This flux is governed by the initial concentration of diffusible hydrogen in the material, the diffusion coefficient, and the time elapsed between the end of the charging step and the beginning of the…
Genes, proteins, chemicals, diseases, species, mutations and cell lines named across the full text — each resolved to its canonical identifier and authoritative record.
Click any figure to enlarge with its caption.
Figure 1
Figure 2Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsHydrogen embrittlement and corrosion behaviors in metals · Nuclear Materials and Properties · Corrosion Behavior and Inhibition
Specifications TableSubjectEngineering & Materials scienceSpecific subject areaModelling diffusion hydrogen on tri-dimensional fluxes, investigation of principal parameters about hydrogen in metals after electrochemical charging. Estimation of hydrogen diffusion coefficient, uptake and waiting time (between end of electrochemical charging and start of discharging).Type of data.mat (MATLAB code).txt (target curve for specific cylindrical geometry).xlsx (experimental data and pre-processed data)Data collectionThe data of target curve are collected via COMSOL simulations reordering all simulation curves obtained by [1] . The experimental curves are obtained detecting the electrochemical discharging circulating current. Via the MATLAB code it is possible elaborated the experimental data as described in [1]Data source locationData collected and elaborated in Laboratories of University of Bergamovia Galvani, 2, 24,044 Dalmine (Bg), Lombardy, ItalyData accessibilityRepository name: Data in Brief: Experimental Data Supporting Solubility ModelData identification number: 10.17632/c239nmw6dp.1Direct URL to data: data.mendelay.comGritti, Luca; Coffetti, Denny; Cabrini, Marina; Pastore, Tommaso (2025), “Data in Brief: Experimental Data Supporting Solubility Model”, Mendeley Data, V1, doi: 10.17632/c239nmw6dp.1Related research articleG. Luca, C. Denny, Marina Cabrini, Tommaso Pastore, A novel approach for estimating hydrogen uptake and diffusion coefficient, Int J Hydrogen Energy (n.d.).
Value of the Data
1
- •The experimental data can be used to verify the code, represents the experimental results of electrochemical discharging curve of hydrogen and average residual concentration.
- •The target curve data can be used to estimate the diffusion coefficients and solubility of hydrogen for the specific cylindrical specimens in electrochemical solubility tests.
- •The MATLAB code elaborates the preprocess concentration discharging curve via data driven optimization for estimate diffusion coefficient, hydrogen uptake and waiting time between electrochemical charge/discharge.
- •By estimating another target curve for a specific geometry, it is possible to use this MATLAB code to extrapolate the diffusion coefficient, solubility and waiting time between electrochemical charge/discharge.
Background
2
Thank this data it is possible elaborate directly the experimental data detected via method explained in the paper “A novel approach for estimating hydrogen uptake and diffusion coefficient” [1]. The data driven optimisation code can be employed to estimate the initial hydrogen concentration C_0_, the diffusion coefficient D, and the time interval t_0_ between the end of the charging phase and the start of the initial discharging phase based on experimental electrochemical discharging curves as explained in [1]. The experimental data should be normalized as described in [1] by assigning the appropriate values to C_0_, D, and t_0_. The normalized experimental data can be adjusted to align with the reference target curve by modifying the normalization parameters C_0_, D, and t_0_. Optimization is employed to minimize the relative error function, which is computed as the difference between the two curves. The procedure was implemented using MATLAB code. The experimental curves and MATLAB procedure is accessible on Mendeley Data [2]. The iterative process utilizes the fminsearch function, a nonlinear optimization solver based on the Nelder–Mead simplex algorithm. This method involves a simplex of n + 1 points, ordered by the decreasing value of the objective function. The worst point is discarded and replaced by a new point according to specific criteria.
Data Description
3
The data are available in the Mendeley Data “Data in Brief of Solubility Model”. The data is arranged in the following folders, in Fig. 1 it is shown a flow chart of procedure:
- 1)**Discharging Hy tests (.xlsx)**This is the excel file with experimental data collected by solubility tests. In the file there are experimental data (time and current) for different charging cathodic polarizations (−1, −1.5, −1.8 V vs SCE). Are reported the pre-elaboration curves: from curve of current measured it is estimated the residual average concentrations as describe in [1].
- 2)HyFit Folder
- ○HyFit_code (.m)This is the MATLAB code to elaborate the data. In this part there is data driven optimization. The code is commented line by line.
- ○Importfile (.m)It is a function to import the data in format .txt in the code
- ○Preprocessed data (.txt)This is the data to import in the MATLAB code for elaboration. Each file is composed of two columns, acquisition time and residual average concentration (estimated by excel file)
- ○Target_Curve (.txt)This file contains the target curve elaborated by COMSOL simulations described in the article [1] Fig. 1. Scheme of procedure and location of data.Fig 1
Experimental Design, Materials and Methods
4
- ■ EXPERIMENTAL DATA, CURVES AND PRE-PROCESSED DATA
The experimental data was acquired following the procedure described in the work [1]. The tests was performed on cylindrical specimens, with a diameter of 13 mm and a height of 45 mm. The experiments are conduct with the experimental apparatus in Fig. 2. Initially, after sample assembly and nitrogen flushing, the test cell was filled with the carbonate-bicarbonate deaerated solution. The specimens were then polarised at +0.306 V versus SCE to obtain the passivation curve. The passivation potential was assumed to be equal to that recommended by the ISO17081 standard for the detection side of the Devanathan–Stachurski cell operating in the 0.1 M sodium hydroxide solution expressed versus SCE. This potential was also applied to the tests conducted in the carbonate–bicarbonate solution at pH 10. Hydrogen charging was conducted through potentiostatic cathodic polarisation in the range of −1 to −1.8 V versus SCE for 15 h, which was sufficient time for the specimens to achieve a homogeneous hydrogen concentration at a typical value of diffusivity reported for low-carbon steel [3,4] and compared with other techniques like the step potential method and cyclic voltammetry methods [5,6]. During this step, part of the hydrogen produced on the surface was absorbed into the specimen. At the end of the charging phase, polarisation was immediately inverted to apply the anodic polarisation again at +0.306 V versus SCE for 15 h to measure the discharging current curve. The discharging anodic current represents the passivity current enhanced by the current due to the oxidation of hydrogen egressing from the metal.Fig. 2. Scheme of the electrochemical charging/discharging cell with a single compartment.Fig 2
To generate the pre-processed data, it was necessary following this protocol. It was estimated the net current due to hydrogen oxidation , the experimental value of the discharging current was depurated by subtracting the passivation current curve measured during the early phase (1)
where is current measured during discharging step, while is current measured during passivation. The integral sum of this curve, over testing time, allows to estimate charge exchanged . It was possible to evaluate the charge evolution over time as follow in (2)
Therefore, the diffusible hydrogen concentration egress from the sample can be calculate as follow
with is the atomic weight of hydrogen, is Faraday’s constant and is the mass of sample in grams. To estimate the average residual diffusible hydrogen concentration that remain into the sample , considering a certain initial concentration at the end of charging, the following evaluation is necessary
where is the maximum final value of egress concentration and is the egress concentration over time. The relative time and the average residual diffusible hydrogen concentration are pre-processed data must be uploaded in the data-driven optimisation MATLABE code.
- ■TARGET CURVE
The tri-dimensional diffusion of hydrogen from the sample during electrochemical discharge was simulated through the FEM model using COMSOL Multiphysics in cylindrical coordinates. The specific cylinder geometry of the sample adopted in this work was considered. The diffusion process in the metal is described by Fick’s second law (5), where e are the hydrogen concentration and time, respectively.
The model includes the initial conditions ( ) of homogeneous hydrogen concentration and constant diffusion coefficient . During discharging, the boundary condition ( ) on the metal–solution surface imposes the concentration to be equal to zero. The simulations conducted varying diffusion coefficients and initial concentrations .
The flux of hydrogen leaving all sample surfaces is then obtained using Fick’s first law (6), given the concentration gradient normal to the external sample surface.
The mole of egress hydrogen ( ) was obtained through the integration of the flux over time. Thus, to obtain the average residual concentration ( ) that remains in the sample at a certain time, considering an initial concentration at the end of charging, the following evaluation is necessary (7):
About the simulation to discretise the geometry, the axisymmetric property of the problem was exploited. As a result, a mesh was generated over a single rectangular section, with one side aligned along the cylinder's axis. The mesh was automatically generated using a quadrilateral mesh generator, which primarily creates quadrilateral elements. However, in regions of the geometry where it deems necessary, the generator may also introduce triangular elements. In this specific case, the computational plane consisted of 1647 quadrilateral elements. The simulation solved a total of 2009 degrees of freedom, with an integration time step of 60,000 s. It is important to note that the flux was applied over all surfaces. The simulation parameters can be modified depending on the intended application. The values presented here were used to analyse this specific geometry.
To obtain the target curve shown in the data, the results of simulated tests, time and residual diffusion hydrogen concentration simulated must be normalised as describe in [1] introducing the normalised time and normalised concentration using Eqs. (8) and (9).
The diffusion coefficient and initial hydrogen concentration are that imposed during the simulation, and formed the target curve (that it is independent by and as described in [1]).
- ■DATA-DRIVEN OPTIMISATION MATLAB CODE
The code to elaborate the pre-processed data and target curve to obtain the better , and by experimental data, is as follows:
Limitations
In the realisation of the experimental apparatus, it is necessary to ensure a homogeneous distribution of the current field on the specimen during the electrochemical charging and discharging phases in order to guarantee the axial-symmetry and homogeneity conditions imposed in the model assumptions.
There are no particular limitations with regard to the theoretical data of the simulations. In order to obtain a good target curve, it is necessary to create adequate discretisation of the geometry to be simulated so as to have low residuals at the end of the simulation
Ethics Statement
The authors confirm that they have read and follow the ethical requirements for publication in Data in Brief. The current work does not involve human subjects, animal experiments, or any data collected from social media platforms. No ethical approval or informed consent was required, as no experiments or direct data collection from individuals were conducted. All data provided in this article are publicly available or were derived from publicly accessible sources, ensuring full compliance with ethical standards for data sharing. The authors also confirm that all data presented in this manuscript are accurate, properly cited, and do not infringe upon any intellectual property rights.
CRediT Author Statement
Luca Gritti: Methodology, Software, Formal analysis, Investigation, Writing - Original Draft, Visualization; Denny Coffetti: Writing - Review & Editing; Marina Cabrini: Supervision, Project administration, Conceptualization; Tommaso Pastore: Project administration, Conceptualization
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1Gritti L.Coffetti D.Cabrini M.Pastore T.A novel approach for estimating hydrogen uptake and diffusion coefficient - under review Int. J. Hydrogen Energy 2025
- 2Luca G.Denny C.Marina C.Tommaso P.Data in brief: experimental Data supporting solubility model Data Brief 202510.17632/c 239nmw 6dp.1 · doi ↗
- 3Peral L.B.Díaz A.Alegre J.M.Cuesta I.I.Hydrogen uptake and diffusion kinetics in a quenched and tempered low carbon steel: experimental and numerical study Int. J. Hydrogen Energy 482023353473536510.1016/j.ijhydene.2023.05.286 · doi ↗
- 4Li X.Ma X.Zhang J.Akiyama E.Wang Y.Song X.Review of hydrogen embrittlement in metals: hydrogen diffusion, hydrogen characterization, hydrogen embrittlement mechanism and prevention Acta Metallur. Sinica (Eng. Lett.)33202075977310.1007/s 40195-020-01039-7 · doi ↗
- 5J. Ed, D.M. Himmelblau, R.N. Adams, G.P. Lewis, P. Ruetschi, M. Breiter, K.Z. Hofmann, E.A. Elektrochem ; Aykazyan, A.I.Fedorova, G. Denualt, M.V. Mirkin, A.J. Bard, M.B. Moressi, H. Fernandez, Determination of the diffusion coefficient of hydrogen in aqueous solution using single and double potential step chronoamperometry at a disk ultramicroelectrode, 1973. https://pubs.acs.org/sharingguidelines.
