예제 #1
0
def _compute_finite_vortex_deriv2(r1, r2, r2_deriv):
    r1_norm = add_ones_axis(compute_norm(r1))
    r2_norm = add_ones_axis(compute_norm(r2))
    r2_norm_deriv = compute_norm_deriv(r2, r2_deriv)

    r1_x_r2 = add_ones_axis(compute_cross(r1, r2))
    r1_d_r2 = add_ones_axis(compute_dot(r1, r2))
    r1_x_r2_deriv = compute_cross_deriv2(r1, r2_deriv)
    r1_d_r2_deriv = compute_dot_deriv(r1, r2_deriv)

    num = (1. / r1_norm + 1. / r2_norm) * r1_x_r2
    num_deriv = (-r2_norm_deriv / r2_norm ** 2) * r1_x_r2 \
        + (1. / r1_norm + 1. / r2_norm) * r1_x_r2_deriv

    den = r1_norm * r2_norm + r1_d_r2
    den_deriv = r1_norm * r2_norm_deriv + r1_d_r2_deriv

    result = np.divide(
        num_deriv * den - num * den_deriv,
        den ** 2 * 4 * np.pi,
        out=np.zeros_like(num),
        where=np.abs(den)>tol
        )

    return result
예제 #2
0
def _compute_semi_infinite_vortex(u, r):
    r_norm = compute_norm(r)
    u_x_r = compute_cross(u, r)
    u_d_r = compute_dot(u, r)

    num = u_x_r
    den = r_norm * (r_norm - u_d_r)
    return num / den / 4 / np.pi
예제 #3
0
def _compute_semi_infinite_vortex(u, r):
    r_norm = compute_norm(r)
    u_x_r = compute_cross(u, r)
    u_d_r = compute_dot(u, r)

    num = u_x_r
    den = r_norm * (r_norm - u_d_r)
    return num / den / 4 / np.pi
예제 #4
0
    def compute(self, inputs, outputs):
        P0 = inputs['nodes'][:-1, :]
        P1 = inputs['nodes'][1:, :]
        norm = compute_norm(P1 - P0)
        row0 = (P1 - P0) / norm

        cross = compute_cross(row0, self.ref_axis)
        norm = compute_norm(cross)
        row1 = cross / norm

        cross = compute_cross(row0, row1)
        row2 = cross

        outputs['transform'] = 0.
        for k in range(4):
            outputs['transform'][:, 3 * k + 0, 3 * k:3 * k + 3] = row0
            outputs['transform'][:, 3 * k + 1, 3 * k:3 * k + 3] = row1
            outputs['transform'][:, 3 * k + 2, 3 * k:3 * k + 3] = row2
예제 #5
0
    def compute(self, inputs, outputs):
        P0 = inputs['nodes'][:-1, :]
        P1 = inputs['nodes'][ 1:, :]
        norm = compute_norm(P1 - P0)
        row0 = (P1 - P0) / norm

        cross = compute_cross(row0, self.ref_axis)
        norm = compute_norm(cross)
        row1 = cross / norm

        cross = compute_cross(row0, row1)
        row2 = cross

        outputs['transform'] = 0.
        for k in range(4):
            outputs['transform'][:, 3*k + 0, 3*k : 3*k + 3] = row0
            outputs['transform'][:, 3*k + 1, 3*k : 3*k + 3] = row1
            outputs['transform'][:, 3*k + 2, 3*k : 3*k + 3] = row2
예제 #6
0
    def compute(self, inputs, outputs):
        rho = inputs['rho'][0]
        horseshoe_circulations = np.outer(inputs['horseshoe_circulations'], np.ones(3))
        velocities = inputs['force_pts_velocities']
        bound_vecs = inputs['bound_vecs']

        # Actually compute the forces by taking the cross of velocities acting
        # at the force points with the bound vortex filament vector.
        outputs['panel_forces'] = \
            rho * horseshoe_circulations * compute_cross(velocities, bound_vecs)
예제 #7
0
    def compute_partials(self, inputs, partials):
        rho = inputs['rho'][0]
        horseshoe_circulations = np.outer(inputs['horseshoe_circulations'], np.ones(3))
        velocities = inputs['force_pts_velocities']
        bound_vecs = inputs['bound_vecs']

        horseshoe_circulations_ones = np.einsum('i,jk->ijk', inputs['horseshoe_circulations'], np.ones((3, 3)))

        deriv_array = np.einsum('i,jk->ijk',
            np.ones(self.system_size),
            np.eye(3))

        partials['panel_forces', 'rho'] = \
            (horseshoe_circulations * compute_cross(velocities, bound_vecs)).flatten()
        partials['panel_forces', 'horseshoe_circulations'] = \
            (rho * compute_cross(velocities, bound_vecs)).flatten()
        partials['panel_forces', 'force_pts_velocities'] = \
            (rho * horseshoe_circulations_ones * compute_cross_deriv1(deriv_array, bound_vecs)).flatten()
        partials['panel_forces', 'bound_vecs'] = \
            (rho * horseshoe_circulations_ones * compute_cross_deriv2(velocities, deriv_array)).flatten()
예제 #8
0
    def compute(self, inputs, outputs):
        system_size = self.system_size

        rho = inputs['rho'][0]
        horseshoe_circulations = np.outer(inputs['horseshoe_circulations'], np.ones(3))
        velocities = inputs['force_pts_velocities']
        bound_vecs = inputs['bound_vecs']

        # Actually compute the forces by taking the cross of velocities acting
        # at the force points with the bound vortex filament vector.
        outputs['panel_forces'] = \
            rho * horseshoe_circulations * compute_cross(velocities, bound_vecs)
예제 #9
0
    def compute_partials(self, inputs, partials):
        system_size = self.system_size

        rho = inputs['rho'][0]
        horseshoe_circulations = np.outer(inputs['horseshoe_circulations'], np.ones(3))
        velocities = inputs['force_pts_velocities']
        bound_vecs = inputs['bound_vecs']

        horseshoe_circulations_ones = np.einsum('i,jk->ijk', inputs['horseshoe_circulations'], np.ones((3, 3)))

        deriv_array = np.einsum('i,jk->ijk',
            np.ones(self.system_size),
            np.eye(3))

        partials['panel_forces', 'rho'] = \
            (horseshoe_circulations * compute_cross(velocities, bound_vecs)).flatten()
        partials['panel_forces', 'horseshoe_circulations'] = \
            (rho * compute_cross(velocities, bound_vecs)).flatten()
        partials['panel_forces', 'force_pts_velocities'] = \
            (rho * horseshoe_circulations_ones * compute_cross_deriv1(deriv_array, bound_vecs)).flatten()
        partials['panel_forces', 'bound_vecs'] = \
            (rho * horseshoe_circulations_ones * compute_cross_deriv2(velocities, deriv_array)).flatten()
예제 #10
0
    def compute_partials(self, inputs, partials):
        surface = self.options['surface']

        ny = surface['mesh'].shape[1]

        P0 = inputs['nodes'][:-1, :]
        P1 = inputs['nodes'][ 1:, :]
        P_deriv = np.einsum('i,jk->ijk', np.ones(ny - 1), np.eye(3))
        norm = compute_norm(P1 - P0)
        norm_deriv = compute_norm_deriv(P1 - P0, P_deriv)
        row0 = (P1 - P0) / norm
        row0_deriv = P_deriv / add_ones_axis(norm) - add_ones_axis(P1 - P0) / add_ones_axis(norm) ** 2 * norm_deriv

        cross = compute_cross(row0, self.ref_axis)
        cross_deriv = compute_cross_deriv1(row0_deriv, self.ref_axis)
        norm = compute_norm(cross)
        norm_deriv = compute_norm_deriv(cross, cross_deriv)
        row1 = cross / norm
        row1_deriv = cross_deriv / add_ones_axis(norm) - add_ones_axis(cross) / add_ones_axis(norm) ** 2 * norm_deriv

        cross = compute_cross(row0, row1)
        cross_deriv = (
            compute_cross_deriv1(row0_deriv, row1) +
            compute_cross_deriv2(row0, row1_deriv)
        )
        row2 = cross
        row2_deriv = cross_deriv

        derivs = partials['transform', 'nodes'].reshape((2, ny - 1, 12, 12, 3))

        for k in range(4):
            derivs[0, :, 3*k + 0, 3*k : 3*k + 3, :] = -row0_deriv
            derivs[1, :, 3*k + 0, 3*k : 3*k + 3, :] =  row0_deriv

            derivs[0, :, 3*k + 1, 3*k : 3*k + 3, :] = -row1_deriv
            derivs[1, :, 3*k + 1, 3*k : 3*k + 3, :] =  row1_deriv

            derivs[0, :, 3*k + 2, 3*k : 3*k + 3, :] = -row2_deriv
            derivs[1, :, 3*k + 2, 3*k : 3*k + 3, :] =  row2_deriv
예제 #11
0
def _compute_finite_vortex(r1, r2):
    r1_norm = compute_norm(r1)
    r2_norm = compute_norm(r2)

    r1_x_r2 = compute_cross(r1, r2)
    r1_d_r2 = compute_dot(r1, r2)

    num = (1. / r1_norm + 1. / r2_norm) * r1_x_r2
    den = r1_norm * r2_norm + r1_d_r2

    result = num / den / 4 / np.pi
    result[np.abs(den) < tol] = 0.
    return result
예제 #12
0
def _compute_finite_vortex(r1, r2):
    r1_norm = compute_norm(r1)
    r2_norm = compute_norm(r2)

    r1_x_r2 = compute_cross(r1, r2)
    r1_d_r2 = compute_dot(r1, r2)

    num = (1. / r1_norm + 1. / r2_norm) * r1_x_r2
    den = r1_norm * r2_norm + r1_d_r2

    result = np.divide(num, den * 4 * np.pi, out=np.zeros_like(num), where=np.abs(den)>tol)

    return result
예제 #13
0
    def compute_partials(self, inputs, partials):
        surface = self.options['surface']

        ny = surface['mesh'].shape[1]

        P0 = inputs['nodes'][:-1, :]
        P1 = inputs['nodes'][1:, :]
        P_deriv = np.einsum('i,jk->ijk', np.ones(ny - 1), np.eye(3))
        norm = compute_norm(P1 - P0)
        norm_deriv = compute_norm_deriv(P1 - P0, P_deriv)
        row0 = (P1 - P0) / norm
        row0_deriv = P_deriv / add_ones_axis(norm) - add_ones_axis(
            P1 - P0) / add_ones_axis(norm)**2 * norm_deriv

        cross = compute_cross(row0, self.ref_axis)
        cross_deriv = compute_cross_deriv1(row0_deriv, self.ref_axis)
        norm = compute_norm(cross)
        norm_deriv = compute_norm_deriv(cross, cross_deriv)
        row1 = cross / norm
        row1_deriv = cross_deriv / add_ones_axis(norm) - add_ones_axis(
            cross) / add_ones_axis(norm)**2 * norm_deriv

        cross = compute_cross(row0, row1)
        cross_deriv = (compute_cross_deriv1(row0_deriv, row1) +
                       compute_cross_deriv2(row0, row1_deriv))
        row2 = cross
        row2_deriv = cross_deriv

        derivs = partials['transform', 'nodes'].reshape((2, ny - 1, 12, 12, 3))

        for k in range(4):
            derivs[0, :, 3 * k + 0, 3 * k:3 * k + 3, :] = -row0_deriv
            derivs[1, :, 3 * k + 0, 3 * k:3 * k + 3, :] = row0_deriv

            derivs[0, :, 3 * k + 1, 3 * k:3 * k + 3, :] = -row1_deriv
            derivs[1, :, 3 * k + 1, 3 * k:3 * k + 3, :] = row1_deriv

            derivs[0, :, 3 * k + 2, 3 * k:3 * k + 3, :] = -row2_deriv
            derivs[1, :, 3 * k + 2, 3 * k:3 * k + 3, :] = row2_deriv
예제 #14
0
def _compute_finite_vortex(r1, r2):
    r1_norm = compute_norm(r1)
    r2_norm = compute_norm(r2)

    r1_x_r2 = compute_cross(r1, r2)
    r1_d_r2 = compute_dot(r1, r2)

    num = (1. / r1_norm + 1. / r2_norm) * r1_x_r2
    den = r1_norm * r2_norm + r1_d_r2

    result = num / den / 4 / np.pi
    result[np.abs(den) < tol] = 0.
    return result
예제 #15
0
def _compute_semi_infinite_vortex_deriv(u, r, r_deriv):
    r_norm = add_ones_axis(compute_norm(r))
    r_norm_deriv = compute_norm_deriv(r, r_deriv)

    u_x_r = add_ones_axis(compute_cross(u, r))
    u_x_r_deriv = compute_cross_deriv2(u, r_deriv)

    u_d_r = add_ones_axis(compute_dot(u, r))
    u_d_r_deriv = compute_dot_deriv(u, r_deriv)

    num = u_x_r
    num_deriv = u_x_r_deriv

    den = r_norm * (r_norm - u_d_r)
    den_deriv = r_norm_deriv * (r_norm - u_d_r) + r_norm * (r_norm_deriv - u_d_r_deriv)

    return (num_deriv * den - num * den_deriv) / den ** 2 / 4 / np.pi
예제 #16
0
def _compute_semi_infinite_vortex_deriv(u, r, r_deriv):
    r_norm = add_ones_axis(compute_norm(r))
    r_norm_deriv = compute_norm_deriv(r, r_deriv)

    u_x_r = add_ones_axis(compute_cross(u, r))
    u_x_r_deriv = compute_cross_deriv2(u, r_deriv)

    u_d_r = add_ones_axis(compute_dot(u, r))
    u_d_r_deriv = compute_dot_deriv(u, r_deriv)

    num = u_x_r
    num_deriv = u_x_r_deriv

    den = r_norm * (r_norm - u_d_r)
    den_deriv = r_norm_deriv * (r_norm - u_d_r) + r_norm * (r_norm_deriv - u_d_r_deriv)

    return (num_deriv * den - num * den_deriv) / den ** 2 / 4 / np.pi
예제 #17
0
def _compute_finite_vortex_deriv2(r1, r2, r2_deriv):
    r1_norm = add_ones_axis(compute_norm(r1))
    r2_norm = add_ones_axis(compute_norm(r2))
    r2_norm_deriv = compute_norm_deriv(r2, r2_deriv)

    r1_x_r2 = add_ones_axis(compute_cross(r1, r2))
    r1_d_r2 = add_ones_axis(compute_dot(r1, r2))
    r1_x_r2_deriv = compute_cross_deriv2(r1, r2_deriv)
    r1_d_r2_deriv = compute_dot_deriv(r1, r2_deriv)

    num = (1. / r1_norm + 1. / r2_norm) * r1_x_r2
    num_deriv = (-r2_norm_deriv / r2_norm ** 2) * r1_x_r2 \
        + (1. / r1_norm + 1. / r2_norm) * r1_x_r2_deriv

    den = r1_norm * r2_norm + r1_d_r2
    den_deriv = r1_norm * r2_norm_deriv + r1_d_r2_deriv

    result = (num_deriv * den - num * den_deriv) / den**2 / 4 / np.pi
    result[np.abs(den) < tol] = 0.
    return result
예제 #18
0
def _compute_finite_vortex_deriv2(r1, r2, r2_deriv):
    r1_norm = add_ones_axis(compute_norm(r1))
    r2_norm = add_ones_axis(compute_norm(r2))
    r2_norm_deriv = compute_norm_deriv(r2, r2_deriv)

    r1_x_r2 = add_ones_axis(compute_cross(r1, r2))
    r1_d_r2 = add_ones_axis(compute_dot(r1, r2))
    r1_x_r2_deriv = compute_cross_deriv2(r1, r2_deriv)
    r1_d_r2_deriv = compute_dot_deriv(r1, r2_deriv)

    num = (1. / r1_norm + 1. / r2_norm) * r1_x_r2
    num_deriv = (-r2_norm_deriv / r2_norm ** 2) * r1_x_r2 \
        + (1. / r1_norm + 1. / r2_norm) * r1_x_r2_deriv

    den = r1_norm * r2_norm + r1_d_r2
    den_deriv = r1_norm * r2_norm_deriv + r1_d_r2_deriv

    result = (num_deriv * den - num * den_deriv) / den ** 2 / 4 / np.pi
    result[np.abs(den) < tol] = 0.
    return result