def clause_b_1_4_1_phi_f_i_column(h_eq, d_2, lambda_1, lambda_2, lambda_3, *_,
                                  **__):
    phi_f_1 = phi_perpendicular_any_br187(
        W_m=h_eq,
        H_m=lambda_1,
        w_m=0.5 * h_eq,
        h_m=0,
        S_m=lambda_3,
    )
    phi_f_2 = phi_perpendicular_any_br187(
        W_m=h_eq,
        H_m=lambda_2,
        w_m=0.5 * h_eq,
        h_m=0,
        S_m=lambda_3,
    )
    phi_f_3 = phi_parallel_any_br187(W_m=lambda_1 + lambda_2 + d_2,
                                     H_m=h_eq,
                                     w_m=lambda_1 + 0.5 * d_2,
                                     h_m=0.5 * h_eq,
                                     S_m=lambda_3)
    phi_f_4 = 0

    _latex = [
        f'\\phi_{{f,1}}={phi_f_1:.5f}\\ \\left[-\\right]',
        f'\\phi_{{f,2}}={phi_f_2:.5f}\\ \\left[-\\right]',
        f'\\phi_{{f,3}}={phi_f_3:.5f}\\ \\left[-\\right]',
        f'\\phi_{{f,4}}={phi_f_4:.5f}\\ \\left[-\\right]',
    ]

    return dict(phi_f_1=phi_f_1,
                phi_f_2=phi_f_2,
                phi_f_3=phi_f_3,
                phi_f_4=phi_f_4,
                _latex=_latex)
def clause_b_1_4_1_phi_f_i_beam(h_eq, w_t, d_aw, lambda_3, lambda_4, *_, **__):
    phi_f_1 = phi_perpendicular_any_br187(
        W_m=w_t,
        H_m=h_eq,
        w_m=-0.5 * w_t,
        h_m=d_aw,
        S_m=lambda_3,
    )
    phi_f_2 = 0
    phi_f_3 = 0
    phi_f_4 = phi_parallel_any_br187(
        W_m=w_t,
        H_m=h_eq,
        w_m=0.5 * w_t,
        h_m=h_eq + d_aw,
        S_m=lambda_4,
    )

    _latex = [
        f'\\phi_{{f,1}}={phi_f_1:.5f}\\ \\left[-\\right]',
        f'\\phi_{{f,2}}={phi_f_2:.5f}\\ \\left[-\\right]',
        f'\\phi_{{f,3}}={phi_f_3:.5f}\\ \\left[-\\right]',
        f'\\phi_{{f,4}}={phi_f_4:.5f}\\ \\left[-\\right]',
    ]

    return dict(phi_f_1=phi_f_1,
                phi_f_2=phi_f_2,
                phi_f_3=phi_f_3,
                phi_f_4=phi_f_4,
                _latex=_latex)
Example #3
0
def _test_solve_phi():
    def helper_get_phi_at_specific_point(xx, yy, vv, x, y):
        v = vv[(np.isclose(xx, x)) & np.isclose(yy, y)]
        print('measured location and value', x, y, v, '.')
        return v

    xx, yy = np.meshgrid(np.arange(-20, 20, .1), np.arange(-20, 20, .1))

    width = 7
    height = 5
    separation = 5

    x_emitter_centre = 0
    y_emitter_centre = 0
    z_emitter_centre = 0

    phi = solver_phi_2d(
        emitter_xy1=[-width / 2 + x_emitter_centre, y_emitter_centre],
        emitter_xy2=[width / 2 + x_emitter_centre, y_emitter_centre],
        emitter_z=[
            -height / 2 + z_emitter_centre, height / 2 + z_emitter_centre
        ],
        xx=xx,
        yy=yy,
        z=height / 2)

    # measure at 5 m from the emitter front
    solved = helper_get_phi_at_specific_point(xx, yy, phi, x_emitter_centre,
                                              separation + y_emitter_centre)
    answer = phi_perpendicular_any_br187(width, height,
                                         0.5 * width + x_emitter_centre,
                                         0.5 * height + y_emitter_centre,
                                         separation)
    print('assertion values', solved, answer)
    assert np.isclose(solved, answer, atol=1e-6)

    # measure at 5 m from the emitter front, offset 5 m x-axis (i.e. edge centre)
    solved = helper_get_phi_at_specific_point(xx, yy, phi,
                                              x_emitter_centre - 5,
                                              separation + y_emitter_centre)
    answer = phi_perpendicular_any_br187(width, height,
                                         0.5 * width + x_emitter_centre - 5,
                                         0.5 * height + y_emitter_centre,
                                         separation)
    print('assertion values', solved, answer)
    assert np.isclose(solved, answer, atol=1e-6)

    # measure at 5 m from the emitter back
    solved = helper_get_phi_at_specific_point(xx, yy, phi, x_emitter_centre,
                                              separation + y_emitter_centre)
    answer = phi_perpendicular_any_br187(width, height,
                                         0.5 * width + x_emitter_centre,
                                         0.5 * height + y_emitter_centre,
                                         separation)
    print('assertion values', solved, answer)
    assert np.isclose(solved, answer, atol=1e-6)

    # measure at 5 m from the emitter front, offset 5 m x-axis and 2.5 m z-zxis (i.e. corner)
    phi = solver_phi_2d(
        emitter_xy1=[-width / 2 + x_emitter_centre, y_emitter_centre],
        emitter_xy2=[width / 2 + x_emitter_centre, y_emitter_centre],
        emitter_z=[
            -height / 2 + z_emitter_centre, height / 2 + z_emitter_centre
        ],
        xx=xx,
        yy=yy,
        z=height / 2 - 2.5)
    solved = helper_get_phi_at_specific_point(xx, yy, phi,
                                              x_emitter_centre - 5,
                                              separation + y_emitter_centre)
    answer = phi_perpendicular_any_br187(width, height,
                                         0.5 * width + x_emitter_centre - 5,
                                         0.5 * height + y_emitter_centre - 2.5,
                                         separation)
    print('assertion values', solved, answer)
    assert np.isclose(solved, answer, atol=1e-6)

    # measure at 5 m from the emitter front, offset 7.5 m x-axis and 5 m z-zxis (i.e. outside of the rectangle by 2.5 and 2.5 m)
    phi = solver_phi_2d(
        emitter_xy1=[-width / 2 + x_emitter_centre, y_emitter_centre],
        emitter_xy2=[width / 2 + x_emitter_centre, y_emitter_centre],
        emitter_z=[
            -height / 2 + z_emitter_centre, height / 2 + z_emitter_centre
        ],
        xx=xx,
        yy=yy,
        z=height / 2 - 5)
    solved = helper_get_phi_at_specific_point(xx, yy, phi,
                                              x_emitter_centre - 7.5,
                                              separation + y_emitter_centre)
    answer = phi_perpendicular_any_br187(width, height,
                                         0.5 * width + x_emitter_centre - 7.5,
                                         0.5 * height + y_emitter_centre - 5.,
                                         separation)
    print('assertion values', solved, answer)
    assert np.isclose(solved, answer, atol=1e-6)
Example #4
0
    def phi_solver(W: float, H: float, w: float, h: float, Q: float, Q_a: float, S=None, UA=None):
        """A wrapper to `phi_perpendicular_any_br187` with error handling and customised IO"""

        # default values

        phi_solved, q_solved, S_solved, UA_solved = [None] * 4
        msg = 'Calculation complete.'
        # phi_solved, solved configuration factor
        # q_solved, solved receiver heat flux
        # S_solved, solved separation distance, surface to surface
        # UA_solved, solved permissible unprotected area
        # msg, a message to indicate calculation status if successful.

        w, h = -w, -h
        # ui convention is that w is the horizontal separation between the receiver and emitter
        # but the calculation function treats w as the x value and emitter has a positive x

        # calculate

        if S:  # to calculate maximum unprotected area
            try:
                phi_solved = phi_perpendicular_any_br187(W_m=W, H_m=H, w_m=w, h_m=h, S_m=S)
            except Exception as e:
                raise ValueError(f'Calculation incomplete. {e}')

            if Q:
                # if Q is provided, proceed to calculate q and UA
                q_solved = Q * phi_solved
                if q_solved == 0:
                    UA_solved = 1
                else:
                    UA_solved = max([min([Q_a / q_solved, 1]), 0])

            q_solved *= UA_solved

        # to calculate minimum separation distance to boundary
        elif UA:

            phi_target = Q_a / (Q * UA)

            try:
                S_solved = linear_solver(
                    func=phi_perpendicular_any_br187,
                    dict_params=dict(W_m=W, H_m=H, w_m=w, h_m=h, S_m=0),
                    x_name='S_m',
                    y_target=phi_target - 0.0005,
                    x_upper=1000,
                    x_lower=0.01,
                    y_tol=0.001,
                    iter_max=500,
                    func_multiplier=-1
                )
            except ValueError as e:
                raise ValueError(f'Calculation failed. {e}')
            if S_solved is None:
                raise ValueError('Calculation failed. Maximum iteration reached.')

            phi_solved = phi_perpendicular_any_br187(W_m=W, H_m=H, w_m=w, h_m=h, S_m=S_solved)
            q_solved = Q * phi_solved * UA

            if S_solved < 2:
                msg = f'Calculation complete. Forced boundary separation to 1 from {S_solved:.3f} m.'
                S_solved = 2

        return phi_solved, q_solved, S_solved, UA_solved, msg
Example #5
0
def solver_phi_2d(
    emitter_xy1: typing.Union[list, tuple, np.ndarray],
    emitter_xy2: typing.Union[list, tuple, np.ndarray],
    emitter_z: typing.Union[list, tuple, np.ndarray],
    xx: typing.Union[list, tuple, np.ndarray],
    yy: typing.Union[list, tuple, np.ndarray],
    z: float,
) -> np.ndarray:
    """

    :param emitter:
    :param xx:
    :param yy:
    :param z:
    :return:
    """

    # calculate the angle between a flat line (1, 0) and the emitter plane on z-plane
    v1 = np.subtract(emitter_xy2, emitter_xy1)
    v2 = (1, 0)
    theta_in_radians = angle_between_two_vectors_2d(v1=v1, v2=v2)

    # solver domain
    xx, yy = rotation_meshgrid(xx, yy, theta_in_radians)

    # calculate the emitter surface level, i.e. everything below this level is behind the emitter.
    x1, y1 = emitter_xy1
    x2, y2 = emitter_xy2
    emitter_x, emitter_y = rotation_meshgrid(np.array((x1, x2)),
                                             np.array((y1, y2)),
                                             theta_in_radians)
    try:
        assert abs(emitter_y[0, 0] - emitter_y[0, 1]) <= 1e-10
    except AssertionError:
        print(emitter_y[0, 0], emitter_y[0, 1], 'do not match.')
        raise AssertionError
    surface_level_y = emitter_y[0, 0]

    emitter_x_centre = np.average(emitter_x)

    # check meshgrid rotation
    # plt.contourf(xx, yy, np.ones_like(xx))
    # plt.show()

    vv = np.zeros_like(xx)
    emitter_height = abs(emitter_z[0] - emitter_z[1])
    emitter_width = sum(np.square(np.subtract(emitter_xy1, emitter_xy2)))**0.5
    for i in range(xx.shape[0]):
        for j in range(xx.shape[1]):
            y = yy[i, j]
            if y > surface_level_y:
                vv[i, j] = phi_perpendicular_any_br187(
                    W_m=emitter_width,
                    H_m=emitter_height,
                    w_m=0.5 * emitter_width + abs(emitter_x_centre - xx[i, j]),
                    h_m=z,
                    S_m=y - surface_level_y)

    # check phi
    # plt.contourf(xx, yy, vv)
    # plt.show()
    # print(theta_in_radians)

    return vv