Numerics
Sub-commands to support the numerics components
BSBT
Bases: BaseSubComponent
BSBT first order propagation scheme.
.. code-block:: text
BSTB
Examples
.. ipython:: python :okwarning:
from rompy_swan.subcomponents.numerics import BSBT
scheme = BSBT()
print(scheme.render())
Source code in rompy_swan/subcomponents/numerics.py
Attributes
model_type
class-attribute
instance-attribute
Functions
GSE
Bases: BaseSubComponent
Garden-sprinkler effect.
.. code-block:: text
GSE [waveage] Sec|MIn|HR|DAy
Garden-sprinkler effect is to be counteracted in the S&L propagation scheme (default for nonstationary regular grid computations) or in the propagation scheme for unstructured grids by adding a diffusion term to the basic equation. This may affect the numerical stability of SWAN.
Examples
.. ipython:: python :okwarning:
from rompy_swan.subcomponents.numerics import GSE
scheme = GSE(waveage=dict(delt=86400, dfmt="day"))
print(scheme.render())
Source code in rompy_swan/subcomponents/numerics.py
Attributes
model_type
class-attribute
instance-attribute
waveage
class-attribute
instance-attribute
waveage: Optional[Delt] = Field(default=None, description='The time interval used to determine the diffusion which counteracts the so-called garden-sprinkler effect. The default value of `waveage` is zero, i.e. no added diffusion. The value of `waveage` should correspond to the travel time of the waves over the computational region.')
Functions
STAT
Bases: BaseSubComponent
Computation parameters in stationary computation.
Source code in rompy_swan/subcomponents/numerics.py
Attributes
model_type
class-attribute
instance-attribute
mxitst
class-attribute
instance-attribute
mxitst: Optional[int] = Field(default=None, description='The maximum number of iterations for stationary computations. The computation stops when this number is exceeded (SWAN default: 50)')
alfa
class-attribute
instance-attribute
alfa: Optional[float] = Field(default=None, description='Proportionality constant used in the frequency-dependent under-relaxation technique. Based on experiences, a suggestion for this parameter is `alfa = 0.01`. In case of diffraction computations, the use of this parameter is recommended (SWAN default: 0.00)')
Functions
cmd
Command file string for this component.
NONSTAT
Bases: BaseSubComponent
Computation parameters in nonstationary computation.
Source code in rompy_swan/subcomponents/numerics.py
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['nonstat', 'NONSTAT'] = Field(default='nonstat', description='Model type discriminator')
mxitns
class-attribute
instance-attribute
mxitns: Optional[int] = Field(default=None, description='The maximum number of iterations per time step for nonstationary computations. The computation moves to the next time step when this number is exceeded (SWAN default: `mxitns = 1`')
Functions
STOPC
Bases: BaseSubComponent
Stopping criteria of Zijlema and Van der Westhuysen (2005).
.. code-block:: text
STOPC [dabs] [drel] [curvat] [npnts] ->STAT|NONSTAT [limiter]
With this option the user can influence the criterion for terminating the iterative
procedure in the SWAN computations (both stationary and nonstationary). The
criterion makes use of the second derivative, or curvature, of the iteration curve
of the significant wave height. As the solution of a simulation approaches full
convergence, the curvature of the iteration curve will tend to zero. SWAN stops the
process if the relative change in Hs from one iteration to the next is less than
drel and the curvature of the iteration curve of Hs normalized with Hs is less
than curvat or the absolute change in Hs from one iteration to the next is less
than dabs. Both conditions need to be fulfilled in more than fraction npnts
percent of all wet grid points.
With respect to the QC modelling, another stopping criteria will be employed.
Namely, SWAN stops the iteration process if the absolute change in Hs from one
iterate to another is less than dabs * Hinc, where Hinc is the representative
incident wave height, or the relative change in Hs from one to the next iteration
is less than drel. These criteria must be fulfilled in more than npnts
percent of all active, well-defined points.
References
- Zijlema, M. and Van der Westhuysen, A. (2005). On convergence behaviour and numerical accuracy in stationary SWAN simulations of nearshore wind wave spectra, Coastal Engineering, 52(3), p. 337-256.
Examples
.. ipython:: python :okwarning:
from rompy_swan.subcomponents.numerics import STOPC
stop = STOPC()
print(stop.render())
stop = STOPC(
dabs=0.005,
drel=0.01,
curvat=0.005,
npnts=99.5,
mode=dict(model_type="nonstat", mxitns=1),
limiter=0.1,
)
print(stop.render())
Source code in rompy_swan/subcomponents/numerics.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | |
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['stopc', 'STOPC'] = Field(default='stopc', description='Model type discriminator')
dabs
class-attribute
instance-attribute
dabs: Optional[float] = Field(default=None, description='Maximum absolute change in Hs from one iteration to the next (SWAN default: 0.005 [m] or 0.05 [-] in case of QC model)')
drel
class-attribute
instance-attribute
drel: Optional[float] = Field(default=None, description='Maximum relative change in Hs from one iteration to the next (SWAN default: 0.01 [-])')
curvat
class-attribute
instance-attribute
curvat: Optional[float] = Field(default=None, description='Maximum curvature of the iteration curve of Hs normalised with Hs (SWAN default: 0.005 [-] (not used in the QC model))')
npnts
class-attribute
instance-attribute
npnts: Optional[float] = Field(default=None, description='Percentage of points in the computational grid above which the stopping criteria needs to be satisfied (SWAN default: 99.5 [-])')
mode
class-attribute
instance-attribute
mode: Optional[Union[STAT, NONSTAT]] = Field(default=None, description='Termination criteria for stationary or nonstationary runs', discriminator='model_type')
limiter
class-attribute
instance-attribute
limiter: Optional[float] = Field(default=None, description='Determines the maximum change per iteration of the energy density per spectral-bin given in terms of a fraction of the omni-directional Phillips level (SWAN default: 0.1)')
Functions
cmd
Command file string for this component.
Source code in rompy_swan/subcomponents/numerics.py
ACCUR
Bases: BaseSubComponent
Stop the iterative procedure.
.. code-block:: text
ACCUR [drel] [dhoval] [dtoval] [npnts] ->STAT|NONSTAT [limiter]
With this option the user can influence the criterion for terminating the iterative procedure in the SWAN computations (both stationary and non-stationary modes). SWAN stops the iterations if (a), (b) and (c) are all satisfied:
a) The change in the local significant wave height Hs from one iteration to the
next is less than (1) fraction drel of that height or (2) fraction dhoval
of the average Hs over all grid points.
b) The change in the local mean wave period Tm01 from one iteration to the next is
less than (1) fraction drel of that period or (2) fraction dtoval of the
average mean wave period over all wet grid points.
c) Conditions (a) and (b) are fulfilled in more than fraction npnts% of all wet
grid points.
Note
This command has become obsolete in SWAN 41.01. The command STOPC should be used.
Examples
.. ipython:: python :okwarning:
from rompy_swan.subcomponents.numerics import ACCUR
accur = ACCUR()
print(accur.render())
accur = ACCUR(
drel=0.01,
dhoval=0.02,
dtoval=0.02,
npnts=98.0,
mode=dict(model_type="nonstat", mxitns=1),
limiter=0.1,
)
print(accur.render())
Source code in rompy_swan/subcomponents/numerics.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | |
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['accur', 'ACCUR'] = Field(default='accur', description='Model type discriminator')
drel
class-attribute
instance-attribute
drel: Optional[float] = Field(default=None, description='Maximum relative change in Hs or Tm01 from one iteration to the next (SWAN default: 0.02)')
dhoval
class-attribute
instance-attribute
dhoval: Optional[float] = Field(default=None, description='Fraction of the average Hs over all wet grid points below which the the stopping criteria needs to be satisfied (SWAN default: 0.02)')
dtoval
class-attribute
instance-attribute
dtoval: Optional[float] = Field(default=None, description='Fraction of the average Tm01 over all wet grid points below which the the stopping criteria needs to be satisfied (SWAN default: 0.02)')
npnts
class-attribute
instance-attribute
npnts: Optional[float] = Field(default=None, description='Percentage of points in the computational grid above which the stopping criteria needs to be satisfied (SWAN default: 98)')
mode
class-attribute
instance-attribute
mode: Optional[Union[STAT, NONSTAT]] = Field(default=None, description='Termination criteria for stationary or nonstationary runs', discriminator='model_type')
limiter
class-attribute
instance-attribute
limiter: Optional[float] = Field(default=None, description='Determines the maximum change per iteration of the energy density per spectral-bin given in terms of a fraction of the omni-directional Phillips level (SWAN default: 0.1)')
Functions
cmd
Command file string for this component.
Source code in rompy_swan/subcomponents/numerics.py
DIRIMPL
Bases: BaseSubComponent
Numerical scheme for refraction.
.. code-block:: text
DIRIMPL [cdd]
Examples
.. ipython:: python :okwarning:
from rompy_swan.subcomponents.numerics import DIRIMPL
dirimpl = DIRIMPL()
print(dirimpl.render())
dirimpl = DIRIMPL(cdd=0.5)
print(dirimpl.render())
Source code in rompy_swan/subcomponents/numerics.py
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['dirimpl', 'DIRIMPL'] = Field(default='dirimpl', description='Model type discriminator')
cdd
class-attribute
instance-attribute
cdd: Optional[float] = Field(default=None, description='A value of `cdd=0` corresponds to a central scheme and has the largest accuracy (diffusion ≈ 0) but the computation may more easily generatespurious fluctuations. A value of `cdd=1` corresponds to a first orderupwind scheme and it is more diffusive and therefore preferable if (strong) gradients in depth or current are present (SWAN default: 0.5)')
Functions
SIGIMPL
Bases: BaseSubComponent
Frequency shifting accuracy.
.. code-block:: text
SIGIMpl [cfl] [eps2] [outp] [niter]
Controls the accuracy of computing the frequency shifting and the stopping criterion and amount of output for the SIP solver (used in the computations in the presence of currents or time varying depth)
Examples
.. ipython:: python :okwarning:
from rompy_swan.subcomponents.numerics import SIGIMPL
sigimpl = SIGIMPL()
print(sigimpl.render())
sigimpl = SIGIMPL(css=0.5, eps2=1e-4, outp=0, niter=20)
print(sigimpl.render())
Source code in rompy_swan/subcomponents/numerics.py
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['sigimpl', 'SIGIMPL'] = Field(default='sigimpl', description='Model type discriminator')
css
class-attribute
instance-attribute
css: Optional[float] = Field(default=None, description='A value of `css=0` corresponds to a central scheme and has the largest accuracy (diffusion ≈ 0) but the computation may more easily generate spurious fluctuations. A value of `css=1` corresponds to a first order upwind scheme and it is more diffusive and therefore preferable if (strong) gradients in depth or current are present (SWAN default: 0.5)')
eps2
class-attribute
instance-attribute
eps2: Optional[float] = Field(default=None, description='Relative stopping criterion to terminate the linear solver (SIP or SOR). (SWAN default: 1.e-4 in case of SIP and 1.e-6 in case of SOR)')
outp
class-attribute
instance-attribute
outp: Optional[Literal[0, 1, 2, 3]] = Field(default=None, description='Output for the iterative solver:\n\n* 0 = no output\n* 1 = additional information about the iteration process is written to the PRINT file \n* 2 = gives a maximal amount of output concerning the iteration process\n* 3 = summary of the iteration process\n\n(SWAN default: 0)')
niter
class-attribute
instance-attribute
niter: Optional[int] = Field(default=None, description='Maximum number of iterations for the linear solver (SWAN default: 20 in case of SIP and 1000 in case of SOR)')
Functions
cmd
Command file string for this component.
Source code in rompy_swan/subcomponents/numerics.py
CTHETA
Bases: BaseSubComponent
Prevents excessive directional turning.
.. code-block:: text
CTheta [cfl]
This option prevents an excessive directional turning at a single grid point or vertex due to a very coarse bathymetry or current locally. This option limits the directional turning rate cθ based on the CFL restriction. (See Eq. 3.41 of Scientific/Technical documentation). See also the final remark in Section 2.6.3. Note that if this command is not specified, then the limiter is not activated.
Examples
.. ipython:: python :okwarning:
from rompy_swan.subcomponents.numerics import CTHETA
ctheta = CTHETA()
print(ctheta.render())
ctheta = CTHETA(cfl=0.9)
print(ctheta.render())
Source code in rompy_swan/subcomponents/numerics.py
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['ctheta', 'CTHETA'] = Field(default='ctheta', description='Model type discriminator')
cfl
class-attribute
instance-attribute
cfl: Optional[float] = Field(default=None, description='Upper limit for the CFL restriction for ctheta. A suggestion for this parameter is `cfl = 0.9` (SWAN default: 0.9 when CTHETA is activated)')
Functions
CSIGMA
Bases: BaseSubComponent
Prevents excessive directional turning.
.. code-block:: text
CSigma [cfl]
This option prevents an excessive frequency shifting at a single grid point or vertex due to a very coarse bathymetry or current locally. This option limits the frequency shifting rate csigma based on the CFL restriction. See also the final remark in Section 2.6.3. Note that if this command is not specified, then the limiter is not activated.
Examples
.. ipython:: python :okwarning:
from rompy_swan.subcomponents.numerics import CSIGMA
csigma = CSIGMA()
print(csigma.render())
csigma = CSIGMA(cfl=0.9)
print(csigma.render())
Source code in rompy_swan/subcomponents/numerics.py
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['ctheta', 'CTHETA'] = Field(default='ctheta', description='Model type discriminator')
cfl
class-attribute
instance-attribute
cfl: Optional[float] = Field(default=None, description='Upper limit for the CFL restriction for csigma. A suggestion for this parameter is `cfl = 0.9` (SWAN default: 0.9 when CSIGMA is activated)')
Functions
SETUP
Bases: BaseSubComponent
Stop criteria in the computation of wave setup.
.. code-block:: text
SETUP [eps2] [outp] [niter]
Controls the stopping criterion and amount of output for the SOR solver in the computation of the wave-induced set-up.
Examples
.. ipython:: python :okwarning:
from rompy_swan.subcomponents.numerics import SETUP
setup = SETUP()
print(setup.render())
setup = SETUP(eps2=1e-4, outp=0, niter=20)
print(setup.render())
Source code in rompy_swan/subcomponents/numerics.py
Attributes
model_type
class-attribute
instance-attribute
model_type: Literal['setup', 'SETUP'] = Field(default='setup', description='Model type discriminator')
eps2
class-attribute
instance-attribute
eps2: Optional[float] = Field(default=None, description='Relative stopping criterion to terminate the linear solver (SIP or SOR). (SWAN default: 1.e-4 in case of SIP and 1.e-6 in case of SOR)')
outp
class-attribute
instance-attribute
outp: Optional[Literal[0, 1, 2, 3]] = Field(default=None, description='Output for the iterative solver:\n\n* 0 = no output\n* 1 = additional information about the iteration process is written to the PRINT file \n* 2 = gives a maximal amount of output concerning the iteration process \n* 3 = summary of the iteration process\n\n(SWAN default: 0)')
niter
class-attribute
instance-attribute
niter: Optional[int] = Field(default=None, description='Maximum number of iterations for the linear solver (SWAN default: 20 in case of SIP and 1000 in case of SOR)')
Functions
cmd
Command file string for this component.