Coverage for src/flexfrac1d/lib/att.py: 100%

1"""Attenuation parameterisations."""

2

3 import enum

4 import typing

5

6 import attrs

7 import numpy as np

8

9

10 def no_attenuation():

11 """No attenuation.

12

13 Waves propagate indifinitely, as if the ice cover is perfectly elastic and

14 the fluid perfectly inviscid.

15

16 Returns

17 -------

18 typing.Literal[0]

19 Amplitude attenuation, in m^-1

20

21 Notes

22 -----

23 The attenuation is defined as:

24

25 .. math::

26

27 \alpha_j = 0 \forall j.

28

29 """

30 return 0

31

32

33 def parameterisation_01(thickness: float, wavenumbers: np.ndarray) -> np.ndarray:

34 """Parameterised attenuation for individual wave modes.

35

36 Parameters

37 ----------

38 thickness : float

39 Ice thickness, in m

40 wavenumbers : np.ndarray

41 Propagating wavenumbers, in rad m^-1

42

43 Returns

44 -------

45 np.ndarray

46 Amplitude attenuation, in m^-1

47

48 Notes

49 -----

50 The attenuation is defined as:

51

52 .. math::

53

54 \alpha_j = \frac{1}{4} {k_j}^2 h.

55

56 """

57 return wavenumbers**2 * thickness / 4

58

59

60 class AttenuationParameterisation(enum.Enum):

61 NO = 0

62 PARAM_01 = 1

63

64

65@attrs.frozen

66 class AttenuationSpecification:

67 function: typing.Callable

68 args: str | None = None

69 kwargs: dict[str, typing.Any] = attrs.field(factory=dict)

70

71

72 Attenuation: typing.TypeAlias = AttenuationParameterisation | AttenuationSpecification