Skip to content

Gridded wind

A wind is a tracerax velocity, wind(t, position), with one velocity per particle. wind_from_speed_direction makes a steady, uniform one. gridded_wind_from_met and gridded_wind_from_prescribed put a MetField or a PrescribedWindField on the les_fvm C-grid (U at x + Δx/2, V at y + Δy/2, W at T-points) as a tracerax.velocity.GriddedVelocity: trilinear in space, piecewise-linear in time, edge value held beyond the walls. tracerax.velocity.uniform and uniform_in_space make the others. Pass a wind as wind to simulate_lagrangian or compute_footprint, or inside a tracerax.advect.Langevin to tracerax.advect.integrate. Tier II.

wind_interp

The winds of plumax as velocities for particles (implementation in plumax.lagrangian._src.wind_interp).

gridded_wind_from_met

gridded_wind_from_met(field: MetField) -> GriddedVelocity

The wind of a :class:~plumax.met.MetField, for particles.

MetField already stores u, v, w on the C-grid with a time axis, so no value changes.

Parameters:

Name Type Description Default
field MetField

Meteorology on an analysis grid.

required

Returns:

Type Description
GriddedVelocity

The wind on field.plume_grid at field.times.

Source code in src/plumax/lagrangian/_src/wind_interp.py
def gridded_wind_from_met(field: MetField) -> GriddedVelocity:
    """The wind of a :class:`~plumax.met.MetField`, for particles.

    ``MetField`` already stores ``u``, ``v``, ``w`` on the C-grid with a time
    axis, so no value changes.

    Args:
        field: Meteorology on an analysis grid.

    Returns:
        The wind on ``field.plume_grid`` at ``field.times``.
    """
    return _on_plume_grid(field.plume_grid, field.times, field.u, field.v, field.w)

gridded_wind_from_prescribed

gridded_wind_from_prescribed(wind_field: PrescribedWindField, times: Num[ArrayLike, ' time']) -> GriddedVelocity

Sample a les_fvm :class:~plumax.les_fvm.wind.PrescribedWindField.

The field is evaluated at each of times; between them the particles see the piecewise-linear interpolant, so times should resolve the field's own time variation.

Parameters:

Name Type Description Default
wind_field PrescribedWindField

The Eulerian solver's wind.

required
times Num[ArrayLike, ' time']

Times [s] to sample it at, strictly increasing.

required

Returns:

Type Description
GriddedVelocity

The wind on wind_field.plume_grid.

Source code in src/plumax/lagrangian/_src/wind_interp.py
def gridded_wind_from_prescribed(
    wind_field: PrescribedWindField, times: Num[ArrayLike, " time"]
) -> GriddedVelocity:
    """Sample a ``les_fvm`` :class:`~plumax.les_fvm.wind.PrescribedWindField`.

    The field is evaluated at each of ``times``; between them the particles see
    the piecewise-linear interpolant, so ``times`` should resolve the field's
    own time variation.

    Args:
        wind_field: The Eulerian solver's wind.
        times: Times [s] to sample it at, strictly increasing.

    Returns:
        The wind on ``wind_field.plume_grid``.
    """
    times = jnp.asarray(times, dtype=float)
    samples = [wind_field(time) for time in times]
    # interior points: drop the one-cell ghost ring the solver pads with
    wind_east, wind_north, wind_up = (
        jnp.stack([sample[component][1:-1, 1:-1, 1:-1] for sample in samples])
        for component in range(3)
    )
    return _on_plume_grid(wind_field.plume_grid, times, wind_east, wind_north, wind_up)

wind_from_speed_direction

wind_from_speed_direction(speed: float, direction_deg: float, w: float = 0.0) -> Velocity

Constant wind from speed + meteorological direction (degrees from North).

direction_deg = 270 is a wind from the west (flowing east), matching the convention used by :func:plumax.gauss_plume.simulate_plume.

Parameters:

Name Type Description Default
speed float

Wind speed [m/s].

required
direction_deg float

Direction the wind blows from [degrees from north].

required
w float

Vertical wind [m/s].

0.0

Returns:

Type Description
Velocity

The wind, as a tracerax.velocity.uniform velocity.

Examples:

>>> import jax.numpy as jnp
>>> wind = wind_from_speed_direction(5.0, 270.0)
>>> bool(jnp.allclose(wind(0.0, jnp.zeros((1, 3)))[0, 0], 5.0))
True
Source code in src/plumax/lagrangian/_src/wind_interp.py
def wind_from_speed_direction(
    speed: float, direction_deg: float, w: float = 0.0
) -> Velocity:
    """Constant wind from speed + meteorological direction (degrees *from* North).

    ``direction_deg = 270`` is a wind from the west (flowing east), matching the
    convention used by :func:`plumax.gauss_plume.simulate_plume`.

    Args:
        speed: Wind speed [m/s].
        direction_deg: Direction the wind blows from [degrees from north].
        w: Vertical wind [m/s].

    Returns:
        The wind, as a ``tracerax.velocity.uniform`` velocity.

    Examples:
        >>> import jax.numpy as jnp
        >>> wind = wind_from_speed_direction(5.0, 270.0)
        >>> bool(jnp.allclose(wind(0.0, jnp.zeros((1, 3)))[0, 0], 5.0))
        True
    """
    wind_east, wind_north = wind_components(speed, direction_deg)
    return uniform(jnp.array([float(wind_east), float(wind_north), w]))