A BMI configuration method for a nearshore ocean model based on finite element

By designing JSON format configuration files and parsers, mapping the configuration file contents into the Thetis model, solving the operational complexity problem caused by the lack of configuration files of Thetis model, and achieving simplification and efficiency improvement of model construction.

CN119538631BActive Publication Date: 2025-05-13NAT UNIV OF DEFENSE TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411477049.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-22
Publication Date
2025-05-13
Estimated Expiration
2044-10-22

AI Technical Summary

Technical Problem

Thetis model lacks configuration files, which leads to users needing to process the underlying code, increasing the learning curve and operational complexity.

Method used

Design and use JSON format configuration files, including grid configuration, model parameters, input and output variables, etc., map the configuration file content into the Thetis model through a parser, and generate initialization files to simplify the model construction process.

Benefits of technology

The initialization and construction process of Thetis model is simplified, the efficiency and accuracy of model construction is improved, the burden on users to handle the underlying code is reduced, and the user experience is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119538631B_ABST
    Figure CN119538631B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a BMI configuration method for a finite element-based nearshore ocean model, including: for a finite element-based nearshore ocean model: Thetis model, constructing a configuration file of a basic model interface BMI, the configuration file being used for the initialization function input of the BMI; constructing a parser capable of reading and parsing the content of the configuration file, mapping the content of the configuration file to the Thetis model; when initializing the Thetis model, editing the content of the configuration file mapped to the Thetis model through BMI, constructing an initialization function, and forming the Thetis model initialization file through the initialization function. By setting the configuration file, the construction process of the initialization stage is simplified, the function of constructing a model according to the configuration file information is realized, and the cumbersome operation of the prior art in the initialization stage is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of environment, and in particular to a BMI configuration method of a nearshore ocean model based on finite elements. Background Art

[0002] In coastal and marine environmental modeling, hydrodynamics and wave interactions (WCI) are critical for a variety of phenomena, such as tidal inlets, coastal zone response to extreme weather conditions, estuarine dynamics, flood risk assessment, terrain evolution, and environmental events such as oil spills and marine energy assessments. These complex phenomena span multiple spatial and temporal scales, from sub-second waves to decades of sediment changes, requiring the coupling of multiple models to fully capture the physical processes.

[0003] Based on the above information, the implementation scheme of the existing technology in the field of environment mainly includes the use of BMI functions for model control and information retrieval. BMI-Thetis and BMI-SWAN are background technologies for environmental modeling. These functions include model control functions (such as initializing, updating and completing the model) and model information functions (such as retrieving the model name and input / output variable counts). The variable information function allows the user to retrieve information about the variables used in the model.

[0004] The Thetis coastal ocean model is implemented in Python, maintaining computational efficiency through the Firedrake finite element framework. It makes use of open source Python packages such as numpy, scipy, and matplotlib, and uses object-oriented programming to implement the IRF life cycle. The reconstructed SWAN model is compiled as a library and integrated into the Fortran 2003 BMI template 'bmi_swan.f90'. Among them, IRF refers to Initialise-Run-Finalise, which is a programming pattern that is often used to ensure that the allocation and release of resources are properly managed when performing a task or operation. This pattern is particularly suitable for scenarios where resources (such as files, network connections, memory, etc.) need to be cleaned up to ensure system stability and performance. The following are the three main steps of the "Initialise-Run-Finalise" pattern:

[0005] 1. Initialize: In this phase, the program allocates the necessary resources for the task to be performed, for example, opening a file, establishing a network connection, or allocating memory.

[0006]

[0007] 2. Run: In this stage, the program uses the resources allocated in the initialization phase to perform actual tasks.

[0008]

[0009] 3. Finalise: After the task is completed, the program needs to release the resources allocated during the initialization phase. This helps prevent resource leaks and ensures system stability and performance.

[0010]

[0011] In actual programming, you can use try-finally statements or context managers to ensure the correct allocation and release of resources. The following is an example of using a context manager:

[0012]

[0013] In this example, when the code block of the `with` statement is executed, the `__exit__` method is automatically called to ensure that resources are properly released.

[0014] in:

[0015] 1. BMI-Thetis and BMI-SWAN: These are two background technologies for environmental modeling. They not only provide model control and information functions, but also help users retrieve and manipulate variables in the model. BMI-Thetis and BMI-SWAN are developed based on the needs of different fields and are suitable for different environmental simulations such as coastal ocean models and wave models, respectively.

[0016] 2. Firedrake finite element framework: Firedrake is a framework for finite element methods for high-performance scientific computing. In the Thetis coastal ocean model, the Firedrake finite element framework helps maintain computational efficiency and supports the implementation and operation of the model. This framework may provide a convenient and efficient way to deal with complex computational problems in ocean dynamics models.

[0017] 3. NumPy, Scipy and Matplotlib: These are important open source packages for Python, used for scientific computing and data visualization. In the Thetis model, the use of these packages may help to handle numerical calculations and result presentation in the model, and improve the visualization and analysis capabilities of the model.

[0018] 4. Fortran programming language: Fortran is an old but still widely used programming language, especially in the field of scientific computing. In the SWAN model, the Fortran programming language is used to compile the model into a library and integrate it with the BMI template to enable the call and execution of the model. This shows the importance and practicality of Fortran in environmental modeling.

[0019] In summary, the implementation scheme of the prior art involves the use of BMI functions to control and retrieve model information, combined with software tools such as Thetis and SWAN to achieve environmental modeling, and developed and integrated using programming languages ​​such as Python and Fortran.

[0020] In the process of implementing the present invention, the applicant discovered that there are at least the following problems in the prior art:

[0021] Since the Thetis model lacks a configuration file, it brings users a certain learning curve and troublesome underlying code processing. Summary of the invention

[0022] The embodiment of the present invention provides a BMI configuration method for a nearshore ocean model based on finite elements, which can solve the technical problems that the Thetis model lacks a configuration file, brings a certain learning curve to users and troublesome underlying code processing.

[0023] To achieve the above-mentioned purpose, an embodiment of the present invention provides a BMI configuration method of a nearshore ocean model based on a finite element, comprising:

[0024] For the finite element-based nearshore ocean model: Thetis model, a configuration file of the basic model interface BMI is constructed, and the configuration file is used for the initialization function input of BMI;

[0025] Constructing a parser capable of reading and parsing the contents of the configuration file, and mapping the contents of the configuration file into the Thetis model;

[0026] When the Thetis model is initialized and constructed, the content of the configuration file mapped to the Thetis model is edited through BMI, an initialization function is constructed, and the Thetis model initialization file is formed through the initialization function.

[0027] The above technical solution has the following beneficial effects: by setting the configuration file, the construction process in the initialization phase is simplified, and the configuration file is read in BMI-Thetis to realize the function of building a model according to the configuration file information. This improves the cumbersome operation in the initialization phase of the prior art and improves the efficiency and accuracy of building the model. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0029] Figure 1 is a flow chart of a BMI configuration method of a nearshore ocean model based on finite elements according to an embodiment of the present invention;

[0030] Figure 2 It is a sequential step diagram of a BMI configuration method of a nearshore ocean model based on finite elements according to an embodiment of the present invention. DETAILED DESCRIPTION

[0031] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0032] like Figure 1 As shown, in combination with an embodiment of the present invention, a BMI configuration method for a nearshore ocean model based on a finite element is provided, comprising:

[0033] S101: for a finite element-based nearshore ocean model: Thetis model, construct a configuration file of a basic model interface BMI, where the configuration file is used for initialization function input of the BMI;

[0034] S102: construct a parser capable of reading and parsing the content of the configuration file, and map the content of the configuration file into the Thetis model;

[0035] S103: When the Thetis model is initialized and constructed, the content of the configuration file mapped to the Thetis model is edited through BMI, an initialization function is constructed, and the Thetis model initialization file is formed through the initialization function.

[0036] Preferably, the configuration file is in JSON format.

[0037] Preferably, S101: the configuration file of the basic model interface BMI is constructed for the finite element-based nearshore ocean model: Thetis model, including:

[0038] For the finite element-based nearshore ocean model: Thetis model, the configuration file of the basic model interface BMI is constructed, including grid configuration, model parameter settings, input variable output variable information settings and mandatory field configuration; among them:

[0039] Constructing a specification for forming a mesh object, setting definitions of all related initialization functions, constructing a two-dimensional solver, the two-dimensional solver is used to perform a check of a smoothing application in the Thetis model, integrating and managing various resources in the Thetis model through the mesh configuration, and constructing the mesh configuration;

[0040] Add relevant parameters of the nearshore ocean, and when the relevant parameters include a first parameter, determine other parameters associated with the first parameter, and add the other parameters to the relevant parameters, and the model parameters are set;

[0041] Determine input parameters from the relevant parameters of the nearshore ocean, determine relevant output parameters based on the input parameters, and construct input variable and output variable information settings;

[0042] Set mandatory fields in model parameters and variable information to ensure that certain columns in the data table always contain valid values.

[0043] Preferably, the BMI configuration method of the finite element-based nearshore ocean model further includes, S104:

[0044] According to the grid configuration in the configuration file, construct a grid object of the Thetis model;

[0045] Define relevant functions, which include initialization functions and update functions. The initialization functions and update functions are used to ensure that the Thetis model can run correctly, and ensure that the Thetis model can correctly update the state and form the value of the output variable according to the input variables and model parameters during operation.

[0046] Preferably, the grid points on the grid object have four input variables: significant wave height H s , the average wave direction θ in the Cartesian convention m and the average wave period T m and wave breaking percentage Q b , the grid points on the grid object have the following output variables: water height and depth-averaged flow velocity.

[0047] Preferably, the BMI configuration method of the finite element-based nearshore ocean model further includes:

[0048] S105: Modify the method for constructing the Thetis model involved in the BMI so that the method for constructing the Thetis model involved in the BMI supports dividing the simulation of the Thetis model into multiple life cycle stages.

[0049] Preferably, S105: the method for constructing the Thetis model involved in the modification of the BMI so that the method for constructing the Thetis model involved in the BMI supports segmenting the simulation of the Thetis model into multiple life cycle stages, including:

[0050] Modify the SWAN code for constructing the Thetis model through the subroutine SWMAIN, divide the SWAN code into IRF steps, and obtain three life cycle stages corresponding to the Thetis model: initialization stage, operation stage and end stage;

[0051] The three parts of the subroutine SWMAIN: the subroutine SWANINIT, the subroutine SWANMAIN and the subroutine SWANFINALIZE correspond to a life cycle stage of the Thetis model respectively:

[0052] In the initialization phase, a subroutine SWINITMPI of the subroutine SWANINIT is used to perform MPI initialization, interpret the configuration file of the SWAN code, allocate and initialize arrays, and allocate default values ​​and user-specified values;

[0053] During the operation phase, the subroutine SWANMAIN is used to retain the subroutine SWMAIN code associated with performing the SWAN calculation, and the subroutine SWMAIN code associated with the SWAN calculation is responsible for advancing the construction of the Thetis model and determining the requested output variable values;

[0054] In the end phase, the stored output variables are transferred to a file using the subroutine SWANFINALIZE, and the execution of the SWAN code and the environment of the MPI build initialization function are terminated by the subroutine SWEXITMPI.

[0055] Preferably, the BMI configuration method of the finite element-based nearshore ocean model further includes:

[0056] S106: Expanding the method of constructing the Thetis model involved in the BMI to support calculation of more input variables and output variables.

[0057] Preferably, the Thetis model initialization file refers to a hot start file used for initializing the Thetis model.

[0058] Preferably, in S101, the configuration file for constructing the basic model interface BMI includes:

[0059] The configuration file for building the basic model interface BMI is generated in a configuration file format in which one line corresponds to one configuration content.

[0060] The above technical solution of the embodiment of the present invention is described in detail below in conjunction with specific application examples. For technical details not introduced during the implementation process, please refer to the relevant description in the previous text.

[0061] A BMI configuration method for a nearshore ocean model based on finite elements in an embodiment of the present invention solves the technical problem of: solving the shortcomings of the initial development of the Thetis model, that is, the lack of configuration files. In order to facilitate the establishment of a two-dimensional Thetis model and solve the input requirements of the initialization function of the BMI, a configuration file in JSON (JavaScript Object Notation) format is developed, from grid configuration to mandatory fields, so that users can more conveniently handle various aspects of the model and avoid the trouble of processing the underlying code. Basic Model Interface is a basic model interface, which refers to a programming concept for defining and implementing the basic operations and functions of AI models. Grid configuration is a method for integrating and managing various resources in a distributed system, aiming to improve the reliability of the system, optimize resource utilization efficiency, enhance data management functions, enhance service flexibility and scalability, and improve security management. A mandatory field is a database constraint that ensures that certain columns in a data table always contain valid values. The mandatory fields in the data table are closely related to the initialization process of the Thetis model. They ensure the validity and integrity of the data in the initialization phase of the Thetis model, thereby supporting the correct construction of the Thetis model and subsequent simulation analysis.

[0062] Through the design and application of configuration files, the initialization phase construction process of the Thetis model is greatly simplified, so that users can build the Thetis model according to the JSON file information, advance the model time step, and generate 'hotfiles' for subsequent simulations without processing the underlying code. This innovation improves user friendliness and work efficiency. Timestep is an important concept in deep learning, especially when processing sequence data. Timestep refers to a time unit corresponding to each training sample when training deep learning models such as recurrent neural networks (RNNs) and long short-term memory networks (LSTMs). When processing sequence data, the timestep is used to represent the information of each position in the input sequence. The timestep helps the model capture the temporal dependencies in the sequence data, increases the complexity of the model, and improves the generalization performance of the model.

[0063] Because the two-dimensional Thetis model is easier to build, it is suitable for fields such as ocean simulation and marine engineering. Through the application of JSON configuration files, users can more easily handle various aspects of the model, thereby improving the operability and practicality of the model.

[0064] The improvements of the embodiments of the present invention based on the shortcomings of the prior art include the following:

[0065] 1. The embodiment of the present invention simplifies the construction process in the initialization phase by introducing the concept of configuration files, and reads configuration files in JSON format in BMI-Thetis, realizing the function of building a model according to configuration file information. This improves the cumbersome operation in the initialization phase of the prior art and improves the efficiency and accuracy of building the model.

[0066] 2. In the existing technology, BMI-Thetis currently only supports limited input and output variables, such as significant wave height, average wave direction, average wave period and wave breaking percentage, which limits the model's ability to accurately simulate complex environmental variables; resulting in limited accuracy and applicability of the model.

[0067] In view of the limitations of input and output variables in the prior art, the embodiments of the present invention introduce more variable support, including the depth average velocity component, etc., to enhance the model's simulation ability for complex environmental variables. This enables the model to more comprehensively reflect the actual situation and improves the accuracy and reliability of the simulation results.

[0068] 3. Although the current BMI function provides model control and information retrieval functions, it is insufficient in dealing with the problem of splitting the model into multiple "running" stages; resulting in logical confusion and low efficiency when frequent simulation calls and executions are performed. By modifying the inherent method of BMI-Thetis, the embodiment of the present invention solves the problem of splitting the model into multiple "running" stages and improves the logical clarity and efficiency of the model when it is frequently called and executed. This allows the model to better cope with complex situations and improves the accuracy and stability of the simulation.

[0069] 4. In the existing technology, BMI-Thetis is strong in processing structured grids, but may have problems in processing unstructured or irregular grids; this limits the applicability of the model on different types of grids and affects the accuracy and stability of the simulation results.

[0070] The core of the embodiment of the present invention is to simplify the BMI configuration process of Thetis by introducing a configuration file. By reading and parsing the JSON file, the user can quickly build the Thetis model, avoiding cumbersome initialization and construction steps. In addition, a user-friendly way is provided to handle various aspects of the model, from grid configuration to mandatory fields, so that users can use Thetis for simulation more conveniently, improving work efficiency and user experience.

[0071] The key steps of the embodiment of the present invention include the following:

[0072] 1. Configuration file design and parsing:

[0073] Design a configuration file in JSON format, which contains information such as mesh configuration, model parameters, input variables and output variables. In computer science and engineering, mesh usually refers to a data structure that is used to discretize continuous physical space in numerical simulations such as finite element analysis (FEA) and computational fluid dynamics (CFD). In these applications, the mesh consists of a series of nodes, elements and edges, which are used to approximate complex geometric shapes and physical phenomena.

[0074] In the finite element model, meshing is the process of dividing a continuous physical area into a finite number of small areas, which are usually simple shapes such as triangles, quadrilaterals, tetrahedrons or hexahedrons. In this way, approximate values ​​of physical quantities (such as temperature, pressure, velocity, etc.) can be defined on these small areas, and the response of the entire physical system can be simulated by solving equations.

[0075] In the Thetis model, the grid is used to integrate and manage various resources in a distributed system, aiming to improve system reliability, optimize resource utilization efficiency, enhance data management capabilities, increase service flexibility and scalability, and improve security management. Grid configuration is an important component of the Thetis model for building models and processing various aspects of the model.

[0076] In summary, grid is a key concept in numerical simulation and engineering applications. It divides the continuous physical space into discrete small units, so that complex physical phenomena can be simulated and analyzed by numerical methods.

[0077] Mesh information refers to the data structure and parameters used to describe the spatial distribution of the model in the finite element model. It usually includes the location information of the mesh nodes, the connection relationship of the units, the topological structure of the mesh, etc. In the nearshore ocean model, mesh information is used to define the geometry and spatial resolution of the model, and is the basis for model construction and simulation.

[0078] The mesh object obtained based on the mesh information refers to the entity used to represent and manage mesh data in the model. In the Thetis model, mesh objects may include mesh points, mesh cells, boundary conditions, etc., which together constitute the geometric framework of the model. Through mesh objects, precise control and management of the spatial distribution of the model can be achieved, providing a basis for subsequent numerical calculations and analysis.

[0079] In the Thetis model, the construction of mesh objects involves the specification of mesh objects for mesh management, the definition of all related initialization functions, the construction of a two-dimensional solver, etc. These steps ensure that the mesh information can be correctly integrated and managed, so as to construct a mesh object that meets the requirements.

[0080] In summary, mesh information is a description of the spatial distribution of the model, and mesh objects are entities constructed based on this information. Together, they support the model construction and simulation process.

[0081] The JSON file is read by BMlexposed Thetis, and a Thetis model is constructed based on the information in the former. This requires the specification of a mesh object and the definition of any related functions, and constructs a two-dimensional solver, which is used to perform some smooth application checks (Algorithm 1; method1 initialization). The two-dimensional solver plays an important role in the Thetis model, which is used to ensure the smoothness and accuracy of the model, thereby supporting the correct operation and simulation analysis of the model. The designed End algorithm is shown in Table 1.

[0082] Equation 1:

[0083] Algorithm 1: BMI-Thetis Class

[0084] Method 1: Initialization (loading from JSON configuration file)

[0085] 1: Load the JSON configuration file.

[0086] 2: Identify the online coupling mode and simulation type, determine the implementation of ICs and the calculation of slope coefficients.

[0087] 3: Create a mesh object from the Gmsh file.

[0088] 4: Create grid coordinate attributes.

[0089] 5: Perform any coordinate reprojection.

[0090] 6: Determine the execution mode, i.e. serial or parallel.

[0091] 7: Define scalar and vector function spaces.

[0092] 8: Define the substrate function.

[0093] 9: Create any user-requested functionality.

[0094] 10: If there is a "viscosity parameter" in the JSON configuration file:

[0095] 11: Continue to include horizontal viscosity terms

[0096] 12: If the "personnel parameter" in the JSON configuration file:

[0097] 13: Continue to consider bed shear stress

[0098] 14: If the JSON configuration file contains Coriolis parameters:

[0099] 15: Continue to include Coriolis frequency effects

[0100] 16: If there is a "wind forcing" item in the JSON configuration file:

[0101] 17: Next consider the wind surface stress

[0102] 18: If there is "tidal forcing" in the JSON configuration file:

[0103] 19: Continue tidal forcing

[0104] 20: If there is "UV Force" in the JSON configuration file:

[0105] 21: Continue to use the current flow rate to force

[0106] 22: Specify boundary conditions (BCs)

[0107] 23: If there is a "WCI" object in the JSON configuration file:

[0108] 24: Continue to configure Thetis-SWAN online coupling

[0109] 25: If there is a "WEoC" object in the JSON configuration file:

[0110] 26: Continue to apply wave effects to tidal currents, i.e. offline coupling

[0111] 27: Create a 2-D Thetis solver object for the shallow water equations

[0112] 28: Perform some checks to ensure the simulation runs seamlessly

[0113] 29: If the online coupling mode is "Bidirectional" or "Thetis-to-SWAN":

[0114] 30: Continue to calculate the required output field (λ, u, v)

[0115] 31: Create time step attributes for BMI-Thetis objects

[0116] End method

[0117] method update()

[0118] 1: Calculate ramp amplification factor / coefficient if necessary

[0119] 2: If "2-way" or "SWAN-to-Thetis" online coupling is specified, or offline coupling: 3: Continue to update the current waveform effect

[0120] 4: Advance the model by one time step

[0121] 5: Update the simulation counter

[0122] 6: Execute model callback, that is, output request

[0123] 7: If the simulation time is equal to the export time:

[0124] 8: Continue to export output quantity

[0125] End Method

[0126] method update_until(time)

[0127] 1: If the online coupling mode is "2-way" or "SWAN-to-Thetis":

[0128] 2: If necessary, continue to perform wave characteristic interpolation

[0129] 3: Call the BMI-Thetis update() method to advance the model by one time step

[0130] 4: If the simulation time is less than the specified time parameter

[0131] 5: Keep moving Thetis forward until the simulation time reaches the specified time

[0132] 6: If the coupling mode is "2-way" or from "Thetis-to-SWAN":

[0133] 7: Continue to calculate the necessary output fields η, u, v

[0134] 8: If the coupling mode is "2-way" or "SWAN-to-Thetis": 9: Continue updating the function that stores the "old" values ​​of the wave properties (for interpolation purposes)

[0135] End Method

[0136] method finalize()

[0137] 1: Determines the output directory and trailing name of the file to be exported.

[0138] 2: Export hot start file of water level elevation and flow velocity (*.hdf5)

[0139] 3: If the coupling mode is "2-way" or "SWAN-to-Thetis":

[0140] 4: Continue to generate hot start files for Hs

[0141] ,θm,λ,Qb

[0142] Table 1 End method

[0143]

[0144] Develop a parser that can read and parse the content of the configuration file and map it into the Thetis model.

[0145] In specific applications, users first need to design a configuration file that conforms to the JSON format, including information such as grid configuration, model parameters, input and output variables, etc. This configuration file should be user-friendly and easy to modify so that users can quickly customize the model as needed. The development of the parser is also crucial, as it needs to be able to accurately parse the various parameters in the configuration file and map them to the Thetis model. In this way, users can build the Thetis model by simply editing the configuration file, avoiding complex programming and initialization processes.

[0146] 2. Thetis model construction:

[0147] Construct the mesh object of the Thetis model according to the mesh information in the configuration file.

[0148] Define related functions, including initialization functions and update functions, to ensure that the model can run correctly; update functions are related functions used to ensure that the Thetis model can run correctly. Specifically, these update functions include initialization functions and update functions, which are used to advance the construction of the Thetis model and determine the requested output variable values ​​during the operation phase of the Thetis model. The definition and use of these functions are part of the Thetis model BMI configuration method, which ensures that the Thetis model can correctly update the state and output results according to the input variables and model parameters during operation.

[0149] According to the mesh information in the configuration file, the user needs to build the mesh object of the Thetis model. This process involves operations such as creating the mesh and connecting the nodes to ensure that the geometry of the model meets the user's needs. At the same time, the user also needs to define some related functions, such as initialization functions and update functions, to ensure that the model can run correctly. The writing of these functions should take into account the parameters in the configuration file so that the model can be initialized and updated accordingly according to the information in the configuration file.

[0150] 3. BMI method modification and expansion:

[0151] The BMI methods of Thetis are modified to support splitting the simulation into multiple "run" phases (the multiple run phases are in Algorithm 2 below, as shown in Table 2). The advancement and iteration of its intrinsic methods constitute the core of the BMI methods update and update_until (Algorithm 2) to advance the model by one time step or until a specified time, respectively. These intrinsic methods need to be modified to split the simulation into multiple "run" phases. As in BMI-SWAN, these changes are implemented in duplicate versions of advance and update_until to ensure the integrity of the original code. Finally, the "hot file" that initializes the subsequent Thetis simulation is generated through the finalize method (Algorithm 1), completing the current Thetis simulation.

[0152] The original source code structure hindered modularization because there was no clear separation of program functionality. Specifically, subroutines SWINITMPI and SWEXITMPI handled the initialization and termination of the message passing interface (MPI), while the rest of the SWAN code was executed through subroutine SWMAIN. To achieve BMI implementation, the code functionality must be clearly divided into IRF steps, so refactoring is essential. A top-down refactoring approach was implemented to minimize the modifications to the SWAN legacy code. Specifically, subroutine SWMAIN was divided into 3 parts: (1) SWANINIT, (2) SWANMAIN; and (3) SWANFINALIZE. Figure 1), each corresponding to a model life cycle phase. In the "Initialize" phase, subroutine SWANINIT is responsible for (i) performing MPI initialization via subroutine SWINITMPI, (ii) interpreting SWAN's configuration file, (iii) allocating and initializing arrays, and (iv) assigning default and user-specified values. For the "Run" phase, subroutine SWANMAIN is used; it retains only the subroutine SWMAIN code related to executing the SWAN calculation, which is responsible for advancing the model and determining the requested output variable values. Finally, in the "Finalize" step, subroutine SWANFINALIZE transfers the stored output variables to file and terminates the SWAN simulation and its MPI environment via subroutine SWEXITMPI.

[0153] Extend the BMI method to support the calculation of more input variables and output variables. To meet the requirement of segmenting the simulation into multiple "run" stages, users need to modify Thetis's BMI method to support this segmented operation. This may involve adding new parameters and functions to the BMI method to enable the calculation and update of the model at different stages. At the same time, users also need to extend the BMI method to support the calculation of more input variables and output variables. These modifications and extensions should be performed while maintaining the integrity of the original code to ensure the stability and accuracy of the model.

[0154] 4. Generate initialization file:

[0155] The method determines the generation of hot start files (see Algorithm 2 for 'hotstart files') to initialize subsequent Thetis simulations. Hot start files are typically used to store information about the state of a model at a specific point in time so that simulations can continue from that state without starting from the beginning. In the Thetis model mentioned in the document, hot start files are used to initialize subsequent simulations, which means that they contain all the necessary information about the model at a specific moment, such as water level elevation and flow rate, which can be used to restore the state of the model so that simulations can continue without recalculating previously completed parts.

[0156] Initialization files are usually used to set the initial conditions of the model in order to start the simulation. In the context of the Thetis model, initialization files may refer to configuration files used to build the model. These files contain information such as grid configuration, model parameters, input and output variables, etc., which are used to guide the initialization process of the model.

[0157] The relationship between hot start files and initialization files is that initialization files are used to set the initial state of the model, while hot start files are used to store the state of the model at a certain point in time so that simulation can continue from that state. In practical applications, initialization files may be used to create hot start files because hot start files need to contain the initial state information of the model.

[0158] In summary, the hot start file is used to store the intermediate state of the model so that the simulation can continue from that state, while the initialization file is used to set the initial state of the model. Both play different roles in the simulation process of the model, but both are crucial to the operation of the model.

[0159] Make sure that the generated initialization file contains the necessary information to fully initialize the Thetis model.

[0160] By determining the generation of 'hotfiles' through the method, the user needs to ensure that the generated initialization file contains the necessary information to fully initialize the subsequent Thetis simulation. This process requires generating the corresponding initialization file based on the parameters and model status in the configuration file. At the same time, the user also needs to verify the generated file to ensure its completeness and correctness to avoid problems in the subsequent simulation process.

[0161] 5. Optimize user experience:

[0162] We need to focus on how to optimize the user experience so that the BMI configuration of Thetis using configuration files is smoother and more efficient. This may include designing a more intuitive and concise configuration file format, providing detailed documentation and examples to help users get started quickly. Users can also consider developing some visualization tools to help users understand the configuration and operation process of the model more intuitively, and improve the user experience of using Thetis for simulation.

[0163] Design a concise and intuitive configuration file format, see Algorithm 2, to facilitate user modification and customization.

[0164] The method involved in the embodiment of the present invention provides corresponding documents and examples to help users quickly get started and understand how to use the configuration file to configure the BMI of Thetis.

[0165] Through the implementation of the above key steps, users can easily configure Thetis's BMI model and complete model construction and simulation without in-depth programming knowledge, which improves work efficiency and optimizes user experience.

[0166] In summary, in order to facilitate the establishment of a two-dimensional Thetis model and solve the input requirements of the BMI initialization function (see Algorithm 2), a configuration file in JavaScript Object Notation (JSON) format was developed. The introduction of the configuration file simplifies the BMI configuration process of Thetis. By reading and parsing the JSON file, users can quickly build the Thetis model, avoiding tedious initialization and construction steps. Providing a user-friendly configuration method enables users to use Thetis for simulation more conveniently, improving work efficiency and user experience. Therefore, this configuration file is designed to handle all aspects of the model, from grid configuration to forced fields, avoiding the trouble of users dealing with the underlying code. Table 1 provides an overview of the JSON objects created so far, and the following shows an example of defining velocity forcing through the configuration file:

[0167]

[0168] The presence of the configuration file simplifies the construction process of the 'initialization' phase. Thetis exposed via BMI reads the JSON file and builds the Thetis model based on the information in the former. This requires the specification of a mesh object and the definition of any relevant functions, constructs a 2-Dsolver and performs some checks for a smoothing application (Algorithm 2, Method 12 Initialization). The advancement and iteration of the intrinsic methods form the core of the BMI methods update and update_to (Algorithm 2), which advance the model by one time step or to a specified time, respectively. Modifications to these intrinsic methods are required to account for the problem of splitting the simulation into multiple 'run' phases. As in BMI-SWAN, these changes are implemented in duplicate versions of advance and update_to to ensure that the integrity of the original code is maintained. Finally, the current Thetis simulation is completed by method determination (Algorithm 2), generating the 'hotfiles' used to initialize subsequent Thetis simulations.

[0169] Currently, BMI-Thetis computes four input variables at its grid points: (i) the significant wave height H, (ii) the mean wave direction θ in a Cartesian convention m , Cartesian Convention is a specification and convention used in mathematics and physics to establish coordinate systems. Cartesian convention defines the direction of coordinate axes and their positive and negative directions in two-dimensional or three-dimensional space in order to describe the position and motion of points or objects in space, (iii) average wave period Tm, (iv) wave breaking percentage q. It supports the following output variables in structured grids: u and v components of average flow velocity at water height and depth. These I / O fields help to include WCI effects in the coupled system composed of SWAN and Thetis.

[0170] Table 2 Algorithm 2

[0171]

[0172]

[0173] The embodiments of the present invention can be applied to the following fields:

[0174] 1. Marine engineering: It can be used for marine simulation and prediction in the marine engineering field. Thetis BMI configuration files can be used to quickly and accurately simulate the impact of natural environmental factors such as waves, tides and currents on marine structures. The configuration files simplify the Thetis model building and initialization process, allowing engineers to build the required models more quickly and predict the impact of the marine environment on structures. This helps design more stable and reliable marine engineering projects. It helps marine engineers design marine structures and plan marine resource development.

[0175] 2. Environmental protection and management: Thetis' BMI profile can be used to simulate the impact of environmental factors such as water flow, wave motion, wave damage and tidal changes in the marine environment on coastlines and ecosystems. The BMI profile simplifies the complexity of the model building process, allowing researchers to more effectively assess the potential impact of environmental changes on ecosystems, better understand the impact of environmental changes on ecosystems, and thus put forward reasonable management recommendations, providing a scientific basis for environmental protection and ecological restoration, and protecting the ecological environment.

[0176] 3. Climate change research: In climate change research, the algorithm can be used to simulate the impact of ocean temperature, sea level rise, and extreme weather events (storm surges, tsunamis, etc.) on the ocean. The design of the configuration file simplifies the model building process, making the model building more flexible and efficient, which can help meteorological experts build disaster prediction models more quickly, better understand the trends and impacts of marine climate change, provide early warnings and take relevant rescue measures, provide support for responding to climate change, and reduce the losses caused by disasters to people and property.

[0177] 4. Marine resource development: In the field of marine resource development, Thetis's BMI configuration files can be used to simulate marine conditions and risk assessments in marine engineering projects, and to simulate the distribution and changes of marine resources, such as marine energy and fishery resources. Through convenient configuration files and initialization functions, the model building process can be simplified through configuration files, and models can be quickly established for simulation analysis, providing accurate marine environmental data support for projects such as marine wind power and marine oil and gas exploration. Developers can more conveniently conduct resource exploration and development planning, improve resource utilization efficiency, and ensure sustainable development.

[0178] 5. Hydraulic engineering field: This algorithm is also applicable to hydrological and water resources research and water conservancy engineering design in the field of hydraulic engineering. Through the BMI configuration of the Thetis model, the hydrodynamic process in rivers and waters can be simulated, including parameters such as water level changes and flow rate, providing technical support for reservoir scheduling, management and sustainable use of water resources.

[0179] The beneficial technical effects achieved by the embodiments of the present invention are as follows:

[0180] 1. The embodiment of the present invention simplifies the construction process and parameter construction process of the initialization phase by introducing the concept of configuration files. At the same time, the configuration files in JSON format are read in BMI-Thetis to realize the function of building a model according to the configuration file information. This improves the cumbersome operation of the prior art in the initialization phase, improves the convenience of operation, and improves the efficiency and accuracy of building models. The user-friendly configuration file design reduces the burden of users processing the underlying code.

[0181] 2. In view of the limitations of input and output variables in the prior art, the embodiments of the present invention introduce more variable support, support richer input and output variables, including depth average velocity components, etc., to enhance the model's simulation ability for complex environmental variables and facilitate the inclusion of WCI effects in the coupled system. This enables the model to more comprehensively reflect the actual situation and improves the accuracy, reliability and applicability of the simulation results.

[0182] 3. By modifying the inherent method of BMI-Thetis, the embodiment of the present invention solves the problem of dividing the model into multiple "running" stages, improves the continuity and reliability of the simulation, and improves the logical clarity and efficiency of the model when it is frequently called and executed. This allows the model to better cope with complex situations and improves the accuracy and stability of the simulation. Modifications and adjustments to the BMI method make the simulation process more flexible and controllable.

[0183] It should be understood that the specific order or hierarchy of steps in the disclosed process is an example of an exemplary method. Based on design preferences, it should be understood that the specific order or hierarchy of steps in the process can be rearranged without departing from the scope of protection of the present disclosure. The attached method claims present the elements of the various steps in an exemplary order and are not intended to be limited to the specific order or hierarchy described.

[0184] In the above detailed description, various features are grouped together in a single embodiment to simplify the disclosure. This method of disclosure should not be interpreted as reflecting an intention that the embodiments of the claimed subject matter require more features than are clearly stated in each claim. On the contrary, as reflected in the appended claims, the invention is in a state of having less than all the features of the disclosed individual embodiments. Therefore, the appended claims are hereby expressly incorporated into the detailed description, with each claim standing on its own as a separate preferred embodiment of the invention.

[0185] The disclosed embodiments are described above to enable any person skilled in the art to implement or use the present invention. Various modifications of these embodiments are obvious to those skilled in the art, and the general principles defined herein may also be applied to other embodiments without departing from the spirit and scope of the present disclosure. Therefore, the present disclosure is not limited to the embodiments given herein, but is consistent with the broadest scope of the principles and novel features disclosed in this application.

[0186] The above description includes examples of one or more embodiments. Of course, it is impossible to describe all possible combinations of components or methods for the purpose of describing the above embodiments, but it should be recognized by those skilled in the art that the various embodiments may be further combined and arranged. Therefore, the embodiments described herein are intended to cover all such changes, modifications and variations that fall within the scope of protection of the appended claims. In addition, with respect to the term "comprising" used in the specification or claims, the word is covered in a manner similar to the term "including", just as "including," is explained as a transitional word in the claims. In addition, any term "or" used in the specification of the claims is intended to mean "non-exclusive or".

[0187] Those skilled in the art may also understand that the various illustrative logical blocks, units, and steps listed in the embodiments of the present invention may be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly demonstrate the interchangeability of hardware and software, the various illustrative components, units, and steps described above have generally described their functions. Whether such functions are implemented by hardware or software depends on the specific application and the design requirements of the entire system. Those skilled in the art may use various methods to implement the described functions for each specific application, but such implementation should not be understood as exceeding the scope of protection of the embodiments of the present invention.

[0188] The various illustrative logic blocks or units described in the embodiments of the present invention can be implemented or operated by a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field programmable gate array or other programmable logic device, a discrete gate or transistor logic, a discrete hardware component, or any combination of the above. The general-purpose processor can be a microprocessor, and optionally, the general-purpose processor can also be any conventional processor, controller, microcontroller or state machine. The processor can also be implemented by a combination of computing devices, such as a digital signal processor and a microprocessor, a plurality of microprocessors, one or more microprocessors combined with a digital signal processor core, or any other similar configuration.

[0189] The steps of the method or algorithm described in the embodiments of the present invention can be directly embedded in hardware, a software module executed by a processor, or a combination of the two. The software module can be stored in a RAM memory, a flash memory, a ROM memory, an EPROM memory, an EEPROM memory, a register, a hard disk, a removable disk, a CD-ROM, or other storage media of any form in the art. Exemplarily, the storage medium can be connected to the processor so that the processor can read information from the storage medium and can write information to the storage medium. Optionally, the storage medium can also be integrated into the processor. The processor and the storage medium can be arranged in an ASIC, and the ASIC can be arranged in a user terminal. Optionally, the processor and the storage medium can also be arranged in different components in the user terminal.

[0190] In one or more exemplary designs, the above functions described in the embodiments of the present invention can be implemented in hardware, software, firmware or any combination of the three. If implemented in software, these functions can be stored on a computer-readable medium, or transmitted in the form of one or more instructions or codes on a computer-readable medium. Computer-readable media include computer storage media and communication media that facilitate the transfer of computer programs from one place to another. The storage medium can be any available medium that can be accessed by any general or special computer. For example, such computer-readable media can include but are not limited to RAM, ROM, EEPROM, CD-ROM or other optical disk storage, disk storage or other magnetic storage devices, or any other medium that can be used to carry or store program codes in the form of instructions or data structures and other forms that can be read by general or special computers, or general or special processors. In addition, any connection can be appropriately defined as a computer-readable medium, for example, if the software is transmitted from a website site, server or other remote resource through a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL) or wirelessly, such as infrared, wireless and microwave, it is also included in the defined computer-readable medium. The disk and disc include compact disk, laser disk, optical disk, DVD, floppy disk and blue-ray disk. Disks usually copy data magnetically, while discs usually copy data optically with lasers. The above combination can also be included in computer readable media.

[0191] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A BMI configuration method for a nearshore ocean model based on finite elements, characterized in that: include: For the finite element-based nearshore ocean model: Thetis model, a configuration file of the basic model interface BMI is constructed, and the configuration file is used for the initialization function input of BMI; Constructing a parser capable of reading and parsing the contents of the configuration file, and mapping the contents of the configuration file into the Thetis model; When the Thetis model is initialized and constructed, the content of the configuration file mapped to the Thetis model is edited through BMI, an initialization function is constructed, and the Thetis model initialization file is formed through the initialization function; The configuration file of the basic model interface BMI is constructed for the finite element-based nearshore ocean model: Thetis model, including: For the finite element-based nearshore ocean model: Thetis model, the configuration file of the basic model interface BMI is constructed, including grid configuration, model parameter settings, input variable output variable information settings and mandatory field configuration; among them: Constructing a specification for forming a mesh object, setting definitions of all related initialization functions, constructing a two-dimensional solver, the two-dimensional solver is used to perform a check of a smoothing application in the Thetis model, integrating and managing various resources in the Thetis model through the mesh configuration, and constructing the mesh configuration; Add relevant parameters of the nearshore ocean, and when the relevant parameters include a first parameter, determine other parameters associated with the first parameter, and add the other parameters to the relevant parameters, and the model parameters are set; Determine input parameters from the relevant parameters of the nearshore ocean, determine relevant output parameters based on the input parameters, and construct input variable and output variable information settings; Set mandatory fields in model parameters and variable information to ensure that certain columns in the data table always contain valid values; The BMI configuration method of the finite element-based nearshore ocean model further includes: According to the grid configuration in the configuration file, a grid object of the Thetis model is constructed; the grid points on the grid object have four input variables: significant wave height H s , the average wave direction θ in the Cartesian convention m and the average wave period T m and wave breaking percentage Q b , the grid points on the grid object have the following output variables: water height and depth average flow velocity; Define relevant functions, which include an initialization function and an update function. The initialization function and the update function are used to ensure that the Thetis model can run correctly and ensure that the Thetis model can correctly update the state and form the value of the output variable according to the input variables and model parameters during operation.

2. The BMI configuration method of the finite element-based nearshore ocean model according to claim 1, characterized in that: The configuration file is in JSON format.

3. The BMI configuration method of the finite element-based nearshore ocean model according to claim 1, characterized in that: Also includes: Modify the method of constructing the Thetis model involved in the BMI so that the method of constructing the Thetis model involved in the BMI supports dividing the simulation of the Thetis model into multiple life cycle stages.

4. The BMI configuration method of the finite element-based nearshore ocean model according to claim 3, characterized in that: The method of constructing the Thetis model involved in modifying the BMI so that the method of constructing the Thetis model involved in the BMI supports segmenting the simulation of the Thetis model into multiple life cycle stages, including: Modify the SWAN code for constructing the Thetis model through the subroutine SWMAIN, divide the SWAN code into IRF steps, and obtain three life cycle stages corresponding to the Thetis model: initialization stage, operation stage and end stage; The three parts of the subroutine SWMAIN: the subroutine SWANINIT, the subroutine SWANMAIN and the subroutine SWANFINALIZE correspond to a life cycle stage of the Thetis model respectively: In the initialization phase, the subroutine SWINITMPI of the subroutine SWANINIT is used to perform MPI initialization, interpret the configuration file of the SWAN code, allocate and initialize arrays, and assign default values ​​and user-specified values; During the operation phase, the subroutine SWANMAIN is used to retain the subroutine SWMAIN code associated with performing the SWAN calculation, and the subroutine SWMAIN code associated with the SWAN calculation is responsible for advancing the construction of the Thetis model and determining the requested output variable values; In the end phase, the stored output variables are transferred to a file using the subroutine SWANFINALIZE and the execution of the SWAN code and the environment of the MPI build initialization function are terminated by the subroutine SWEXITMPI.

5. The BMI configuration method of the finite element-based nearshore ocean model according to claim 3, characterized in that: Also includes: Expanding the BMI involves the method of constructing the Thetis model to support the calculation of more input variables and output variables.

6. The BMI configuration method of the finite element-based nearshore ocean model according to claim 1, characterized in that: The Thetis model initialization file refers to a hot start file used for initializing the Thetis model.

7. The BMI configuration method of the finite element-based nearshore ocean model according to claim 1, characterized in that: The configuration file for constructing the basic model interface BMI includes: The configuration file for building the basic model interface BMI is generated in a configuration file format in which one line corresponds to one configuration content.

Citation Information

Patent Citations

  • Method for assessing tide energy resource through numerical simulation of sea model

    CN103390248A

  • Automatic restarting and reconfiguration of physics-based models in event of model failure

    US20200233747A1