Skip to content

Numerics

PROP and NUMERIC: propagation scheme and numerical settings.

SWAN Numerics Components

This module contains components for configuring the numerical schemes and parameters used in SWAN for wave propagation, frequency shifting, and other numerical aspects.

logger module-attribute

logger = get_logger(__name__)

PROP_TYPE module-attribute

PROP_TYPE = Annotated[
    Union[BSBT, GSE],
    Field(
        description="Propagation scheme",
        discriminator="model_type",
    ),
]

PROP pydantic-model

PROP(**data: Any)

Bases: BaseComponent

Propagation scheme.

PROP BSBT|GSE

Notes

  • The scheme defaults to S&L and SORDUP for nonstationary and stationary simulations if not specified.
  • All schemes (BSBT, SORDUP and S&L) can be used in combination with curvilinear grids. With the higher order schemes (S&L and SORDUP) it is important to use a gradually varying grid otherwise there may be a severe loss of accuracy. If sharp transitions in the grid cannot be avoided it is safer to use the BSBT scheme.
  • In the computation with unstructured meshes, a lowest order upwind scheme will be employed. This scheme is very robust but rather diffusive. This may only be significant for the case when swell waves propagate over relative large distances (in the order of thousands of kilometers) within the model domain. However and most fortunately, in such a case this will alleviate the garden-sprinkler effect.
  • Alleviating the garden-sprinkler effect by adding some diffusion makes the SWAN computation conditionally stable. You can either use (i) a smaller time step, (ii) a lower value of waveage, (iii) better resolution in the directional space, or (iv) worse resolution in the geographic space, in order of preference, to make the model stable when necessary.

Examples

from rompy_swan.components.numerics import PROP
prop = PROP()
print(prop.render())
prop = PROP(scheme=dict(model_type="bsbt"))
print(prop.render())
prop = PROP(
    scheme=dict(
        model_type="gse",
        waveage=dict(delt="PT5H", dfmt="hr"),
    ),
)
print(prop.render())
PROP
PROP BSBT
PROP GSE waveage=5.0 HR

Fields:

model_type pydantic-field

model_type: Literal['prop', 'PROP'] = 'prop'

Model type discriminator

scheme pydantic-field

scheme: Optional[PROP_TYPE] = None

Propagation scheme, by default S&L for nonstationary and SORDUP for stationary computation.

cmd

cmd() -> str

Command file string for this component.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

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.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.

NUMERIC pydantic-model

NUMERIC(**data: Any)

Bases: BaseComponent

Numerical properties.

NUMeric ( STOPC [dabs] [drel] [curvat] [npnts] ->STAT|NONSTAT [limiter] ) &
    ( DIRimpl [cdd] ) ( SIGIMpl [css] [eps2] [outp] [niter] ) &
    ( CTheta [cfl] ) ( CSigma [cfl] ) ( SETUP [eps2] [outp] [niter] )

Examples

from rompy_swan.components.numerics import NUMERIC
numeric = NUMERIC()
print(numeric.render())
numeric = NUMERIC(
    stop=dict(
        model_type="stopc",
        dabs=0.05,
        drel=0.01,
        curvat=0.05,
        npnts=99.5,
    ),
    dirimpl=dict(cdd=0.5),
    sigimpl=dict(css=0.5, eps2=1e-4, outp=0, niter=20),
    ctheta=dict(cfl=0.9),
    csigma=dict(cfl=0.9),
    setup=dict(eps2=1e-4, outp=0, niter=20),
)
print(numeric.render())
NUMERIC
NUMERIC STOPC dabs=0.05 drel=0.01 curvat=0.05 npnts=99.5 DIRIMPL cdd=0.5 SIGIMPL css=0.5 eps2=0.0001 outp=0 niter=20 CTHETA cfl=0.9 CSIGMA cfl=0.9 SETUP eps2=0.0001 outp=0 niter=20

Fields:

model_type pydantic-field

model_type: Literal['numeric', 'NUMERIC'] = 'numeric'

Model type discriminator

stop pydantic-field

stop: Optional[Union[STOPC, ACCUR]] = None

Iteration termination criteria

dirimpl pydantic-field

dirimpl: Optional[DIRIMPL] = None

Numerical scheme for refraction

sigimpl pydantic-field

sigimpl: Optional[SIGIMPL] = None

Frequency shifting accuracy

ctheta pydantic-field

ctheta: Optional[CTHETA] = None

Prevents excessive directional turning

csigma pydantic-field

csigma: Optional[CSIGMA] = None

Prevents excessive frequency shifting

setup pydantic-field

setup: Optional[SETUP] = None

Stop criteria in the computation of wave setup

cmd

cmd() -> str

Command file string for this component.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

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.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

render

render(cmd: Optional[str | list] = None) -> str

Render the component to a string.

Parameters:

Name Type Description Default
cmd Optional[str | list]

Command string or list of command strings to render, by default self.cmd().

None

Returns:

Name Type Description
cdmstr str

The rendered command file component.