Coverage for src/flexfrac1d/lib/curvature.py: 90%
19 statements
« prev ^ index » next coverage.py v7.4.1, created at 2024-07-03 16:40 +0200
« prev ^ index » next coverage.py v7.4.1, created at 2024-07-03 16:40 +0200
1import numpy as np
3from .displacement import _dis_hom_coefs, _dis_par_amps
4from . import numerical
7def _cur_wavefield(x, red_num: float, wave_params):
8 """Second derivative of the interface"""
9 _, c_wavenumbers = wave_params
11 return -np.imag(
12 (_dis_par_amps(red_num, wave_params) * c_wavenumbers**2)
13 @ np.exp(1j * c_wavenumbers[:, None] * x)
14 )
17def _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 )
32def _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)
37def 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)