Startup¶
The commands at the start of the command file: PROJECT, SET, MODE and COORDINATES.
SWAN Startup Components
This module contains components for initializing and configuring SWAN model runs, including project settings, coordinate systems, and run modes.
PROJECT
pydantic-model
¶
PROJECT(**data: Any)
Bases: BaseComponent
SWAN Project.
With this required command the user defines a number of strings to identify the SWAN run (project name e.g., an engineering project) in the print and plot file.
Examples¶
from rompy_swan.components.startup import PROJECT
proj = PROJECT(nr="01")
print(proj.render())
proj = PROJECT(
name="waus",
nr="001",
title1="Western Australia",
title2="Perth Nest"
)
print(proj.render())
Config:
extra:forbid
Fields:
-
model_type(Literal['project', 'PROJECT']) -
name(Optional[str]) -
nr(str) -
title1(Optional[str]) -
title2(Optional[str]) -
title3(Optional[str])
model_type
pydantic-field
¶
model_type: Literal['project', 'PROJECT'] = 'project'
Model type discriminator
name
pydantic-field
¶
Is the name of the project, at most 16 characters long
nr
pydantic-field
¶
nr: str
Is the run identification (to be provided as a character string; e.g. the run number) to distinguish this run among other runs for the same project; it is at most 4 characters long. It is the only required information in this command.
title1
pydantic-field
¶
A string of at most 72 characters provided by the user to appear in the output of the program for the user's convenience (SWAN default: blanks)
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
render
¶
SET
pydantic-model
¶
SET(**data: Any)
Bases: BaseComponent
SWAN setting commands.
SET [level] [nor] [depmin] [maxmes] [maxerr] [grav] [rho] [cdcap] &
[inrhog] [hsrerr] NAUTICAL|->CARTESIAN [pwtail] [froudmax] [icewind]
With this optional command the user assigns values to various general parameters.
Notes¶
The error level maxerr is coded as follows:
- 1: warnings
- 2: errors (possibly automatically repaired or repairable by SWAN)
- 3: severe errors
Default values for pwtail depend on formulations of physics:
- command GEN1:
pwtail = 5 - command GEN2:
pwtail = 5 - command GEN3 KOMEN:
pwtail = 4 - command GEN3 WESTH:
pwtail = 4 - command GEN3 JANSSEN:
pwtail = 5
Examples¶
from rompy_swan.components.startup import SET
set = SET(level=0.5, direction_convention="nautical")
print(set.render())
set = SET(
level=-1.0,
nor=90,
depmin=0.01,
maxerr=3,
grav=9.81,
rho=1025,
cdcap=2.5e-3,
inrhog=0,
hsrerr=0.1,
direction_convention="nautical",
)
print(set.render())
SET level=0.5 NAUTICAL
SET level=-1.0 nor=90.0 depmin=0.01 maxerr=3 grav=9.81 rho=1025.0 cdcap=0.0025 inrhog=0 hsrerr=0.1 NAUTICAL
Fields:
-
model_type(Literal['set', 'SET']) -
level(Optional[float]) -
nor(Optional[float]) -
depmin(Optional[float]) -
maxmes(Optional[int]) -
maxerr(Optional[Literal[1, 2, 3]]) -
grav(Optional[float]) -
rho(Optional[float]) -
cdcap(Optional[float]) -
inrhog(Optional[Literal[0, 1]]) -
hsrerr(Optional[float]) -
direction_convention(Literal['nautical', 'cartesian']) -
pwtail(Optional[int]) -
froudmax(Optional[float]) -
icewind(Optional[Literal[0, 1]])
Validators:
level
pydantic-field
¶
Increase in water level that is constant in space and time can be given with this option, level is the value of this increase (in m). For a variable water level reference is made to the commands INPGRID and READINP (SWAN default: 0)
nor
pydantic-field
¶
Direction of North with respect to the x-axis (measured counterclockwise); default nor = 90, i.e. x-axis of the problem coordinate system points East. When spherical coordinates are used (see command COORD) the value of nor may not be modified
depmin
pydantic-field
¶
Threshold depth (in m). In the computation any positive depth smaller than depmin is made equal to depmin (SWAN default: 0.05)
maxmes
pydantic-field
¶
Maximum number of error messages during the computation at which the computation is terminated. During the computational process messages are written to the print file (SWAN default: 200)
maxerr
pydantic-field
¶
During pre-processing SWAN checks input data. Depending on the severity of the errors encountered during this pre-processing, SWAN does not start computations. The user can influence the error level above which SWAN will not start computations (at the level indicated the computations will continue) (SWAN default: 1)
grav
pydantic-field
¶
The gravitational acceleration (in m/s2) (SWAN default: 9.81)
cdcap
pydantic-field
¶
The maximum value for the wind drag coefficient. A value of 99999 meansno cutting off the drag coefficient. A suggestion for this parameter is cdcap = 2.5x 10-3 (SWAN default: 99999)
inrhog
pydantic-field
¶
To indicate whether the user requires output based on variance or based on true energy (see Section 2.5). inrhog = 0: output based on variance, inrhog = 1: output based on true energy (SWAN default: 0)
hsrerr
pydantic-field
¶
The relative difference between the user imposed significant wave height and the significant wave height computed by SWAN (anywhere along the computational grid boundary) above which a warning will be given. This relative difference is the difference normalized with the user provided significant wave height. This warning will be given for each boundary grid point where the problem occurs (with its x- and y-index number of the computational grid). The cause of the difference is explained in Section 2.6.3. To suppress these warnings (in particular for nonstationary computations), set hsrerr at a very high value or use command OFF BNDCHK (SWAN default: 0.10) (ONLY MEANT FOR STRUCTURED GRIDS)
direction_convention
pydantic-field
¶
direction_convention: Literal['nautical', 'cartesian']
Direction convention: nautical indicates that the Nautical convention for wind and wave direction (SWAN input and output) will be used, cartesian indicates that the Cartesian convention for wind and wave direction will be used. For definition, see Section 2.5 or Appendix A (SWAN default: cartesian)
pwtail
pydantic-field
¶
Power of high frequency tail; defines the shape of the spectral tail above the highest prognostic frequency fhigh (see command CGRID). The energy density is assumed to be proportional to frequency to the power pwtail. If the user wishes to use another value, then this SET command should be located in the command file after GEN1, GEN2 or GEN3 command (these will override the SET command with respect to pwtail)
froudmax
pydantic-field
¶
Is the maximum Froude number (U/√gd with U the current and d the water depth). The currents taken from a circulation model may mismatch with given water depth d in the sense that the Froude number becomes larger than 1. For this, the current velocities will be maximized by Froude number times sqrt(gh) (SWAN default: 0.8)
icewind
pydantic-field
¶
Controls the scaling of wind input by open water fraction. Default value of zero corresponds to the case where wind input is scaled by the open water fraction. If icewind = 1 then sea ice does not affect wind input directly. (Though there is still indirect effect via the sea ice sink term; see command SICE) (SWAN default: 0)
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
render
¶
MODE
pydantic-model
¶
MODE(**data: Any)
Bases: BaseComponent
SWAN Mode.
With this optional command the user indicates that the run will be either stationary or nonstationary and one-dimensional (1D-mode) or two-dimensional (2D-mode). Nonstationary means either (see command COMPUTE):
- (a) one nonstationary computations or
- (b) a sequence of stationary computations or
- (c) a mix of (a) and (b)
Examples¶
from rompy_swan.components.startup import MODE
mode = MODE()
print(mode.render())
mode = MODE(kind="nonstationary", dim="twodimensional")
print(mode.render())
Fields:
-
model_type(Literal['mode', 'MODE']) -
kind(Literal['stationary', 'nonstationary']) -
dim(Literal['onedimensional', 'twodimensional'])
kind
pydantic-field
¶
kind: Literal['stationary', 'nonstationary'] = 'stationary'
Indicates if run will be stationary or nonstationary
dim
pydantic-field
¶
dim: Literal["onedimensional", "twodimensional"] = (
"twodimensional"
)
Indicates that the run will be either one-dimensional (1D-mode) or two-dimensional (2D-mode)
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.
render
¶
COORDINATES
pydantic-model
¶
COORDINATES(**data: Any)
Bases: BaseComponent
SWAN Coordinates.
Command to choose between Cartesian and spherical coordinates (see Section 2.5). A nested SWAN run must use the same coordinate system as the coarse grid SWAN run.
Examples¶
from rompy_swan.components.startup import COORDINATES
coords = COORDINATES()
print(coords.render())
coords = COORDINATES(
kind=dict(model_type="spherical", projection="ccm"),
reapeating=True,
)
print(coords.render())
Fields:
-
model_type(Literal['coordinates', 'COORDINATES']) -
kind(CARTESIAN | SPHERICAL) -
reapeating(bool)
model_type
pydantic-field
¶
model_type: Literal["coordinates", "COORDINATES"] = (
"coordinates"
)
Model type discriminator
reapeating
pydantic-field
¶
reapeating: bool = False
This option is only for academic cases. It means that wave energy leaving at one end of the domain (in computational x-direction) enter at the other side; it is as if the wave field repeats itself in x-direction with the length of the domain in x-direction. This option cannot be used in combination with computation of set-up (see command SETUP). This option is available only with regular grids
check_for_typos
classmethod
¶
Suggest the closest field name for an unknown input key.
A field can be given by its name or, like in pydantic, by its alias.