Die casting gas hole defect prediction method and system based on two-stage graph neural network
Patent Information
- Application Number
- CN202611101442.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-23
- Publication Date
- 2026-10-09
AI Technical Summary
(1)端到端方法直接将工艺参数映射至气孔分布,跳过充型物理场中间过程,无法利用"工艺参数→充型物理场→气孔缺陷"的物理因果链,预测精度受限且物理可解释性差
[0017]本申请提供的基于两阶段图神经网络的压铸气孔缺陷预测方法,先利用第一阶段图网络预测物理场中间特征,并通过调制机制使全局工艺参数动态干预局部节点特征,实现深浅层信息深度融合;同时,将离散型物理场特征经旁路传递输入第二阶段,有效避免图消息传递引发的特征过度平滑并降低计算延迟;最后,融合物理场、旁路及几何特征,利用第二阶段图注意力网络精准输出节点气孔概率。本申请高度契合压铸物理因果逻辑,显著提升了气孔缺陷预测精度与效率。
Smart Images

Figure CN122885659A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of intelligent manufacturing for high-pressure die casting, specifically to a method and system for predicting porosity defects in die casting based on a two-stage graph neural network. Background Technology
[0002] Porosity defects in high-pressure die castings (HPDC) severely affect the mechanical properties of the product. Their formation is closely related to the spatial distribution of physical fields such as temperature, velocity, and pressure during the filling process. Achieving rapid and accurate prediction of the porosity defect distribution in various functional areas of the casting has significant engineering value for process optimization and quality control.
[0003] Existing stomatal prediction methods have the following main shortcomings: (1) The end-to-end method directly maps the process parameters to the porosity distribution, skips the intermediate process of the filling physical field, and cannot utilize the physical causal chain of "process parameters → filling physical field → porosity defects", resulting in limited prediction accuracy and poor physical interpretability.
[0004] (2) Some existing two-stage methods use the output of numerical simulation software as the input of the second stage, rely on simulation calculations that take several hours, and cannot support real-time process decisions; and lack systematic analysis of the performance difference between the predicted physical field in the first stage and the actual physical field in numerical simulation in downstream tasks.
[0005] (3) The same processing strategy as that for continuous physical field quantities is used for categorical physical field quantities (physical field quantities that are discretely distributed among different castings due to fixed filling paths, die casting machine gear response, etc.), resulting in systematic prediction errors and affecting the quality of downstream classification features. Summary of the Invention
[0006] To address one of the shortcomings in the existing technology, the purpose of this application is to provide a method and system for predicting porosity defects in die casting based on a two-stage graph neural network.
[0007] According to a first aspect of this application, a method for predicting porosity defects in die casting based on a two-stage graph neural network is provided, comprising: The casting is divided into several sub-regions, and a graph structure is constructed with each sub-region as a node and the spatial adjacency relationship between sub-regions as an edge. Using process parameters and casting geometry as input, a first-stage graph neural network is used to predict the continuous physical field characteristics of each node; wherein, the process parameters are dynamically applied to the node characteristics after each layer of message passing through a modulation mechanism. The preset discrete physical field features are not predicted by the graph neural network in the first stage. Instead, their normalized values are used as bypass propagation quantities and directly used as inputs to the graph attention network in the second stage. The continuous physical field characteristics of the first stage, the bypass transfer amount, and the geometric characteristics of the casting are combined. Using the combined feature matrix as input, the second-stage graph attention network is used to classify and predict porosity defects at each node, and outputs the porosity probability of each node.
[0008] Optionally, in the graph neural network of the first stage, the process parameters are dynamically applied to the node features after each layer of message passing through a modulation mechanism, including: The process parameters are input into a preset modulation parameter generator to independently generate corresponding modulation parameter pairs for each network layer of the graph neural network in the first stage. The modulation parameter pairs include scaling factors and offset factors. After message transmission is completed at each network layer, the modulation parameters are used to perform an affine transformation on the node features of the current layer to achieve hierarchical dynamic modulation of the local physical field features at the node level by the global process parameters at the casting level.
[0009] Optionally, the step of using its normalized value as a bypass transfer quantity includes: when predicting porosity defects in the casting under test, directly obtaining the normalized value of the discrete physical field characteristics that has been pre-calculated and stored from a preset storage medium.
[0010] Optionally, the graph attention network in the second stage introduces node position encoding, which integrates binary features representing regional topological attributes and discretized features representing the path distance of the liquid metal filling type. The discretized features are transformed into continuous vectors through a trained embedding layer and then concatenated or added element-wise with the concatenated feature matrix to serve as the final input features of each node in the graph attention network in the second stage.
[0011] Optionally, the continuous physical field characteristics of the first stage, the bypass transfer amount, and the casting geometric characteristics are combined, including: During the training phase, the names of the continuous physical field features, the bypass transfer amount, and the casting geometric features are recorded in the feature name list according to the combination order and persistently saved. During the inference phase, the feature order is read from the feature name list, and the continuous physical field features, the bypass transfer amount, and the casting geometric features are rearranged according to the feature order and then combined to ensure the consistency of the feature arrangement between the inference and training phases.
[0012] Optionally, the graph attention network in the second stage is obtained through the following training process: In the second stage of training the graph attention network, a weighted batch sampling strategy is used to construct training batches; The weighted batch sampling strategy includes: identifying target casting samples in the training sample set whose number of defect nodes is lower than a preset sparse threshold, wherein the training sample set includes multiple casting samples as graph structure samples; during the training batch construction stage, assigning a higher sampling weight to the target casting samples than to non-target casting samples, so as to dynamically adjust the probability of the target casting samples appearing in the training batch, while keeping the sample distribution of the training sample set unchanged.
[0013] Optionally, the graph neural network in the first stage and the graph attention network in the second stage are trained based on a feature recursive elimination strategy, which includes: For the graph neural network in the first stage and the graph attention network in the second stage, feature recursive elimination operations are performed independently respectively; The recursive feature elimination operation includes: training a model for the corresponding stage based on the current input features, evaluating the feature importance of each input feature, eliminating features with lower importance ranking, and iteratively executing the above process until the corresponding stopping condition is met. The stopping conditions for the first-stage graph neural network include a double stopping condition consisting of prediction error and the number of features; the stopping conditions for the second-stage graph attention network include a joint stopping condition consisting of three metrics: AUC, F1 score, and recall.
[0014] According to a second aspect of this application, a die-casting porosity defect prediction system based on a two-stage graph neural network is provided, comprising: The graph structure construction module is used to divide the casting into several sub-regions, and construct a graph structure with each sub-region as a node and the spatial adjacency relationship between sub-regions as an edge. The physical field feature prediction module is used to predict the continuous physical field features of each node using process parameters and casting geometric features as inputs and a graph neural network in the first stage; wherein, the process parameters are dynamically applied to the node features after each layer of message transmission through a modulation mechanism. The bypass propagation module is used to take the preset discrete physical field features without the first stage graph neural network prediction, and use their normalized values as bypass propagation quantities, directly as the input of the second stage graph attention network. The feature assembly module is used to combine the continuous physical field features of the first stage, the bypass transfer amount, and the geometric features of the casting. The porosity defect prediction module takes the combined feature matrix as input, uses the second-stage graph attention network to classify and predict porosity defects at each node, and outputs the porosity probability of each node.
[0015] According to a third aspect of this application, a terminal is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, can be used to perform the method described in the first aspect.
[0016] According to a fourth aspect of this application, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, can be used to perform the method described in the first aspect.
[0017] This application provides a two-stage graph neural network-based method for predicting porosity defects in die casting. First, a first-stage graph network predicts intermediate physical field features. Then, a modulation mechanism dynamically intervenes in local node features using global process parameters, achieving deep fusion of shallow and deep information. Simultaneously, discrete physical field features are input to the second stage via a bypass, effectively avoiding excessive feature smoothing caused by graph message passing and reducing computational latency. Finally, physical field, bypass, and geometric features are fused, and the second-stage graph attention network accurately outputs the probability of porosity at each node. This application highly aligns with the causal logic of die casting physics, significantly improving the accuracy and efficiency of porosity defect prediction.
[0018] Other technical effects resulting from the additional features will be further illustrated in the corresponding embodiments. Attached Figure Description
[0019] Other features, objects, and advantages of this application will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings: Figure 1 The flowchart illustrates a die casting porosity defect prediction method based on a two-stage graph neural network according to an exemplary embodiment. Figure 2 This is a flowchart illustrating a die casting porosity defect prediction method based on a two-stage graph neural network according to an exemplary embodiment. Figure 3 This is a comparison diagram of a two-stage prediction framework and a numerical simulation path according to an exemplary embodiment; Figure 4 This is a schematic diagram illustrating a bypass channel mechanism according to an exemplary embodiment; Figure 5 This is a schematic diagram illustrating the second-stage input feature assembly and sequence alignment according to an exemplary embodiment; Figure 6 This is a comparison chart of ablation experiment results according to an exemplary embodiment; Figure 7 This is a schematic diagram illustrating the spatial distribution prediction results of the porosity probability of a casting according to an exemplary embodiment; Figure 8This is a schematic diagram illustrating the structure of a die casting porosity defect prediction method based on a two-stage graph neural network according to an exemplary embodiment. Detailed Implementation
[0020] The present application will now be described in detail with reference to specific embodiments. These embodiments will help those skilled in the art to further understand the present application, but do not limit the present application in any way. It should be noted that those skilled in the art can make several modifications and improvements without departing from the concept of the present application, and these all fall within the protection scope of the present application. Parts not described in detail in the following embodiments can be implemented using existing technology.
[0021] Existing end-to-end methods suffer from poor physical interpretability, while existing two-stage methods rely on time-consuming simulations and suffer from limited prediction accuracy due to improper handling of discrete physical field features. To address these issues, this application provides a die-casting porosity defect prediction method based on a two-stage graph neural network to resolve these problems.
[0022] Reference Figure 1 and Figure 2 One embodiment of this application provides a method for predicting porosity defects in die casting based on a two-stage graph neural network, comprising the following steps: S1. Divide the casting into several sub-regions, and construct a graph structure with each sub-region as a node and the spatial adjacency relationship between sub-regions as an edge. S2. Using process parameters and casting geometric features as input, the continuous physical field features of each node are predicted using the graph neural network of the first stage. Among them, the process parameters are dynamically applied to the node features after each layer of message transmission through the modulation mechanism, so as to realize the hierarchical modulation of the casting-level process signal on the node-level physical field features. S3. The preset discrete physical field features are not predicted by the graph neural network in the first stage. Their normalized values are used as bypass transit quantities and directly used as the input of the graph attention network in the second stage. S4. Combine the continuous physical field characteristics, bypass transfer quantity and casting geometric characteristics of the first stage; S5. Using the combined feature matrix as input, the second-stage graph attention network is used to classify and predict the porosity defects of each node, and the porosity probability of each node is output.
[0023] Specifically, the casting is divided into M (M≥2) sub-regions. The continuous physical field features in the first stage are four dimensions: T13, V4, P4, and P5. The preset discrete physical field feature is only P1 (baseline pressure), which is determined to be discrete (i.e., categorical) by residual distribution diagnosis. Instead, the true value of the discrete physical field feature is normalized and then passed through a bypass path, without participating in regression prediction.
[0024] The two-stage serial architecture uses intermediate physical field features as the connecting link, decomposing the prediction task into two sub-tasks that conform to the physical causal relationship: "process parameters → physical field" and "physical field → porosity". This conforms to the physical causal logic of "process parameters → physical field distribution → defect generation" in the die casting process, thereby achieving physical causal chain alignment. Moreover, it avoids the black box problem caused by direct prediction by a single network at the end, making the learning objectives of each stage clear and significantly improving the physical interpretability and prediction accuracy of the prediction.
[0025] like Figure 3 As shown, when the physical field features predicted in the first stage are used as the input for the second stage, the stomatal classification performance (such as AUC, F1, node-level recall, and casting-level recall) is comprehensively better than the real physical field output directly from the numerical simulation software. This reveals the deep mechanism of the two-stage framework: the prediction process in the first stage has an implicit filtering effect on the local noise of the simulation data, and the intermediate representation generated is more suitable as the feature input for stomatal classification than the original simulation data; the effect does not require the design of an additional denoising module and is naturally generated by the training mechanism of the two-stage cascaded framework.
[0026] A modulation mechanism is introduced into the first-stage graph neural network, enabling global process parameters to dynamically affect local node features (e.g., through affine transformation) after message passing at each layer. This mechanism effectively addresses the limitation of traditional graph neural networks in distinguishing between global process influences and local geometric influences, achieving hierarchical dynamic intervention of process parameters on the physical field feature flow, and significantly improving the robustness of physical field prediction under complex operating conditions.
[0027] For discrete physical field quantities, instead of predicting them through the first-stage graph neural network, they are normalized and directly passed to the second stage as bypass quantities. This effectively avoids the information loss problem caused by excessive smoothing of discrete features in the multi-layer message passing of the graph neural network, eliminates the systematic quantization error introduced by forced continuous regression to discrete quantities, and thus improves the quality of input features in the second stage.
[0028] The method in this embodiment is based on a two-stage graph neural network, using the intermediate representation of the physical field as the connecting link. First, the first-stage graph network predicts the intermediate features of the physical field, and then a modulation mechanism dynamically intervenes in local node features using global process parameters, achieving deep fusion of shallow and deep information. Simultaneously, discrete physical field features are input to the second stage via a bypass, effectively avoiding excessive feature smoothing caused by graph message passing and reducing computational latency. Finally, the physical field, bypass, and geometric features are fused, and the second-stage graph attention network accurately outputs the probability of node porosity. The method in this embodiment highly conforms to the physical causal logic of die casting, significantly improving the accuracy and efficiency of porosity defect prediction.
[0029] In the feature preparation step, process parameters, geometric features, and physical field features are grouped and normalized according to their distribution type, and the normalized parameters are persistently saved; discrete physical field features are identified and marked, and the rest are marked as continuous physical field features.
[0030] Specifically, the identification methods for discrete physical field features include: using a regression model to predict candidate physical field features; if the statistical distribution of the prediction residuals shows a multi-peak characteristic, or if the true values of the candidate physical field features show a discrete clustering distribution in the historical sample set (i.e., different casting sample sets), then the candidate physical field features are determined to be discrete physical field features.
[0031] In die casting, process parameters such as injection speed and mold temperature are global variables, while geometric features such as wall thickness and curvature are local variables. Traditional GNNs typically concatenate global variables directly into the feature vector of each node, which makes it difficult for the network to distinguish between global and local effects. To address this issue, in some specific embodiments of this application, in step S2, in the first-stage graph neural network, process parameters are dynamically applied to node features after message passing at each layer through a modulation mechanism, including: Input the casting-level process parameters into the preset modulation parameter generator to independently generate corresponding modulation parameter pairs for each network layer of the graph neural network in the first stage. The modulation parameter pairs include scaling factors and offset factors. After message transmission is completed at each network layer, affine transformation is performed on the node features of the current layer using modulation parameters to achieve hierarchical dynamic modulation of the local physical field features at the node level by global process parameters at the casting level.
[0032] Specifically, die-casting process parameters (such as injection speed and mold temperature) are casting-level / global variables (only one set of values for each casting), while geometric features (such as wall thickness and curvature) are node-level / local variables (different for each region). If the traditional GNN approach is adopted—directly broadcasting global process parameters and splicing them into the feature vector of each node—the network has difficulty distinguishing between "global process influence" and "local geometric influence" during message transmission. Furthermore, as the number of GNN layers increases, the spliced global signal is diluted by message aggregation layer by layer, making it difficult to continuously exert a modulation effect.
[0033] This application addresses this issue through a FiLM (Feature-wise Linear Modulation) modulation mechanism: instead of incorporating process parameters into node features, the FiLM generator takes only process parameters as input and independently generates a set of affine modulation parameters (γ, β) after each layer's message passing. γ is a scaling factor, and β is an offset factor. Element-wise modulation of the hidden layer features of that layer's nodes is performed using h' = γ⊙h + β, where h is the node feature of the current layer, and h' is the output feature. Since (γ, β) is regenerated at each layer, the process signal is re-injected at each layer and does not significantly attenuate as the network deepens, thus achieving hierarchical modulation of local node features by the global process signal.
[0034] In this step, the modulation parameter generator is jointly trained end-to-end with the graph neural network of the first stage.
[0035] In this embodiment, through the first-stage physical field intermediate feature prediction step, the generator independently generates parameter pairs and implements a layer-by-layer affine transformation mechanism, thereby realizing the dynamic intervention of global variables on local feature flows.
[0036] In order to reduce inference computation latency and avoid feature oversmoothing caused by graph message passing, in some specific embodiments of this application, the normalized value is used as a bypass pass-through quantity, including: when predicting porosity defects in the casting under test, the normalized value of the pre-calculated and stored discrete physical field feature is directly obtained from the preset storage medium to skip the real-time calculation process.
[0037] Specifically, for the labeled discrete physical field features, their normalized values are pre-calculated and stored in a preset storage medium, and the normalized true values are persistently saved. During inference, without first-stage model prediction, the normalized values are directly read from the persistent file and passed in parallel with the continuous physical field features predicted in the first stage to step S4, such as... Figure 4 As shown, by using a bypass channel to pass the steps, not only is the prediction accuracy guaranteed, but the computational latency of the second stage is also significantly reduced.
[0038] To enable the model to better understand the physical filling sequence and topological properties of the casting in three-dimensional space, in some specific embodiments of this application, the second-stage graph attention network introduces node position encoding. The node position encoding integrates binary features representing the topological properties of the region and discretized features representing the distance of the molten metal filling path. After the discretized features are transformed into continuous vectors through the trained embedding layer, they are concatenated or element-wise added with the concatenated feature matrix to serve as the final input features of each node in the second-stage graph attention network.
[0039] The formation of porosity in die casting (especially entrapment and shrinkage cavities) is highly correlated with the filling path of the molten metal and the final solidification region (topological dead zone). The farther away from the gate, the lower the temperature of the molten metal and the greater the risk of entrapment. By using the filling path distance as a discretized feature and learning it, the model can automatically capture the nonlinear relationship between "distance-temperature-porosity". For example, the binary topological properties of regions such as "dead zones" and "thin-walled transition zones" directly determine whether venting is smooth. Encoding both as positions allows the model to understand not only the topological connections of the graph but also the physical filling sequence of the casting in three-dimensional space.
[0040] Discretizing the filling path distance into categorical features (e.g., dividing it into near, middle, and far, or specific flow channel levels) and then mapping it into a continuous vector solves the gradient problem caused by the excessively large range or uneven distribution of the filling path distance values.
[0041] In existing two-stage systems, the consistency of feature order is not guaranteed; inconsistencies between feature arrangement during inference and training can lead to complete prediction failure. To address this issue, in some embodiments of this application, the method introduces a feature order alignment mechanism. For example... Figure 5 As shown, the continuous physical field features, bypass transport quantities, and casting geometric features of the first stage are combined into a feature name list. This includes: during the training stage, the names of the continuous physical field features, bypass transport quantities, and casting geometric features are recorded in the combination order and persistently saved; during the inference stage, the feature order is read from the feature name list, and the continuous physical field features, bypass transport quantities, and casting geometric features are rearranged in the feature order and combined to ensure consistency between the feature arrangement in the inference and training stages.
[0042] Specifically, the normalized parameters of process parameters, casting geometric features, and continuous physical field features are persistently stored in a preset storage medium. When predicting porosity defects in the casting under test, the normalized configuration parameters are loaded from the storage medium, and the input features under test are subjected to numerical standardization transformation consistent with the training phase.
[0043] The continuous physical field prediction values output in step S2, the discrete physical field feature normalization values passed by the bypass in step S3, and the geometric feature subset are all persistently saved in the form of structured files. They are then combined in the order recorded in the feature name list pre-stored during training to form the input feature matrix for the second stage. The feature order alignment mechanism ensures strict consistency between the feature arrangement in the inference stage and the training stage, eliminating the risk of prediction failure caused by inconsistent feature arrangement in training and inference from the system design level, and ensuring deployment stability.
[0044] To address the issues of overfitting the model to normal, small noise points and low recall rate due to sparse defect nodes, in some specific embodiments of this application, the second-stage graph attention network is obtained through the following training process: In the second stage of training the graph attention network, a weighted batch sampling strategy is used to construct training batches; The weighted batch sampling strategy includes: identifying target casting samples whose number of defect nodes in the training sample set is lower than a preset sparse threshold; the training sample set includes multiple casting samples as graph structure samples; during the training batch construction stage, the target casting samples are assigned a higher sampling weight than non-target casting samples to dynamically adjust the probability of the target casting samples appearing in the training batch, while keeping the overall sample distribution of the original training sample set unchanged.
[0045] Preferably, the target casting sample, i.e. the casting with fewer positive samples, refers to the number of nodes in the casting determined to have porosity defects (number of positive sample nodes n). pos The number of defect nodes should not exceed a preset sparsity threshold, which ranges from 3 to 15. The sampling weight of the target casting sample is 3 to 10 times that of the sampling weight of the non-target casting sample, preferably 6 times. When the threshold is below 3, the model will overfit to normal small noise points, and when it is above 15, it will lose its specificity for sparse defects. A factor between 3 and 10 times can better balance the stability of gradient descent and the recall rate of sparse samples.
[0046] To eliminate redundant features, reduce model complexity, and improve generalization ability, in some specific embodiments of this application, the first-stage graph neural network and the second-stage graph attention network are trained based on a feature recursive elimination strategy. The feature recursive elimination strategy includes: For the graph neural network in the first stage and the graph attention network in the second stage, the feature recursive elimination operation is performed independently. The recursive feature elimination operation includes: training the model for the corresponding stage based on the current input features, evaluating the feature importance of each input feature, eliminating features with lower importance ranking, and iteratively executing the above process until the corresponding stopping condition is met; The stopping conditions for the first-stage graph neural network include a double stopping condition consisting of prediction error and the number of features; the stopping conditions for the second-stage graph attention network include a joint stopping condition consisting of three metrics: AUC, F1 score, and recall.
[0047] Specifically, the three-indicator joint stopping condition does not require all three indicators to be optimal simultaneously, but rather has a clear priority order: recall (core business indicator, with the highest cost for missing defective castings) > AUC (primary guiding indicator in the hyperparameter search phase, not dependent on specific thresholds) > F1 score (auxiliary monitoring indicator for threshold rationality). Training and hyperparameter search primarily optimize node-level AUC, with final acceptance based on node-level recall, and F1 score used for process monitoring.
[0048] To avoid data leakage of node features of the same casting between the training and validation sets and to ensure the objectivity of model evaluation, in some specific embodiments of this application, the first-stage graph neural network and the second-stage graph attention network are trained based on a training sample set partitioned using a K-fold cross-validation strategy. The training sample set is divided into K data subsets, and the K-fold cross-validation strategy partitioning method is as follows: Using the entire casting as the smallest unit of division, several sub-region nodes belonging to the same casting are forcibly assigned to the same data subset to avoid data leakage of node features of the same casting between the training set and the validation set.
[0049] For example, K can take values from 3 to 10.
[0050] Step S5 is the second stage of stoma classification prediction. Using the feature matrix assembled in step S4 as input, a graph attention network is used to perform stoma defect classification (such as binary classification) prediction on each node, and the stoma probability value of each node is output. Stoma determination is performed on each node according to the preset probability threshold.
[0051] The embodiments described above in this application connect the two prediction stages through an intermediate physical field representation and introduce bypass channels and dynamic modulation mechanisms for process parameters, thus achieving real-time inference and enabling rapid and accurate prediction of the probability of porosity defects in each sub-region of the casting. Experimental results show that the two-stage cascaded inference time does not exceed 1 second per piece, which is about four orders of magnitude better than numerical simulation, meeting the needs of real-time process optimization in industry.
[0052] Furthermore, the above embodiments of this application can realize the visualization of the spatial distribution of die casting porosity defects. Specifically, after independently outputting porosity probability values for 36 node regions, color mapping is performed according to the actual spatial position of each node in the casting outline (color / grayscale depth corresponds to the porosity probability, such as 0.0~1.0), generating a heat map of casting porosity risk. This visualization is automatically generated after the node-level probability prediction is completed, and the entire process (including visualization rendering) takes seconds per piece.
[0053] The preferred features in the above embodiments can be used individually in any embodiment, or in any combination thereof, provided they do not conflict with each other. Furthermore, parts not described in detail in the embodiments can be implemented using existing technologies.
[0054] The following examples will be used to further illustrate this application in order to better understand the above-mentioned technical solutions. It should be understood that the following are only some examples and are not intended to limit this application.
[0055] Application Example 1: This application example provides a two-stage prediction method for porosity defects in magnesium alloy die-castings. The specific process is as follows: 1. Dataset For AZ91D magnesium alloy die castings, 200 sets of process parameter combinations (9-dimensional process parameters) were generated using Latin hypercube sampling. ProCAST simulation was used to extract the physical field temporal features of 36 sub-regions. Combined with X-ray flaw detection, node-level pore labels were obtained (pore area ratio exceeding a preset threshold is a positive sample node).
[0056] 2. First Phase Training Using 9-dimensional process parameters and 9-dimensional geometric features (18 dimensions in total) as inputs, four continuous physical field features—T13_temperature standard deviation, V4_filling duration, P4_pressure settling time, and P5_filling peak pressure—are used as prediction targets. P1_baseline pressure (mBar) is determined to be discrete through residual distribution diagnosis and is normalized and then a bypass channel is set. The first stage adopts the FiLM-GATv2 architecture, and the mean R² of each target exceeds 0.83 in 5-fold cross-validation.
[0057] 3. Second Phase Training The 4D continuous physics predictions from the first stage, the P1 normalized values from the bypass propagation, and the 6D subsets (G3_shape factor, G21_maximum curvature, G4_bounding box X, G5_bounding box Y, G23_mean curvature, G1_volume) selected from the 9D geometric features are combined in the order of features recorded during training to form an 11D node feature matrix (36 nodes × 11 dimensions). The second stage adopts the PoroNet architecture, which includes a position encoding module and a sparse casting oversampling mechanism. The node-level AUC of 5-fold cross-validation exceeds 0.94, and the casting-level Recall exceeds 0.85.
[0058] 4. Key experimental verification Experimental verification results are as follows Figure 6 As shown, ablation experiment E4 replaces the predicted physics field in the second-stage input with the ProCAST simulation of the real physics field. The results show that the complete two-stage model (E1) outperforms E4 in both node-level AUC and casting-level Recall, verifying the implicit filtering effect of the two-stage framework on simulation noise. The comparison between ablation experiment E1 and a completely graph-free baseline (MLP+MLP) and an end-to-end graph-based baseline (E2) verifies the necessity of the two-stage framework and graph structure. Specifically: E1 - Graph without Field: Process parameters and geometric features are directly input into PoroNet for end-to-end mapping, skipping the intermediate physical field representation, to verify the necessity of the intermediate physical field layer; E2 - Field-Free Without Graph: Verifying the necessity of graph structures by using only physical fields and geometric features to predict through node-independent MLP (message passing without graph); E3 - This application's method: a complete two-stage concatenation (FiLM-GATv2 → physics field → PoroNet), which is optimal overall; E4 - Real Physics: The second-stage input is replaced with ProCAST simulated real physics (instead of the first-stage prediction) to compare and verify the implicit filtering effect of the two-stage framework on simulation noise. E5-FiLM-Free Full Chain: In the first phase, the FiLM modulation mechanism was replaced with ordinary broadcast splicing (ConcatGAT). The entire chain was compared to verify the contribution of the FiLM mechanism. E6-P1 Prediction Alternative Transmission: P1 is now predicted by the first-stage model instead of being directly transmitted via a bypass, verifying the necessity of the bypass transmission design.
[0059] Each group compared their performance against four metrics: node-level AUC, F1, node-level Recall, and casting-level Recall, quantifying the independent contribution of each module (graph structure / two-stage framework / FiLM mechanism / bypass pass-through) to the final performance.
[0060] 5. Reasoning Process During inference, the input features undergo the same transformation as the normalized parameter file saved during training. The P1 bypass directly reads the normalized values from the persistent file, aligns them according to the saved feature name list, and performs a two-stage cascaded inference based on the optimal model weights. The entire inference process takes no more than 1 second per item, and the prediction results are as follows: Figure 7 As shown. Figure 7 The spatial distribution of the porosity probability prediction results of 36 node regions in a typical casting in Application Example 1 on the casting outline is shown. The color of the nodes corresponds to the porosity probability (dark color is high risk, light color is low risk), and the key areas with higher probabilities in the prediction results are marked.
[0061] Application Example 2: This application example provides a two-stage prediction method for porosity defects in aluminum alloy die-casting parts, including: For AlSi9Cu3 aluminum alloy die castings, the same two-stage method flow as in Application Example 1 is adopted. The sub-regions are re-divided according to the actual geometry of the casting, and the physical field feature screening results are adjusted. The types of discrete physical field features are re-determined based on the distribution characteristics of simulation data. The core design of the two-stage framework (bypass channel, feature sequence alignment, modulation mechanism) does not change with the alloy system, and can achieve accurate prediction of porosity defects in aluminum alloy die castings, verifying the general applicability of the method of this application to different alloy systems.
[0062] Based on the same concept, another embodiment of this application provides a die-casting porosity defect prediction system based on a two-stage graph neural network, referring to... Figure 8 The die-casting porosity defect prediction system 10 includes: Graph structure construction module 11 is used to divide the casting into several sub-regions, and construct a graph structure with each sub-region as a node and the spatial adjacency relationship between sub-regions as an edge. The physical field feature prediction module 12 is used to predict the continuous physical field features of each node by taking process parameters and casting geometric features as inputs and using the graph neural network of the first stage; wherein, the process parameters are dynamically applied to the node features after each layer of message transmission through a modulation mechanism. The bypass propagation module 13 is used to directly use the normalized value of the preset discrete physical field features as the bypass propagation quantity, without the first stage graph neural network prediction, as the input of the second stage graph attention network. Feature assembly module 14 is used to combine the continuous physical field features, bypass transfer amount and casting geometric features of the first stage; The porosity defect prediction module 15 is used to perform porosity defect classification and prediction on each node using the combined feature matrix as input and the second-stage graph attention network, and outputs the porosity probability of each node.
[0063] The specific implementation techniques of each module / unit in the above examples of this application can be referred to the steps of the die casting porosity defect prediction method based on two-stage graph neural network in the above embodiments, and will not be repeated here.
[0064] Based on the same concept, another embodiment of this application provides a terminal, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it can be used to perform the methods in any of the above embodiments.
[0065] Based on the same concept, another embodiment of this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, can be used to perform the methods in any of the above embodiments.
[0066] Optionally, the memory is used to store programs; the memory may include volatile memory, such as random-access memory (RAM), such as static random-access memory (SRAM), double data rate synchronous dynamic random-access memory (DDR SDRAM), etc.; the memory may also include non-volatile memory, such as flash memory. The memory is used to store computer programs (such as application programs and functional modules that implement the above methods), computer instructions, etc., and the aforementioned computer programs and computer instructions can be partitioned and stored in one or more memories. Furthermore, the aforementioned computer programs, computer instructions, data, etc., can be accessed by the processor.
[0067] The aforementioned computer programs, computer instructions, etc., can be stored in partitions within one or more memory locations. Furthermore, the aforementioned computer programs, computer instructions, data, etc., can be accessed by a processor.
[0068] A processor is used to execute a computer program stored in memory to implement the various steps of the methods involved in the above embodiments. For details, please refer to the relevant descriptions in the preceding method embodiments.
[0069] The processor and memory can be separate structures or integrated structures. When the processor and memory are separate structures, they can be coupled together via a bus.
[0070] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0071] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0072] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0073] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0074] The foregoing has described some specific embodiments of this application. It should be understood that this application is not limited to the specific embodiments described above, and those skilled in the art can make various modifications or variations within the scope of the claims, which do not affect the substantive content of this application. The above-described preferred features can be used in any combination without conflict.
Claims
1. A method for predicting porosity defects in die casting based on a two-stage graph neural network, characterized in that, include: The casting is divided into several sub-regions, and a graph structure is constructed with each sub-region as a node and the spatial adjacency relationship between sub-regions as an edge. Using process parameters and casting geometry as input, a first-stage graph neural network is used to predict the continuous physical field characteristics of each node; wherein, the process parameters are dynamically applied to the node characteristics after each layer of message passing through a modulation mechanism. The preset discrete physical field features are not predicted by the graph neural network in the first stage. Instead, their normalized values are used as bypass propagation quantities and directly used as inputs to the graph attention network in the second stage. The continuous physical field characteristics of the first stage, the bypass transfer amount, and the geometric characteristics of the casting are combined. Using the combined feature matrix as input, the second-stage graph attention network is used to classify and predict porosity defects at each node, and outputs the porosity probability of each node.
2. The method for predicting porosity defects in die casting based on a two-stage graph neural network according to claim 1, characterized in that, In the first stage of the graph neural network, the process parameters are dynamically applied to node features after each layer of message passing through a modulation mechanism, including: The process parameters are input into a preset modulation parameter generator to independently generate corresponding modulation parameter pairs for each network layer of the graph neural network in the first stage. The modulation parameter pairs include scaling factors and offset factors. After the message transmission is completed at each network layer, the modulation parameters are used to perform an affine transformation on the node features of the current layer, so as to realize the hierarchical dynamic modulation of the local physical field features at the node level by the global process parameters at the casting level.
3. The method for predicting porosity defects in die casting based on a two-stage graph neural network according to claim 1, characterized in that, The step of using the normalized value as a bypass transfer quantity includes: when predicting porosity defects in the casting under test, directly obtaining the normalized value of the discrete physical field characteristics that has been pre-calculated and stored from the preset storage medium.
4. The method for predicting porosity defects in die casting based on a two-stage graph neural network according to claim 1, characterized in that, The second-stage graph attention network introduces node position encoding, which integrates binary features representing regional topological attributes and discretized features representing the path distance of the liquid metal filling type. The discretized features are transformed into continuous vectors through a trained embedding layer and then concatenated or element-wise added with the concatenated feature matrix to serve as the final input features of each node in the second-stage graph attention network.
5. The method for predicting porosity defects in die casting based on a two-stage graph neural network according to claim 1, characterized in that, The continuous physical field characteristics of the first stage, the bypass transfer quantity, and the geometric characteristics of the casting are combined, including: During the training phase, the names of the continuous physical field features, the bypass transfer amount, and the casting geometric features are recorded in the feature name list according to the combination order and persistently saved. During the inference phase, the feature order is read from the feature name list, and the continuous physical field features, the bypass transfer amount, and the casting geometric features are rearranged according to the feature order and then combined to ensure the consistency of the feature arrangement between the inference and training phases.
6. The method for predicting porosity defects in die casting based on a two-stage graph neural network according to claim 1, characterized in that, The graph attention network in the second stage is obtained through the following training process: In the second stage of training the graph attention network, a weighted batch sampling strategy is used to construct training batches; The weighted batch sampling strategy includes: identifying target casting samples in the training sample set whose number of defect nodes is lower than a preset sparse threshold, wherein the training sample set includes multiple casting samples as graph structure samples; during the training batch construction stage, assigning a higher sampling weight to the target casting samples than to non-target casting samples, so as to dynamically adjust the probability of the target casting samples appearing in the training batch, while keeping the sample distribution of the training sample set unchanged.
7. The method for predicting porosity defects in die casting based on a two-stage graph neural network according to claim 1, characterized in that, The graph neural network in the first stage and the graph attention network in the second stage are trained based on a feature recursive elimination strategy, which includes: For the graph neural network in the first stage and the graph attention network in the second stage, feature recursive elimination operations are performed independently respectively; The recursive feature elimination operation includes: training a model for the corresponding stage based on the current input features, evaluating the feature importance of each input feature, eliminating features with lower importance ranking, and iteratively executing the above process until the corresponding stopping condition is met. The stopping conditions for the first-stage graph neural network include a double stopping condition consisting of prediction error and the number of features; the stopping conditions for the second-stage graph attention network include a joint stopping condition consisting of three metrics: AUC, F1 score, and recall.
8. A die-casting porosity defect prediction system based on a two-stage graph neural network, characterized in that, include: The graph structure construction module is used to divide the casting into several sub-regions, and construct a graph structure with each sub-region as a node and the spatial adjacency relationship between sub-regions as an edge. The physical field feature prediction module is used to predict the continuous physical field features of each node using process parameters and casting geometric features as inputs and a graph neural network in the first stage; wherein, the process parameters are dynamically applied to the node features after each layer of message transmission through a modulation mechanism. The bypass propagation module is used to take the preset discrete physical field features without the first stage graph neural network prediction, and use their normalized values as bypass propagation quantities, directly as the input of the second stage graph attention network. The feature assembly module is used to combine the continuous physical field features of the first stage, the bypass transfer amount, and the geometric features of the casting. The porosity defect prediction module takes the combined feature matrix as input, uses the second-stage graph attention network to classify and predict porosity defects at each node, and outputs the porosity probability of each node.
9. A terminal, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it can be used to perform the method of any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the program can be used to perform the method of any one of claims 1-7.