Die-casting gas pore spatial distribution prediction method and system based on graph neural network
Patent Information
- Application Number
- CN202611134276.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-29
- Publication Date
- 2026-10-30
AI Technical Summary
(1)充型路径先验知识未被利用:现有技术未将铸件区域拓扑属性(如是否连通内浇口、是否为汇流区等)和充型路径距离(近/中/远端)等工业先验知识结构化融入模型,导致模型对高风险区域(远浇口区、汇流区)的识别能力不足
[0018]本申请提供的基于图神经网络的压铸气孔空间分布预测方法,融合区域拓扑与充型距离的位置编码向量将物理先验融入模型,显著提升远浇口等高风险区的识别准确率;利用多层图注意力消息传递机制有效捕捉相邻区域间的风险传播特征,增强模型对空间上下文的聚合能力;针对气孔稀疏性引入过采样机制,提升稀疏铸件采样权重,改善对低频气孔模式的学习,缓解类别不平衡导致的漏检;通过节点级概率独立输出突破铸件级分类局限,提供细粒度空间分辨率,为工艺优化提供定量决策依据。本申请实现了气孔缺陷的高精度、细粒度空间分布预测。
Smart Images

Figure CN123012412A_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 the spatial distribution of porosity in die casting based on graph neural networks. Background Technology
[0002] Porosity defects in high-pressure die castings exhibit a non-uniform spatial distribution: the entrainment and retention of gas during the filling process are affected by physical factors such as the filling path, confluence location, and exhaust conditions, causing pores to tend to accumulate in specific areas (such as the far gate area, multi-flow confluence area, thin-walled corner area, etc.).
[0003] Existing technologies for predicting stomatal spatial distribution have the following main shortcomings: (1) Prior knowledge of filling path is not utilized: Existing technologies do not structurally integrate industrial prior knowledge such as the topological properties of casting area (e.g., whether it is connected to the ingate, whether it is a confluence area, etc.) and filling path distance (near / middle / far end) into the model, resulting in insufficient model recognition of high-risk areas (far gate area, confluence area).
[0004] (2) High rate of missed detection in sparse castings: In the die casting production data, some castings have only a few areas with porosity (sparse castings). These castings account for a low proportion in the training data, and conventional training strategies do not learn them sufficiently, resulting in a high rate of missed detection at the casting level. The harm of missed detection to industrial quality control is far greater than that of false alarms.
[0005] (3) Lack of node-level probability output: Existing technologies usually output the overall classification results of the casting, but lack the independent porosity probability output of each sub-region, which cannot support the differentiated risk assessment and targeted process improvement of the casting region.
[0006] Therefore, it is necessary to propose a method for predicting the spatial distribution of porosity in die casting to solve the above-mentioned technical problems. Summary of the Invention
[0007] To address one of the shortcomings of existing technologies, the purpose of this application is to provide a method and system for predicting the spatial distribution of porosity in die casting based on graph neural networks.
[0008] According to a first aspect of this application, a method for predicting the spatial distribution of porosity in die casting based on graph neural networks is provided, comprising: The casting is divided into multiple sub-regions as nodes in a graph structure, and the edges of the graph structure are constructed based on the spatial adjacency relationship between the regions. The initial features of the node are obtained. The category features representing the path distance are mapped into continuous embedding vectors through a learnable embedding layer and combined with the binary features representing the topological attributes of the region to generate a location encoding vector. The location encoding vector is concatenated with the initial features to obtain the node input features. The node input features are input into the graph attention network to perform multi-layer message passing and output the stomatal probability prediction value of each node. When constructing training batches, the sampling weight of casting samples with no more than the sparse threshold of positive sample nodes is increased; the loss is calculated based on the predicted porosity probability value and the true label, and the parameters of the graph attention network and the learnable embedding layer are updated in reverse. The trained network is used to independently output the porosity probability value of each node of the casting to be predicted, and the spatial distribution prediction result of porosity is obtained.
[0009] Optionally, the binary feature representing the topological attributes of the region includes: the ingate direct filling zone, multi-flow confluence zone, connected slag bag zone, and other filling zones to which the region belongs; The category feature representing the filling path distance is obtained by discretizing the filling path distance between each region and the ingate according to a preset threshold range, resulting in multiple distance categories.
[0010] Optionally, the multi-layer graph attention message passing uses the graph attention network V2 convolution operator to capture the correlation strength between the interstitial state of adjacent sub-regions and stomatal evolution. Its attention coefficients are obtained by linear mapping and nonlinear activation dynamic calculation after concatenating the features of the target node and the adjacent source node. The multi-layer graph attention message passing is composed of multi-layer graph attention computation layers connected in series, with each layer sequentially performing attention feature aggregation, batch normalization, ELU activation and residual connection operations; The explicit edge weights between adjacent nodes are calculated based on the three-dimensional spatial physical distance between sub-regions using a Gaussian distance kernel to characterize the spatial attenuation effect of molten metal flow and heat conduction during die casting. They are also fused with the attention coefficient during message passing for node feature weighted aggregation.
[0011] Optionally, in the step of increasing the sampling weight, the sparse threshold and the sampling weight increase factor are preset as configurable training hyperparameters based on the statistical distribution characteristics of pore defects in the training dataset; When constructing the training batch, casting samples with zero positive sample nodes are filtered out, and weight boosting is performed only on casting samples with a positive sample node count greater than zero and not greater than the sparse threshold.
[0012] Optionally, during the model training phase, the following may also be included: K-fold cross-validation is used to evaluate the model performance. The training set and validation set are divided according to the casting as a whole, so that nodes of the same casting are not simultaneously assigned to the training set and the validation set. Calculate the node-level AUC and casting-level recall of the validation set, wherein the casting-level recall is the arithmetic mean of the positive sample node recall calculated independently for each casting. The optimal network structure is determined through hyperparameter search and iteration based on the node-level AUC and the casting-level recall.
[0013] Optionally, the method further includes a step of performing inference data preprocessing, specifically: Load the feature normalization parameters saved during the model training phase, and perform the same numerical transformation as during the training phase on the node features of the inference input, which include die casting process parameters and geometric properties, to eliminate the differences between different physical dimensions. Read the feature name index list stored in the training phase, and align the node feature vectors of the inference input according to the dimensional order of the index list to ensure that the dimensions of the process and geometric feature inputs during inference are consistent with those during the model training phase.
[0014] Optionally, after using the trained network to independently output the porosity probability values of each node in the casting to be predicted, the method further includes: Using the geometric contour of the casting as the base map, the porosity probability value corresponding to each node is mapped to the spatial coordinate position to generate a spatial distribution map of porosity risk.
[0015] According to a second aspect of this application, a die-casting porosity spatial distribution prediction system based on graph neural networks is provided, comprising: The graph structure construction module is used to divide the casting into multiple sub-regions as nodes in the graph structure, and to construct the edges of the graph structure based on the spatial adjacency relationship between the regions. The node location encoding module is used to obtain the initial features of the node, map the category features representing the filling path distance into a continuous embedding vector through a learnable embedding layer, and combine it with the binary features representing the topological attributes of the region to generate a location encoding vector; the location encoding vector is concatenated with the initial features to obtain the node input features; The graph attention message passing module is used to input the node input features into the graph attention network to perform multi-layer message passing and output the stomatal probability prediction value of each node. The sparse casting oversampling module is used to increase the sampling weight of casting samples whose number of positive sample nodes is not greater than the sparse threshold when constructing training batches; and to calculate the loss based on the predicted porosity probability value and the true label, and to update the parameters of the graph attention network and the learnable embedding layer in reverse. The node-level porosity probability output module is used to independently output the porosity probability value of each node of the casting to be predicted using the trained network, so as to obtain the spatial distribution prediction result of porosity.
[0016] 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.
[0017] According to a fourth aspect of this application, a computer-readable storage medium is provided having a computer program stored thereon, characterized in that the program, when executed by a processor, can be used to perform the method described in the first aspect.
[0018] This application provides a graph neural network-based method for predicting the spatial distribution of porosity in die casting. It integrates the location encoding vectors of the region topology and filling distance to incorporate physical priors into the model, significantly improving the accuracy of identifying high-risk areas such as far-gate areas. A multi-layer graph attention message passing mechanism effectively captures the risk propagation characteristics between adjacent regions, enhancing the model's ability to aggregate spatial context. An oversampling mechanism is introduced to address porosity sparsity, increasing the sampling weight of sparse castings, improving the learning of low-frequency porosity patterns, and mitigating missed detections caused by class imbalance. By using independent node-level probabilities, it overcomes the limitations of casting-level classification, providing fine-grained spatial resolution and quantitative decision-making basis for process optimization. This application achieves high-precision, fine-grained spatial distribution prediction of porosity defects.
[0019] Other technical effects resulting from the additional features will be further illustrated in the corresponding embodiments. Attached Figure Description
[0020] 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 This is a flowchart illustrating a method for predicting the spatial distribution of porosity in die casting based on a graph neural network, according to an exemplary embodiment. Figure 2 This is a flowchart illustrating a graph neural network-based method for predicting the spatial distribution of porosity in die casting, according to an exemplary embodiment. Figure 3 This is a schematic diagram illustrating node position encoding according to an exemplary embodiment; Figure 4 This is a schematic diagram illustrating the topological properties of a casting region according to an exemplary embodiment. Figure 5 This is a schematic diagram illustrating a sparse casting oversampling mechanism according to an exemplary embodiment; Figure 6 This is a comparison chart of ablation experiment results according to an exemplary embodiment (comparing with / without sparse oversampling mechanism). Figure 7 This is a comparison chart of ablation experiment results according to an exemplary embodiment (with / without location coding, i.e., E3 vs. removal of location coding). Figure 8 This is a schematic diagram illustrating the spatial distribution prediction results of the porosity probability of a casting according to an exemplary embodiment; Figure 9This is a schematic diagram of a graph neural network-based system for predicting the spatial distribution of porosity in die casting, according to an exemplary embodiment. Detailed Implementation
[0021] 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.
[0022] Existing technologies face three major challenges in predicting porosity in die casting: first, the lack of a structured representation of the filling physical mechanisms (such as near and far ends, and confluence) leads to blind model searching; second, the extreme imbalance between positive and negative samples makes it difficult to fully learn from sparse defect castings with a small number of pores, resulting in a high false negative rate; and third, the output granularity is coarse, failing to guide local process improvements. To address these issues, this application provides a graph neural network-based method for predicting the spatial distribution of porosity in die casting.
[0023] Reference Figure 1 and Figure 2 The method for predicting the spatial distribution of porosity in die casting based on graph neural networks, provided in one embodiment of this application, includes the following steps: S100. Divide the casting into multiple sub-regions as nodes in the graph structure, and construct the edges of the graph structure based on the spatial adjacency relationship between regions. S200. Obtain the initial features of the node. Map the category features representing the path distance to the filling layer into a continuous embedding vector through a learnable embedding layer, and combine them with the binary features representing the topological attributes of the region to generate a location encoding vector. Concatenate the location encoding vector with the initial features to obtain the node input features. S300: Input the node input features into the graph attention network to perform multi-layer message passing and output the stomatal probability prediction value of each node; S400. When constructing training batches, increase the sampling weight of casting samples with no more than the sparse threshold for positive sample nodes. Calculate the loss based on the predicted porosity probability and the true label, and update the parameters of the graph attention network and the learnable embedding layer in reverse. Here, positive sample nodes are nodes whose true label is that there are porosity defects. S500: The trained network independently outputs the porosity probability value of each node of the casting to be predicted, and obtains the spatial distribution prediction result of porosity.
[0024] Specifically, in step S100, the area division of the casting is based on the following two points: (1) Geometric basis: Based on prior knowledge, the casting is divided into multiple parts according to the geometric characteristics of the casting (e.g., the casting can be divided into a 36-node physical adjacency graph structure). The sub-regions are divided into corresponding sensor installation points to obtain the temperature / speed / pressure time series curves of the filling process. (2) Topological basis: The edges of the graph structure are constructed based on the three-dimensional spatial physical adjacency relationship between regions. The edge weights are calculated using a Gaussian distance kernel based on the spatial physical distance between sub-regions, which is used to characterize the attenuation of the association strength between regions.
[0025] In step S200, the initial features include physical field features and geometric features. The physical field features may include temperature standard deviation (T13), filling duration (V4), baseline pressure (P1), pressure settling time (P4), filling peak pressure (P5), etc. The geometric features may include volume, shape factor, bounding box X, bounding box Y, maximum curvature, average curvature, etc.
[0026] In step S400, the real labels can be constructed based on the three-dimensional distribution of pores obtained from non-destructive testing such as industrial CT. The total volume or number of pores falling into each sub-region is counted. If it exceeds a preset defect threshold, the real label of the corresponding node in that sub-region is marked as a positive sample; otherwise, it is marked as a negative sample. The sampling weighting rule is: for defect-free castings (n... pos =0) weight=0 (not involved in oversampling); sparse defect castings (0 <n pos ≤T sparse weight = α (lifting factor, in this embodiment α = 3~10, preferably 6); defective castings (n pos >T sparse (weight=1, meaning the defective casting is the weighting benchmark, where n) pos T represents the number of positive sample nodes. sparse The threshold is the sparsity threshold.
[0027] By integrating structured location encoding that combines regional topological attributes with filling path distances, the model incorporates prior physical information of the casting into a learnable embedding, enabling it to accurately perceive the physical characteristics of high-risk areas such as the far-gate area and confluence zone, significantly improving the accuracy of porosity identification under complex topological structures. Through a multi-layer graph attention message passing mechanism, the model fully utilizes the spatial adjacency relationships between regions to effectively capture the propagation and correlation characteristics of local porosity risks between adjacent regions, enhancing the model's ability to aggregate spatial contextual information. To address the sparsity problem of porosity distribution, an oversampling mechanism is introduced. By increasing the batch sampling weight of sparse castings (with fewer positive sample nodes), the model's learning ability for low-frequency, local porosity patterns is effectively improved, mitigating the missed detection problem caused by class imbalance. A node-level independent output mechanism for porosity probability is adopted, overcoming the limitation of traditional methods that can only output casting-level overall classification results, providing a finer spatial resolution and offering regional-level quantitative decision-making basis for targeted optimization of die-casting process parameters. In summary, this application can achieve high-precision, fine-grained prediction of the probability of porosity defects in each sub-region of a casting, effectively guiding the optimization of the die-casting process.
[0028] To address the problem of insufficient high-risk area identification due to the lack of utilization of prior knowledge of the filling path, in some specific embodiments of this application, reference is made to... Figure 3 and Figure 4 In step S200, the binary features representing the region's topological attributes include: the region's a priori industrial topological attributes such as the ingate direct filling area, multi-flow confluence area, connected slag bag area, and other filling areas. Other filling areas are defined as: the remaining areas in the four-category classification of region topological attributes, excluding the ingate direct filling area, multi-flow confluence area, and connected slag bag area. The category features representing the filling path distance are obtained by discretizing the filling path distance between each region and the ingate according to a preset threshold interval, resulting in multiple distance categories. These categories are mapped to continuous embedding vectors through a learnable embedding layer with shared weights. The parameters of the learnable embedding layer are jointly trained end-to-end with the parameters of the graph attention network.
[0029] like Figure 4 The diagram showing the topological attribute division of the casting region illustrates the following: The left side displays the 36-node region division and 6-category location coding attribute definitions for the same casting (using the same region topological classification rules); the right side, "Casting 1" and "Casting 2," represent two different porosity states of the same casting under different process conditions: Casting 1 corresponds to the low porosity condition (positive sample node number n). pos Fewer, sparse porosity distribution, and milder degree), casting 2 corresponds to a high porosity condition (n posThe text describes the characteristics of sparse castings (more numerous, with wider and more severe porosity distribution) to illustrate how changes in process parameters can lead to significant differences in the spatial distribution and severity of porosity within the same casting geometry. It also addresses the problem scenario targeted by the sparse casting oversampling mechanism (casting 1 is an example of a sparse casting). The "Total Number of Castings" indicates the total number of castings in the dataset (200 simulation data points), representing the proportion of sparse castings in the entire dataset (approximately 16%), providing data support for the design of the oversampling strategy.
[0030] Specifically, the location encoding vector contains two types of features: the first type is a binary feature representing the topological attributes of the region, forming a 4-dimensional feature; the second type is a category feature representing the filling path distance between the region and the ingate. The filling path distance between each region and the ingate is divided into at least three categories, such as near, medium, and far, or further subdivided into more categories according to the casting size. Each category is mapped into a continuous embedding vector (4-dimensional) through a learnable embedding layer with shared weights (such as an embedding lookup layer).
[0031] Binary features are concatenated with continuous embedding vectors to form the position encoding vectors of each node. These position encoding vectors are then combined with the initial input features of the nodes (such as geometric features, physical field features, etc.) and input into the graph attention network. The total dimension after concatenation can range from 15 to 35 dimensions to balance information content and computational complexity; for example, the aforementioned 11-dimensional node features and 8-dimensional position encoding vectors form 19-dimensional input data.
[0032] In the die-casting filling process, the multi-flow confluence zone is highly susceptible to gas and oxide scale entrainment due to the encounter of molten metal fronts. Meanwhile, the distal end and the venting slag pack area, as the filling endpoints, are areas with low molten metal temperature, poor fluidity, and where gas is easily pushed, making both high-risk areas for porosity defects. Steps S100 and S200 incorporate prior knowledge of the filling path. The position encoding vector integrates regional topological attributes and filling path distances into the model in a learnable embedding form, enabling the model to directly perceive high-risk physical boundaries such as the distal gate area and confluence zone in die-casting fluid dynamics, thereby improving the accuracy of porosity defect identification in these areas.
[0033] During die casting, the multi-flow confluence zone is prone to gas entrapment due to the encounter of molten metal at the front end. The distal end and the slag venting area, as the filling endpoints, have lower molten metal temperatures, poorer fluidity, and are prone to gas accumulation and compression; both are high-risk physical boundaries with high porosity. The distance of the filling path directly affects the porosity risk (insufficient filling at the distal end), and whether the area is connected to the ingate determines the priority of pressure transmission. Location coding, by incorporating this prior industrial knowledge, enables the model to directly perceive these high-risk physical boundaries, rather than relying solely on data-driven passive learning.
[0034] Compared to one-hot encoding (fixed 3 dimensions, forced orthogonality between categories, and inability to express similarity), learnable embedding layers can automatically learn similarity measures between categories during training (e.g., the embedding vectors of the near end and the middle end will automatically move closer in the embedding space due to similar filling behavior), and the embedding dimension is adjustable (15~35 dimensions), which has stronger expressive power. Furthermore, it can be jointly trained with the parameters of the graph attention network and adaptively optimized according to the task.
[0035] To effectively capture the risk propagation characteristics between adjacent regions and enhance spatial context aggregation capabilities, in some specific embodiments of this application, in step S300, the multi-layer graph attention message passing employs the graph attention network V2 convolution operator (GATv2Conv) to capture the correlation strength between the filling state and stomatal evolution between adjacent sub-regions. Its attention coefficients are dynamically calculated based on the concatenation of features of the target node and adjacent source nodes, followed by linear mapping and nonlinear activation. The multi-layer graph attention message passing is composed of multi-layer graph attention calculation layers connected in series. The graph attention network can contain 2 to 4 layers, with 2 to 8 attention heads in each layer and a hidden layer dimension of 16 to 64, without FiLM modulation. Each layer sequentially performs attention feature aggregation, batch normalization, ELU activation, and residual connection operations. The explicit edge weights between adjacent nodes are calculated based on the three-dimensional spatial physical distance between sub-regions using a Gaussian distance kernel and are fused with the attention coefficients during message passing for node feature weighted aggregation. The weighted aggregation mechanism accurately simulates the spatial attenuation effect of the physical field during die casting and suppresses long-distance noise by adaptively adjusting the feature contribution of adjacent regions. This enables the model to effectively capture the spatial local aggregation and propagation law of porosity defects, thereby significantly improving the accuracy of porosity distribution prediction.
[0036] Specifically, the multi-layer graph attention message passing uses the GATv2Conv operator: the attention coefficients are dynamically calculated based on the concatenation of features of the target node and its neighboring source nodes, followed by linear mapping and nonlinear activation; the model is stacked in 2 to 4 layers, with 2 to 8 attention heads in each layer and 16 to 64 hidden layer dimensions; each layer sequentially performs attention feature aggregation → batch normalization → ELU activation → residual connection; the explicit edge weights between adjacent nodes are calculated based on the three-dimensional physical distance between sub-regions using a Gaussian distance kernel, and are fused with the attention coefficients during message passing (i.e., both participate in the weighted aggregation of node features, rather than simple addition or substitution), to adaptively adjust the feature contribution of adjacent regions, simulate the physical field spatial attenuation effect, and suppress long-distance noise.
[0037] In the embodiments described above, the attention coefficients of each layer of the multi-layer graph attention network are dynamically calculated based on the features of query nodes and key nodes, effectively capturing the physical field coupling relationship and porosity risk correlation between adjacent regions; the edge weights between adjacent regions are calculated using a Gaussian distance kernel, reflecting the distance decay characteristics of the spatial physical association between regions.
[0038] To address the issue of high failure rate in sparse castings, in some specific embodiments of this application, reference is made to... Figure 5 For step S400, in the step of increasing the sampling weight, the sparsity threshold... The sampling weight boost factor is used as a configurable training hyperparameter, which is preset based on the statistical distribution characteristics of porosity defects in the training dataset; When constructing the training batch, casting samples with zero positive sample nodes are filtered out, and only those positive sample nodes that meet the requirement are processed. The weighting of the casting samples was increased.
[0039] Specifically, in the training phase of step S400, the number of positive sample nodes for each casting is counted, and the number of positive sample nodes satisfies... The sampling weight of the castings (sparse castings) is increased during batch sampling, and the sparsity threshold is increased. The value ranges from 3 to 15 positive sample nodes, and the sampling weight boost factor ranges from 3 to 10 times, for example, 6 times. The oversampling mechanism is implemented through weighted random sampling, without changing the actual composition of the original training dataset, so that sparse castings are sampled more frequently in the training batch, improving the model's ability to recognize low-frequency sparse porosity patterns.
[0040] It should be noted that the sparsity threshold and sampling weight boost factor are configurable parameters that can be flexibly adjusted according to the sparsity of the training pore distribution.
[0041] In actual die-casting production, castings are typically mass-produced, with the vast majority being defect-free and normal castings. Furthermore, die-cast parts (such as automotive structural components and aerospace parts) have extremely high safety requirements; failing to detect even a casting containing minute porosity can lead to serious structural failure. Existing technologies typically evaluate performance only using node-level AUC, neglecting casting-level recall as a core evaluation metric. This results in an optimization direction inconsistent with the core industrial requirement of "not missing any porosity castings." To ensure that the model optimization direction aligns with the zero-defect delivery requirement for die-cast safety parts, in some specific embodiments of this application, the model training phase in step S400 further includes the following steps: K-fold cross-validation (K can be 3 to 10) is used to evaluate the model performance. The training set and validation set are divided according to the casting as a whole, so that nodes of the same casting are not simultaneously assigned to the training set and the validation set. The node-level AUC and casting-level recall of the validation set are calculated. The casting-level recall is the arithmetic mean of the positive sample node recall calculated independently for each casting, reflecting the core industrial requirement of not missing any porosity castings. The optimal network structure is determined iteratively through hyperparameter search (at least 30 searches) based on node-level AUC and casting-level recall.
[0042] Specifically, the node-level metric aggregates all nodes from all castings into a single node pool for unified calculation (e.g., 200 groups × 36 nodes = 7200 nodes), regardless of which casting a node belongs to. All 36 nodes of a zero-defect casting have negative labels, and they still participate in this unified calculation as usual. For recall, nodes of zero-defect castings have no positive samples and contribute neither TP nor FN, so they have no direct impact on the value of node-level recall (the numerator and denominator remain unchanged). For F1 (which depends on precision), if the model falsely reports positive (FP) at nodes that should be negative samples, it will lower the overall precision and thus lower the F1. Therefore, the nodes of zero-defect castings indirectly affect F1 (through the false alarm rate). Regarding AUC, AUC depends on the overall ranking ability of positive and negative samples. Zero-defect castings contribute a large number of real negative samples, which participate in the calculation of the negative sample side of the ROC curve and are included normally.
[0043] In other words, node-level metrics do not require any special exclusion of zero-defect castings; they naturally participate in the unified calculation as negative samples.
[0044] The definition of casting-level recall rate is to calculate the recall rate individually for each casting with porosity and then take the average. Zero-defect castings (n...) pos =0) Because the denominator (the actual number of pore nodes) is 0, Recall cannot be defined, so it is not included in the numerator and denominator statistics of this mean, that is, it is naturally excluded from the casting-level Recall index.
[0045] F1 is the harmonic mean of node-level precision and recall, used to balance false positives and false negatives at a selected decision threshold, compensating for the insensitivity to false positives when recall is used alone.
[0046] It should be noted that the three metrics do not need to be optimal simultaneously, but rather have a clear priority order: node-level Recall (core business metric, with the highest cost for missing defective castings) > node-level AUC (primary guiding metric in the hyperparameter search phase, not dependent on specific thresholds) > node-level F1 (auxiliary monitoring metric for threshold rationality). Training and hyperparameter search primarily optimize node-level AUC, with final acceptance based on node-level Recall, and F1 serving as a process monitoring metric.
[0047] By using casting-level recall as a supplementary evaluation metric, the prediction method aligns with the core requirement of ensuring no defective castings are missed in industrial production. The oversampling mechanism addresses the issue of sparse porosity by increasing the batch sampling weight for sparse castings, improving the model's learning of low-frequency porosity patterns and significantly reducing the missed detection rate for sparse castings. Experimental data show that the casting-level recall rate significantly improved from 0.777 to 0.855, reducing the casting-level missed detection rate by approximately 7.8 percentage points.
[0048] To ensure the stability and accuracy of the prediction results during the inference stage, in some specific embodiments of this application, step S500 further includes a step of performing inference data preprocessing. Specifically, this includes: Load the feature normalization parameters saved during the model training phase, and perform the same numerical transformation as during the training phase on the node features of the inference input, which include die casting process parameters and geometric properties, to eliminate the differences between different physical dimensions. Read the pre-stored feature name index list from the training phase, and align the node feature vectors of the inference input according to the dimensional order of the index list to prevent prediction failure due to inconsistent feature order, and ensure that the dimensions of the process and geometric feature inputs during inference are consistent with those during the model training phase.
[0049] To provide an intuitive basis for quality assessment and support process optimization, in some specific embodiments of this application, after independently outputting the porosity probability values of each node in step S500 for the casting to be predicted, a step of generating a spatial distribution map of porosity risk is also included. Specifically, using the geometric contour of the casting as a base map, the porosity probability values corresponding to each node are mapped to spatial coordinate positions to generate a spatial distribution map of porosity risk.
[0050] Specifically, the feature vectors of each node output by the graph attention network are mapped to binary classification logical values through a fully connected classification head. The porosity probability value of each node is then normalized using the Softmax function, with the probability value ranging from 0 to 1. Based on a preset probability threshold, each node is judged to be porosity, and nodes with a probability higher than the threshold are identified as porosity nodes. The judgment results of each node are summarized to support casting-level porosity risk assessment. The output module also supports generating a casting porosity risk heat map, using the casting outline as the base map and the porosity probability of each node as the coloring basis, to output a spatial distribution map of casting porosity risk.
[0051] Compared to methods that only output casting-level classification results, the embodiments of this application provide a finer spatial resolution by outputting node-level porosity probability, supporting differentiated evaluation and providing regional-level quantitative decision-making basis for process optimization.
[0052] The embodiments described above in this application achieve accurate prediction of the probability of porosity defects in each sub-region of the casting by fusing the location encoding vector of the region topology attribute and the filling path distance, as well as the oversampling weight adjustment mechanism for sparse porosity castings, thereby realizing node-level porosity defect binary classification and casting-level porosity risk assessment.
[0053] Based on the same technical concept, another embodiment of this application provides a die-casting porosity spatial distribution prediction system based on graph neural networks, referring to... Figure 9 The die casting porosity spatial distribution prediction system 10 based on graph neural networks includes: Graph structure construction module 11 is used to divide the casting into multiple sub-regions as nodes in the graph structure and construct the edges of the graph structure based on the spatial adjacency relationship between regions. The node location encoding module 12 is used to obtain the initial features of the node, map the category features representing the filling path distance into a continuous embedding vector through a learnable embedding layer, and combine it with the binary features representing the topological attributes of the region to generate a location encoding vector; the location encoding vector is concatenated with the initial features to obtain the node input features; The graph attention message passing module 13 is used to input node input features into the graph attention network to perform multi-layer message passing and output the stomatal probability prediction value of each node. The sparse casting oversampling module 14 is used to increase the sampling weight of casting samples whose number of positive sample nodes is not greater than the sparse threshold when constructing training batches; the loss is calculated based on the predicted value of porosity probability and the true label, and the parameters of the graph attention network and the learnable embedding layer are updated in reverse. The node-level porosity probability output module 15 is used to independently output the porosity probability value of each node of the casting to be predicted using the trained network, so as to obtain the spatial distribution prediction result of porosity.
[0054] 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 spatial distribution prediction method based on graph neural networks in the above embodiments, and will not be repeated here.
[0055] The system in the above embodiments of this application supports two deployment modes: the first is an independent deployment mode, where the input is known physical field characteristics (including real physical field characteristics output by simulation software or measured characteristics). This deployment mode is suitable for scenarios where simulation data is available but rapid inference is not required, demonstrating the system's independent applicability. The second is a serial deployment mode, where the prediction system acts as the second-stage component of a two-stage framework. The input can be the predicted physical field characteristics output by the first-stage component (such as a physics-based neural network or traditional fluid simulation software). The core structure of the system remains unchanged under both deployment modes; only the input data source needs to be adjusted, allowing for flexible adaptation to different industrial application scenarios.
[0056] 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.
[0057] The following examples and comparative 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.
[0058] Application Example 1: This application example focuses on predicting the spatial distribution of porosity in magnesium alloy die-casting parts, as detailed below: (1) Casting area division and diagram structure The AZ91D magnesium alloy die-casting parts were divided into 36 sub-regions (B1-B36). A graph structure was constructed based on physical connectivity, and edge weights were calculated using a Gaussian distance kernel, with weights ranging from 0.896 to 0.994. Each sub-region was classified into topological attributes based on the characteristics of the filling path: ingate direct filling area (B1-B5), multi-flow confluence area (the area where filling flows intersect), venting slag bag area (the area connecting the slag bag), and ordinary filling area; the filling path distance was classified into three categories: near end, middle end, and far end according to the filling sequence with respect to the ingate.
[0059] (2) Location encoding construction Binary topological attribute features: Each region is assigned a value of 0 or 1 according to four types of topological attributes, forming a 4-dimensional binary feature vector; Filling distance embedding: Each of the three types of filling distance (near / medium / far) corresponds to a learnable embedding vector, and the embedding dimension is set to 4 dimensions; The 4-dimensional binary features are combined with the 4-dimensional embedding vector to form an 8-dimensional position encoding vector, which is then combined with the 11-dimensional node input features and fed into the graph attention network through the input projection layer.
[0060] (3) Node input features Since the values of physical field quantities such as P1 (baseline pressure) are uniquely determined by process parameters (not dependent on geometric features and message passing process), there is no need to predict through graph neural network regression. The normalized process parameter values can be directly and deterministically transmitted to downstream node features. This mechanism of skipping the first stage of physical field regression and transmitting directly is called bypass transmission.
[0061] The 11-dimensional node features input include: the predicted 4-dimensional continuous physical field features (T13 / V4 / P4 / P5), the 1-dimensional categorical physical field quantity passed by bypass (P1_baseline pressure normalization value), and a 6-dimensional geometric feature subset (G3, G21, G4, G5, G23, G1); these are input into the system after being aligned in the order of the feature name list recorded during training.
[0062] The above geometric feature statistics are not based on a single casting, but rather on the geometric features of all 36 regions. Wherein: G3 = Shape Factor (derived from the volume / surface area relationship); G21 = Maximum curvature; G4 = Bounding box dimension in the X direction; G5 = Bounding box dimension in the Y direction; G23 = Average curvature; G1 = Volume.
[0063] (4) Oversampling of sparse castings The distribution of the number of positive sample nodes for each casting in the statistical training set is analyzed, and a sparsity threshold is set. Sampling weight increase factor Training batches are constructed using weighted random sampling, with sparse castings ( The sampling weight of the casting is 6 times that of the normal casting.
[0064] (5) Model training and validation The graph attention network stacks two layers of GATv2Conv and employs a multi-head attention mechanism; the optimal network size is determined by performing no less than 50 hyperparameter searches (3-fold cross-validation) using Optuna. 50% cross-validation results: node-level AUC = 0.9419, casting-level Recall = 0.855; E3 serves as the control group for oversampling ablation: that is, a control experiment that removes the oversampling mechanism of sparse castings while preserving the graph structure and positional coding, used to independently verify the contribution of the oversampling mechanism to the casting-level missed detection rate (E3 casting-level Recall = 0.777, significantly lower than 0.855 of the complete method).
[0065] Figure 7 Figure 1 shows the results of the graph structure ablation experiment: E1 = complete method (including graph attention message passing); E2 = control group without graph structure (node-independent multilayer perceptron MLP, no message passing, only node features are used to predict stomatal probability), used to verify the contribution of graph attention message passing mechanism to stomatal prediction.
[0066] like Figure 6 and Figure 7 As shown, the casting-level Recall of the ablation experiment control group (removing sparse oversampling, E3 without oversampling) was 0.777, verifying the significant contribution of the oversampling mechanism to reducing the casting-level false negative rate. Figure 7 The study compares the graph-based (GATv2Conv, E1) and graph-free (node-independent MLP, E2) structures in terms of four metrics: node-level AUC, F1, node-level Recall, and casting-level Recall, verifying the contribution of the graph message passing mechanism to capturing the porosity risk correlation between regions.
[0067] The prediction results of the spatial distribution of the probability of porosity in castings are as follows: Figure 8As shown. Figure 8 The spatial distribution of the predicted porosity probability of 36 node regions in a typical casting on the casting outline is shown. The node colors, black and white, correspond to the high and low porosity probabilities (black for high risk, white for low / no risk). Key areas with high probabilities in the predicted results (such as multi-flow confluence areas, venting slag packs at the far gate, etc.) are marked. The results are compared with the actual X-ray flaw detection results to verify the consistency between the predicted spatial distribution and the actual defect distribution.
[0068] Application Example 2: This application example focuses on predicting the spatial distribution of porosity in aluminum alloy die-casting parts, as detailed below: For AlSi9Cu3 aluminum alloy die castings, the same system structure as in Application Example 1 is adopted. The topological attribute categories are redefined based on the actual filling path of the casting, and the sparsity threshold is adjusted to adapt to the porosity distribution density characteristics of the casting. Accurate prediction of the spatial distribution of porosity in AlSi9Cu3 aluminum alloy die castings can be achieved without modifying the core design of the system. This embodiment verifies the general applicability of this system to different alloy systems and casting geometries, demonstrating the scalability of the positional coding framework for different casting structures.
[0069] Based on the same technical concept, in other embodiments 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. When the processor executes the program, it can be used to perform the methods in any of the above embodiments.
[0070] Based on the same technical concept, in other embodiments of this application, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, can be used to perform the methods in any of the above embodiments.
[0071] 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.
[0072] 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.
[0073] 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.
[0074] 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.
[0075] 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.
[0076] 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.
[0077] 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.
[0078] 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.
[0079] 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 the spatial distribution of porosity in die casting based on graph neural networks, characterized in that, include: The casting is divided into multiple sub-regions as nodes in a graph structure, and the edges of the graph structure are constructed based on the spatial adjacency relationship between the regions. The initial features of the node are obtained. The category features representing the path distance are mapped into continuous embedding vectors through a learnable embedding layer and combined with the binary features representing the topological attributes of the region to generate a location encoding vector. The location encoding vector is concatenated with the initial features to obtain the node input features. The node input features are input into the graph attention network to perform multi-layer message passing and output the stomatal probability prediction value of each node. When constructing training batches, increase the sampling weight for casting samples whose number of positive sample nodes is no greater than the sparse threshold; Based on the predicted stomatal probability value and the actual label, the loss is calculated, and the parameters of the graph attention network and the learnable embedding layer are updated in reverse. The trained network is used to independently output the porosity probability value of each node of the casting to be predicted, and the spatial distribution prediction result of porosity is obtained.
2. The method for predicting the spatial distribution of porosity in die casting based on graph neural networks according to claim 1, characterized in that, The binary features representing the topological attributes of the region include: the ingate direct filling zone, multi-flow confluence zone, connected slag bag zone, and other filling zones to which the region belongs; The category feature representing the filling path distance is obtained by discretizing the filling path distance between each region and the ingate according to a preset threshold range, resulting in multiple distance categories.
3. The method for predicting the spatial distribution of porosity in die casting based on graph neural networks according to claim 1, characterized in that, The multi-layer graph attention message passing uses the graph attention network V2 convolution operator to capture the correlation strength between the filling state and stomatal evolution between adjacent sub-regions. Its attention coefficient is obtained by linear mapping and nonlinear activation dynamic calculation after concatenating the features of the target node and the adjacent source node. The multi-layer graph attention message passing is composed of multi-layer graph attention computation layers connected in series, with each layer sequentially performing attention feature aggregation, batch normalization, ELU activation and residual connection operations; The explicit edge weights between adjacent nodes are calculated based on the three-dimensional spatial physical distance between sub-regions using a Gaussian distance kernel to characterize the spatial attenuation effect of molten metal flow and heat conduction during die casting. They are also fused with the attention coefficient during message passing for node feature weighted aggregation.
4. The method for predicting the spatial distribution of porosity in die casting based on graph neural networks according to claim 1, characterized in that, In the step of increasing the sampling weight, the sparse threshold and the sampling weight increase factor are used as configurable training hyperparameters and are preset according to the statistical distribution characteristics of pore defects in the training dataset. When constructing the training batch, casting samples with zero positive sample nodes are filtered out, and weight boosting is performed only on casting samples with a positive sample node count greater than zero and not greater than the sparse threshold.
5. The method for predicting the spatial distribution of porosity in die casting based on graph neural networks according to claim 1, characterized in that, The model training phase also includes: K-fold cross-validation is used to evaluate the model performance. The training set and validation set are divided according to the casting as a whole, so that nodes of the same casting are not simultaneously assigned to the training set and the validation set. Calculate the node-level AUC and casting-level recall of the validation set, wherein the casting-level recall is the arithmetic mean of the positive sample node recall calculated independently for each casting. The optimal network structure is determined through hyperparameter search iteration based on the node-level AUC and the casting-level recall.
6. The method for predicting the spatial distribution of porosity in die casting based on graph neural networks according to claim 1, characterized in that, It also includes the step of performing inference data preprocessing, specifically: Load the feature normalization parameters saved during the model training phase, and perform the same numerical transformation as during the training phase on the node features of the inference input, which include die casting process parameters and geometric properties, to eliminate the differences between different physical dimensions. Read the feature name index list stored in the training phase, and align the node feature vectors of the inference input according to the dimensional order of the index list to ensure that the dimensions of the process and geometric feature inputs during inference are consistent with those during the model training phase.
7. The method for predicting the spatial distribution of porosity in die casting based on graph neural networks according to claim 1, characterized in that, After using the trained network to independently output the porosity probability values of each node in the casting to be predicted, the following steps are also included: Using the geometric contour of the casting as the base map, the porosity probability value corresponding to each node is mapped to the spatial coordinate position to generate a spatial distribution map of porosity risk.
8. A die-casting porosity spatial distribution prediction system based on graph neural networks, characterized in that, include: The graph structure construction module is used to divide the casting into multiple sub-regions as nodes in the graph structure, and to construct the edges of the graph structure based on the spatial adjacency relationship between regions. The node location encoding module is used to obtain the initial features of the node, map the category features representing the filling path distance into a continuous embedding vector through a learnable embedding layer, and combine it with the binary features representing the topological attributes of the region to generate a location encoding vector; the location encoding vector is concatenated with the initial features to obtain the node input features; The graph attention message passing module is used to input the node input features into the graph attention network to perform multi-layer message passing and output the stomatal probability prediction value of each node. The sparse casting oversampling module is used to increase the sampling weight of casting samples whose number of positive sample nodes is not greater than the sparse threshold when constructing training batches. Based on the predicted stomatal probability value and the actual label, the loss is calculated, and the parameters of the graph attention network and the learnable embedding layer are updated in reverse. The node-level porosity probability output module is used to independently output the porosity probability value of each node of the casting to be predicted using the trained network, so as to obtain the spatial distribution prediction result of porosity.
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 the program is executed by a processor, it can be used to perform the method of any one of claims 1-7.
