Method, device, medium and electronic equipment for encapsulating and servicing hydrodynamic models
By encapsulating the hydrodynamic model as a class and providing an HTTP interface for verification and prediction, and using the FastAPI framework to handle multi-tasking, the problems of difficult integration and low computational efficiency of traditional hydrodynamic models are solved, and the convenient and efficient deployment of hydrodynamic models is achieved. application.
Patent Information
- Application Number
- CN202410443747.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-13
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-04-13
AI Technical Summary
Traditional hydrodynamic models have problems such as integration difficulties, high resource consumption, and low computational efficiency in practical applications, making deployment and application difficult.
By encapsulating the hydrodynamic model as a class and providing an HTTP interface for verification and prediction, the integrity and correctness of the input data is ensured. The FastAPI framework is used to handle multi-tasking and avoid resource competition, and the model is service-oriented and remotely called.
It reduces the difficulty of deploying and applying hydrodynamic models, improves calculation efficiency and resource utilization, and enables convenient integration and sharing of hydrodynamic models.
Smart Images

Figure CN118113340B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of model packaging technology, and in particular to a method, device, medium and electronic equipment for packaging and servicing a hydrodynamic model. Background Art
[0002] With the rapid development of water conservancy engineering, environmental engineering, marine engineering and other fields, hydrodynamic models, as important numerical simulation tools, play an indispensable role in predicting and analyzing hydrological processes such as water flow and water quality. It can simulate complex flow phenomena in different waters and provide a scientific basis for decision-making. Among them, the hydrodynamic model refers to a mathematical model that describes the relationship between the force and movement of water flow. It is based on the basic equations of fluid mechanics and simulates the dynamic process of flowing water by establishing a set of mathematical equations. With the continuous development of computer technology, hydrodynamic models can be used in more practical application scenarios. Among them, hydrodynamic models are often widely used in the simulation and prediction of water flow and water quality in rivers, lakes, reservoirs, offshore waters and other waters.
[0003] At present, when hydrodynamic models are applied to actual application scenarios, they often need to face users' complex and changeable prediction or simulation needs. Accordingly, more professional hydrodynamic model configuration and analysis are required to further match the needs. However, due to the problems of traditional hydrodynamic models such as difficulty in integration, high resource consumption and low computational efficiency, it is difficult to deploy and apply hydrodynamic models. Summary of the invention
[0004] In order to reduce the difficulty of deploying and applying hydrodynamic models, the present application provides a method, device, medium and electronic device for encapsulating and servitizing a hydrodynamic model.
[0005] In a first aspect of the present application, a method for encapsulating and servitizing a hydrodynamic model is provided, which specifically includes:
[0006] The current hydrodynamic model to be deployed is encapsulated into a class to obtain a hydrodynamic model target class;
[0007] Receiving target request parameters input by a user terminal through the HTTP interface of the hydrodynamic model target class, and verifying the target request parameters to obtain verified parameters, wherein the target request parameters are request parameters corresponding to the target water state simulation task;
[0008] According to the actual task identifier and the upstream model identifier of the target water state simulation task in the verified parameters, the output result of the upstream hydrodynamic model of the current hydrodynamic model in the same target water state simulation task is obtained, and the target field in the verified parameters is parsed to obtain the parsing result, wherein the target field includes the water inflow rate of the current region corresponding to the current hydrodynamic model, and the upstream model identifier is the model identifier of the upstream hydrodynamic model on which the current hydrodynamic model depends;
[0009] Based on the acquisition of the output result and the analysis result, actual inflow boundary information corresponding to the current hydrodynamic model is obtained, and the hydrodynamic model target class is instantiated to obtain preset inflow boundary information corresponding to the current hydrodynamic model;
[0010] If the preset inflow boundary information is consistent with the actual inflow boundary information, then determining the actual regional model file corresponding to the target water state simulation task, loading the actual regional model file through the instantiated hydrodynamic model target class and predicting the outflow boundary of the current hydrodynamic model to obtain a prediction result;
[0011] When the prediction result is in a normal state, the prediction result, the actual task identifier and the model identifier of the current hydrodynamic model are combined and added to a preset database.
[0012] By adopting the above technical solution, the current hydrodynamic model is encapsulated into a class to obtain the hydrodynamic model target class, so as to facilitate the subsequent remote call of the current hydrodynamic model function, and then the target request parameters are verified to ensure the integrity and correctness of the model input data. Further, according to the acquisition of the output results and the analysis results, the actual inflow boundary information of the current hydrodynamic model is finally determined. If the actual inflow boundary information is consistent with the preset inflow boundary information, and then the actual inflow boundary information is verified to be correct, then based on this actual inflow boundary information, the regional model file corresponding to the current region is determined, that is, the actual regional model file corresponding to the target water state simulation task. Further, the hydrodynamic model target class is instantiated, and its corresponding methods are called for specific use. The current hydrodynamic model makes predictions based on the actual regional model file, thereby executing the target water state simulation task. If the prediction result is normal, it means that the current hydrodynamic model simulates the current area correctly. Then the prediction result, the actual task identifier and the model identifier of the current hydrodynamic model are added to the database, and finally the current hydrodynamic model is encapsulated and serviced, so as to better call and integrate the hydrodynamic model and reduce the difficulty of deploying and applying the hydrodynamic model.
[0013] Optionally, verifying the target request parameters to obtain verified parameters specifically includes:
[0014] Performing integrity check on the target dictionary key value corresponding to the target request parameter;
[0015] After the integrity check is passed, a format check is performed on the data corresponding to each field in the target request parameter, and after the format check is passed, the checked parameters are obtained.
[0016] By adopting the above technical solution, if the integrity check passes, it means that the data in the target request parameters are complete. Furthermore, the data corresponding to each field in the target request parameters is format checked. If the format check passes, it means that the format of each data in the target request parameters is standardized. Then, the checked parameters are finally obtained, thereby ensuring the correctness and security of the data in the target request parameters to a certain extent.
[0017] Optionally, the method further includes:
[0018] Build FastAPI based on Python, and determine FastAPI as the backend framework;
[0019] If the preset inflow boundary information is inconsistent with the actual inflow boundary information, an exception log is generated and submitted to the FastAPI.
[0020] By adopting the above technical solution, FastAPI is determined as the backend framework, so that its high performance and asynchronous care capabilities can be used to support the simultaneous processing of multiple water state simulation tasks, avoiding resource competition and performance bottlenecks of multiple simulation tasks and multiple hydrodynamic models. Furthermore, if the preset inflow boundary information is inconsistent with the actual inflow boundary information, indicating that the actual inflow boundary information is incorrect, then an abnormal log is generated and submitted to this FastAPI to expose it to the user, thereby better reminding the user.
[0021] Optionally, the operation of encapsulating the current hydrodynamic model to be deployed into a class to obtain a hydrodynamic model target class includes:
[0022] Compile the current hydrodynamic model to be deployed into a dynamic library with the dll suffix;
[0023] Encapsulating the interface corresponding to the dynamic library through a preset ctypes library to obtain a corresponding encapsulated interface;
[0024] Based on the instantiated first preset class, the instantiated second preset class and the instantiated third preset class, the externally inputted information required for regional simulation is received, wherein the first preset class is a class for recording the key process status of the current hydrodynamic model, the second preset class is a regional model file for statistics of the current hydrodynamic model, and the third preset class is a class for standardized output of the current hydrodynamic model;
[0025] Based on the preset logical rules, a fourth preset class is defined, wherein the fourth preset class can simulate the water state through the current hydrodynamic model based on the information required for the regional simulation, and collect all calculation results returned when the current hydrodynamic model is running;
[0026] Based on the instantiated first preset class, the instantiated second preset class, the instantiated third preset class, the fourth preset class, the dynamic library and the encapsulated interface, a hydrodynamic model target class is determined.
[0027] By adopting the above technical solution, the current hydrodynamic model is compiled into a dynamic library, thereby isolating the algorithm corresponding to the current hydrodynamic model, making the call more convenient. Then, the interface of the dynamic library is encapsulated through the ctypes library, thereby providing users with a more simplified interface, which is convenient for calling through the interface. Furthermore, through the instantiation of the first preset class, the second preset class, the third preset class and the defined fourth preset class, after the external input of the required information for regional simulation, the regional model file can be successfully read to smoothly perform water state simulation, and then the hydrodynamic model target class can be finally obtained, so that the hydrodynamic model can be quickly deployed and applied by directly calling the hydrodynamic model target class in the future, and various water state simulation tasks can be achieved.
[0028] Optionally, before receiving externally inputted regional simulation information based on the instantiated first preset class, the instantiated second preset class and the instantiated third preset class, the method further includes:
[0029] Instantiate the first preset class, and initialize the state of the LoadFile function corresponding to the first preset class to False, to obtain the instantiated first preset class;
[0030] Instantiating the second preset class to obtain the instantiated second preset class, so that when the state of the LoadFile function is converted to True, the instantiated second preset class obtains the number of sections in the current region;
[0031] The third preset class is instantiated to obtain the instantiated second preset class, so that the instantiated third preset class is output in a standardized manner based on the number of sections when the LoadFile function state is converted to True.
[0032] By adopting the above technical solution, the state of the LoadFile function corresponding to the first preset class is initialized to False, so that the loading status of the file can be better judged. After the second preset class is instantiated, when the state of the LoadFile function is converted to True, it means that the dynamic library has been successfully loaded, and the number of sections in the current region in the file is obtained. Furthermore, after the third preset class is instantiated, when the state of the LoadFile function is converted to True, it means that the dynamic library is successfully loaded and the instantiated second preset class successfully obtains the number of sections, then the current hydrodynamic model is controlled to perform standardized output, thereby completing the water state simulation of the model, and then the methods defined in the three preset classes can be used specifically, which is convenient for subsequent direct calls and integration.
[0033] Optionally, the information required for the regional simulation includes the regional simulation start time, the regional simulation end time and the input regional model file, and the logical rule is:
[0034] Reading the regional simulation start time, the regional simulation end time and the input regional model file, and based on the regional simulation start time and the input regional model file, controlling the current hydrodynamic model to perform water state simulation at a specified time interval to obtain a current calculation result returned by the current hydrodynamic model;
[0035] Comparing the return time of the current calculation result with the end time of the regional simulation;
[0036] If the return time is earlier than the end time of the regional simulation, the step of controlling the current hydrodynamic model to perform water state simulation at a specified time interval based on the regional simulation start time and the input regional model file is repeatedly executed until the return time is no earlier than the end time of the regional simulation.
[0037] By adopting the above technical solution, if the return time of the current calculation result is earlier than the end time of the regional simulation, it means that the water state simulation of the current region through the current hydrodynamic model has not been completed, then the steps of controlling the current hydrodynamic model to perform water state simulation at the specified time interval based on the regional simulation start time and the input regional model file are repeatedly executed until the return time is no earlier than the end time of the regional simulation. Among them, if the return time is no earlier than the end time of the regional simulation, it means that the water state simulation of the current region through the current hydrodynamic model has been completed, then the water state simulation is terminated, and finally all the calculation results collected in the entire water state simulation process can be obtained.
[0038] Optionally, the determining of the actual regional model file corresponding to the target water state simulation task specifically includes:
[0039] Selecting target boundary information of an upstream hydrodynamic model on which the current hydrodynamic model depends from the verified parameters;
[0040] Based on the target boundary information and the actual inflow boundary information, an actual area model file corresponding to the target water state simulation task is generated.
[0041] By adopting the above technical solution, since the outflow of the upstream hydrodynamic model will become the inflow condition of the current hydrodynamic model, the target boundary information will directly affect the water state simulation of the current hydrodynamic model. Therefore, after the actual inflow boundary information is correct, the actual regional model file of the current hydrodynamic model is obtained according to the target boundary information of the upstream hydrodynamic model and the actual inflow boundary information of the current hydrodynamic model, so that the subsequent current hydrodynamic model can accurately simulate the water state according to the actual inflow boundary information.
[0042] In a second aspect of the present application, a device for encapsulating and servicing a hydrodynamic model is provided, specifically comprising:
[0043] The model encapsulation module is used to encapsulate the current hydrodynamic model to be deployed into a class to obtain the hydrodynamic model target class;
[0044] A request verification module, used to receive target request parameters input by a user terminal through the HTTP interface of the hydrodynamic model target class, and verify the target request parameters to obtain verified parameters, wherein the target request parameters are request parameters corresponding to the target water state simulation task;
[0045] A result determination module is used to obtain the output result of the upstream hydrodynamic model of the current hydrodynamic model in the same target water state simulation task according to the actual task identifier and the upstream model identifier of the target water state simulation task in the verified parameters, and parse the target field in the verified parameters to obtain the parsing result, wherein the target field includes the water inflow rate of the current region corresponding to the current hydrodynamic model, and the upstream model identifier is the model identifier of the upstream hydrodynamic model on which the current hydrodynamic model depends;
[0046] A boundary determination module, used to obtain actual inflow boundary information corresponding to the current hydrodynamic model based on the acquisition of the output result and the analysis result, and to instantiate the hydrodynamic model target class to obtain preset inflow boundary information corresponding to the current hydrodynamic model;
[0047] A result output module is used to determine the actual regional model file corresponding to the target water state simulation task if the preset inflow boundary information is consistent with the actual inflow boundary information, load the actual regional model file through the instantiated hydrodynamic model target class and predict the outflow boundary of the current hydrodynamic model to obtain a prediction result;
[0048] The result storage module is used to combine the prediction result, the actual task identifier and the model identifier of the current hydrodynamic model and add them to a preset database when the prediction result is in a normal state.
[0049] By adopting the above technical solution, the model encapsulation module encapsulates the current hydrodynamic model into a class to obtain the hydrodynamic model target class, the request verification module verifies the target request parameters to obtain the verified parameters, and then the result determination module obtains the output result of the upstream hydrodynamic model and the analysis result of the target field, and then the boundary determination module determines the actual inflow boundary information and the preset inflow boundary information, and then the result output module determines the actual regional model file corresponding to the target water state simulation task when the preset inflow boundary information is consistent with the actual inflow boundary information and obtains the prediction result, and finally when the prediction result is normal, the prediction result, the actual task identifier and the model identifier of the current hydrodynamic model are combined and added to the preset database.
[0050] In a third aspect of the present application, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is loaded and executed by a processor, the method steps described in any one of the first aspects are performed.
[0051] In a fourth aspect of the present application, an electronic device is provided, specifically comprising:
[0052] A processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the processor is used to load and execute the computer program stored in the memory so that the electronic device performs the method as described in any one of the first aspects.
[0053] In summary, the present application includes at least one of the following beneficial technical effects: instantiating the hydrodynamic model target class, calling its corresponding methods for specific use, and the current hydrodynamic model predicts according to the actual regional model file, thereby executing the target water state simulation task. If the prediction result is normal, it means that the current hydrodynamic model simulates the current region correctly, then the prediction result, the actual task identifier and the model identifier of the current hydrodynamic model are added to the database, and finally the encapsulation and service operation of the current hydrodynamic model is completed, so as to better perform the call integration of the hydrodynamic model and reduce the difficulty of deploying and applying the hydrodynamic model. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 It is a flow chart of a method for encapsulating and servitizing a hydrodynamic model provided in an embodiment of the present application;
[0055] Figure 2 It is a flow chart of another method for encapsulating and servitizing a hydrodynamic model provided in an embodiment of the present application;
[0056] Figure 3 It is a structural schematic diagram of a device for encapsulating and servicing a hydrodynamic model provided in an embodiment of the present application;
[0057] Figure 4 It is a structural schematic diagram of another device for encapsulating and servicing a hydrodynamic model provided in an embodiment of the present application.
[0058] Explanation of the accompanying drawings: 11. Model encapsulation module; 12. Request verification module; 13. Result determination module; 14. Boundary determination module; 15. Result output module; 16. Result storage module; 17. Abnormal reminder module; 18. Instance creation module. DETAILED DESCRIPTION
[0059] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments.
[0060] In the description of the embodiments of the present application, words such as "illustrative", "for example" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "illustrative", "for example" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "illustrative", "for example" or "for example" is intended to present related concepts in a concrete way.
[0061] In the description of the embodiments of the present application, the term "and / or" is only a kind of association relationship describing the associated objects, indicating that there may be three kinds of relationships, for example, A and / or B, which can represent: A exists alone, B exists alone, and A and B exist at the same time. In addition, unless otherwise specified, the meaning of the term "multiple" refers to two or more. For example, multiple systems refer to two or more systems, and multiple screen terminals refer to two or more screen terminals. In addition, the terms "first" and "second" are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the indicated technical features. Thus, the features defined as "first" and "second" can explicitly or implicitly include one or more of the features. The terms "include", "comprise", "have" and their variations all mean "including but not limited to", unless otherwise specifically emphasized.
[0062] See also Figure 1 The present application embodiment discloses a flow chart of a method for encapsulating and servitizing a hydrodynamic model, which can be implemented by a computer program or run on a device for encapsulating and servitizing a hydrodynamic model based on a von Neumann system. The computer program can be integrated into an application or run as an independent tool application, specifically including:
[0063] S101: encapsulate the current hydrodynamic model to be deployed into a class to obtain a hydrodynamic model target class.
[0064] Specifically, the current hydrodynamic model to be deployed refers to a hydrodynamic model that is about to be implemented or applied in an actual scenario, wherein the actual scenario may be a water flow model or flood prediction in a watershed, etc. In other embodiments, the actual scenario may be a scenario such as water quality prediction or water resource management. The current hydrodynamic model may be a one-dimensional hydrodynamic model, and in other embodiments, it may also be a two-dimensional hydrodynamic model. The operation of encapsulating into a class refers to combining data (variables) and behaviors (functions or methods) together to form an independent unit, which is called a "class". In the embodiment of the present application, the current hydrodynamic model is written in C++, and encapsulating into a class refers to encapsulating the current hydrodynamic model into a class through Python to obtain a hydrodynamic model target class, which can better break down the barriers between different programming languages, so that the current hydrodynamic model can be widely used in various platforms and systems, simplifying the subsequent current hydrodynamic model integration and calling process.
[0065] In an achievable implementation, the process of encapsulating into a class is: compiling the current hydrodynamic model into a dynamic library with a dll suffix through a preset compiler, thereby isolating the algorithm corresponding to the current hydrodynamic model, which means that the current hydrodynamic model can be called only through the interface provided by the dynamic library, which is more convenient. Moreover, when the current hydrodynamic model needs to be updated or replaced, only the dynamic library needs to be replaced without modifying the entire application.
[0066] Furthermore, by calling the ctypes library in Python, the dynamic library, that is, the interface provided by the algorithm of the compiled current hydrodynamic model is encapsulated to obtain the encapsulated interface, thereby providing users with a more simplified interface, which is convenient for calling through the interface. The specific interface encapsulation process is: encapsulating the first interface to open the model file to load the regional information and return the status code; encapsulating the second interface to initialize the model to prepare for the calculation and return the status code; encapsulating the third interface to realize the user-specified time interval for model calculation and return the status code; encapsulating the fourth interface to realize the memory release after the model calculation is completed and return the status code; encapsulating the fifth interface to obtain the results of each step of the model calculation, including the cross-sectional water level, water depth, flow, flow velocity, water flow area, and water flow width information; encapsulating the sixth interface to obtain the number of time series; encapsulating the seventh interface to obtain the time series name list, etc.
[0067] Furthermore, the first preset class, the second preset class and the third preset class are implemented by Python, wherein the process of implementing the "class" involves defining classes, adding attributes and method steps. In an embodiment of the present application, the first preset class is a class used to record the key process status of the current hydrodynamic model, so as to monitor the operation of the current hydrodynamic model, ensure the normal calculation of the current hydrodynamic model, and locate operational anomalies. The second preset class is a class used to count the regional model files of the current hydrodynamic model. The regional model file is a file used to define and integrate various types of information required for model simulation in the current hydrodynamic model. The third preset class is a class used to perform standardized output of the current hydrodynamic model. The standardized output includes key parameters related to the water flow in the region obtained by simulating the current hydrodynamic model, specifically, cross-sectional water level (elevation), cross-sectional depth (Depth), cross-sectional flow (Flow), cross-sectional flow velocity (Velocity), cross-sectional area (area), and the like.
[0068] Furthermore, the first preset class, the second preset class and the third preset class are respectively instantiated through Python, wherein the process of instantiating a "class" is mainly to create an instance according to the defined "class", that is, to create a specific object, and the method added in the "class" can be called for specific use. First, the first preset class is instantiated, and the state of the LoadFile function corresponding to the first preset class is initialized to False, and finally the instantiated first preset class is obtained, wherein the LoadFile function in the first preset class is mainly used to load files, including file reading, file parsing and data storage. The state of the LoadFile function is initialized to False, which means that the file has not been loaded yet.
[0069] Instantiate the second preset class, and obtain the instantiated second preset class, so that when the state of the LoadFile function is converted to True, it means that the dynamic library has been successfully loaded, and then parse it through the LoadFile function to obtain the number of sections in the current region. The current region refers to the region corresponding to the current hydrodynamic model. In hydrodynamics, a section refers to the cross-sectional shape of a river, channel, lake or other water body at a specific location.
[0070] Furthermore, the third preset class is instantiated to obtain the instantiated third preset class, so that when its state in the LoadFile function is converted to True, it indicates that the dynamic library is successfully loaded and the instantiated second preset class successfully obtains the number of sections, then a standardized output of the number of sections is created, and the current hydrodynamic model is controlled to output various standardized outputs to complete the water area simulation or prediction of the model.
[0071] Based on the instantiated first preset class, the instantiated second preset class, and the instantiated third preset class, the information required for the regional simulation inputted from the outside is received, which can be understood as the information required for the water state simulation of the model simulating the actual external input at the logical level, wherein the information required for the regional simulation includes the regional simulation start time, the regional simulation end time, and the input regional model file, and in other embodiments, it may also include the number of threads required for the model calculation. The regional simulation start time is the start time of the water state simulation of the current region through the current hydrodynamic model. The regional simulation end time is the end time of the water state simulation of the current region through the current hydrodynamic model. The input regional model file is the regional model file that simulates the actual external input.
[0072] Then, through the preset logical rules, the fourth preset class is defined so that it can simulate the water state through the current hydrodynamic model according to the information required for regional simulation, and collect all calculation results returned when the current hydrodynamic model is running, that is, the standardized output of the current hydrodynamic model.
[0073] Among them, in the embodiment of the present application, the logical rule is specifically: read the regional simulation start time, the regional simulation end time and the input regional model file, and at the regional simulation start time, according to the read input regional model file, control the current hydrodynamic model to simulate the water state at the specified time interval, and obtain the current calculation result returned by the current hydrodynamic model, specifically, read the regional simulation start time, the regional simulation end time and the input regional model file through the LoadFile function in the instantiated first preset class, wherein, after reading the input regional model file, the state of the LoadFile function is switched to True, indicating that the input regional model file is successfully loaded, and the current hydrodynamic model can be called to simulate the water state. Further, the number of sections in the current region can be obtained through the instantiated second preset class, and the water state of the corresponding current region is simulated by the current hydrodynamic model according to the specified time interval set in advance, and the standardized output of the number of sections is output, which is specifically realized by the instantiated third preset class. Among them, the current calculation result returned after the current hydrodynamic model simulation at the current time is collected, and the current calculation result is collected in a dictionary format. It should be noted that the process of reading files through the LoadFile function is implemented based on the encapsulated interface.
[0074] Furthermore, if the return time of the current calculation result is earlier than the end time of the regional simulation, it means that the water state simulation of the current region through the current hydrodynamic model has not yet ended, then the steps of controlling the current hydrodynamic model to perform water state simulation at the specified time interval based on the regional simulation start time and the input regional model file are repeatedly executed until the return time is no earlier than the end time of the regional simulation. Among them, if the return time is no earlier than the end time of the regional simulation, it means that the water state simulation of the current region through the current hydrodynamic model has ended, then the water state simulation is ended, and finally all the calculation results collected in the entire water state simulation process can be obtained.
[0075] Furthermore, the instantiated first preset class, the instantiated second preset class, the instantiated third preset class, the fourth preset class, the dynamic library and each encapsulated interface are combined to finally obtain the hydrodynamic model target class.
[0076] It should be noted that the executor of the method for encapsulating and servitizing the hydrodynamic model provided by the present application is a server, and external input refers to input through a terminal. The terminal and the server are connected through a wireless network. The terminal can be a smart phone or a personal computer, and the server can be an independent physical server or a server cluster composed of multiple physical servers.
[0077] S102: receiving target request parameters input by the user terminal through the HTTP interface of the hydrodynamic model target class, and verifying the target request parameters to obtain verified parameters, where the target request parameters are request parameters corresponding to the target water state simulation task.
[0078] Specifically, after encapsulating the current hydrodynamic model into a class, it needs to be further exposed as a service through the HTTP interface, that is, encapsulating the service process, and then realizing the remote call of the current hydrodynamic model function, reducing the difficulty of deploying and applying the hydrodynamic model. Among them, the HTTP interface is a communication interface based on the Hypertext Transfer Protocol. In the embodiment of the present application, the HTTP interface adopts the Representational State Transfer ful (RESTful) interface, that is, a unified interface designed for the hydrodynamic model target class. Furthermore, the server receives the target request parameters input by the user terminal through the HTTP interface, wherein the target request parameters are the request parameters corresponding to the target water state simulation task, which are used to remotely call the current hydrodynamic model. The user terminal is the terminal of the user who needs to deploy and use the current hydrodynamic model to actually perform the target water state simulation task. In addition, in the embodiment of the present application, the target water state simulation task requires multiple hydrodynamic models including the current hydrodynamic model to jointly run and calculate to complete. In other embodiments, the target water state simulation task can also be completed by only running and calculating the current hydrodynamic model.
[0079] Furthermore, it is necessary to verify the target request parameters to obtain the verified parameters. A feasible implementation method is: first, the target dictionary key value corresponding to the target request parameter is integrity verified, specifically through the preset Cerberus library, where the target dictionary key value is used to specify the key and value of the target request parameter. When the server receives the target request parameter, the target request parameter is often organized in the dictionary in the form of key-value pairs, where the key represents the name of the target request parameter and the value represents the value of the target request parameter. If the integrity check passes, it means that the data in the target request parameter is complete. Further, the data corresponding to each field in the target request parameter is format-verified. If the format check passes, it means that the format of each data in the target request parameter is standardized, and finally the verified parameters are obtained, thereby ensuring the correctness and security of the data in the target request parameter to a certain extent.
[0080] S103: According to the actual task identifier and upstream model identifier of the target water state simulation task in the verified parameters, the output result of the upstream hydrodynamic model of the current hydrodynamic model in the same target water state simulation task is obtained, and the target field in the verified parameters is parsed to obtain the parsing result.
[0081] Specifically, the actual task identifier and upstream model identifier corresponding to the target water state simulation task are extracted from the verified parameters, wherein the upstream model identifier refers to the model identifier of the upstream hydrodynamic model on which the current hydrodynamic model depends. In an embodiment of the present application, the dependent upstream hydrodynamic model is a hydrodynamic model corresponding to the upstream region adjacent to the current region corresponding to the current hydrodynamic model.
[0082] Further, according to the actual task identifier and the upstream model identifier, the output result of the upstream hydrodynamic model whose task identifier is consistent with the actual task identifier and whose model identifier is consistent with the upstream model identifier is obtained from the output results of the historical hydrodynamic model in the database. Among them, since the current hydrodynamic model can only run normally after the upstream hydrodynamic model on which the current hydrodynamic model depends is completed, the output result of the upstream hydrodynamic model has an impact on the water state simulation of the current hydrodynamic model.
[0083] Furthermore, the target field in the verified parameters is parsed to obtain the parsing result, wherein the target field includes the inflow and outflow of the current region corresponding to the current hydrodynamic model. Since the verified parameters also include the simulation task start time and the simulation task end time, the target field also includes the inflow boundary. Therefore, the inflow of the current region is the inflow of the current region during the continuous period from the simulation task start time to the simulation task end time, that is, the outflow of the inflow boundary. In addition, the outflow of the current region defaults to 0. In an embodiment of the present application, the target field is the "timeseries" field. Among them, the inflow boundary can be understood as the boundary between the current region and the adjacent upstream region, which is used to define the conditions or parameters for calculating the water flow entering the current region.
[0084] S104: Based on the acquisition of the output results and the analysis results, the actual inflow boundary information corresponding to the current hydrodynamic model is obtained, and the hydrodynamic model target class is instantiated to obtain the preset inflow boundary information corresponding to the current hydrodynamic model.
[0085] Specifically, the acquisition status of the output result is acquired or not acquired. If the acquisition status is not acquired, it means that in this target water state simulation task, the upstream hydrodynamic model of the current hydrodynamic model does not participate in the calculation, and the operation of the current hydrodynamic model does not rely on the upstream hydrodynamic model. Then the analysis result is directly determined as the actual inflow boundary information corresponding to the current hydrodynamic model, that is, the inflow boundary information of the current region from the start time of the simulation task to the end time of the simulation task. If the acquisition status is acquired, it means that in this target water state simulation task, the upstream hydrodynamic model of the current hydrodynamic model participates in the calculation, and the operation of the current hydrodynamic model needs to rely on the upstream hydrodynamic model. Since the output result of the upstream hydrodynamic model includes information such as the inflow boundary and the flow rate of the water outflow from the inflow boundary, the output result is determined as the actual inflow boundary information. In other embodiments, the similarity between the output result and the analysis result is determined, and the similarity is determined by calculating the cosine distance. If the similarity is less than the similarity threshold, the analysis result is determined as the actual inflow boundary information.
[0086] Furthermore, the hydrodynamic model target class encapsulated by the current hydrodynamic model is instantiated through Python, and the dynamic library corresponding to the current hydrodynamic model and the default regional model file of the current region are loaded, and the preset inflow boundary information of the current hydrodynamic model is parsed from the default regional model file through the LoadFile function.
[0087] S105: If the preset inflow boundary information is consistent with the actual inflow boundary information, the actual regional model file corresponding to the target water state simulation task is determined, the actual regional model file is loaded through the instantiated hydrodynamic model target class, and the outflow boundary of the current hydrodynamic model is predicted to obtain the prediction result.
[0088] Specifically, the preset inflow boundary information is compared with the actual inflow boundary information. If the preset inflow boundary information is consistent with the actual inflow boundary information, and the actual inflow boundary information is verified to be correct, then the actual regional model file corresponding to the target water state simulation task is determined. A feasible implementation method is: select the target boundary information of the upstream hydrodynamic model on which the current hydrodynamic model depends from the verified parameters;
[0089] Based on the target boundary information and the actual inflow boundary information, an actual regional model file corresponding to the target water state simulation task is generated.
[0090] Specifically, since the verified parameters also include the target boundary information of the upstream hydrodynamic model on which the current hydrodynamic model depends, after determining that the actual inflow boundary information is correct, the target boundary information is extracted from the verified parameters, wherein the target boundary information is used to define the physical characteristics and water flow dynamic conditions of the region corresponding to the upstream hydrodynamic model, and the outflow of the upstream hydrodynamic model will become the inflow condition of the current hydrodynamic model. The target boundary information will directly affect the initial conditions of the current hydrodynamic model, and the initial conditions are the physical state of the current region before the target water state simulation task. Therefore, according to the target boundary information and the actual inflow boundary information, the actual regional model file corresponding to the target water state simulation task is generated. A feasible generation method is: through a Geographic Information System (GIS), the actual regional model file is generated according to the target boundary information and the actual inflow boundary information.
[0091] Furthermore, the actual regional model file is loaded through the instantiated hydrodynamic model target class, and the target water state simulation task is executed to predict the outflow boundary of the current hydrodynamic model, and finally obtain the prediction result, that is, the output result of the model. The outflow boundary is used to define the conditions when the water flows out of the current region during the water state simulation of the current region by the current hydrodynamic model. Among them, the prediction result includes information such as water level, flow rate, flow velocity and water width when the water flows out of the current area. It should be noted that in the embodiment of the present application, the prediction results obtained include multiple, corresponding to different moments from the start time of the simulation task to the end time of the simulation task.
[0092] S106: When the prediction result is in a normal state, the prediction result, the actual task identifier and the model identifier of the current hydrodynamic model are combined and added to a preset database.
[0093] Specifically, to determine whether all the prediction results are abnormal, a feasible judgment method is: according to the simulation task start time, simulation task end time and the preset time interval of each simulation of the target water state simulation task corresponding to the target water state simulation task, determine the number of times the current hydrodynamic model should be simulated. Each simulation will output a prediction result. If the number of all prediction results is consistent with this number, the prediction result is determined to be normal. Further, all prediction results, the actual task identifier of the target water state simulation task and the model identifier of the current hydrodynamic model are combined and added to the preset database, so as to complete the encapsulation and service operation of the current hydrodynamic model, and then realize the sharing, reuse and integration of the hydrodynamic model. In addition, when the downstream hydrodynamic model of the current hydrodynamic model is subsequently encapsulated and serviced, the prediction results of the current hydrodynamic model can be obtained from the database.
[0094] See also Figure 2 The present application embodiment discloses a flow chart of another method for encapsulating and servitizing a hydrodynamic model, which can be implemented by a computer program or run on a device for encapsulating and servitizing a hydrodynamic model based on a von Neumann system. The computer program can be integrated into an application or run as an independent tool application, specifically including:
[0095] S201: Encapsulate the current hydrodynamic model to be deployed into a class to obtain a hydrodynamic model target class.
[0096] S202: receiving target request parameters input by the user terminal through the HTTP interface of the hydrodynamic model target class, and verifying the target request parameters to obtain verified parameters, where the target request parameters are request parameters corresponding to the target water state simulation task.
[0097] S203: According to the actual task identifier and upstream model identifier of the target water state simulation task in the verified parameters, the output result of the upstream hydrodynamic model of the current hydrodynamic model in the same target water state simulation task is obtained, and the target field in the verified parameters is parsed to obtain the parsing result.
[0098] S204: Based on the acquisition of the output results and the analysis results, the actual inflow boundary information corresponding to the current hydrodynamic model is obtained, and the hydrodynamic model target class is instantiated to obtain the preset inflow boundary information corresponding to the current hydrodynamic model.
[0099] S205: If the preset inflow boundary information is consistent with the actual inflow boundary information, the actual regional model file corresponding to the target water state simulation task is determined, the actual regional model file is loaded through the instantiated hydrodynamic model target class, and the outflow boundary of the current hydrodynamic model is predicted to obtain the prediction result.
[0100] S206: When the prediction result is in a normal state, the prediction result, the actual task identifier and the model identifier of the current hydrodynamic model are combined and added to a preset database.
[0101] For details, please refer to steps S101-S106, which will not be described in detail here.
[0102] S207: Build FastAPI based on Python and determine FastAPI as the backend framework.
[0103] S208: If the preset inflow boundary information is inconsistent with the actual inflow boundary information, an exception log is generated and submitted to FastAPI.
[0104] Specifically, FastAPI is a modern, high-performance web framework designed specifically for building APIs. It is suitable for the Python language and is optimized for building RESTful APIs. FastAPI is built with Python and is identified as the backend framework, so that its high performance and asynchronous processing capabilities can be used to support the simultaneous processing of multiple water state simulation tasks, avoiding resource competition and performance bottlenecks for multiple simulation tasks and multiple hydrodynamic models.
[0105] Furthermore, if the preset inflow boundary information is inconsistent with the actual inflow boundary information, it means that the actual inflow boundary information is incorrect, then an exception log is generated and submitted to this FastAPI to be exposed to the user, thereby better reminding the user.
[0106] The implementation principle of the method for encapsulating and servitizing the hydrodynamic model in the embodiment of the present application is as follows: instantiate the hydrodynamic model target class, call its corresponding methods for specific use, and let the current hydrodynamic model make predictions based on the actual regional model file, thereby executing the target water state simulation task. If the prediction result is normal, it means that the current hydrodynamic model simulates the current region correctly, then the prediction result, the actual task identifier, and the model identifier of the current hydrodynamic model are added to the database, and finally the encapsulation and servitization of the current hydrodynamic model are completed, so as to better perform the call integration of the hydrodynamic model and reduce the difficulty of deploying and applying the hydrodynamic model.
[0107] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0108] See also Figure 3 , which is a schematic diagram of the structure of the device for encapsulating and servitizing the hydrodynamic model provided in the embodiment of the present application. The device for encapsulating and servitizing the hydrodynamic model can be implemented as all or part of the device through software, hardware or a combination of both. The device includes a model encapsulation module 11, a request verification module 12, a result determination module 13, a boundary determination module 14, a result output module 15 and a result storage module 16.
[0109] The model encapsulation module 11 is used to encapsulate the current hydrodynamic model to be deployed into a class to obtain a hydrodynamic model target class;
[0110] The request verification module 12 is used to receive the target request parameters input by the user terminal through the HTTP interface of the hydrodynamic model target class, and verify the target request parameters to obtain the verified parameters, where the target request parameters are the request parameters corresponding to the target water state simulation task;
[0111] The result determination module 13 is used to obtain the output result of the upstream hydrodynamic model of the current hydrodynamic model in the same target water state simulation task according to the actual task identifier and the upstream model identifier of the target water state simulation task in the verified parameters, and parse the target field in the verified parameters to obtain the parsing result, wherein the target field includes the water inflow flow of the current region corresponding to the current hydrodynamic model, and the upstream model identifier is the model identifier of the upstream hydrodynamic model on which the current hydrodynamic model depends;
[0112] The boundary determination module 14 is used to obtain the actual inflow boundary information corresponding to the current hydrodynamic model based on the acquisition of the output result and the analysis result, and to instantiate the hydrodynamic model target class to obtain the preset inflow boundary information corresponding to the current hydrodynamic model;
[0113] The result output module 15 is used to determine the actual regional model file corresponding to the target water state simulation task if the preset inflow boundary information is consistent with the actual inflow boundary information, load the actual regional model file through the instantiated hydrodynamic model target class and predict the outflow boundary of the current hydrodynamic model to obtain the prediction result;
[0114] The result storage module 16 is used to combine the prediction result, the actual task identifier and the model identifier of the current hydrodynamic model and add them to a preset database when the prediction result is in a normal state.
[0115] Optionally, the request verification module 12 is specifically used to:
[0116] Perform integrity check on the target dictionary key value corresponding to the target request parameter;
[0117] After the integrity check is passed, the data corresponding to each field in the target request parameter is format checked. After the format check is passed, the checked parameters are obtained.
[0118] Optional, such as Figure 4 As shown, the device also includes an abnormality reminder module 17, which is specifically used to:
[0119] Build FastAPI based on Python and identify FastAPI as the backend framework;
[0120] If the preset inflow boundary information is inconsistent with the actual inflow boundary information, an exception log is generated and submitted to FastAPI.
[0121] Optionally, the model encapsulation module 11 is specifically used for:
[0122] Compile the current hydrodynamic model to be deployed into a dynamic library with the dll suffix;
[0123] Encapsulate the interface corresponding to the dynamic library through the preset ctypes library to obtain the corresponding encapsulated interface;
[0124] Based on the instantiated first preset class, the instantiated second preset class and the instantiated third preset class, the externally inputted information required for regional simulation is received, wherein the first preset class is a class for recording the key process status of the current hydrodynamic model, the second preset class is a regional model file for statistics of the current hydrodynamic model, and the third preset class is a class for standardized output of the current hydrodynamic model;
[0125] Based on the preset logical rules, a fourth preset class is defined. The fourth preset class can simulate the water state through the current hydrodynamic model based on the information required for regional simulation, and collect all calculation results returned when the current hydrodynamic model is running;
[0126] Based on the instantiated first preset class, the instantiated second preset class, the instantiated third preset class, the fourth preset class, the dynamic library and the encapsulated interface, the hydrodynamic model target class is determined.
[0127] Optionally, the device further includes an instance creation module 18, which is specifically used to:
[0128] Instantiate the first preset class, and initialize the state of the LoadFile function corresponding to the first preset class to False, so as to obtain the instantiated first preset class;
[0129] Instantiate the second preset class to obtain the instantiated second preset class, so that when the state of the LoadFile function is converted to True, the instantiated second preset class obtains the number of sections in the current region;
[0130] The third preset class is instantiated to obtain the instantiated second preset class, so that the instantiated third preset class is output in a standardized manner based on the number of sections when the LoadFile function state is converted to True.
[0131] Optionally, the model encapsulation module 11 is specifically used for:
[0132] Read the regional simulation start time, the regional simulation end time and the input regional model file, and based on the regional simulation start time and the input regional model file, control the current hydrodynamic model to simulate the water state at the specified time interval to obtain the current calculation result returned by the current hydrodynamic model;
[0133] Compare the return time of the current calculation result with the end time of the regional simulation;
[0134] If the return time is earlier than the end time of the regional simulation, the steps of controlling the current hydrodynamic model to perform water state simulation at the specified time interval based on the regional simulation start time and the input regional model file are repeatedly executed until the return time is no earlier than the end time of the regional simulation.
[0135] Optionally, the result output module 15 is specifically used for:
[0136] Selecting target boundary information of the upstream hydrodynamic model on which the current hydrodynamic model depends from the verified parameters;
[0137] Based on the target boundary information and the actual inflow boundary information, an actual regional model file corresponding to the target water state simulation task is generated.
[0138] It should be noted that the device for encapsulating and servicing a hydrodynamic model provided in the above embodiment only uses the division of the above functional modules as an example when executing the method for encapsulating and servicing a hydrodynamic model. In actual applications, the above functional distribution can be completed by different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device for encapsulating and servicing a hydrodynamic model provided in the above embodiment and the method embodiment for encapsulating and servicing a hydrodynamic model belong to the same concept. The implementation process is detailed in the method embodiment and will not be repeated here.
[0139] An embodiment of the present application further discloses a computer-readable storage medium, and the computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, a method for encapsulating and servitizing a hydrodynamic model of the above embodiment is adopted.
[0140] Among them, the computer program can be stored in a computer-readable medium, the computer program includes computer program code, the computer program code can be in the form of source code, object code, executable file or certain middleware, etc. The computer-readable medium includes any entity or device that can carry the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the computer-readable medium includes but is not limited to the above-mentioned components.
[0141] Among them, through this computer-readable storage medium, a method of encapsulating and servitizing a hydrodynamic model of the above embodiment is stored in a computer-readable storage medium, and is loaded and executed on a processor to facilitate the storage and application of the above method.
[0142] An embodiment of the present application further discloses an electronic device, in which a computer program is stored in a computer-readable storage medium. When the computer program is loaded and executed by a processor, the above-mentioned method of encapsulating and servitizing a hydrodynamic model is adopted.
[0143] The electronic device may be a desktop computer, a laptop computer, a cloud server or other electronic device, and the electronic device includes but is not limited to a processor and a memory. For example, the electronic device may also include input and output devices, a network access device, and a bus.
[0144] Among them, the processor can adopt a central processing unit (CPU). Of course, according to actual usage, other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. can also be adopted. The general-purpose processor can adopt a microprocessor or any conventional processor, etc., and this application does not impose any restrictions on this.
[0145] Among them, the memory can be an internal storage unit of the electronic device, such as a hard disk or memory of the electronic device, or it can be an external storage device of the electronic device, such as a plug-in hard disk, a smart memory card (SMC), a secure digital card (SD) or a flash memory card (FC) equipped on the electronic device. Moreover, the memory can also be a combination of an internal storage unit and an external storage device of the electronic device. The memory is used to store computer programs and other programs and data required by the electronic device. The memory can also be used to temporarily store data that has been output or is to be output, and this application does not impose any restrictions on this.
[0146] Among them, through this electronic device, a method of encapsulating and servitizing a hydrodynamic model in the above embodiment is stored in the memory of the electronic device, and is loaded and executed on the processor of the electronic device for easy use.
[0147] The above is only an exemplary embodiment of the present disclosure, and the scope of the present disclosure cannot be limited thereto. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the specification and practicing the disclosure here, those skilled in the art will easily think of other embodiments of the present disclosure. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary technical means in the technical field not recorded in the present disclosure. The description and examples are only regarded as exemplary, and the scope and spirit of the present disclosure are defined by the claims.
Claims
1. A method for encapsulating and servitizing hydrodynamic models. It is characterized in that The method comprises: The current hydrodynamic model to be deployed is encapsulated into a class to obtain a hydrodynamic model target class; Receiving target request parameters input by a user terminal through the HTTP interface of the hydrodynamic model target class, and verifying the target request parameters to obtain verified parameters, wherein the target request parameters are request parameters corresponding to the target water state simulation task; According to the actual task identifier and the upstream model identifier of the target water state simulation task in the verified parameters, the output result of the upstream hydrodynamic model of the current hydrodynamic model in the same target water state simulation task is obtained, and the target field in the verified parameters is parsed to obtain the parsing result, wherein the target field includes the water inflow rate of the current region corresponding to the current hydrodynamic model, and the upstream model identifier is the model identifier of the upstream hydrodynamic model on which the current hydrodynamic model depends; Based on the acquisition of the output result and the analysis result, the actual inflow boundary information corresponding to the current hydrodynamic model is obtained, and the hydrodynamic model target class is instantiated to obtain the preset inflow boundary information corresponding to the current hydrodynamic model, wherein, based on the acquisition of the output result and the analysis result, the actual inflow boundary information corresponding to the current hydrodynamic model is obtained, including: if the acquisition situation is that the information is not obtained, the analysis result is determined as the actual inflow boundary information corresponding to the current hydrodynamic model; if the acquisition situation is that the information is obtained, the output result is determined as the actual inflow boundary information; If the preset inflow boundary information is consistent with the actual inflow boundary information, the actual regional model file corresponding to the target water state simulation task is determined, the actual regional model file is loaded through the instantiated hydrodynamic model target class and the outflow boundary of the current hydrodynamic model is predicted to obtain a prediction result, wherein the determining the actual regional model file corresponding to the target water state simulation task specifically includes: Selecting target boundary information of an upstream hydrodynamic model on which the current hydrodynamic model depends from the verified parameters; Based on the target boundary information and the actual inflow boundary information, generating an actual regional model file corresponding to the target water state simulation task; When the prediction result is in a normal state, the prediction result, the actual task identifier and the model identifier of the current hydrodynamic model are combined and added to a preset database.
2. The method for encapsulating and servitizing the hydrodynamic model according to claim 1, It is characterized in that Verifying the target request parameters to obtain verified parameters specifically includes: Performing integrity check on the target dictionary key value corresponding to the target request parameter; After the integrity check is passed, a format check is performed on the data corresponding to each field in the target request parameter, and after the format check is passed, the checked parameters are obtained.
3. The method for encapsulating and servitizing the hydrodynamic model according to claim 1, It is characterized in that The method further comprises: Build FastAPI based on Python, and determine FastAPI as the backend framework; If the preset inflow boundary information is inconsistent with the actual inflow boundary information, an exception log is generated and submitted to the FastAPI.
4. The method for encapsulating and servitizing the hydrodynamic model according to claim 1, It is characterized in that The operation of encapsulating the current hydrodynamic model to be deployed into a class to obtain a hydrodynamic model target class includes: Compile the current hydrodynamic model to be deployed into a dynamic library with the dll suffix; Encapsulating the interface corresponding to the dynamic library through a preset ctypes library to obtain a corresponding encapsulated interface; Based on the instantiated first preset class, the instantiated second preset class and the instantiated third preset class, the externally inputted information required for regional simulation is received, wherein the first preset class is a class for recording the key process status of the current hydrodynamic model, the second preset class is a regional model file for statistics of the current hydrodynamic model, and the third preset class is a class for standardized output of the current hydrodynamic model; Based on the preset logical rules, a fourth preset class is defined, wherein the fourth preset class can simulate the water state through the current hydrodynamic model based on the information required for the regional simulation, and collect all calculation results returned when the current hydrodynamic model is running; Based on the instantiated first preset class, the instantiated second preset class, the instantiated third preset class, the fourth preset class, the dynamic library and the encapsulated interface, a hydrodynamic model target class is determined.
5. The method for encapsulating and servitizing the hydrodynamic model according to claim 4, It is characterized in that Before receiving external input regional simulation information based on the instantiated first preset class, the instantiated second preset class and the instantiated third preset class, the method further includes: Instantiate the first preset class, and initialize the state of the LoadFile function corresponding to the first preset class to False, to obtain the instantiated first preset class; Instantiating the second preset class to obtain the instantiated second preset class, so that when the state of the LoadFile function is converted to True, the instantiated second preset class obtains the number of sections in the current region; The third preset class is instantiated to obtain the instantiated second preset class, so that the instantiated third preset class is output in a standardized manner based on the number of sections when the LoadFile function state is converted to True.
6. The method for encapsulating and servitizing the hydrodynamic model according to claim 4, It is characterized in that The information required for the regional simulation includes the regional simulation start time, the regional simulation end time and the input regional model file. The logical rule is: Reading the regional simulation start time, the regional simulation end time and the input regional model file, and based on the regional simulation start time and the input regional model file, controlling the current hydrodynamic model to perform water state simulation at a specified time interval to obtain a current calculation result returned by the current hydrodynamic model; Comparing the return time of the current calculation result with the end time of the regional simulation; If the return time is earlier than the end time of the regional simulation, the step of controlling the current hydrodynamic model to perform water state simulation at a specified time interval based on the regional simulation start time and the input regional model file is repeatedly executed until the return time is no earlier than the end time of the regional simulation.
7. A device for encapsulating and servicing a hydrodynamic model. It is characterized in that include: A model encapsulation module (11) is used to encapsulate the current hydrodynamic model to be deployed into a class to obtain a hydrodynamic model target class; A request verification module (12), used for receiving target request parameters input by a user terminal through the HTTP interface of the hydrodynamic model target class, and verifying the target request parameters to obtain verified parameters, wherein the target request parameters are request parameters corresponding to the target water state simulation task; A result determination module (13) is used to obtain the output result of the upstream hydrodynamic model of the current hydrodynamic model in the same target water state simulation task according to the actual task identifier and the upstream model identifier of the target water state simulation task in the verified parameters, and parse the target field in the verified parameters to obtain the parsing result, wherein the target field includes the water inflow rate of the current region corresponding to the current hydrodynamic model, and the upstream model identifier is the model identifier of the upstream hydrodynamic model on which the current hydrodynamic model depends; A boundary determination module (14) is used to obtain actual inflow boundary information corresponding to the current hydrodynamic model based on the acquisition of the output result and the analysis result, and to instantiate the hydrodynamic model target class to obtain preset inflow boundary information corresponding to the current hydrodynamic model, wherein the actual inflow boundary information corresponding to the current hydrodynamic model is obtained based on the acquisition of the output result and the analysis result, including: if the acquisition is not obtained, then the analysis result is determined as the actual inflow boundary information corresponding to the current hydrodynamic model; if the acquisition is obtained, then the output result is determined as the actual inflow boundary information; A result output module (15) is used to determine the actual regional model file corresponding to the target water state simulation task if the preset inflow boundary information is consistent with the actual inflow boundary information, load the actual regional model file through the instantiated hydrodynamic model target class and predict the outflow boundary of the current hydrodynamic model to obtain a prediction result, wherein the determining the actual regional model file corresponding to the target water state simulation task specifically includes: Selecting target boundary information of an upstream hydrodynamic model on which the current hydrodynamic model depends from the verified parameters; Based on the target boundary information and the actual inflow boundary information, generating an actual regional model file corresponding to the target water state simulation task; The result storage module (16) is used to combine the prediction result, the actual task identifier and the model identifier of the current hydrodynamic model and add them to a preset database when the prediction result is in a normal state.
8. A computer-readable storage medium having a computer program stored therein, It is characterized in that When the computer program is loaded and executed by a processor, the method according to any one of claims 1 to 6 is adopted.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, It is characterized in that When the processor loads and executes the computer program, the method according to any one of claims 1 to 6 is adopted.
Citation Information
Patent Citations
Coupling method of 1D and 2D hydrodynamic models based on spatial topology
AU2020101587A4
Implementation method of multifunctional environmental hydrodynamic numerical simulation software system
CN114492221A
