Skip to content

papoto_model

convert_grad_to_rad

convert_grad_to_rad(angle_in_grad: ndarray) -> ndarray

Converts an angle in grad to radians.

Parameters:

Name Type Description Default

angle_in_grad

ndarray

array of angles in grad

required

Returns:

Type Description
ndarray

np.ndarray: array of angles in radians

Source code in src/mechaphlowers/core/papoto/papoto_model.py
269
270
271
272
273
274
275
276
277
278
def convert_grad_to_rad(angle_in_grad: np.ndarray) -> np.ndarray:
    """Converts an angle in grad to radians.

    Args:
        angle_in_grad (np.ndarray): array of angles in grad

    Returns:
        np.ndarray: array of angles in radians
    """
    return angle_in_grad / 200 * np.pi

function_f

function_f(
    p: ndarray,
    a: ndarray,
    h: ndarray,
    delta: ndarray,
    x: ndarray,
) -> ndarray

Function for which we want to find the root.

\(f(p) = p * (\cosh(\frac{val}{p}) - \cosh(\frac{x-val}{p}) - \delta\)

with \(val = \frac{a}{2} - p * \sinh^{-1}(\frac{h} {2 * p * sinh(\frac{a} {2 * p})})\)

Parameters:

Name Type Description Default

p

ndarray

parameter (variable to find)

required

a

ndarray

span length

required

h

ndarray

altitude difference between supports

required

delta

ndarray

altitude difference between point 1 and left support

required

x

ndarray

abscissa of chosen point 1

required

Returns:

Type Description
ndarray

np.ndarray: value of the function f at p

Source code in src/mechaphlowers/core/papoto/papoto_model.py
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
def function_f(
    p: np.ndarray,
    a: np.ndarray,
    h: np.ndarray,
    delta: np.ndarray,
    x: np.ndarray,
) -> np.ndarray:
    """Function for which we want to find the root.

    $f(p) = p * (\\cosh(\\frac{val}{p}) - \\cosh(\\frac{x-val}{p}) - \\delta$

    with $val = \\frac{a}{2} - p * \\sinh^{-1}(\\frac{h} {2 * p * sinh(\\frac{a} {2 * p})})$

    Args:
        p (np.ndarray): parameter (variable to find)
        a (np.ndarray): span length
        h (np.ndarray): altitude difference between supports
        delta (np.ndarray): altitude difference between point 1 and left support
        x (np.ndarray): abscissa of chosen point 1

    Returns:
        np.ndarray: value of the function f at p
    """
    # val: distance between lowest point with left support
    val = a / 2 - p * np.asinh(h / (2 * p * np.sinh(a / 2 / p)))
    f = p * (np.cosh(val / p) - np.cosh((x - val) / p)) - delta
    return f

function_f_prime

function_f_prime(
    p: ndarray,
    a: ndarray,
    h: ndarray,
    delta: ndarray,
    x: ndarray,
) -> ndarray

Approximation of the derivate of function_f with respect to p, computed using finite difference.

Parameters:

Name Type Description Default

p

ndarray

parameter (variable to find)

required

a

ndarray

span length

required

h

ndarray

altitude difference between supports

required

delta

ndarray

altitude difference between point 1 and left support

required

x

ndarray

abscissa of chosen point 1

required

Returns:

Type Description
ndarray

np.ndarray: approximation of \(f'(p)\)

Source code in src/mechaphlowers/core/papoto/papoto_model.py
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
def function_f_prime(
    p: np.ndarray,
    a: np.ndarray,
    h: np.ndarray,
    delta: np.ndarray,
    x: np.ndarray,
) -> np.ndarray:
    """Approximation of the derivate of function_f with respect to p, computed using finite difference.

    Args:
        p (np.ndarray): parameter (variable to find)
        a (np.ndarray): span length
        h (np.ndarray): altitude difference between supports
        delta (np.ndarray): altitude difference between point 1 and left support
        x (np.ndarray): abscissa of chosen point 1

    Returns:
        np.ndarray: approximation of $f'(p)$
    """
    _ZETA = options.solver.papoto_zeta
    return (
        function_f(p + _ZETA, a, h, delta, x) - function_f(p, a, h, delta, x)
    ) / _ZETA

papoto_2_points

papoto_2_points(
    a: ndarray,
    HL: ndarray,
    VL: ndarray,
    HR: ndarray,
    VR: ndarray,
    H1: ndarray,
    V1: ndarray,
    H2: ndarray,
    V2: ndarray,
) -> ndarray

Computes PAPOTO method with 2 points.

Parameters:

Name Type Description Default

a

ndarray

Length of the span

required

HL

ndarray

horizontal angle in rad of the left part of the span

required

VL

ndarray

vertical angle in rad of the left part of the span

required

HR

ndarray

horizontal angle in rad of the right part of the span

required

VR

ndarray

vertical angle in rad of the right part of the span

required

H1

ndarray

horizontal angle in rad of point 1

required

V1

ndarray

vertical angle in rad of point 1

required

H2

ndarray

horizontal angle in rad of point 2

required

V2

ndarray

vertical angle in rad of point 2

required

Returns: parameter (np.ndarray): parameter value

Source code in src/mechaphlowers/core/papoto/papoto_model.py
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
def papoto_2_points(
    a: np.ndarray,
    HL: np.ndarray,
    VL: np.ndarray,
    HR: np.ndarray,
    VR: np.ndarray,
    H1: np.ndarray,
    V1: np.ndarray,
    H2: np.ndarray,
    V2: np.ndarray,
) -> np.ndarray:
    """Computes PAPOTO method with 2 points.

    Args:
        a (np.ndarray): Length of the span
        HL (np.ndarray): horizontal angle in rad of the left part of the span
        VL (np.ndarray): vertical angle in rad of the left part of the span
        HR (np.ndarray): horizontal angle in rad of the right part of the span
        VR (np.ndarray): vertical angle in rad of the right part of the span
        H1 (np.ndarray): horizontal angle in rad of point 1
        V1 (np.ndarray): vertical angle in rad of point 1
        H2 (np.ndarray): horizontal angle in rad of point 2
        V2 (np.ndarray): vertical angle in rad of point 2
    Returns:
        parameter (np.ndarray): parameter value
    """
    Alpha = HR - HL
    Alpha1 = H1 - HL
    Alpha2 = H2 - HL
    VL = np.pi / 2 - VL  # null angle = horizon
    VR = np.pi / 2 - VR
    V1 = np.pi / 2 - V1
    V2 = np.pi / 2 - V2

    nb_loops = 100

    iteration = (np.pi - Alpha) / 2
    AlphaR = np.zeros_like(Alpha)

    for loop_index in range(1, nb_loops):
        AlphaR = (
            AlphaR + iteration
        )  # for first loop: alphaD = (np.pi - alpha) / 2
        AlphaL = (
            np.pi - Alpha - AlphaR
        )  # for first loop: alphaG = (np.pi - alpha) / 2

        # computing distances between station and supports G and D
        distL = a / np.sin(Alpha) * np.sin(AlphaR)
        distR = distL * np.cos(Alpha) + a * np.cos(AlphaR)

        # computing attachment altitudes + elevation difference
        zL = distL * np.tan(VL)
        zR = distR * np.tan(VR)
        h = zR - zL

        # computing distances between station and points 1 and 2 + a1, a2, z1, z2
        dist1 = distL * np.sin(AlphaL) / np.sin(np.pi - Alpha1 - AlphaL)
        dist2 = distL * np.sin(AlphaL) / np.sin(np.pi - Alpha2 - AlphaL)

        a1 = distL * np.cos(AlphaL) + dist1 * np.cos(np.pi - Alpha1 - AlphaL)
        a2 = distL * np.cos(AlphaL) + dist2 * np.cos(np.pi - Alpha2 - AlphaL)

        z1 = dist1 * np.tan(V1)
        z2 = dist2 * np.tan(V2)

        # first approximation of parameter using parabola model
        p0 = a1 * (a - a1) / (2 * ((zL - z1) + h * a1 / a))
        p = parameter_solver(a, h, zL - z1, a1, p0)

        # computing an elevation difference using newly found parameter, and comparing with zG - z2
        # val: distance between lowest point with left support
        val = a / 2 - p * np.asinh(h / (2 * p * np.sinh(a / (2 * p))))
        dif = p * (np.cosh(val / p) - np.cosh((a2 - val) / p))

        iteration = (
            np.sign(dif - (zL - z2))
            * (np.pi - Alpha)
            / (2 ** (1 + loop_index))
        )

        stop_variable = abs(dif - (zL - z2))
        stop_value = 0.001
        if (
            np.logical_or(stop_variable < stop_value, np.isnan(stop_variable))
        ).all():
            break

    return p

papoto_3_points

papoto_3_points(
    a: ndarray,
    HL: ndarray,
    VL: ndarray,
    HR: ndarray,
    VR: ndarray,
    H1: ndarray,
    V1: ndarray,
    H2: ndarray,
    V2: ndarray,
    H3: ndarray,
    V3: ndarray,
) -> ndarray

Computes PAPOTO 3 times, and return the mean between those 3 values.

Parameters:

Name Type Description Default

a

ndarray

Length of the span

required

HL

ndarray

horizontal distance of the left part of the span

required

VL

ndarray

vertical distance of the left part of the span

required

HR

ndarray

horizontal distance of the right part of the span

required

VR

ndarray

vertical distance of the right part of the span

required

H1

ndarray

horizontal distance of point 1

required

V1

ndarray

vertical distance of point 1

required

H2

ndarray

horizontal distance of point 2

required

V2

ndarray

vertical distance of point 2

required

H3

ndarray

horizontal distance of point 3

required

V3

ndarray

vertical distance of point 3

required

Returns: parameter_mean (np.ndarray): mean of the 3 computed parameters

Source code in src/mechaphlowers/core/papoto/papoto_model.py
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
def papoto_3_points(
    a: np.ndarray,
    HL: np.ndarray,
    VL: np.ndarray,
    HR: np.ndarray,
    VR: np.ndarray,
    H1: np.ndarray,
    V1: np.ndarray,
    H2: np.ndarray,
    V2: np.ndarray,
    H3: np.ndarray,
    V3: np.ndarray,
) -> np.ndarray:
    """Computes PAPOTO 3 times, and return the mean between those 3 values.

    Args:
        a (np.ndarray): Length of the span
        HL (np.ndarray): horizontal distance of the left part of the span
        VL (np.ndarray): vertical distance of the left part of the span
        HR (np.ndarray): horizontal distance of the right part of the span
        VR (np.ndarray): vertical distance of the right part of the span
        H1 (np.ndarray): horizontal distance of point 1
        V1 (np.ndarray): vertical distance of point 1
        H2 (np.ndarray): horizontal distance of point 2
        V2 (np.ndarray): vertical distance of point 2
        H3 (np.ndarray): horizontal distance of point 3
        V3 (np.ndarray): vertical distance of point 3
    Returns:
        parameter_mean (np.ndarray): mean of the 3 computed parameters
    """
    parameter_1_2 = papoto_2_points(a, HL, VL, HR, VR, H1, V1, H2, V2)
    parameter_2_3 = papoto_2_points(a, HL, VL, HR, VR, H2, V2, H3, V3)
    parameter_1_3 = papoto_2_points(a, HL, VL, HR, VR, H1, V1, H3, V3)
    parameter_mean = np.mean(
        np.array([parameter_1_2, parameter_2_3, parameter_1_3]), axis=0
    )
    return parameter_mean

papoto_validity

papoto_validity(
    parameter_1_2: ndarray,
    parameter_2_3: ndarray,
    parameter_1_3: ndarray,
) -> ndarray

papoto_validity

Function providing a validity criteria for the papoto method, based on the 3 computed values.

Parameters:

Name Type Description Default

parameter_1_2

float

first computed parameters

required

parameter_2_3

float

second computed parameters

required

parameter_1_3

float

third computed parameters

required

Returns:

Type Description
ndarray

np.float: validity criteria vector

Source code in src/mechaphlowers/core/papoto/papoto_model.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
def papoto_validity(
    parameter_1_2: np.ndarray,
    parameter_2_3: np.ndarray,
    parameter_1_3: np.ndarray,
) -> np.ndarray:
    """papoto_validity

    Function providing a validity criteria for the papoto method, based on the 3 computed values.

    Args:
        parameter_1_2 (np.float): first computed parameters
        parameter_2_3 (np.float): second computed parameters
        parameter_1_3 (np.float): third computed parameters

    Returns:
        np.float: validity criteria vector
    """

    validity = (
        np.diff(
            np.array(
                [
                    parameter_1_2,
                    parameter_2_3,
                    parameter_1_3,
                    parameter_1_2,
                ]
            ).T
        )
        / np.array([parameter_2_3, parameter_1_3, parameter_1_2]).T
    )

    return np.max(validity, axis=1)