CMS-Flow:Features: Difference between revisions

From CIRPwiki
Jump to navigation Jump to search
mNo edit summary
 
(176 intermediate revisions by 2 users not shown)
Line 1: Line 1:
='''General Parameters'''=
= Hot Start =
The general parameters include solution scheme, time settings such as start time, duration and time step as well as wetting and drying depth. Most of the general parameters are set by going to "Model Parameters" tab within the "CMS-Flow Model Control" window. Below are some of the CMS cards related to the "Model Parameters" tab.
The term Hot start refers to starting a  simulation with an initial condition other zero (cold start). Hot starts  are used for specifying initial conditions or restarting simulations at  intermediate times. The hot start controls are set in the ''Flow'' tab of the ''CMS-Flow Model Control'' window.  


{| border="1"
==Hot Start  File ==
! Card !! Arguments !! Default !! Range !! Description
[[Image:Hot_Start_HDFView.png|thumb|right|500px| Figure 1. HDFView showing the structure of the CMS Hot Start File. ]]
The  CMS hot start feature CMS lets the user restart simulations that have been stopped due to electric outages, hardware malfunctions, or model crashes. In the case of a model crash the user, may restart the model using larger solver iterations and/or time steps to stabilize the simulation. The user has the option to specify a hot start output time or an interval for outputting a recurring hot start file. Every time the hot start file is written, it overwrites the previous information. The CMS Hot Start file saves information on the water elevation (pressure), and current velocities. If the sediment transport is active, then the water depth and sediment concentrations are also saved for each size class. Only the very last record of information is preserved (no starting from earlier intervals).
 
The CMS hot start files are written as binary XMDF files by default. Depending on the type of hot start (single file or recurring), the names are as follows are saved in the directory of the CMS-Flow files:
* SingleHotStart.h5
* AutoHotStart.h5
 
After saving a CMS Hot Start file, it is a good idea to rename the file with a different name before using it as an initial conditions file. This way, the file will not be overwritten in future simulations.
 
'''Table 1.  Hot Start CMS-Flow Cards'''
{| class=wikitable border="1"
! Card !! Arguments !! Default !! Range !!   Description
|-
|-
| HYDRO_TIME_STEP || REAL || Calculated based on solution scheme and courant number || none || Sets to the time step for hydrodynamics in seconds.
| HOT_START_TIME || REAL || none || none || Single time after start at which to output a single hot start file.
|-
|-
| DURATION_RUN || REAL || 48.0 || >RAMP>0 || Sets the duration of the model simulation in hours.
| AUTO_HOT_START_INTERVAL || REAL || none || none || Sets the recurring hot start output interval .
|-
| DURATION_RAMP || REAL || 1.0 || Sets the length of the ramp period in which the model forcing is slowly ramped from zero.
|}
|}


='''Boundary Conditions'''=
<br style="clear:both"  />
[[Image:CMS-Flow_Boundary_Conditions_Window.PNG|thumb|right|500px|CMS-Flow Boundary Conditions window]]
CMS-Flow has five types of boundary conditions which are listed and discussed below. The figure below shows the CMS-Flow Boundary Conditions window in SMS. All CMS-Flow boundary conditions are forced at the edges of the domain by use of cellstrings defined with the Surfacewater Modeling System (SMS). Cellstrings can either be created manually or using the SMS tool called ''Generate Along Boundary'' which is found under the ''Cellstring'' menu.


<br style="clear:both" />
==Initial Conditions File==
==Land==
[[Image:Hot_Start_XMDFView_Initial_Condition.png|thumb|right|300px|  Figure 2. Dataset  Toolbox showing a time step sample of the water elevation and current velocity datasets for use in a hot start (initial condition) file.]]
The land boundary conditions is equivalent to a zero flux boundary condition. The land boundary condition is the default boundary condition when a cell string is created. It is not necessary to define land boundaries in the interior of the CMS-Flor domain, since land boundarys will automatically be detected by CMS-Flow based on the local water depths and the presence of inactive land cells.  


==Flow Rate-Forcing==
There are several situations where it is desired to specify a user-defined hot start file from which to start a simulation. If the user has previously specified a hot start file be written either at a specific time or at a recurring interval, they can simply indicate to start from that hot start as an initial condition from the SMS interface, or by adding a card to the parameter file. The card name and format are shown below.
The flow rate boundary condition specifies a time series of water fluxes in units of m^3/s per cell.  


NOTES:
<br  style="clear:both" />
* Total flow rate specified is divided between the total number of cells in the cellstring with each carrying a portion of the total.
'''Table 2. CMS-Flow card for specifying the initial condition file.'''
* This boundary type may only be specified along cell strings which are straight.
{| class=wikitable border="1"
* The sign of the flow rate curve is dependent on the direction of flow with respect to the origin (always lower-left hand corner of the grid).
! Card !! Arguments !! Default !! Range !! Description
|-
| INITIAL_STARTUP_FILE <nowiki>|</nowiki> INITIAL_CONDITION_FILE || CHARACTER ||  none  || none || Hot start filename that contains the information for a Hot Start.
|}


:This guide should assist in proper assignment:
:** Flow rate from the East  - Negative value
:** Flow rate from the West  - Positive value
:** Flow rate from the North - Negative value
:** Flow rate from the South - Positive value


==Water Surface Elevation Forcing==
Sometimes, the user may forget to set up the model output a hot start file or may have been running steady-state conditions. In these cases, a hot start file can easily be created and exported by the user from the SMS interface. The model requires records for water levels, current velocities, concentrations, and water depths and datasets that are missing from the initial file.
Two types of Water Surface Elevation Forcing exist for CMS-Flow. Once a water surface elevation curve (or series of curves) is applied, the user is able to display the curve information graphically.
Note: It is important that the names and paths of the initial condition datasets are written correctly.  


1. Define curve (single time series curve for each cell string)
'''Table 3. Path and name for initial condition file variables.'''
 
{| class=wikitable border="1"
User creates a cellstring for the given boundary and defines a time series curve. The value for each time on this curve is applied to all cells along the designated cellstring. The time series curve may be specified by either importing an SMS *.xys file, copying tabular data into SMS, or manually entered the time series information in SMS.
! Variable !!  Path and Name
 
|-
 
| Water surface elevation ||  Datasets\Water_Elevation
2. Extract from data set (time series curve for each cell on cell string)
|-
| Current velocity ||  Datasets\Current_Velocity
|-
| Sediment concentrations || Datasets\Concentration
|-
| Salinity concentrations ||  Datasets\Salinity
|}
<br  style="clear:both" />


User creates a cellstring for the given boundary and extracts multiple time series curves from a dataset or database.  Each cell along the cellstring is given its own time-series curve information. Examples are:
One example showing the steps for creating a user-defined hot start or initial condition file from a CMS-Flow solution file is outlined below.  
* Extraction of water surface elevation values from a larger domain solution (ie. Larger CMS-Flow or ADCIRC grid)
:1. Import CMS-Flow grid and solution file.
* Extraction of tidal constituent information from a tidal database, from which a water surface elevation curve can be generated.
:2. Sample a time step of the solution datasets for use in the initial condition
::* Click on ''Data'' | ''Data Set Toolbox''
:::* Under the ''Tools'' section, select ''Sample time steps''.
:::* Under the ''Datasets'' section, click on the ''Water Elevation''
:3. Export the initial condition  datasets to an XMDF file


==Tidal Constituent Forcing==
More to come about the process above.
[[Image:CMS-Flow_Model_Control_Tidal.png|thumb|right|500px|Tidal Constituent Forcing window in SMS]]
CMS-Flow as the option of forcing with a harmonic tidal water surface elevation. To assign a boundary as a tidal boundary:


# Select a cellstring
[[Image:Hot_Start_Sample.png|thumb|left|500px| Figure 3. Dataset  Toolbox showing a time step sample of the water elevation and current  velocity datasets for use in a hot start (initial condition) file.]]
# Click under ''CMS-Flow | Assign BC...''
[[Image:Hot_Explorting_User_Defined_Arrows.png|thumb|right|500px| Figure 4. Dataset Toolbox showing a time step sample of the water elevation and current velocity datasets for use in a hot start (initial  condition) file.]]
# In the ''CMS-Flow Boundary Conditions'' window, click on ''Tidal constituent-forcing'', and click ''OK''.
# Open the ''CMS-Flow Model Control'' window and click on the tab labeled ''Tidal''.
# Enter the amplitudes and phases of the tidal constituents. Note that the same amplitude and phase are applied to entire cellstring and click ''OK''


<br style="clear:both" />
<br style="clear:both" />


==Water Surface Elevation and Velocity Forcing==
= Global Output =
Users are able to extract both water surface elevations and velocity components from a larger domain solution (ie. Larger CMS-Flow or ADCIRC grid).
[[image:Output_Tab.png|thumb|right|400px| Figure 1. ''Output'' tab in SMS 11.0 ]]
 
Global output refers to the variables that are output on every active cell on the grid. The global output options are specified in ''Output'' tab of the ''CMS-Flow Model Control'' window. More information on the global output variables, groups and CMS-Flow cards is provided in the sections below.
==Salinity Concentration Forcing==
If salinity transport is active for the simulation, the user has the ability to use existing hydrodynamic cellstrings in the interface in order to provide a time-series curve of salinity concentrations. The salinity concentrations must be provided in units of ppt.
 
='''Global Forcing'''=
There are two main types of global forcing available in CMS-Flow, wind and wave.  Global forcing means that the forcing is applied on a cell-by-cell nature, rather than forcing along a boundary. 
 
==Wind Forcing==
'''Wind Curve'''
[[Image:CMS-Flow_Model_Control_Wind-Wave.png|thumb|right|500px|SMS 10.1 | alt=SMS 10.1]]
Temporally varying, spatially constant winds are input in CMS in the Wind Section of the CMS-Flow Model Control Window. To add wind forcing to a current CMS-Flow project click on ''CMS-Flow'' | ''Model Control'' and then on the ''Wind/Wave'' tab. Activate wind forcing by clicking on the ''Include Wind'' check box. Winds may be imported using an *.m2w file or by specifying a curve for wind speed and direction. To specify a curve for each click on the respective box which says ''Curve undefined'' which will open the ''XY Series Editor''. The time series may be manually entered, copied or imported from an *.xys file in the ''XY Series Editor''.
 
<br style="clear:both" />
'''Spatially Variable Wind and Atmospheric Pressure'''
CMS-Flow V4.0 and higher have the option to use spatially variable wind and atmospheric pressure forcing. Currently, this feature is specified in the advanced card section using the cards listed in the table below.


'''CMS-Flow cards related to wind'''
<br clear="all">
{| border="1"
== Output Datasets ==
! Card !! Arguments !! Type
A description of the CMS-Flow cards used to specify the global output variable datasets is provided below.
 
'''Table 4. Output datasets.'''
{| class=wikitable  style="text-align: center; border: 1px solid black;"
! Output Dataset !! Group  !! Description !! <span style="color: red">Scalar</span>/<span style="color: darkblue">Vector</span> !! Units
|- style="border-bottom: 1px solid red;"
| Water_Elevation  || Water surface elevation|| Cell-centered water surface elevation || <span style="color: red">'''Scalar'''</span> || <math>m</math>
|-
|-
| WIND_OUT_TIMES_LIST || Id number of output times list || integer
| Current_Velocity  || Velocity || Depth-averaged and cell-centered current velocity '''Vector''' dataset and with respect to local grid coordinates || <span style="color: darkblue">'''Vector'''</span> || <math>m/s</math>
|-
| Current_Magnitude  || Velocity || Depth-averaged and cell-centered current velocity magnitude dataset || <span style="color: red">'''Scalar'''</span> || <math>m/s</math>
|-
| Eddy_Viscosity || Eddy viscosity || Cell-centered horizontal eddy viscosity || <span style="color: red">'''Scalar'''</span> || <math>m^2/s</math>
|-
| Concentration  ||  Sediment|| Depth-averaged and cell-centered sediment concentration  || <span style="color: red">'''Scalar'''</span> || <math>kg/m^3</math>
|-
|-
| WIND_DRAG_COEFFICIENT || kappa in Hsu (1988) (default 0.4) || real
| Capacity  || Sediment || Depth-averaged and cell-centered sediment concentration capacity || <span style="color: red">'''Scalar'''</span> || <math>kg/m^3</math>
|-
|-
| WIND_INPUT_CURVE ||  Name of model parameter file followed wind curve path || character
| Total_Sediment_Transport ||  Sediment || Depth-averaged and cell-centered total-load sediment transport || <span style="color: darkblue">'''Vector'''</span> || <math>kg/m/s</math>
|-
| Morphology_Change ||  Morphology ||  Cell-centered  morphology (bed) change. Positive is accretion and negative is erosion || <span style="color: red">'''Scalar'''</span> || <math>m</math>
|-
|-
| ANEMOMETER_HEIGHT || Height of wind speeds || meter
| Depth || Morphology || Cell-centered still water depth || <span style="color: red">'''Scalar'''</span> || <math>m</math>
|-
| Salinity  ||  Salinity Transport  || Depth-averaged and cell-centered sediment  concentration capacity || <span style="color: red">'''Scalar'''</span> || <math>ppt</math>
|-
| Wave_Height  ||  Waves ||  Cell-centered significant wave height || <span style="color: red">'''Scalar'''</span> || <math>m</math>
|-
|-
| [[OCEANWEATHER_WIND_FILE]] || Name of Oceanweather, Inc. wind file (*.win) || character
| Wave_Height_Vec  || Waves || Cell-centered  significant wave height '''Vector''' || <span style="color: darkblue">'''Vector'''</span> || <math>m</math>
|-
|-
| [[OCEANWEATHER_PRES_FILE]] ||  Name of Oceanweather, Inc. pressure file (*.pre) || character
| Wave_Period  ||  Waves ||  Cell-centered peak wave period || <span style="color: red">'''Scalar'''</span> || <math>s</math>
|-
| Wind_Magnitude  ||  Wind ||  Cell-centered wind speed || <span style="color: red">'''Scalar'''</span> || <math>m/s</math>
|-
|-
| [[OCEANWEATHER_XY_FILE]] ||  Name of Oceanweather, Inc. coordinate file (*.xy) || character
| Wind_Velocity  ||  Wind ||  Cell-centered wind velocity '''Vector''' dataset with respect to local grid coordinates || <span style="color: darkblue">'''Vector'''</span> || <math>m/s</math>
|-
|-
| WIND_PRESSURE_FLEET_FILE ||  Name of fleet wind and pressure file || character
| Atm_Pressure  ||  Wind ||  Cell-centered atmospheric pressure || <span style="color: red">'''Scalar'''</span> || <math>Pa</math>
|-
|-
| WIND_PRESSURE_GRID_PARAM ||  Nwlat,Nwlon,wLatMax,wLonMin,wLatInc,wLonInc || integer and real
| Atm_Pressure_GradX  ||  Wind ||  Cell-centered atmospheric pressure gradients in the X direction || <span style="color: red">'''Scalar'''</span> || <math>Pa/m</math>
|-
|-
| WIND_PRESSURE_TIME_INCREMENT || wTimeInc || real
| Atm_Pressure_GradY  ||  Wind ||  Cell-centered atmospheric pressure gradients in the Y direction || <span style="color: red">'''Scalar'''</span> || <math>Pa/m</math>
|}
|}


==Wave Forcing==
== Output Time Series and Lists ==
Temporally and spatially varying. 
The times at which each group is output is determined by the selecting one of four user defined output time series or lists. In SMS versions 10.1 and earlier, the output time series were used. However, because the output time series can become very large for long-term simulations, the time series have been replaced by lists in which the output times are specifying a list of starting, ending and increments. This option is more compact and also makes it easier to manually change the output options in the cmcards file.  
* Wave forcing is generally provided by the user selecting to use the Steering Module within SMS. The mapping of wave data from wave grid to flow grid is automated during the course of the steering process.
* If a choice is made not to use the steering process, the user must provide several datasets of information which has been mapped to the flow grid geometery.
**Radiation stress gradient
**Wave height
**Wave period
**Wave direction
**Wave dissipation


'''CMS-Flow cards  related to wave forcing (one-way coupling)'''
'''Table 5. Time series and List Cards.'''
{| border="1"
{| class=wikitable  border="1"
! Card !! Arguments !! Type
! Card !! Aguments/Format !! Default value !!   Description
|-
| TIME_SERIES_1 ||  [length of list 1] [output times for list 1] || 0 || Output time series  for list 1 in hours.
|-
|-
|WAVE_RSTRESS_DATASET || "File name" "Dataset path" || character
| TIME_SERIES_2  || [length  of list 2] [output times for list 2] || 0 || Output time  series for list 2 in hours.
|-
|-
|WAVE_HEIGHT_DATASET || "File name" "Dataset path" || character
| TIME_SERIES_3 || [length of list 3] [output times for list 3] || 0 || Output time series for list 3 in hours.
|-
|-
|WAVE_PERIOD_DATASET || "File name" "Dataset path" || character
| TIME_SERIES_4 || [length  of list 4] [output times for list  4] || 0 || Output time series for list 4 in hours.
|-
|-
|WAVE_DIRECTION_DATASET || "File name" "Dataset path" || character
| TIME_LIST_1 || [number of sublists] [sublist 1: start, end,  increment] [sublist 2: start, end, increment]...|| 0 || Sublist(s) for  output time series 1. For each sublist, the arguments are starting time,  end time and increment in hours.
|-
|-
|WAVE_DISSIPATION_DATASET || "File name" "Dataset path" || character
| TIME_LIST_2 || [number of sublist] [sublist 1: start, end, increment]  [sublist 2: start, end, increment]...|| 0 || Sublist(s) for output time  series 2. For each sublist, the arguments are starting time, end time  and increment in hours.
|-
| TIME_LIST_3  || [number of sublist] [sublist 1:  start, end, increment] [sublist 2: start, end, increment]...|| 0 || Sublist(s) for output time series 3.  For each sublist, the arguments are starting time, end time and  increment in hours.
|-
| TIME_LIST_4 ||  [number of sublist] [sublist 1:  start, end, increment] [sublist 2:  start, end, increment]...|| 0 || Sublist(s) for output time series 4.  For each sublist, the arguments are starting time, end time and  increment in hours..
|}
|}


='''Transport Options'''=
'''Table 6. Cards used to specify the output time series or list for each output group or dataset.'''
==Sediment Transport==
{| class=wikitable  border="1"
 
! Card !! Arguments !! Default  value !! Description
[[Image:CMS-Flow_Model_Control_Transport.png|thumb|right|400px|SMS 10.1 | alt=SMS 10.1]]
|-
The sediment transport controls are located in the ''Transport'' section of the ''CMS-Flow Model Control'' window as shown in the figure below. The sediment transport is activated by going to the ''Transport'' section of the ''CMS-Flow Model Control'' and checking the box labeles ''Calculate sediment transport''.
| WSE_OUT_TIMES_LIST || INTEGER || 0 || Output time series  id for the water surface elevation in m.  
The CMS card used to turn on or off the sediment transport is described in the table below.
|-
 
| VEL_OUT_TIMES_LIST || INTEGER || 0 || Output time series  id for currentvelocity and magnitude in m/s.  
{| border="1"
|-
! Card !! Arguments !! Default !! Range !! Description
| MORPH_OUT_TIMES_LIST || INTEGER || 0 || Output time series  id for the water depth and morphology (bed) change in m.  
|-
| TRANS_OUT_TIMES_LIST || INTEGER || 0 || Output time series  id for sediment transport rates, concentations, and salinity.  
|-
| WAVES_OUT_TIMES_LIST || INTEGER || 0 || Output time series  id for the wave height in m, period in sec, and wave vectors.  
|-
| EDDY_VISCOSITY_OUT_TIMES_LIST || INTEGER || 0 || Output time series  id for the eddy viscosity in m^2/s.
|-
|-
| CALC_SEDIMENT_TRANSPORT || CHARACTER || OFF || ON <nowiki>|</nowiki> OFF || Turns on or off the sediment transport calculation.
| VISC_OUT_TIMES_LIST || INTEGER || 0 || Output time series  id for the eddy viscosity in m^2/s.  
|}
 
=== Transport model ===
There are currently three sediment transport models available in CMS: (1) Equilibrium total load, (2) Equilibrium bed load plus advection-diffusion for suspended load, and (3) Non-equilibrium total load. The first two models are selected by unchecking the checkbox which says "Use non-equilibrium transport" and selecting either "Total load" for the first model, or "Advection-diffusion" for the second next to input item named "Formulation". The third model is selected by checking the box "Use non-equilibrium transport".
 
{| border="1"
! Card !! Arguments !! Default !! Range !! Description !! Versions
|-
|-
| SED_TRAN_FORMULATION || CHARACTER || NET || WATANABE <nowiki>|</nowiki> LUND_CIRP <nowiki>|</nowiki> A-D <nowiki>|</nowiki> NET || Selects the sediment transport model. || >1.0
| WIND_OUT_TIMES_LIST || INTEGER || 0 || Output time series  id for wind velocity and magnitude in m/s.  
|-
|-
| SED_TRAN_CALC_INTERVAL || REAL || || greater or equal to hydro time step for explicit scheme, or equal hydro time step for implicit scheme || Time step used for transport equation ||
| STRESS_OUT_TIMES_LIST || INTEGER || 0 || Output time series id for mean bed shear stress in Pa.
|-
|-
| MORPH_UPDATE_INTERVAL || REAL ||  || greater or equal to hydro time step for explicit scheme, or equal hydro  time step for implicit scheme || Time step used for updating bed elevation ||
| WAVE_OUTPUT_DETAILS || ON  <nowiki>|</nowiki> OFF || OFF || Outputs additional wave variables including wave direction, radiation stresses, breaking dissipation and roller energy.
|}
|}


Note that the when selecting the equilibrium total load model, the SED_TRAN_FORMULATION card is set to either WATANABE or LUND_CIRP depending on the transport formula chosen. When selecting the equilibrium A-D model, the transport formula is specified through the concentration profile formula (described below).
== XMDF Output ==
The default option in CMS 4.2 and previous was to have all output information stored in one single XMDF file (*_sol.h5). That was fine, but this file could end up being really large and would take a long time to read into the SMS.  Starting in CMS version 5.0 and later is to output all output groups to the same individual XMDF files with according to information type (*_wse.h5, *_vel.h5, etc.).
 
=== Multiple Output Files ===
In the recent versions of CMS, all solution output is broken into multiple files. If you want some of the output placed into the same file, you must specify cards in the CMCARDS file to change from the default. The following cards should be Advanced card section of the SMS interface or manually added to the parameter file.


Any of the following cards can be added to put only those datasets into one solution file.  Other datasets not specified will still go into separate files. The cards needed are as follows:


==== 1. Equilibrium Total load ====
  WSE_OUT_FILE          project_sol.h5
In this model, both the bed load and suspended load are assumed to be in equilibrium. The bed change is solved using a simple mass balance equation known as the Exner equation.
  VEL_OUT_FILE          project_sol.h5
More information on the this model can be found [[CMS-Flow:Equilibrium Total Load|'''here''']].
  VISC_OUT_FILE          project_sol.h5
  TRANS_OUT_FILE        project_sol.h5
  MORPH_OUT_FILE        project_sol.h5
  WAVES_OUT_FILE        project_sol.h5
  WIND_OUT_FILE          project_sol.h5


==== 2. Equilibrium Bed load plus Advection-Diffusion Suspended Load====
To put all output into a single file, one simple card can be added (shown below). In SMS 12.3+ (CMS Version 5.1+), a simpler way has been created. There is an option in the interface named 'Use single XMDF solution file (_sol.h5)'.  
Calculations of suspended load and bed load are conducted separately. The bed load is assumed to be in equilibrium and is included in the bed change equation while the suspended load is solved through the solution of an advection-diffusion equation. Actually the advection diffusion equation is a non-equilibrium formulation, but because the bed load is assumed to be in equilibrium, this model is referred to the "Equilibrium A-D" model.


More information on the this model can be found [[CMS-Flow:Equilibrium Bed load plus AD Suspended load|'''here''']].
  USE_COMMON_SOLUTION_FILE            ON


==== 3. Non-equilibrium Total Load====
=== File Compression ===
The non-equilibrium sediment transport algorithm (NET) simulates non-cohesive, single size sediment transport and bed change using a Finite Volume method and includes advection, diffusion, hiding and exposure, and avalanching.  NET sediment transport is calculated with a non-equilibrium bed-material (total load) formulation. In this approach, the suspended- and bed-load transport equations are combined into a single equation and thus there is one less empirical parameter to estimate (adaptation length).  
The standard CMS-Flow output is written to an XMDF file with the name <Case Name>_sol.h5. The binary file may be written in compressed format using the card described in the table below. An option exists in the SMS named 'XMDF file compression' that enables this from the interface.


Additional information on NET can be found [[CMS-Flow:Non-equilibrium_Sediment_Transport|'''here''']].
'''Table 7. CMS-Flow card for compressing the XMDF output file'''
{| class=wikitable border="1"
! Card !! Arguments !!  Default  value !! Description
|-
| XMDF_COMPRESSION || ON  <nowiki>|</nowiki> OFF  || OFF || Compresses the h5 file by a factor of about 7
|}


All of the previously mentioned models account for hard bottom and effect of the bed slope on bed load.
== ASCII Output ==
In addition to the XMDF output file, CMS-Flow provides the output two types of ASCII output files:
# Tecplot snap shot (*.dat), and history files (*.his)
# SMS Super ASCII files (*.sup, *.xy, *.dat)


=== Transport Formula ===
The CMS-Flow cards used for outputting these two types of files are described in the Table below.
The nearbed sediment concentation or concentration capacity are calculated with one of the following transport formula:
# Lund-CIRP (2006)
# Van Rijn (1998)
# Watanabe (1987)
# Soulsby-van Rijn (1997) (>=V4.0)


<br style="clear:both" />
'''Table 8. CMS-Flow cards used to output Tecplot and SMS Super ASCII files.'''
{| border="1"
{| class=wikitable border="1"
! Card !! Arguments !! Default !! Range !! Description
! Card !! Arguments !! Description !! Default value
|-
| NET_TRANSPORT_CAPACITY || CHARACTER || LUND-CIRP || LUND-CIRP <nowiki>|</nowiki> VAN_RIJN <nowiki>|</nowiki> WATANABE <nowiki>|</nowiki> SOULSBY || Selects the transport formula. Note that SOULSBY is only available in v>=4.0
|-
| TRANSPORT_FORMULA || CHARACTER || LUND-CIRP || LUND-CIRP <nowiki>|</nowiki> VAN_RIJN <nowiki>|</nowiki> WATANABE <nowiki>|</nowiki> SOULSBY || Selects the transport formula. Note that SOULSBY is only available in v>=4.0.
|-
|-
| SED_TRANS_FORMULATION || CHARACTER || LUND-CIRP || LUND-CIRP <nowiki>|</nowiki> A-D <nowiki>|</nowiki> WATANABE <nowiki>|</nowiki> NET|| Selects the transport formula for the equilibrium total load model. Does not specify the transport formula for the equilibrium A-D and non-equilibrium total load models.
| GLOBAL_TECPLOT_FILES || ON <nowiki>|</nowiki> OFF |Outputs Tecplot ASCII files || OFF
|-
|-
| CONCENTRATION_PROFILE || CHARACTER || LUND-CIRP|| LUND-CIRP<nowiki>|</nowiki>EXPONENTIAL<nowiki>|</nowiki> ROUSE<nowiki>|</nowiki> VAN_RIJN|| Selects the concentration profile to be used either in the equilibrium A-D or total load nonequilibrium models.
| GLOBAL_SUPER_FILES || ON  <nowiki>|</nowiki> OFF || Outputs general ASCII solution files || OFF
|-
| A_COEFFICIENT_WATANABE || REAL || 0.1 || 0.05-0.5 || Empirical coefficient which goes into the Watanabe transport formula. ||
|}
|}


=== Scaling Factors ===
= Statistics =
==== Transport Scaling Factors ====
CMS V4.0 has the option to calculate  statistics over the whole model domain for a user-specified time period.  This option is accessed using the advanced cardss. The starting time, end time, and time interval should be specified in hours with respect to the model start time. The time  interval should be larger or equal to the hydrodynamic time step. When  activated the global statistics will be output in the same solution file  within a subfolder named ''stats''.  
The bed and suspended transport scaling factors multiply directly by the transport capacity or near-bed sediment concentration calculated from the transport formula. These factors should be used to calibrate sediment transport rates and due to the large uncertainty in the transport formula, it is generally acceptable to use scaling factors in the range of 0.5-2.0.
 
<br style="clear:both" />
This option outputs the statistics for hydrodynamics, sediment and salinity transport. If only the statistics for one group
{| border="1"
 
! Card !! Arguments !! Default !! Range !! Description
* '''Hydrodynamics:'''
|-
:# Maximum  current velocity
| BED_LOAD_SCALE_FACTOR || REAL || 1.0 || 0.5-2.0 || Calibration factor for bed load transport capacity formula
:# Maximum water level
|-
:# Residual currents  (vectors and magnitude)
| SUSP_LOAD_SCALE_FACTOR || REAL || 1.0 || 0.5-2.0 || Calibration factor for suspended load transport capacity formula
:# Hydroperiod
|}
:# Maximum spatial  gradient for water levels
:# Maximum spatial gradient for current  magnitude
 
* '''Sediment Transport and Morphology Change''':
:# Maximum total load transport rate, m^2/s
:# Net total load sediment transport rates, m^2/s
:# Average  total  load sediment transport rates, m^2/s
:# Gross  total load sediment  transport rates, m^2/s
:# Positive  and negative total load transport rates (in x and y directions), m^2/s
:# Maximum spatial  gradient of bathymetry
 
* '''Salinity Statistics''':
:# Mean Salinity


==== Morphologic Scaling Factor ====
'''Table 9. CMS-Flow cards related to output statistics'''
The morphologic scaling factor is directly multiplied by the calculated bed change at every time step and is intended as a means of speeding up the computational time. It is only recommended for periodic boundary conditions or conditions that do not change rapidly over time.
{| class=wikitable border="1"
<br style="clear:both" />
! Card !! Arguments !! Description !! Default value !! Notes
{| border="1"
! Card !! Arguments !! Default !! Range !! Description
|-
|-
| MORPH_ACCEL_FACTOR || REAL || 1.0 || 1-100 || Morphologic acceleracion factor. Directly multiplies by calculated bed change.
| GLOBAL_STATISTICS || [t0] [tn] [dt]  || Calculates  global statistics if specified || none || [start] [end] [increment]
|}
 
=== Sediment Characteristics ===
{| border="1"
!  Card !! Arguments !! Default !! Range !! Description !! Versions
|-
|-
| SEDIMENT_POROSITY || REAL  || 0.4 || 0-1 || Sets the sediment porosity ||  
| FLOW_STATISTICS || [t0] [tn] [dt] || Calculates  flow statistics if specified || none || [start] [end] [increment]
|-
|-
| SEDIMENT_DENSITY|| REAL  || 2650  || none || Sets the sediment density in kg/m^3 ||  
| SEDIMENT_STATISTICS || [t0] [tn] [dt] || Calculates sediment statistics if specified || none || [start] [end] [increment]
|-
|-
| SEDIMENT_FALL_VELOCITY || REAL || none || 4.0e-4 - 0.4 || Sets the sediment fall velocity to a constant in m/s  || v>=3.5
| SALINITY_STATISTICS || [t0] [tn] [dt] ||  Calculates salinity statistics if specified || none || [start] [end] [increment]
|}
|}


=== Bedslope term ===
=Numerical Methods=
{| border="1"
== Solution Scheme ==
!  Card !! Arguments !! Default !! Range !! Description !! Versions
This refers to the temporal discritization of the hydrodynamic, sediment and salinity transport equations. There are two options in CMS:
1. Implicit - First order backward Euler scheme. Uses a time step on the order of 5-15 minutes. Appropriate for cases which can be simulated with large computational time steps such as long term morphology change at inlets.
2. Explicit - First order forward Euler scheme. Uses a time step on the order of 0.5-1.0 second. Appropriate for cases that vary quickly in time such as flooding or barrier island breaching.
 
{| class=wikitable border="1"
!  Card !! Arguments !! Default !! Range !!   Description
|-
|-
| SLOPE_COEFFICIENT || REAL  || 1.0 || 0-5 || Bed slope coefficient which controls enters a diffusion term which moves sediment down slope  ||  
| SOLUTION_SCHEME || CHARACTER || EXPLICIT || EXPLICIT <nowiki>|</nowiki> IMPLICIT || Determines the solution scheme used in CMS-Flow. 
|}
|}
== Solver Options ==
The four different solvers implemented in the implicit solution scheme are the Gauss-Seidel, Gauss-Seidel with Successive-Over-Relaxation, BICGSTAB, and GMRES. The same solver is applied to flow, sediment and salinity. The default solver is the GMRES. The solver may be changed using the advanced card in the table below.


=== Advanced ===
{| class=wikitable border="1"
 
! Card !! Arguments !! Default !! Range !! Description
{| border="1"
|-
! Card !! Arguments !! Default !! Range !! Description !! Versions
| MATRIX_SOLVER  ||  CHARACTER || GMRES ||  GAUSS-SEIDEL <nowiki>|</nowiki>  GAUSS-SEIDEL-SOR  <nowiki>|</nowiki> BICGSTAB  <nowiki>|</nowiki>  GMRES || Selects the matrix solver for  flow, sediment and salinity.
|-
|-
| HIDING_EXPOSURE_COEFFICIENT || REAL || 0.7 || 0.6-1.0 || Hiding and exposure coefficient. || v>=3.5
| HYDRO_MAX_ITERATIONS || INTEGER || Function of grid size ||  >0 || Sets the maximum number of iterations for the flow (hydro)  solver (outer  loop). Typical range: 30-50 for GAUSS-SEIDEL and GAUSS-SEIDEL-SOR, and 20-30 for BICGSTAB and GMRES.
|-
|-
| SCHMIDT_NUMBER || REAL ||  1.0 || none || Controls the sediment mixing strength || v>=4.0
| PRESSURE_ITERATIONS ||  INTEGER || Depends on Solver || >0 ||  Sets  the number of solver  iterations for the pressure equation (inner loop). Typical range: 80-100 for GAUSS-SEIDEL and GAUSS-SEIDEL-SOR, and 15-25 for BICGSTAB and GMRES.
|}
 
=== Boundary and Initial Conditions ===
{| border="1"
! Card !! Arguments !! Default !! Range !! Description !! Versions
|-
|-
| NET_LOADING_FACTOR || REAL || 1.0 || 0.5-2.0 || Used to specify under- or overloading at sediment inflow boundaries. Only for NET. || 3.5=>v<=4.0
| VELOCITY_ITERATIONS || INTEGER || Depends  on Solver || >0 ||  Sets the number of solver iterations for the  velocity or momentum  equations (inner loop). Typical range: 20-30 for GAUSS-SEIDEL and GAUSS-SEIDEL-SOR, and 5-10 for BICGSTAB and GMRES.
|-
|-
| SEDIMENT_INFLOW_LOADING_FACTOR || REAL || 1.0 || 0.5-2.0 || Used to specify under- or overloading at sediment inflow boundaries. || >=4.0
| SEDIMENT_MAX_ITERATIONS || integer  || 20 || >0 || Maximum number of iterations (outer loop) for the sediment transport
|-
|-
| CALC_MORPH_DURING_RAMP || CHARACTER|| ON  || ON <nowiki>| </nowiki> OFF || Determines whether to calculate the morphology change during the ramp period || v>=3.5
| SALINITY_MAX_ITERATIONS || integer  || 20 || >0|| Maximum number of iterations (outer loop) for the salinity transport
|}
|}


==Salinity Transport==
== Advection scheme ==
In many estuaries, the density gradients caused by spatial variations in salinity can be an important driving force in the circulation. Salinity is also a key water quality variable in estuaries, since it affects the chemical and biological processes. Salinity is simulated in the Coastal Modeling System (CMS) in a depth-averaged sense. This means that the estuary or body of water is assumed to be well mixed vertically and the salinity is constant over the water column.
As in the case of the implicit solution scheme, the same advection scheme is applied for the flow, sediment and salinity transport equations. There are three  choices for advection schemes with upwinding in the implicit model:  hybrid, exponential and HLPA. The hybrid scheme is fast but is the most  diffusive. The exponential scheme is based on the 1D analytical solution  to an advection-diffusion equation and produces very stable results. The HLPA is very stable and non-diffusive, but requires slightly more computational time. For most applications, the exponential scheme is recommended and is set as the default. The advection scheme may be  change using the advanced card


The salinity transport equation is solved with an explicit, finite volume method. The advection term is discretized with upwind scheme, and the diffusion term is discretized with the standard central difference scheme.
'''Table 10. CMS-Flow cards  related to numerical methods.'''
{| class=wikitable border="1"
!  Card !! Arguments !! Default !! Range !!  Description
|-
| ADVECTION_SCHEME  || CHARACTER ||  EXPONENTIAL || NONE  <nowiki>|</nowiki> HYBRID  <nowiki>|</nowiki>  EXPONENTIAL  <nowiki>|</nowiki> HLPA || Sets the advection scheme for  flow, sediment and salinity.
|}


The CMS-Flow salinity cards are listed in the table below.  
== Wetting and Drying ==
 
'''Table 11. CMS-Flow cards related to numerical methods.'''
<br style="clear:both" />
{| class=wikitable border="1"
{| border="1"
! Card !! Arguments !! Description !! Versions
|-
| CALC_SALINITY || ON <nowiki>|</nowiki> OFF || Turns salinity on or off || >=v3.75
|-
|-
| SALT_OUT_TIMES_LIST || integer || Index of times list of output times || >=v3.75
| DRYING_DEPTH || REAL || Calculated  based on solution scheme and courant number || none || Sets to the time  step for hydrodynamics in seconds.
|-
|-
| SALINITY_IC || real || Specifies the initial salinity value in ppt for the whole computational domain || >=v3.75
| WATER_PONDING || CHARACTER || OFF || ON      <nowiki>|</nowiki> OFF || Turns ''On'' or ''Off'' water      ponding. If water ponding is ''Off'', isolated bodies of water will      become dry.  
|-
|-
| SALINITY_IC_ASCII || character || Specifies the file name of a scatter set file (*.pts) containing the coordiantes and initial salinity values to be interpolated using the Laplacian interpolation || >=4.0
| ONE_CELL_WIDE_CHANNELS    || CHARACTER || ON || ON  <nowiki>|</nowiki> OFF|| Limits    wetting and drying to areas with at least 3 cells wide. When turned  off,    the model  stability is improved.
|}
|}


Additional information on Salinity Transport in CMS-Flow can be found [[CMS-Flow:Salinity_Calculation|'''here''']].
== Parallelization with OpenMP ==
Both Intel and AMD processors now  are shipping chips with multiple cores/processors (henceforth referred  to as "processors") available.  CMS-Flow is now configured to make use  of these extra processes that are available on newer machines.


='''Other Processes'''=
Additional information on using Multiple Processors with CMS-Flow can be found [[CMS-Flow:Multiple_Processor_Capability|'''here''']].
==Bottom Friction==
[[image:CMS-Flow_Example_Project_Explorer.png|thumb|right|400px|SMS Project Explorer showing CMS-Flow project.]]
The bottom friction parameter (related to Manning <math>n</math>) is spatially varying (cell-specific) over the grid domain.  The default value upon grid creation is 0.025. At times a user may desire to represent locations where added friction is needed due to structures or increased turbulence due to sharp changes in current speed.  More information on using this feature of CMS-Flow can be found [[CMS-Flow:Bottom_Friction|'''here''']].


<br style="clear:both" />
'''Table 12. CMS-Flow cards related to numerical methods.'''
{| border="1"
{| class=wikitable border="1" style="text-align:center"
! Card !! Arguments !! Default !! Range !! Description !! Versions
! Card !! Arguments !! Default !! Solver Range !! Description
|-
| USE_WALL_FRICTION || CHARACTER || ON || ON <nowiki>|</nowiki> OFF || Turns on or off wall friction || >=3.5
|-
| MANNING_N_DATASET || CHARACTER CHARACTER || [<grid file>] [<grid name>//"Datasets/ManningsN"] || none || Grid file name and dataset path for the input Manning's n dataset || >=v3.5
|-
|-
| MANNING_N_CONSTANT || real number || none || 0.001-0.5 || Specifies input Manning n dataset || >=v3.5
| NUM_THREADS
|-
|| INTEGER || 1
| WAVE-CURRENT_MEAN_STRESS || character || W09 || W09 <nowiki>|</nowiki> DATA2 <nowiki>| </nowiki> DATA13 <nowiki>| </nowiki> F85 <nowiki>| </nowiki> HT95 || Defines the model used for calculating the mean bottom shear stress used in hydro || >=4.0
|width="230px"| '''Explicit''' - 1 to number of threads<br>'''Implicit''' - 1 to 4
|| Determines the number of threads used for parallel processing.  
|}
|}


==Hard Bottom==
= Scripting =
[[Image:CMS-Flow_Hard-Bottom.png|thumb|right|400px| SMS Project Explorer showing Hard bottom dataset]]
Scipting refers to the automation of running multiple CMS runs with different parameters, without manually having to create and edit each alternative. The scripting process can include the following steps:
Hard Bottom is a morphologic constraint that provides the capability to simulate mixed bottom types within a single simulation.  This cell-specific feature limits the erodibility of the constrained cells down to a specified depth below the water surface. More information on the use of hard bottom within the SMS can be found [[CMS-Flow:Hard_Bottom|'''here''']].
# Setting up alternatives
 
# Creating batch file
<br style="clear:both" />
# Plotting and analyzing results
[[Image:CMS-Flow_Model_Control_Transport.png|thumb|left|300px| CMS-Flow Model Control window showing the location where the hard bottom dataset is specified.]]
<br style="clear:both" />


==Variable D50==
Scripting can be done using a variety of software programs. The examples shown here were written in Matlab becase it is widely used, easy to read and convenient for plotting and analyzing results.  
When sediment transport and morphology change are activated, sometimes it may be desired to designate areas of the grid to have a certain grain size.  This cell-specific parameter allows each cell to take on the characteristics of a certain sediment grain size. More information on the use of variable grain size (D50) can be found [[CMS-Flow:Variable_D50|'''here''']].


==Eddy Viscosity==
== Setting Up Alternatives ==
Eddy Viscosity in CMS-Flow is not a user definable parameter. A description of the advanced cards related to eddy viscosity is shown in the table below.
‎[[Image:Scripting_Explorer.png|thumb|right|700px|Figure  1. Example of scripting showing the files used.]]
<br clear="all">
In this example, 4 cases or alterantives are setup using the Matlab script below. The script copies the base setup files into subfolders and then modifies specific CMS-Flow cards in the *.cmcards file. The settings for each case are setup using a structure variable with field names corresponding to each CMS-Flow card (e.g. TIME_SERIES_INCREMENT). Separating each case into its own subfolder keeps the input and output separate and also allows for the different cases to be run at the same time.  


<br style="clear:both" />
<br style="clear:both" />
{| border="1"
<font size=2>
! Card !! Arguments !! Default !! Range !! Description !! Versions
  <font color=green>% Matlab Script: setup_cases.m</font>
|-
clear <font color=magenta>all</font>
| TURBULENCE_MODEL || CHARACTER|| SUBGRID || SUBGRID <nowiki>|</nowiki>FALCONER<nowiki>| </nowiki>PARABOLIC <nowiki>| </nowiki>MIXING-LENGTH || Specifies the turbulence model used || >=3.5
flow = <font color=magenta>'Flow_Shark'</font>;
|-
wave = <font color=magenta>'Wave_Shark'</font>;
| EDDY_VISCOSITY_CONSTANT || REAL|| 1.0E-6 || >=1.0E-6 || Constant contribution or base value of eddy viscosity || >=3.5
ncases = 4; <font color=green>%Number of cases or alternatives</font>
|-
r(1).MANNINGS_N_DATASET = <font color=magenta>'"Manning_Alt1.h5" "Flow_Shark/Datasets/ManningsN"'</font>;
| EDDY_VISCOSITY_BOTTOM || REAL|| 0.0667 || 0.01-0.2 || Coefficient related to the contribution to eddy viscosity from the bottom shear || >=3.5
r(1).WAVE_CURRENT_MEAN_STRESS = <font color=magenta>'W09'</font>;
|-
  r(1).TIME_SERIES_INCREMENT = 1800;
| EDDY_VISCOSITY_HORIZONTAL || REAL|| 0.4 || 0.2-0.6 || Coefficient related to the contribution to eddy viscosity from horizontal velocity gradients || >=3.5
  r(2).MANNINGS_N_DATASET = <font color=magenta>'"Manning_Alt1.h5" "Flow_Shark/Datasets/ManningsN"'</font>;
|-
r(2).WAVE_CURRENT_MEAN_STRESS = <font color=magenta>'DATA2'</font>;
| EDDY_VISCOSITY_WAVE || REAL|| 0.5 || 0.2-1.0 ||  Coefficient related to the wave bottom friction contribution to eddy viscosity || >=4.0
r(2).TIME_SERIES_INCREMENT = 900;
|-
r(3).MANNINGS_N_DATASET = <font color=magenta>'"Manning_Alt2.h5" "Flow_Shark/Datasets/ManningsN"'</font>;
| EDDY_VISCOSITY_BREAKING || REAL|| 0.05 ||  0.04-0.08 ||  Coefficient related to the wave breaking contribution to eddy viscosity || >=4.0
r(3).WAVE_CURRENT_MEAN_STRESS = <font color=magenta>'W09'</font>;
|}
r(3).TIME_SERIES_INCREMENT = 900;
 
r(4).MANNINGS_N_DATASET = <font color=magenta>'"Manning_Alt2.h5" "Flow_Shark/Datasets/ManningsN"'</font>;
More information can be found [[CMS-Flow:Subgrid_Turbulence_Model|'''here''']].
r(4).WAVE_CURRENT_MEAN_STRESS = <font color=magenta>'DATA2'</font>;
r(4).TIME_SERIES_INCREMENT = 600;
  <font color=blue>for</font> i=1:ncases
  d = [<font color=magenta>'Case'</font>,int2str(i)];
  <font color=blue>if</font> ~exist(d,<font color=magenta>'dir'</font>)
    mkdir(d)
  <font color=blue>end</font>
  copyfile([wave,<font color=magenta>'.*'</font>],d)
  copyfile([flow,<font color=magenta>'.*'</font>],d)
  copyfile([flow,<font color=magenta>'_mp.h5'</font>],d);
  copyfile([flow,<font color=magenta>'_grid.h5'</font>],d)
  cards = fieldnames(r(i));
  file = [<font color=magenta>'.\'</font>,d,<font color=magenta>'\'</font>,flow,<font color=magenta>'.cmcards'</font>];
  <font color=blue>for</font>k=1:length(cards)
    setcard(file,cards{k},r(i).(cards{k}));
  <font color=blue>end</font>
<font color=blue>end</font>
<font color=blue>return</font>
</font>


='''Other Features'''=
The script above requires the subroutine below.  
==Parallelization with OpenMP==
Both Intel and AMD processors now are shipping chips with multiple cores/processors (henceforth referred to as "processors") available.  CMS-Flow is now configured to make use of these extra processes that are available on newer machines.


Additional information on using Multiple Processors with CMS-Flow can be found [[CMS-Flow:Multiple_Processor_Capability|'''here''']].
<font size=2>
<font color=blue>function</font> setcard(cmcardsfile,card,value)
<font color=green>% setcard(file,card,value)</font>
<font color=green>% Overwrites or appends a CMS-Flow card</font>
<font color=green>% in the *.cmcards file</font>
copyfile(cmcardsfile,<font color=magenta>'temp'</font>)
fid=fopen(<font color=magenta>'temp'</font>,<font color=magenta>'r'</font>);
fid2=fopen(cmcardsfile,<font color=magenta>'w'</font>);
nc=length(card);
ok = false(1);
<font color=blue>if </font>~ischar(value)   
  value = num2str(value);
<font color=blue>end</font>
<font color=blue>while</font> 1   
  tline = fgets(fid);       
  <font color=blue>if</font> ~ischar(tline), <font color=blue>break</font>, <font color=blue>end</font>   
  <font color=blue>if</font> strncmp(card,tline,nc)       
    fprintf(fid2,<font color=magenta>'%s      %s %s'</font> ,card,value,tline(end));               
    ok = true(1);       
    <font color=blue>continue </font> 
  <font color=blue>end</font>   
  nline = length(tline);   
  <font color=blue>if</font> (~ok && strcmp(tline(1:min(nline,14)),<font color=magenta>'END_PARAMETERS'</font>))       
    fprintf(fid2,<font color=magenta>'%s      %s %s'</font>,card,value,tline(end));       
    fprintf(fid2,<font color=magenta>'%s'</font> ,tline);       
    <font color=blue>break</font>
  <font color=blue>end</font>   
  fprintf(fid2,<font color=magenta>'%s'</font> ,tline);
<font color=blue>end</font>
fclose(fid);
fclose(fid2);
delete(<font color=magenta>'temp'</font>)
<font color=blue>return</font>
</font>


== Advanced Output ==
== Batch File ==
The following advanced cards have been added to CMS v4.0 and higher for outputting additional output information, ASCII file output, and more.
Although it is possible to launch CMS from Matlab a batch file is preferable to use a batch file because it allows running all of the cases without opening Matlab.  


{| border="1"
<font size=2>
! Card !! Arguments !! Description !! Default value
<font color=green>% Matlab Script: create_bat.m</font>
|-
cmsexe = <font color=magenta>'cms2d_v4b42_x64p.exe'</font>; <font color=green>%CMS-Flow executable</font>
| WAVE_OUT_TIMES_LIST || integer || Output time series id || 0
batfile = <font color=magenta>'run_cases.bat'</font>; <font color=green>%Output batch file</font>
|-
fid = fopen(batfile,<font color=magenta>'w'</font>);
| EDDY_OUT_TIMES_LIST || integer || Output time series id || 0
<font color=blue>for</font> i=1:ncases
|-
  cmcards = [<font color=magenta>'.\Case'</font>,int2str(i),<font color=magenta>'\'</font>,flow,<font color=magenta>'.cmcards'</font>]; <font color=green>%CMS-Flow cmcards file</font>
| GLOBAL_TECPLOT_FILES || ON <nowiki>|</nowiki> OFF || Outputs Tecplot ASCII files || OFF
  fprintf(fid,<font color=magenta>'START %s %s %s'</font>,cmsexe,cmcards,char(10));
|-
<font color=blue>end</font>
| GLOBAL_SUPER_FILES || ON <nowiki>|</nowiki> OFF || Outputs Tecplot ASCII files || OFF
fclose(fid);
|-
<font color=blue>return</font>
| [[GLOBAL_STATISTICS]] || [t0] [tn] [dt] || Calculates global statistics if specified || none
</font>
|}


==Matrix solver==
The following text shows what the resulting batch file (*.bat) looks like
The four different solvers implemented in the implicit model are the Gauss-Seidel, Gauss-Seidel with Successive-Over-Relaxation, BICGSTAB, and GMRES. The same solver is applied to flow, sediment and salinity. The default solver is the GMRES. The solver may be changed using the advanced card in the table below.


{| border="1"
<font size=2>
! Card !! Arguments !! Description !! Default value
START cms2d_v4b42_x64p.exe .\Case1\Flow_Shark.cmcards
|-
START cms2d_v4b42_x64p.exe .\Case2\Flow_Shark.cmcards
| SOLVER_TYPE || GAUSS-SEIDEL <nowiki>|</nowiki> GAUSS-SEIDEL-SOR <nowiki>|</nowiki> BICGSTAB <nowiki>|</nowiki> GMRES || Determines the numerical solver used || GMRES
  START cms2d_v4b42_x64p.exe .\Case3\Flow_Shark.cmcards
|-
  START cms2d_v4b42_x64p.exe .\Case4\Flow_Shark.cmcards
| HYDRO_MAX_ITER || integer || Maximum number of iterations (outer loop) for the hydrodynamics || 20
</font>
|-
| SEDIMENT_MAX_ITER || integer || Maximum number of iterations (outer loop) for the sediment transport || 20
|-
| SALINITY_MAX_ITER || integer || Maximum number of iterations (outer loop) for the salinity transport || 20
|}


==Advection scheme==
To run the batch file, simply double click on the file and each case will launch separately in its own MS-DOS window.
As in the case of the solver, the same advection scheme is applied for the flow, sediment and salinity transport equations. There are three choices for advection schemes with upwinding in the implicit model: hybrid, exponential and HLPA. The hybrid scheme is fast but is the most diffusive. The exponential scheme is based on the 1D analytical solution to an advection-diffusion equation and produces very stable results. The HLPA is very stable and non-diffusive, but requires slightly more computational time. For most applications, the exponential scheme is recommended and is set as the default. The advection scheme may be change using the advanced card


{| border="1"
== Plotting ==
! Card !! Arguments !! Description !! Default value
The following example reads the Observation Point time series output file (*_eta.txt) and plots the 3rd
|-
----
| ADVECTION_SCHEME || HYBRID <nowiki>|</nowiki> EXPONENTIAL <nowiki>|</nowiki> HLPA || Determines the advection scheme || EXPONENTIAL
<font size=2>
|}
<font color=green>% Matlab Script: plot_cases.m</font>
close <font color=magenta>all</font>
eta = cell(ncases,1);
<font color=blue>for</font>  i=1:ncases   
  etafile = [<font color=magenta>'.\Case'</font> ,int2str(i),<font color=magenta>'\'</font>,flow,<font color=magenta>'_eta.txt'</font> ]; <font color=green>%Water elevation</font>
  eta{i} = load(etafile);   
<font color=blue>end</font>
figure
hold on
<font color=blue>for</font> i=1:ncases   
  h = plot(eta{i}(:,1),eta{i}(:,3),'-');  <font color=green>%3 is the index is the observation point index</font>
<font color=blue>end</font>
ylabel(<font color=magenta>'Water elevation, m'</font>)
  xlabel(<font color=magenta>'Elapsed Time, hr'</font>)
<font color=blue>return</font>
</font>
----


='''Units of Measurement'''=
=Units of Measurement=


{| border="1"
{| class=wikitable border="1"
! Variable !! Units !! Symbol
! Variable !! Units !! Symbol
|-
|-
| Water Surface Elevation || meters || (<math>m</math>)
| Water Surface Elevation || meters || <math>m</math>
|-
| Current Velocity || meters per second  || <math>m/sec</math>
|-
|-
| Current Velocity || meters per second || (<math>m/sec</math>)
| Flow Rate || cubic meters per second || <math> m^3/sec </math>
|-
|-
| Flow Rate || cubic meters per second || (<math> m^3/sec </math>)
| Salinity Concentration || parts per thousand || <math>ppt</math>
|-
|-
| Salinity Concentration || parts per thousand || (<math>ppt</math>)
| Sediment Concentration || kilogram per meter cubed || <math>kg/m^3</math>
|-
|-
| Sediment Concentration || kilogram per meter cubed || (<math>kg/m^3</math>)
| Sediment Transport || kilogram per meter per second || <math>kg/m/sec</math>
|-
|-
| Sediment Transport || meter squared per second || (<math>m^2/sec</math>)
| Bed Shear Stress || kilogram per meter per second squared (Pascals) || <math>Pa</math>
|}
|}


---------------------------------
---------------------------------
[[CMS-Flow]]
[[CMS-Flow]]

Latest revision as of 14:55, 7 April 2022

Hot Start

The term Hot start refers to starting a simulation with an initial condition other zero (cold start). Hot starts are used for specifying initial conditions or restarting simulations at intermediate times. The hot start controls are set in the Flow tab of the CMS-Flow Model Control window.

Hot Start File

Figure 1. HDFView showing the structure of the CMS Hot Start File.

The CMS hot start feature CMS lets the user restart simulations that have been stopped due to electric outages, hardware malfunctions, or model crashes. In the case of a model crash the user, may restart the model using larger solver iterations and/or time steps to stabilize the simulation. The user has the option to specify a hot start output time or an interval for outputting a recurring hot start file. Every time the hot start file is written, it overwrites the previous information. The CMS Hot Start file saves information on the water elevation (pressure), and current velocities. If the sediment transport is active, then the water depth and sediment concentrations are also saved for each size class. Only the very last record of information is preserved (no starting from earlier intervals).

The CMS hot start files are written as binary XMDF files by default. Depending on the type of hot start (single file or recurring), the names are as follows are saved in the directory of the CMS-Flow files:

  • SingleHotStart.h5
  • AutoHotStart.h5

After saving a CMS Hot Start file, it is a good idea to rename the file with a different name before using it as an initial conditions file. This way, the file will not be overwritten in future simulations.

Table 1. Hot Start CMS-Flow Cards

Card Arguments Default Range Description
HOT_START_TIME REAL none none Single time after start at which to output a single hot start file.
AUTO_HOT_START_INTERVAL REAL none none Sets the recurring hot start output interval .


Initial Conditions File

Figure 2. Dataset Toolbox showing a time step sample of the water elevation and current velocity datasets for use in a hot start (initial condition) file.

There are several situations where it is desired to specify a user-defined hot start file from which to start a simulation. If the user has previously specified a hot start file be written either at a specific time or at a recurring interval, they can simply indicate to start from that hot start as an initial condition from the SMS interface, or by adding a card to the parameter file. The card name and format are shown below.


Table 2. CMS-Flow card for specifying the initial condition file.

Card Arguments Default Range Description
INITIAL_STARTUP_FILE | INITIAL_CONDITION_FILE CHARACTER none none Hot start filename that contains the information for a Hot Start.


Sometimes, the user may forget to set up the model output a hot start file or may have been running steady-state conditions. In these cases, a hot start file can easily be created and exported by the user from the SMS interface. The model requires records for water levels, current velocities, concentrations, and water depths and datasets that are missing from the initial file. Note: It is important that the names and paths of the initial condition datasets are written correctly.

Table 3. Path and name for initial condition file variables.

Variable Path and Name
Water surface elevation Datasets\Water_Elevation
Current velocity Datasets\Current_Velocity
Sediment concentrations Datasets\Concentration
Salinity concentrations Datasets\Salinity


One example showing the steps for creating a user-defined hot start or initial condition file from a CMS-Flow solution file is outlined below.

1. Import CMS-Flow grid and solution file.
2. Sample a time step of the solution datasets for use in the initial condition
  • Click on Data | Data Set Toolbox
  • Under the Tools section, select Sample time steps.
  • Under the Datasets section, click on the Water Elevation
3. Export the initial condition datasets to an XMDF file

More to come about the process above.

Figure 3. Dataset Toolbox showing a time step sample of the water elevation and current velocity datasets for use in a hot start (initial condition) file.
Figure 4. Dataset Toolbox showing a time step sample of the water elevation and current velocity datasets for use in a hot start (initial condition) file.


Global Output

Figure 1. Output tab in SMS 11.0

Global output refers to the variables that are output on every active cell on the grid. The global output options are specified in Output tab of the CMS-Flow Model Control window. More information on the global output variables, groups and CMS-Flow cards is provided in the sections below.


Output Datasets

A description of the CMS-Flow cards used to specify the global output variable datasets is provided below.

Table 4. Output datasets.

Output Dataset Group Description Scalar/Vector Units
Water_Elevation Water surface elevation Cell-centered water surface elevation Scalar
Current_Velocity Velocity Depth-averaged and cell-centered current velocity Vector dataset and with respect to local grid coordinates Vector
Current_Magnitude Velocity Depth-averaged and cell-centered current velocity magnitude dataset Scalar
Eddy_Viscosity Eddy viscosity Cell-centered horizontal eddy viscosity Scalar
Concentration Sediment Depth-averaged and cell-centered sediment concentration Scalar
Capacity Sediment Depth-averaged and cell-centered sediment concentration capacity Scalar
Total_Sediment_Transport Sediment Depth-averaged and cell-centered total-load sediment transport Vector
Morphology_Change Morphology Cell-centered morphology (bed) change. Positive is accretion and negative is erosion Scalar
Depth Morphology Cell-centered still water depth Scalar
Salinity Salinity Transport Depth-averaged and cell-centered sediment concentration capacity Scalar
Wave_Height Waves Cell-centered significant wave height Scalar
Wave_Height_Vec Waves Cell-centered significant wave height Vector Vector
Wave_Period Waves Cell-centered peak wave period Scalar
Wind_Magnitude Wind Cell-centered wind speed Scalar
Wind_Velocity Wind Cell-centered wind velocity Vector dataset with respect to local grid coordinates Vector
Atm_Pressure Wind Cell-centered atmospheric pressure Scalar
Atm_Pressure_GradX Wind Cell-centered atmospheric pressure gradients in the X direction Scalar
Atm_Pressure_GradY Wind Cell-centered atmospheric pressure gradients in the Y direction Scalar

Output Time Series and Lists

The times at which each group is output is determined by the selecting one of four user defined output time series or lists. In SMS versions 10.1 and earlier, the output time series were used. However, because the output time series can become very large for long-term simulations, the time series have been replaced by lists in which the output times are specifying a list of starting, ending and increments. This option is more compact and also makes it easier to manually change the output options in the cmcards file.

Table 5. Time series and List Cards.

Card Aguments/Format Default value Description
TIME_SERIES_1 [length of list 1] [output times for list 1] 0 Output time series for list 1 in hours.
TIME_SERIES_2 [length of list 2] [output times for list 2] 0 Output time series for list 2 in hours.
TIME_SERIES_3 [length of list 3] [output times for list 3] 0 Output time series for list 3 in hours.
TIME_SERIES_4 [length of list 4] [output times for list 4] 0 Output time series for list 4 in hours.
TIME_LIST_1 [number of sublists] [sublist 1: start, end, increment] [sublist 2: start, end, increment]... 0 Sublist(s) for output time series 1. For each sublist, the arguments are starting time, end time and increment in hours.
TIME_LIST_2 [number of sublist] [sublist 1: start, end, increment] [sublist 2: start, end, increment]... 0 Sublist(s) for output time series 2. For each sublist, the arguments are starting time, end time and increment in hours.
TIME_LIST_3 [number of sublist] [sublist 1: start, end, increment] [sublist 2: start, end, increment]... 0 Sublist(s) for output time series 3. For each sublist, the arguments are starting time, end time and increment in hours.
TIME_LIST_4 [number of sublist] [sublist 1: start, end, increment] [sublist 2: start, end, increment]... 0 Sublist(s) for output time series 4. For each sublist, the arguments are starting time, end time and increment in hours..

Table 6. Cards used to specify the output time series or list for each output group or dataset.

Card Arguments Default value Description
WSE_OUT_TIMES_LIST INTEGER 0 Output time series id for the water surface elevation in m.
VEL_OUT_TIMES_LIST INTEGER 0 Output time series id for currentvelocity and magnitude in m/s.
MORPH_OUT_TIMES_LIST INTEGER 0 Output time series id for the water depth and morphology (bed) change in m.
TRANS_OUT_TIMES_LIST INTEGER 0 Output time series id for sediment transport rates, concentations, and salinity.
WAVES_OUT_TIMES_LIST INTEGER 0 Output time series id for the wave height in m, period in sec, and wave vectors.
EDDY_VISCOSITY_OUT_TIMES_LIST INTEGER 0 Output time series id for the eddy viscosity in m^2/s.
VISC_OUT_TIMES_LIST INTEGER 0 Output time series id for the eddy viscosity in m^2/s.
WIND_OUT_TIMES_LIST INTEGER 0 Output time series id for wind velocity and magnitude in m/s.
STRESS_OUT_TIMES_LIST INTEGER 0 Output time series id for mean bed shear stress in Pa.
WAVE_OUTPUT_DETAILS ON | OFF OFF Outputs additional wave variables including wave direction, radiation stresses, breaking dissipation and roller energy.

XMDF Output

The default option in CMS 4.2 and previous was to have all output information stored in one single XMDF file (*_sol.h5). That was fine, but this file could end up being really large and would take a long time to read into the SMS. Starting in CMS version 5.0 and later is to output all output groups to the same individual XMDF files with according to information type (*_wse.h5, *_vel.h5, etc.).

Multiple Output Files

In the recent versions of CMS, all solution output is broken into multiple files. If you want some of the output placed into the same file, you must specify cards in the CMCARDS file to change from the default. The following cards should be Advanced card section of the SMS interface or manually added to the parameter file.

Any of the following cards can be added to put only those datasets into one solution file. Other datasets not specified will still go into separate files. The cards needed are as follows:

 WSE_OUT_FILE           project_sol.h5
 VEL_OUT_FILE           project_sol.h5
 VISC_OUT_FILE          project_sol.h5
 TRANS_OUT_FILE         project_sol.h5
 MORPH_OUT_FILE         project_sol.h5
 WAVES_OUT_FILE         project_sol.h5
 WIND_OUT_FILE          project_sol.h5

To put all output into a single file, one simple card can be added (shown below). In SMS 12.3+ (CMS Version 5.1+), a simpler way has been created. There is an option in the interface named 'Use single XMDF solution file (_sol.h5)'.

 USE_COMMON_SOLUTION_FILE            ON

File Compression

The standard CMS-Flow output is written to an XMDF file with the name <Case Name>_sol.h5. The binary file may be written in compressed format using the card described in the table below. An option exists in the SMS named 'XMDF file compression' that enables this from the interface.

Table 7. CMS-Flow card for compressing the XMDF output file

Card Arguments Default value Description
XMDF_COMPRESSION ON | OFF OFF Compresses the h5 file by a factor of about 7

ASCII Output

In addition to the XMDF output file, CMS-Flow provides the output two types of ASCII output files:

  1. Tecplot snap shot (*.dat), and history files (*.his)
  2. SMS Super ASCII files (*.sup, *.xy, *.dat)

The CMS-Flow cards used for outputting these two types of files are described in the Table below.

Table 8. CMS-Flow cards used to output Tecplot and SMS Super ASCII files.

Card Arguments Description Default value
GLOBAL_TECPLOT_FILES ON | OFF Outputs Tecplot ASCII files OFF
GLOBAL_SUPER_FILES ON | OFF Outputs general ASCII solution files OFF

Statistics

CMS V4.0 has the option to calculate statistics over the whole model domain for a user-specified time period. This option is accessed using the advanced cardss. The starting time, end time, and time interval should be specified in hours with respect to the model start time. The time interval should be larger or equal to the hydrodynamic time step. When activated the global statistics will be output in the same solution file within a subfolder named stats.

This option outputs the statistics for hydrodynamics, sediment and salinity transport. If only the statistics for one group

  • Hydrodynamics:
  1. Maximum current velocity
  2. Maximum water level
  3. Residual currents (vectors and magnitude)
  4. Hydroperiod
  5. Maximum spatial gradient for water levels
  6. Maximum spatial gradient for current magnitude
  • Sediment Transport and Morphology Change:
  1. Maximum total load transport rate, m^2/s
  2. Net total load sediment transport rates, m^2/s
  3. Average total load sediment transport rates, m^2/s
  4. Gross total load sediment transport rates, m^2/s
  5. Positive and negative total load transport rates (in x and y directions), m^2/s
  6. Maximum spatial gradient of bathymetry
  • Salinity Statistics:
  1. Mean Salinity

Table 9. CMS-Flow cards related to output statistics

Card Arguments Description Default value Notes
GLOBAL_STATISTICS [t0] [tn] [dt] Calculates global statistics if specified none [start] [end] [increment]
FLOW_STATISTICS [t0] [tn] [dt] Calculates flow statistics if specified none [start] [end] [increment]
SEDIMENT_STATISTICS [t0] [tn] [dt] Calculates sediment statistics if specified none [start] [end] [increment]
SALINITY_STATISTICS [t0] [tn] [dt] Calculates salinity statistics if specified none [start] [end] [increment]

Numerical Methods

Solution Scheme

This refers to the temporal discritization of the hydrodynamic, sediment and salinity transport equations. There are two options in CMS: 1. Implicit - First order backward Euler scheme. Uses a time step on the order of 5-15 minutes. Appropriate for cases which can be simulated with large computational time steps such as long term morphology change at inlets. 2. Explicit - First order forward Euler scheme. Uses a time step on the order of 0.5-1.0 second. Appropriate for cases that vary quickly in time such as flooding or barrier island breaching.

Card Arguments Default Range Description
SOLUTION_SCHEME CHARACTER EXPLICIT EXPLICIT | IMPLICIT Determines the solution scheme used in CMS-Flow.

Solver Options

The four different solvers implemented in the implicit solution scheme are the Gauss-Seidel, Gauss-Seidel with Successive-Over-Relaxation, BICGSTAB, and GMRES. The same solver is applied to flow, sediment and salinity. The default solver is the GMRES. The solver may be changed using the advanced card in the table below.

Card Arguments Default Range Description
MATRIX_SOLVER CHARACTER GMRES GAUSS-SEIDEL | GAUSS-SEIDEL-SOR | BICGSTAB | GMRES Selects the matrix solver for flow, sediment and salinity.
HYDRO_MAX_ITERATIONS INTEGER Function of grid size >0 Sets the maximum number of iterations for the flow (hydro) solver (outer loop). Typical range: 30-50 for GAUSS-SEIDEL and GAUSS-SEIDEL-SOR, and 20-30 for BICGSTAB and GMRES.
PRESSURE_ITERATIONS INTEGER Depends on Solver >0 Sets the number of solver iterations for the pressure equation (inner loop). Typical range: 80-100 for GAUSS-SEIDEL and GAUSS-SEIDEL-SOR, and 15-25 for BICGSTAB and GMRES.
VELOCITY_ITERATIONS INTEGER Depends on Solver >0 Sets the number of solver iterations for the velocity or momentum equations (inner loop). Typical range: 20-30 for GAUSS-SEIDEL and GAUSS-SEIDEL-SOR, and 5-10 for BICGSTAB and GMRES.
SEDIMENT_MAX_ITERATIONS integer 20 >0 Maximum number of iterations (outer loop) for the sediment transport
SALINITY_MAX_ITERATIONS integer 20 >0 Maximum number of iterations (outer loop) for the salinity transport

Advection scheme

As in the case of the implicit solution scheme, the same advection scheme is applied for the flow, sediment and salinity transport equations. There are three choices for advection schemes with upwinding in the implicit model: hybrid, exponential and HLPA. The hybrid scheme is fast but is the most diffusive. The exponential scheme is based on the 1D analytical solution to an advection-diffusion equation and produces very stable results. The HLPA is very stable and non-diffusive, but requires slightly more computational time. For most applications, the exponential scheme is recommended and is set as the default. The advection scheme may be change using the advanced card

Table 10. CMS-Flow cards related to numerical methods.

Card Arguments Default Range Description
ADVECTION_SCHEME CHARACTER EXPONENTIAL NONE | HYBRID | EXPONENTIAL | HLPA Sets the advection scheme for flow, sediment and salinity.

Wetting and Drying

Table 11. CMS-Flow cards related to numerical methods.

DRYING_DEPTH REAL Calculated based on solution scheme and courant number none Sets to the time step for hydrodynamics in seconds.
WATER_PONDING CHARACTER OFF ON | OFF Turns On or Off water ponding. If water ponding is Off, isolated bodies of water will become dry.
ONE_CELL_WIDE_CHANNELS CHARACTER ON ON | OFF Limits wetting and drying to areas with at least 3 cells wide. When turned off, the model stability is improved.

Parallelization with OpenMP

Both Intel and AMD processors now are shipping chips with multiple cores/processors (henceforth referred to as "processors") available. CMS-Flow is now configured to make use of these extra processes that are available on newer machines.

Additional information on using Multiple Processors with CMS-Flow can be found here.

Table 12. CMS-Flow cards related to numerical methods.

Card Arguments Default Solver Range Description
NUM_THREADS INTEGER 1 Explicit - 1 to number of threads
Implicit - 1 to 4
Determines the number of threads used for parallel processing.

Scripting

Scipting refers to the automation of running multiple CMS runs with different parameters, without manually having to create and edit each alternative. The scripting process can include the following steps:

  1. Setting up alternatives
  2. Creating batch file
  3. Plotting and analyzing results

Scripting can be done using a variety of software programs. The examples shown here were written in Matlab becase it is widely used, easy to read and convenient for plotting and analyzing results.

Setting Up Alternatives

Figure 1. Example of scripting showing the files used.


In this example, 4 cases or alterantives are setup using the Matlab script below. The script copies the base setup files into subfolders and then modifies specific CMS-Flow cards in the *.cmcards file. The settings for each case are setup using a structure variable with field names corresponding to each CMS-Flow card (e.g. TIME_SERIES_INCREMENT). Separating each case into its own subfolder keeps the input and output separate and also allows for the different cases to be run at the same time.


% Matlab Script: setup_cases.m
clear all
flow = 'Flow_Shark';
wave = 'Wave_Shark';
ncases = 4; %Number of cases or alternatives  
r(1).MANNINGS_N_DATASET = '"Manning_Alt1.h5" "Flow_Shark/Datasets/ManningsN"';
r(1).WAVE_CURRENT_MEAN_STRESS = 'W09';
r(1).TIME_SERIES_INCREMENT = 1800;
r(2).MANNINGS_N_DATASET = '"Manning_Alt1.h5" "Flow_Shark/Datasets/ManningsN"';
r(2).WAVE_CURRENT_MEAN_STRESS = 'DATA2';
r(2).TIME_SERIES_INCREMENT = 900;
r(3).MANNINGS_N_DATASET = '"Manning_Alt2.h5" "Flow_Shark/Datasets/ManningsN"';
r(3).WAVE_CURRENT_MEAN_STRESS = 'W09';
r(3).TIME_SERIES_INCREMENT = 900;
r(4).MANNINGS_N_DATASET = '"Manning_Alt2.h5" "Flow_Shark/Datasets/ManningsN"';
r(4).WAVE_CURRENT_MEAN_STRESS = 'DATA2';
r(4).TIME_SERIES_INCREMENT = 600;
for i=1:ncases
  d = ['Case',int2str(i)];
  if ~exist(d,'dir')
    mkdir(d)
  end
  copyfile([wave,'.*'],d)
  copyfile([flow,'.*'],d)
  copyfile([flow,'_mp.h5'],d);
  copyfile([flow,'_grid.h5'],d)
  cards = fieldnames(r(i));
  file = ['.\',d,'\',flow,'.cmcards'];
  fork=1:length(cards)
    setcard(file,cards{k},r(i).(cards{k})); 
  end
end
return

The script above requires the subroutine below.

function setcard(cmcardsfile,card,value)
% setcard(file,card,value)
% Overwrites or appends a CMS-Flow card
% in the *.cmcards file
copyfile(cmcardsfile,'temp')
fid=fopen('temp','r');
fid2=fopen(cmcardsfile,'w');
nc=length(card);
ok = false(1);
if ~ischar(value)    
  value = num2str(value);
end
while 1    
  tline = fgets(fid);        
  if ~ischar(tline), break, end    
  if strncmp(card,tline,nc)        
    fprintf(fid2,'%s       %s %s' ,card,value,tline(end));                
    ok = true(1);        
    continue    
  end    
  nline = length(tline);    
  if (~ok && strcmp(tline(1:min(nline,14)),'END_PARAMETERS'))        
    fprintf(fid2,'%s       %s %s',card,value,tline(end));        
    fprintf(fid2,'%s' ,tline);        
    break 
  end    
  fprintf(fid2,'%s' ,tline);
end
fclose(fid);
fclose(fid2);
delete('temp')
return

Batch File

Although it is possible to launch CMS from Matlab a batch file is preferable to use a batch file because it allows running all of the cases without opening Matlab.

% Matlab Script: create_bat.m
cmsexe = 'cms2d_v4b42_x64p.exe'; %CMS-Flow executable
batfile = 'run_cases.bat'; %Output batch file
fid = fopen(batfile,'w');
for i=1:ncases 
  cmcards = ['.\Case',int2str(i),'\',flow,'.cmcards']; %CMS-Flow cmcards file
  fprintf(fid,'START %s %s %s',cmsexe,cmcards,char(10)); 
end
fclose(fid);
return

The following text shows what the resulting batch file (*.bat) looks like

START cms2d_v4b42_x64p.exe .\Case1\Flow_Shark.cmcards
START cms2d_v4b42_x64p.exe .\Case2\Flow_Shark.cmcards
START cms2d_v4b42_x64p.exe .\Case3\Flow_Shark.cmcards
START cms2d_v4b42_x64p.exe .\Case4\Flow_Shark.cmcards

To run the batch file, simply double click on the file and each case will launch separately in its own MS-DOS window.

Plotting

The following example reads the Observation Point time series output file (*_eta.txt) and plots the 3rd


% Matlab Script: plot_cases.m
close all 
eta = cell(ncases,1); 
for  i=1:ncases    
  etafile = ['.\Case' ,int2str(i),'\',flow,'_eta.txt' ]; %Water elevation
  eta{i} = load(etafile);    
end
figure
hold on
for i=1:ncases    
  h = plot(eta{i}(:,1),eta{i}(:,3),'-');  %3 is the index is the observation point index
end
ylabel('Water elevation, m')
xlabel('Elapsed Time, hr')
return


Units of Measurement

Variable Units Symbol
Water Surface Elevation meters
Current Velocity meters per second
Flow Rate cubic meters per second
Salinity Concentration parts per thousand
Sediment Concentration kilogram per meter cubed
Sediment Transport kilogram per meter per second
Bed Shear Stress kilogram per meter per second squared (Pascals)

CMS-Flow