.. role:: cpp(code) :language: c++ .. _CouplingToAMRWind: Coupling To AMR-Wind ==================== The simplest form of coupling is one-way, file-based coupling. With this approach, an ERF simulation is run and output files with relevant simulation data are stored at regular time intervals. Once the ERF simulation is complete, an AMR-Wind simulation begins, using the ERF output files as time-dependent boundary conditions or forcing. 1D File-based coupling ---------------------- The 1D file-based coupling scheme is based on the Time-Height Profile Assimilation Technique proposed by `Allaerts et al. `_ In this approach, the time evolution of the vertical profile of the horizontal velocity components and potential temperature at a particular position from the mesoscale simulation is saved, and a forcing term is added to the microscale simulation to indirectly assimilate the mesoscale data at the microscale. The output files generated by ERF are NetCDF files of a format compatible with the `AMR-Wind implementation `_ of this form of coupling. We note that the solution variables in ERF are .. math:: (\rho, \rho u, \rho v, \rho w, \rho \theta) while those in AMR-Wind are .. math:: (u, v, w, T, p) We convert the variables from conservative to primitive form prior to saving the output files. The following parameters control the generation of 1D column output files in ERF. To use this capability, the user must install the `NetCDF library `_ and link to it at compile time, which can be done by setting `USE_NETCDF = TRUE` in the GNUMakefile for ERF. +----------------------------+------------------+------------------+-----------------+ | Parameter | Definition | Acceptable | Default | | | | Values | | +============================+==================+==================+=================+ | **erf.output_1d_column** | whether to output| 0 or 1 | 0 | | | for coupling | | | | | to AMR-Wind | | | +----------------------------+------------------+------------------+-----------------+ | **erf.column_file_name** | prefix for | String | “column_data.nc”| | | output files | | | +----------------------------+------------------+------------------+-----------------+ | **erf.column_interval** | how often (by | Integer | -1 | | | level-0 time | :math:`> 0` | | | | steps) to output | | | | | data files | | | +----------------------------+------------------+------------------+-----------------+ | **erf.column_per** | how often (by | Real :math:`> 0` | -1.0 | | | simulation time) | | | | | to write output | | | | | data files | | | +----------------------------+------------------+------------------+-----------------+ | **erf.column_loc_x** | x-coordinate | prob_lo(0) <= x | 0.0 | | | where vertical | <= prob_hi(0) | | | | profile will be | | | | | extracted | | | +----------------------------+------------------+------------------+-----------------+ | **erf.column_loc_y** | y-coordinate | prob_lo(1) <= y | 0.0 | | | where vertical | <= prob_hi(1) | | | | profile will be | | | | | extracted | | | +----------------------------+------------------+------------------+-----------------+ * You should specify either **erf.output_int** or **erf.output_per**, but not both. 2D File-based coupling ---------------------- For 2D file-based coupling to AMR-Wind, vertical planes are saved from an ERF simulation to define inflow boundary conditions for AMR-Wind. These files are in native-AMReX format and contain the AMReX data structure known as a :cpp:`BndryRegister`. These files are specifically meant to be read by AMR-Wind, which is also AMReX-based, or ERF itself. To generate the boundary data files for each of the four planes, the following (or similar) should be added to the input file: .. code-block:: none erf.output_bndry_planes = 1 erf.bndry_output_planes_interval = 2 erf.bndry_output_start_time = 0.0 erf.bndry_output_planes_file = "BndryFiles" erf.bndry_output_var_names = temperature velocity density erf.bndry_output_box_lo = 256. 256. erf.bndry_output_box_hi = 768. 768. The above inputs will output boundary planes of data at x=xlo, x=xhi, y=ylo and y=yhi, where xlo and ylo are defined by :cpp:`bndry_output_box_lo` and xhi and yhi are defined by :cpp:`bndry_output_box_hi`. Note that the selected lo and hi values must be interior to the first and last cell centers on the coarse grid (i.e., at least one half cell width from the boundary). Except if the domain is periodic in that direction, any location up to and including the domain boundary may be chosen. In this case the variables that are written are temperature, velocity and density, and they are written every 2 coarse time steps starting at :cpp:`bndry_output_start_time` which is 0 in this case. We also have the functionality in ERF to read in these types of files; for this one would add the following (or similar) line to the inputs file: .. code-block:: none erf.input_bndry_planes = 1 erf.bndry_file = "BndryFiles" erf.bndry_input_var_names = density temperature velocity When run with these inputs, ERF will read in the time sequence of files contained in the folder :cpp:`BndryFiles`, and perform time interpolation as necessary. The only assumption about the times associated with the files is that the start and end times of the current simulation lie in the time period covered by the files in :cpp:`BndryFiles`. Within :cpp:`BndryFiles` there is an ascii file :cpp:`time.dat` which contains the (originating) timesteps and physical times associated with each of the files. It is assumed at this point that the physical domain of the simulation reading the files is exactly the physical domain specified by :cpp:`bndry_output_box_lo` and :cpp:`bndry_output_box_hi` when the files were written. If not, ERF will abort with an error message. We note that the boundary plane data will only be used on faces identified in the inputs file as inflow faces, i.e. if we specific inflow/outflow in the x-direction, and periodic in the y-direction, as below, then only the "xlo" boundary data from :cpp:`BndryFiles` will actually be used. :: geometry.is_periodic = 0 1 0 xlo.type = "Inflow" xhi.type = "Outflow"