Coverage for src/flexfrac1d/lib/curvature.py: 90%

1 import numpy as np

2

3 from .displacement import _dis_hom_coefs, _dis_par_amps

4 from . import numerical

5

6

7 def _cur_wavefield(x, red_num: float, wave_params):

8 """Second derivative of the interface"""

9 _, c_wavenumbers = wave_params

10

11 return -np.imag(

12 (_dis_par_amps(red_num, wave_params) * c_wavenumbers**2)

13 @ np.exp(1j * c_wavenumbers[:, None] * x)

14 )

15

16

17 def _cur_hom(x, floe_params, wave_params):

18 """Second derivative of the homogeneous part of the displacement"""

19 red_num, length = floe_params

20 arr = red_num * x

21 cosx, sinx = np.cos(arr), np.sin(arr)

22 expx = np.exp(-red_num * (length - x))

23 exmx = np.exp(-arr)

24 return (

25 2

26 * red_num**2

27 * np.vstack(([-expx * sinx, expx * cosx, exmx * sinx, -exmx * cosx])).T

28 @ _dis_hom_coefs(floe_params, wave_params)

29 )

30

31

32 def _cur_par(x, red_num, wave_params):

33 """Second derivative of the particular part of the displacement"""

34 return _cur_wavefield(x, red_num, wave_params)

35

36

37 def curvature(

38 x,

39 floe_params: tuple[float],

40 wave_params: tuple[np.ndarray],

41 growth_params: tuple | None = None,

42 an_sol: bool | None = None,

43 num_params: dict | None = None,

44):

45 """Curvature of the floe, i.e. second derivative of the vertical displacement"""

46 if numerical._use_an_sol(an_sol, floe_params[1], growth_params): 46 ↛ 50line 46 didn't jump to line 50, because the condition on line 46 was never false

47 return _cur_hom(x, floe_params, wave_params) + _cur_par(

48 x, floe_params[0], wave_params

49 )

50 return numerical.curvature(x, floe_params, wave_params, growth_params, num_params)