A python-based method and system for thermogravimetric analysis
By using Python-based modular design and automated processing, the problems of data noise interference and inaccurate stage division in thermogravimetric analysis are solved, realizing efficient and automated thermogravimetric dynamics analysis, which is applicable to the pyrolysis process of complex materials.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA COAL TECH & ENG GRP SHENYANG ENG CO
- Filing Date
- 2026-04-03
- Publication Date
- 2026-07-21
AI Technical Summary
Existing thermogravimetric analysis methods suffer from data noise interference, inaccurate division of reaction stages, and high cost of commercial software with a lack of quality diagnostic functions, making it difficult to achieve efficient and automated kinetic analysis of complex materials.
It adopts a modular design based on Python, integrating data preprocessing, signal smoothing, pyrolysis reaction stage division, kinetic calculation and visualization functions. It uses Savitzky-Golay filter to smooth the data, fixes the temperature threshold to divide the stages, and automatically optimizes the fitting process. It also combines the Coats-Redfern method for kinetic calculation and quality diagnosis.
It improves the automation and accuracy of thermogravimetric analysis, reduces manual intervention, significantly enhances computational efficiency, and is suitable for large-scale data analysis, especially the pyrolysis process of complex materials such as coal samples.
Smart Images

Figure CN122436028A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of thermogravimetric analysis technology, and in particular to a thermogravimetric dynamics analysis method and system based on Python. Background Technology
[0002] Thermogravimetric analysis (TGA) is an important tool for studying the pyrolysis kinetics of materials. By monitoring changes in sample mass over temperature or time, it reveals the pyrolysis mechanism. Traditional kinetic analysis methods, such as the Coats-Redfern method, calculate activation energy and pre-exponential factor based on a single non-isothermal curve, but they face many challenges in practical applications.
[0003] First, thermogravimetric data are often affected by measurement noise, especially DTG curves, which impacts fitting accuracy. Second, the division of reaction stages depends on the peak and trough characteristics of the DTG curve, and reliability decreases when multiple stages overlap or when there is high noise. Furthermore, while commercial software is powerful, it is expensive, lacks flexibility, and lacks targeted quality diagnostic functions.
[0004] In existing technologies, the Coats-Redfern method requires manual selection of the reaction mechanism function and temperature range, a cumbersome process prone to human error. Some open-source tools (such as Python libraries) provide basic kinetic calculations, but lack integrated preprocessing, optimization, and visualization modules. For example, conventional methods may directly apply the Coats-Redfern equations, but ignore data distribution uniformity or physical plausibility, leading to unreliable results. Particularly for complex materials like coal, the pyrolysis process involves multiple stages (water leaching, thermal decomposition, combustion, etc.), with significant differences in kinetic parameters across stages, necessitating automated systems to ensure accuracy.
[0005] Therefore, developing a highly automated thermogravimetric analysis tool with quality diagnosis and optimization functions, based on an open-source platform, is of great significance for improving the efficiency of thermal analysis research. Summary of the Invention
[0006] The purpose of this invention is to provide an automated and highly reliable thermogravimetric analysis method and system. Through modular design, it integrates data processing, signal smoothing, pyrolysis reaction stage division, kinetic calculation, quality diagnosis, and visualization functions. The system incorporates a Savitzky-Golay filter to smooth the data, fixes temperature thresholds for stage division, and automatically optimizes the fitting process, significantly improving the practicality of the Coats-Redfern method. Compared with traditional methods, this invention offers a high degree of automation, requires no frequent manual intervention, and boasts excellent computational efficiency, making it suitable for large-scale data analysis.
[0007] To achieve the above objectives, the present invention adopts the following technical solution: a thermogravimetric analysis method based on Python, specifically including the following steps: Step 1, Data Preprocessing: Read the thermogravimetric data file, use the built-in csv module in Python to read and write the file, automatically identify the data columns, including Time, Temperature T, Thermogravimetric TG and Differential Thermogravimetric TG data columns; calculate the conversion rate α, limit α to the range of [0,1] using a clipping function, output the temperature T range, and store the data as a NumPy array format; Step 2, Signal Processing: Apply Savitzky-Golay filter to smooth the TG-DTG curve and suppress high-frequency noise based on the principle of local polynomial least squares fitting. Step 3, Pyrolysis reaction stage division: Based on the TG-DTG curve, the pyrolysis process is divided into four pyrolysis reaction stages, including water precipitation stage, thermal decomposition stage, combustion stage and burnout stage. The temperature range, number of data points and average DTG value of each stage are recorded. Step 4, Calculation of kinetic parameters and correlation coefficient R²: The Coats-Redfern method is used to calculate the kinetic parameters of each pyrolysis reaction stage and the correlation coefficient R² is calculated. The kinetic parameters include the activation energy E and the pre-exponential factor A. The reaction mechanism functions of the Coats-Redfern method include the first-order reaction model, the diffusion-controlled model, the phase boundary reaction model and the power law model. The first-order reaction model is used by default. Step 5, Quality Diagnosis and Optimization: Perform fitting quality diagnosis on the water separation stage, thermal decomposition stage, and combustion stage, including the diagnosis and optimization of the correlation coefficient R² value of the water separation stage, thermal decomposition stage, and combustion stage, requiring the correlation coefficient R² of each stage to be ≥0.7; Step 6, Visualization chart generation: Generate TG-DTG curves and conversion rate curves based on the Matplotlib library; Step 7, Output Results: Generate a structured data report in CSV format and a detailed analysis report in TXT format, including the name of each pyrolysis reaction stage, the temperature range of each pyrolysis reaction stage, activation energy E, pre-exponential factor A, correlation coefficient R² value, number of data points, and reliability assessment.
[0008] Furthermore, in step 1, the formula for calculating the conversion rate α is: α = (m0 - m) / (m0 - m f ), where m0 is the initial mass, m is the current mass, and m f For final quality.
[0009] Furthermore, in step 2, the default window size for smoothing the TG-DTG curve using the Savitzky-Golay filter is 51, and the polynomial order is 3.
[0010] Furthermore, in step 4, the Coats-Redfern equation is expressed as: ln[g(α) / T²]=ln(AR / βE) - E / (RT); Where α is the conversion rate; β is the heating rate, in K / min; R is the gas constant, 8.314 J·mol⁻¹ - ¹·K - ¹; T is absolute temperature, and its unit is K. E is the activation energy, expressed in kJ·mol⁻¹. - ¹; A is the pre-exponential factor, with units of s. - ¹; g(α) is the reaction mechanism function.
[0011] Furthermore, the heating rate β is set to 10 K / min by default, but can be customized by the user.
[0012] Furthermore, in step 5, the fitting quality diagnosis and optimization of the water separation stage, thermal decomposition stage, and combustion stage specifically involves: First, the correlation coefficient R² for the water separation stage is diagnosed: if R² ≥ 0.7, the fitting quality for this stage is deemed acceptable, and the correlation coefficient R² for the thermal decomposition stage is calculated. If R² < 0.7 for the water separation stage, a temperature range optimization strategy is initiated. Within the temperature range of the raw water separation stage, the temperature range is gradually expanded or reduced in increments of 0.5℃. After each adjustment, the conversion rate α, kinetic parameters, and correlation coefficient R² for this stage are recalculated until the optimal temperature sub-range with R² ≥ 0.7 is found. The optimal conversion rate α, kinetic parameters, and correlation coefficient are then output. If the temperature range adjustment still fails to find a sub-interval with R² ≥ 0.7, the reaction model optimization strategy will be automatically switched. In the raw water separation stage, the diffusion control model, phase boundary reaction model, and power law model will be tried in the temperature range and temperature sub-intervals in turn. The kinetic parameters and correlation coefficient R² will be recalculated under each model. The model with the optimal R² value will be adopted. If R² ≥ 0.7 after switching models, the result of that model will be adopted. If all models fail to make R² ≥ 0.7, an abnormal fitting quality warning will be issued for the water separation stage, and the acquisition quality of the original thermogravimetric data will be checked or the smoothing parameters will be adjusted. After the fitting quality of the water separation stage is qualified, the highest temperature value of the optimized temperature sub-interval is used as the starting temperature of the thermal decomposition stage, and the correlation coefficient R² of the thermal decomposition stage is diagnosed according to the diagnostic process of the water separation stage until R²≥0.7 for this stage. After the fitting quality of the thermal decomposition stage is qualified, the highest temperature value of its optimized temperature sub-interval is used as the starting temperature of the combustion stage. Then, the same correlation coefficient R² diagnosis and optimization process is performed on the combustion stage until the combustion stage R²≥0.7, then it is judged as qualified. The burnout phase is not included in the fitting quality diagnosis range; its temperature range and number of data points are recorded.
[0013] On the other hand, the present invention also provides a Python-based thermogravimetric analysis system for performing the Python-based thermogravimetric analysis method as described in any one of claims 1-6, comprising: The data preprocessing module is used to read thermogravimetric data files. It utilizes Python's built-in csv module for file reading and writing, automatically identifying data columns including Time, Temperature (T), Thermogravimetric (TG), and Differential Thermogravimetric (DTG) data columns; and calculating the conversion rate α using the formula α = (m0 - m) / (m0 - m) f ), where m0 is the initial mass, m is the current mass, and m f To achieve the final quality, and by limiting α to the range of [0,1] through a clipping function, the output temperature range T is determined, and the data is stored as a NumPy array format. Signal processing module: Used to smooth the TG-DTG curve with Savitzky-Golay filter, with a default window size of 51 and a polynomial order of 3, and suppresses high-frequency noise based on the principle of local polynomial least squares fitting. The pyrolysis reaction stage division module is used to divide the pyrolysis process into four pyrolysis reaction stages based on the TG-DTG curve, including the water precipitation stage, the thermal decomposition stage, the combustion stage, and the burnout stage, and to record the temperature range, number of data points, and average DTG value for each stage. Kinetics Calculation Module: Used for calculating kinetic parameters and correlation coefficients R². It applies the Coats-Redfern method to calculate the kinetic parameters and correlation coefficients R² for each pyrolysis reaction stage. Kinetic parameters include activation energy E and pre-exponential factor A. The reaction mechanism functions of the Coats-Redfern method include first-order reaction model, diffusion-controlled model, phase boundary reaction model and power law model. The first-order reaction model is used by default. Quality Diagnosis and Optimization Module: Used to perform fitting quality diagnosis on the water separation stage, thermal decomposition stage, and combustion stage, including the diagnosis and optimization of the correlation coefficient R² value of the water separation stage, thermal decomposition stage, and combustion stage, requiring the correlation coefficient R² of each stage to be ≥0.7; Visualization module: Used to generate TG-DTG curves and conversion rate curves based on the Matplotlib library, supports automatic switching between Chinese and English bilingual labels, and output formats include PNG, PDF, and SVG, with adjustable resolution; Results output module: Generates a structured data report in CSV format and a detailed analysis report in TXT format, including the name of each pyrolysis reaction stage, the temperature range of each pyrolysis reaction stage, activation energy E, pre-exponential factor A, correlation coefficient R² value, number of data points, and reliability assessment.
[0014] Furthermore, the visualization module automatically detects the loading status of Chinese fonts; if it fails, it switches to English labels to ensure that the charts are displayed correctly. The output module has an exception handling mechanism, including input validation, calculation fault tolerance, and logging, to ensure stable system operation.
[0015] Compared with existing technologies, the beneficial effects of this invention are as follows: 1. High degree of automation, reducing manual intervention: This invention streamlines the entire process from data preprocessing, signal smoothing, stage division, kinetic calculation, quality diagnosis and optimization, to result output. It uses a Savitzky-Golay filter to smooth the TG-DTG curve, preserving curve characteristics while suppressing noise; it divides reaction stages based on fixed temperature thresholds to avoid the instability of automatic division; it applies the Coats-Redfern method for kinetic calculation, supporting multiple reaction mechanism functions, and solves for activation energy and pre-exponential factors through linear regression; and through quality diagnosis and optimization strategies, it automatically initiates temperature range optimization or model switching strategies if the fitting quality is substandard, significantly simplifying the operation process.
[0016] 2. Robust data processing enhances analytical accuracy: The Savitzky-Golay filter smooths the DTG curve, and local polynomial least squares fitting effectively suppresses high-frequency noise. The default window size of 51 and polynomial order of 3 balance smoothing with curve feature preservation. Simultaneously, a fitting quality diagnostic mechanism is introduced to strictly control the correlation coefficient R² for water leaching, thermal decomposition, and combustion stages (requiring R² ≥ 0.7). Temperature range adjustment (optimized in 0.5℃ increments within ±150℃) and switching between multiple reaction models (diffusion control, phase boundary reaction, power law model) ensure the reliability of kinetic parameter calculations and avoid result deviations due to data noise or inappropriate model selection.
[0017] 3. Significant advantages in computational efficiency and resource consumption: Implemented using Python programming, the system processes curves for over 37,900 data points in less than 10 seconds, meeting the needs of large-scale batch data analysis. The system uses NumPy arrays to store data, improving computational efficiency and making it suitable for efficient thermogravimetric dynamics research in fields such as coal and chemical materials.
[0018] 4. Modular Functional Design: The Python-based thermogravimetric analysis system of this invention comprises seven modules: data preprocessing, signal processing, stage division, kinetic calculation, quality diagnosis, visualization, and result output. These modules work collaboratively to achieve full-process analysis from raw data to kinetic parameters. The visualization module supports the generation of TG-DTG curves and conversion rate curves, automatic switching between Chinese and English bilingual labels, and multiple output formats (PNG, PDF, SVG). The result output module provides CSV structured data reports and TXT detailed analysis reports to meet the data display and archiving needs of different scenarios.
[0019] 5. Open source platform support reduces usage costs and technical barriers: The thermogravimetric analysis system based on Python of this invention is developed based on Python, is open source and free, can run on ordinary computers (memory <100MB), and is suitable for laboratory and industrial applications. Attached Figure Description
[0020] Figure 1 This is a flowchart of a Python-based thermogravimetric analysis method according to Embodiment 1 of the present invention; Figure 2 This is the starting data of the dataset read in Embodiment 1 of the present invention; Figure 3 This refers to the data at the end of the dataset read in Embodiment 1 of the present invention; Figure 4 This is the operating environment and user interface of Embodiment 1 of the present invention; Figure 5 This is a thermogravimetric analysis curve and conversion rate curve in step 3 of embodiment 1 of the present invention, which divides the pyrolysis process into four pyrolysis reaction stages based on the TG-DTG curve and using a fixed temperature threshold. Figure 6 This is a detailed output diagram of the thermodynamic analysis results of a Python-based thermogravimetric kinetic analysis method according to Embodiment 1 of the present invention; Figure 7 This is a framework diagram of a Python-based thermogravimetric analysis system according to Embodiment 2 of the present invention. Detailed Implementation
[0021] The following is in conjunction with the appendix Figure 1-7The following examples further illustrate the detailed content of the present invention. This example uses a thermogravimetric analysis (TGA) of a coal sample with 10% moisture content after soaking in mine water as an example. The heating rate β = 10 K / min, and the data file is in CSV format. The system is implemented using the Python class TGKineticsAnalyzerEnhanced, where TGKineticsAnalyzerEnhanced is a custom class name. TG represents thermogravimetric analysis; KineticsAnalyzer indicates that this class performs reaction kinetic calculations on the thermogravimetric data, such as solving for activation energy and pre-exponential factors; and Enhanced indicates an "enhanced version." During initialization, the Chinese font is first set to ensure that the chart labels display correctly.
[0022] Example 1
[0023] Reference Figure 1 This embodiment provides a thermogravimetric analysis method based on Python, which specifically includes the following steps: Reference Figure 2 and Figure 3 Step 1, Data Preprocessing: Read the thermogravimetric data file, use the built-in csv module in Python to read and write the file, automatically identify the data columns, including Time, Temperature T, Thermogravimetric TG and Differential Thermogravimetric TG data columns; calculate the conversion rate α, limit α to the range of [0,1] using a clipping function, output the temperature T range, and store the data as a NumPy array format; The formula for calculating the conversion rate α is: α = (m0 - m) / (m0 - m f ); Where m0 is the initial mass, m is the current mass, and m f For final quality; In this embodiment, 37923 rows of data were read, with a shape of (37923,4), containing time, temperature, TG, and DTG values; the initial mass m0 was 8.6341 mg, and the final mass m f The value is -0.0011 mg; after data cleaning steps, such as removing blank lines, filtering invalid points, and converting numerical types, the system output temperature range is 30.0-800.0℃, and the conversion rate α ranges from 0.0000 to 1.0000. Step 2, Signal Processing: Apply Savitzky-Golay filter to smooth the TG-DTG curve. The default window size is 51 and the polynomial order is 3. Suppress high-frequency noise based on the principle of local polynomial least squares fitting. like Figures 4-5As shown, step 3, pyrolysis reaction stage division: Based on the TG-DTG curve, according to the characteristics of the TG-DTG curve and the characteristics of the coal pyrolysis process, the pyrolysis process is divided into four pyrolysis reaction stages using a fixed temperature threshold (characteristic temperature point), including the water separation stage, thermal decomposition stage, combustion stage and burnout stage. The temperature range, number of data points and average DTG value of each stage are recorded. In this embodiment, the four pyrolysis reaction stages are as follows: (1) Water separation stage: 30.0-360.0℃; (2) Thermal decomposition stage: 360.0-451.0℃; (3) Combustion stage: 451.0-693.0℃; (4) Burnout stage: 693.0-800.0℃; Step 4, Calculation of kinetic parameters and correlation coefficient R²: The Coats-Redfern method is used to calculate the kinetic parameters of each pyrolysis reaction stage and the correlation coefficient R² is calculated. The kinetic parameters include the activation energy E and the pre-exponential factor A. The reaction mechanism functions of the Coats-Redfern method include the first-order reaction model, the diffusion-controlled model, the phase boundary reaction model and the power law model. The first-order reaction model is used by default. The Coats-Redfern equation is expressed as: ln[g(α) / T²]=ln(AR / βE) - E / (RT); Where α is the conversion rate; β is the heating rate, in K / min; R is the gas constant, 8.314 J·mol⁻¹ - ¹·K - ¹; T is absolute temperature, and its unit is K. E is the activation energy, expressed in kJ·mol⁻¹. - ¹; A is the pre-exponential factor, with units of s. - ¹; g(α) is the reaction mechanism function; This embodiment takes the water leaching stage as an example. A first-order reaction model is used to calculate the activation energy E and the pre-exponential factor A. First, stage data is extracted, and X = 1 / T and Y = ln[g(α) / T²] are calculated, where g(α) is the first-order reaction function, g(α) = -ln(1-α). Plotting ln[g(α) / T²] against 1 / T yields a linear line. The line is fitted using linear regression. The slope k is used to calculate the activation energy E, E = -kR / 1000; the intercept b is used to calculate the pre-exponential factor A, A = (βE×1000 / R)×exp(b). The correlation coefficient R² is calculated using linear regression and is used to assess the goodness of fit. Step 5, Quality Diagnosis and Optimization: Perform fitting quality diagnosis on the water separation stage, thermal decomposition stage, and combustion stage, including the correlation coefficient R² value diagnosis of the water separation stage, thermal decomposition stage, and combustion stage, requiring the correlation coefficient R² of each stage to be ≥0.7; Quality assessment also includes checks on data sufficiency (no fewer than 10 data points per stage), uniformity of distribution (conversion rate interval division), and physical rationality (activation energy range 20-300 kJ·mol⁻¹). - ¹, Pre-exponential factor range 10 5 -10² 0 s - ¹); In step 5, the fitting quality diagnosis and optimization of the water separation stage, thermal decomposition stage, and combustion stage are specifically performed as follows: First, the correlation coefficient R² of the water separation stage is diagnosed: if R² ≥ 0.7, the fitting quality of this stage is deemed acceptable, and the correlation coefficient R² calculation for the thermal decomposition stage continues; if R² < 0.7 for the water separation stage, a temperature range optimization strategy is initiated. Within ±150℃ of the highest temperature value of the raw water separation stage, the temperature range is gradually expanded or reduced in increments of 0.5℃. After each adjustment, the conversion rate α, kinetic parameters, and correlation coefficient R² for this stage are recalculated until an optimal temperature sub-interval with R² ≥ 0.7 is found, and the optimal conversion rate α, kinetic parameters, and correlation coefficient R² are output; if the temperature range... If no sub-interval with R² ≥ 0.7 is found after adjustment, the reaction model optimization strategy is automatically switched. In the raw water separation stage, the diffusion control model, phase boundary reaction model, and power law model are tried in the temperature range and temperature sub-intervals in turn. The kinetic parameters and correlation coefficient R² are recalculated under each model. The model with the optimal R² value is adopted. If R² ≥ 0.7 after switching models, the results of that model (optimized temperature value, conversion rate α, kinetic parameters, and correlation coefficient R²) are adopted. If all models fail to achieve R² ≥ 0.7, an abnormal fitting quality is indicated in the water separation stage, and the acquisition quality of the original thermogravimetric data is checked or the smoothing parameters are adjusted. After the fitting quality of the water separation stage is qualified, the highest temperature value of the optimized temperature sub-interval is used as the starting temperature of the thermal decomposition stage, and the correlation coefficient R² of the thermal decomposition stage is diagnosed according to the diagnostic process of the water separation stage until R²≥0.7 for this stage. After the fitting quality of the thermal decomposition stage is qualified, the highest temperature value of its optimized temperature sub-interval is used as the starting temperature of the combustion stage. Then, the same correlation coefficient R² diagnosis and optimization process is performed on the combustion stage until the combustion stage R²≥0.7, then it is judged as qualified. The burnout phase can be considered an extension of the combustion phase; only data from the combustion phase is needed, R. 2 The values are not included in the fitting quality diagnosis range; only the temperature range and the number of data points are recorded. In this embodiment, the optimized temperature range values for the four pyrolysis reaction stages are as follows: (1) Water separation stage: 30.0-222.5℃, R 2 It is 0.9525; (2) Thermal decomposition stage: 222.5-415.0℃, R 2 It is 0.9771; (3) Combustion stage: 415.0-607.5℃, R 2 It is 0.9922; (4) Burnout stage: 607.5-800.0℃; Step 6, Visualization chart generation: Generate TG-DTG curves and conversion rate curves based on the Matplotlib library; The TG-DTG curve displays mass change and weight loss rate on dual Y-axis. The pyrolysis reaction stages are marked with vertical dashed lines and color blocks. It supports automatic switching between Chinese and English bilingual labels. Output formats include PNG, PDF, and SVG, and the resolution is adjustable. Step 7, Output Results: Generate a structured data report in CSV format and a detailed analysis report in TXT format, including the name of each pyrolysis reaction stage, the temperature range of each pyrolysis reaction stage, activation energy E, pre-exponential factor A, correlation coefficient R² value, number of data points, and reliability assessment.
[0024] The final output of this implementation is as follows: Figure 6 As shown, the output includes the name of each pyrolysis reaction stage, the temperature range of each pyrolysis reaction stage, the activation energy E, the pre-exponential factor A, the correlation coefficient R² value, the number of data points, as well as the average activation energy and the number of effective stages.
[0025] Example 2
[0026] This embodiment provides a Python-based thermogravimetric analysis system for executing the Python-based thermogravimetric analysis method described in Embodiment 1, including: The data preprocessing module is used to read thermogravimetric data files. It utilizes Python's built-in csv module for file reading and writing, automatically identifying data columns including Time, Temperature (T), Thermogravimetric (TG), and Differential Thermogravimetric (DTG) data columns; and calculating the conversion rate α using the formula α = (m0 - m) / (m0 - m) f ), where m0 is the initial mass, m is the current mass, and m fTo achieve the final quality, and by limiting α to the range of [0,1] through a clipping function, the output temperature range T is determined, and the data is stored as a NumPy array format. Signal processing module: Used to smooth the TG-DTG curve with Savitzky-Golay filter, with a default window size of 51 and a polynomial order of 3, and suppresses high-frequency noise based on the principle of local polynomial least squares fitting. The pyrolysis reaction stage division module is used to divide the pyrolysis process into four pyrolysis reaction stages based on the TG-DTG curve, including the water precipitation stage, the thermal decomposition stage, the combustion stage, and the burnout stage, and to record the temperature range, number of data points, and average DTG value for each stage. Kinetics Calculation Module: Used for calculating kinetic parameters and correlation coefficients R². It applies the Coats-Redfern method to calculate the kinetic parameters and correlation coefficients R² for each pyrolysis reaction stage. Kinetic parameters include activation energy E and pre-exponential factor A. The reaction mechanism functions of the Coats-Redfern method include first-order reaction model, diffusion-controlled model, phase boundary reaction model and power law model. The first-order reaction model is used by default. Quality Diagnosis and Optimization Module: Used to perform fitting quality diagnosis on the water separation stage, thermal decomposition stage, and combustion stage, including the diagnosis and optimization of the correlation coefficient R² value of the water separation stage, thermal decomposition stage, and combustion stage, requiring the correlation coefficient R² of each stage to be ≥0.7; Visualization module: Used to generate TG-DTG curves and conversion rate curves based on the Matplotlib library, supports automatic switching between Chinese and English bilingual labels, and output formats include PNG, PDF, and SVG, with adjustable resolution; The visualization module automatically detects the loading status of Chinese fonts; if it fails, it switches to English labels to ensure that the charts are displayed correctly. Results output module: Generates a structured data report in CSV format and a detailed analysis report in TXT format, including the name of each pyrolysis reaction stage, the temperature range of each pyrolysis reaction stage, activation energy E, pre-exponential factor A, correlation coefficient R² value, number of data points, and reliability assessment.
[0027] The output module has an exception handling mechanism, including input validation (checking file existence and format correctness), calculation fault tolerance (boundary checks to avoid division by zero errors), and logging, to ensure stable system operation.
[0028] This invention is implemented using Python code and can run directly in a Python environment. It boasts excellent processing efficiency, processing a curve with 37,923 data points in approximately 10 seconds (Intel i7 processor) with memory usage below 100MB. An exception handling mechanism ensures stability; for example, it automatically skips calculations when there are insufficient data points.
[0029] Although the present invention has been described in detail above with general descriptions and specific embodiments, modifications or improvements can be made to it, which will be obvious to those skilled in the art. Therefore, all such modifications or improvements made without departing from the spirit of the present invention fall within the scope of protection claimed by the present invention.
Claims
1. A thermogravimetric analysis method based on Python, characterized in that, Specifically, the following steps are included: Step 1, Data Preprocessing: Read the thermogravimetric data file, use the built-in csv module in Python to read and write the file, automatically identify the data columns, including Time, Temperature T, Thermogravimetric TG and Differential Thermogravimetric TG data columns; calculate the conversion rate α, limit α to the range of [0,1] using a clipping function, output the temperature T range, and store the data as a NumPy array format; Step 2, Signal Processing: Apply Savitzky-Golay filter to smooth the TG-DTG curve and suppress high-frequency noise based on the principle of local polynomial least squares fitting. Step 3, Pyrolysis reaction stage division: Based on the TG-DTG curve, the pyrolysis process is divided into four pyrolysis reaction stages, including water precipitation stage, thermal decomposition stage, combustion stage and burnout stage. The temperature range, number of data points and average DTG value of each stage are recorded. Step 4, Calculation of kinetic parameters and correlation coefficient R²: The Coats-Redfern method is used to calculate the kinetic parameters of each pyrolysis reaction stage and the correlation coefficient R² is calculated. The kinetic parameters include the activation energy E and the pre-exponential factor A. The reaction mechanism functions of the Coats-Redfern method include the first-order reaction model, the diffusion-controlled model, the phase boundary reaction model and the power law model. The first-order reaction model is used by default. Step 5, Quality Diagnosis and Optimization: Perform fitting quality diagnosis on the water separation stage, thermal decomposition stage, and combustion stage, including the diagnosis and optimization of the correlation coefficient R² value of the water separation stage, thermal decomposition stage, and combustion stage, requiring the correlation coefficient R² of each stage to be ≥0.7; Step 6, Visualization chart generation: Generate TG-DTG curves and conversion rate curves based on the Matplotlib library; Step 7, Output Results: Generate a structured data report in CSV format and a detailed analysis report in TXT format, including the name of each pyrolysis reaction stage, the temperature range of each pyrolysis reaction stage, activation energy E, pre-exponential factor A, correlation coefficient R² value, number of data points, and reliability assessment.
2. The thermogravimetric analysis method based on Python according to claim 1, characterized in that: In step 1, the formula for calculating the conversion rate α is: α = (m0 - m) / (m0 - m f ), where m0 is the initial mass, m is the current mass, and m f For final quality.
3. The thermogravimetric analysis method based on Python according to claim 1, characterized in that: In step 2, the default window size for smoothing the TG-DTG curve using the Savitzky-Golay filter is 51, and the polynomial order is 3.
4. The thermogravimetric analysis method based on Python according to claim 1, characterized in that: In step 4, the Coats-Redfern equation is expressed as: ln[g(α) / T²]=ln(AR / βE) - E / (RT); Where α is the conversion rate; β is the heating rate, in K / min; R is the gas constant, 8.314 J·mol⁻¹ - ¹·K - ¹; T is absolute temperature, and its unit is K. E is the activation energy, expressed in kJ·mol⁻¹. - ¹; A is the pre-exponential factor, with units of s. - ¹; g(α) is the reaction mechanism function.
5. The thermogravimetric analysis method based on Python according to claim 4, characterized in that: The heating rate β is set to 10 K / min by default, but can be customized by the user.
6. The thermogravimetric analysis method based on Python according to claim 1, characterized in that: In step 5, the fitting quality diagnosis and optimization of the water separation stage, thermal decomposition stage, and combustion stage are specifically performed as follows: First, the correlation coefficient R² of the water separation stage is diagnosed: if R² ≥ 0.7, the fitting quality of this stage is deemed acceptable, and the correlation coefficient R² calculation for the thermal decomposition stage continues; if R² < 0.7 for the water separation stage, a temperature range optimization strategy is initiated. Within ±150℃ of the original water separation stage temperature range, the temperature range is gradually expanded or reduced in increments of 0.5℃. After each adjustment, the conversion rate α, kinetic parameters, and correlation coefficient R² for this stage are recalculated until the optimal temperature sub-interval with R² ≥ 0.7 is found, and the optimal conversion rate α, kinetic parameters, and correlation coefficient R² are output. The correlation coefficient R² is used. If the temperature range adjustment still fails to find a sub-interval with R² ≥ 0.7, the reaction model optimization strategy is automatically switched. In the raw water separation stage, the diffusion control model, phase boundary reaction model, and power law model are tried in the temperature range and temperature sub-intervals in turn. The kinetic parameters and correlation coefficient R² are recalculated under each model. The model with the optimal R² value is adopted. If R² ≥ 0.7 after switching models, the result of that model is adopted. If all models fail to make R² ≥ 0.7, an abnormal fitting quality is indicated in the water separation stage, and the acquisition quality of the original thermogravimetric data is checked or the smoothing parameters are adjusted. After the fitting quality of the water separation stage is qualified, the highest temperature value of the optimized temperature sub-interval is used as the starting temperature of the thermal decomposition stage, and the correlation coefficient R² of the thermal decomposition stage is diagnosed according to the diagnostic process of the water separation stage until R²≥0.7 for this stage. After the fitting quality of the thermal decomposition stage is qualified, the highest temperature value of its optimized temperature sub-interval is used as the starting temperature of the combustion stage. Then, the same correlation coefficient R² diagnosis and optimization process is performed on the combustion stage until the combustion stage R²≥0.7, then it is judged as qualified. The burnout phase is not included in the fitting quality diagnosis range; its temperature range and number of data points are recorded.
7. A Python-based thermogravimetric analysis system for executing the Python-based thermogravimetric analysis method as described in any one of claims 1-6, characterized in that, include: Data preprocessing module: Used to read thermogravimetric data files. It uses Python's built-in csv module to read and write files and automatically identifies data columns, including Time, Temperature (T), Thermogravimetric (TG), and Differential Thermogravimetric (DTG) data columns. And calculate the conversion rate α, using the formula α = (m0 - m) / (m0 - m) f ), where m0 is the initial mass, m is the current mass, and m f To achieve the final quality, and by limiting α to the range of [0,1] through a clipping function, the output temperature range T is determined, and the data is stored as a NumPy array format. Signal processing module: Used to smooth the TG-DTG curve with Savitzky-Golay filter, with a default window size of 51 and a polynomial order of 3, and suppresses high-frequency noise based on the principle of local polynomial least squares fitting. The pyrolysis reaction stage division module is used to divide the pyrolysis process into four pyrolysis reaction stages based on the TG-DTG curve, including the water precipitation stage, the thermal decomposition stage, the combustion stage, and the burnout stage, and to record the temperature range, number of data points, and average DTG value for each stage. Kinetics Calculation Module: Used for calculating kinetic parameters and correlation coefficients R². It applies the Coats-Redfern method to calculate the kinetic parameters and correlation coefficients R² for each pyrolysis reaction stage. Kinetic parameters include activation energy E and pre-exponential factor A. The reaction mechanism functions of the Coats-Redfern method include first-order reaction model, diffusion-controlled model, phase boundary reaction model and power law model. The first-order reaction model is used by default. Quality Diagnosis and Optimization Module: Used to perform fitting quality diagnosis on the water separation stage, thermal decomposition stage, and combustion stage, including the diagnosis and optimization of the correlation coefficient R² value of the water separation stage, thermal decomposition stage, and combustion stage, requiring the correlation coefficient R² of each stage to be ≥0.7; Visualization module: Used to generate TG-DTG curves and conversion rate curves based on the Matplotlib library, supports automatic switching between Chinese and English bilingual labels, and output formats include PNG, PDF, and SVG, with adjustable resolution; Results output module: Generates a structured data report in CSV format and a detailed analysis report in TXT format, including the name of each pyrolysis reaction stage, the temperature range of each pyrolysis reaction stage, activation energy E, pre-exponential factor A, correlation coefficient R² value, number of data points, and reliability assessment.
8. The thermogravimetric analysis system based on Python according to claim 7, characterized in that: The visualization module automatically detects the loading status of Chinese fonts. If it fails, it switches to English labels to ensure that the charts are displayed correctly. The output module has an exception handling mechanism, including input validation, calculation fault tolerance, and logging, to ensure stable system operation.