Ejemplo n.º 1
0
    def generate_multibody_file():
        global end_of_fuselage_node
        global LC
        # LCR = gc.LagrangeConstraint()
        # LCR.behaviour = 'lin_vel_node_wrtG'
        # LCR.velocity = np.zeros((3,))
        # LCR.body_number = 0
        # LCR.node_number = flat_end_node[0]

        # LCL = gc.LagrangeConstraint()
        # LCL.behaviour = 'lin_vel_node_wrtG'
        # LCL.velocity = np.zeros((3,))
        # LCL.body_number = 0
        # LCL.node_number = flat_end_node[1]

        LCF = gc.LagrangeConstraint()
        LCF.behaviour = 'lin_vel_node_wrtG'
        LCF.velocity = np.zeros((3, ))
        LCF.body_number = 0
        LCF.node_number = end_of_fuselage_node

        LCCR = gc.LagrangeConstraint()
        LCCR.behaviour = 'lin_vel_node_wrtG'
        LCCR.velocity = np.zeros((3, ))
        LCCR.body_number = 0
        LCCR.node_number = first_node_centre[0]

        LCCL = gc.LagrangeConstraint()
        LCCL.behaviour = 'lin_vel_node_wrtG'
        LCCL.velocity = np.zeros((3, ))
        LCCL.body_number = 0
        LCCL.node_number = first_node_centre[1]

        # LC = [LCR, LCL, LCF, LCCR, LCCL]
        LC = [LCF, LCCR, LCCL]

        MB1 = gc.BodyInformation()
        MB1.body_number = 0
        MB1.FoR_position = np.zeros((6, ))
        MB1.FoR_velocity = np.zeros((6, ))
        MB1.FoR_acceleration = np.zeros((6, ))
        MB1.FoR_movement = 'free'
        MB1.quat = np.array([1.0, 0.0, 0.0, 0.0])

        MB = [MB1]
        gc.generate_multibody_file(LC, MB, route, case_name)
def generate_multibody_file():
    LC2 = gc.LagrangeConstraint()
    LC2.behaviour = 'hinge_FoR'
    LC2.rot_axis_AFoR = np.array([1.0, 0.0, 0.0])
    LC2.body_FoR = 0
    # LC2.node_number = int(0)

    LC = []
    LC.append(LC2)

    MB1 = gc.BodyInformation()
    MB1.body_number = 0
    MB1.FoR_position = np.zeros((6, ))
    MB1.FoR_velocity = np.zeros((6, ))
    MB1.FoR_acceleration = np.zeros((6, ))
    MB1.FoR_movement = 'free'
    MB1.quat = np.array([1.0, 0.0, 0.0, 0.0])

    MB = []
    MB.append(MB1)
    gc.clean_test_files(route, case_name)
    gc.generate_multibody_file(LC, MB, route, case_name)
Ejemplo n.º 3
0
def generate_from_excel_type02(
        chord_panels,
        rotation_velocity,
        pitch_deg,
        excel_file_name='database_excel_type02.xlsx',
        excel_sheet_parameters='parameters',
        excel_sheet_structural_blade='structural_blade',
        excel_sheet_discretization_blade='discretization_blade',
        excel_sheet_aero_blade='aero_blade',
        excel_sheet_airfoil_info='airfoil_info',
        excel_sheet_airfoil_coord='airfoil_coord',
        excel_sheet_structural_tower='structural_tower',
        m_distribution='uniform',
        h5_cross_sec_prop=None,
        n_points_camber=100,
        tol_remove_points=1e-3,
        user_defined_m_distribution_type=None,
        wsp=0.,
        dt=0.):
    """
    generate_from_excel_type02

    Function needed to generate a wind turbine from an excel database according to OpenFAST inputs

    Args:
        chord_panels (int): Number of panels on the blade surface in the chord direction
        rotation_velocity (float): Rotation velocity of the rotor
        pitch_deg (float): pitch angle in degrees
        excel_file_name (str):
        excel_sheet_structural_blade (str):
        excel_sheet_aero_blade (str):
        excel_sheet_airfoil_coord (str):
        excel_sheet_parameters (str):
        excel_sheet_structural_tower (str):
        m_distribution (str):
        n_points_camber (int): number of points to define the camber of the airfoil,
        tol_remove_points (float): maximum distance to remove adjacent points
        user_defined_m_distribution_type (string): type of distribution of the chordwise panels when 'm_distribution' == 'user_defined'
        camber_effects_on_twist (bool): When true plain airfoils are used and the blade is twisted and preloaded based on thin airfoil theory
        wsp (float): wind speed (It may be needed for discretisation purposes)
        dt (float): time step (It may be needed for discretisation purposes)

    Returns:
        wt (sharpy.utils.generate_cases.AeroelasticInfromation): Aeroelastic infrmation of the wind turbine
        LC (list): list of all the Lagrange constraints needed in the cases (sharpy.utils.generate_cases.LagrangeConstraint)
        MB (list): list of the multibody information of each body (sharpy.utils.generate_cases.BodyInfrmation)
    """

    rotor = rotor_from_excel_type02(
        chord_panels,
        rotation_velocity,
        pitch_deg,
        excel_file_name=excel_file_name,
        excel_sheet_parameters=excel_sheet_parameters,
        excel_sheet_structural_blade=excel_sheet_structural_blade,
        excel_sheet_discretization_blade=excel_sheet_discretization_blade,
        excel_sheet_aero_blade=excel_sheet_aero_blade,
        excel_sheet_airfoil_info=excel_sheet_airfoil_info,
        excel_sheet_airfoil_coord=excel_sheet_airfoil_coord,
        m_distribution=m_distribution,
        h5_cross_sec_prop=h5_cross_sec_prop,
        n_points_camber=n_points_camber,
        tol_remove_points=tol_remove_points,
        user_defined_m_distribution_type=user_defined_m_distribution_type,
        wsp=0.,
        dt=0.)

    ######################################################################
    ## TOWER
    ######################################################################

    # Read from excel file
    HtFract = gc.read_column_sheet_type01(excel_file_name,
                                          excel_sheet_structural_tower,
                                          'HtFract')
    TMassDen = gc.read_column_sheet_type01(excel_file_name,
                                           excel_sheet_structural_tower,
                                           'TMassDen')
    TwFAStif = gc.read_column_sheet_type01(excel_file_name,
                                           excel_sheet_structural_tower,
                                           'TwFAStif')
    TwSSStif = gc.read_column_sheet_type01(excel_file_name,
                                           excel_sheet_structural_tower,
                                           'TwSSStif')
    # TODO> variables to be defined
    TwGJStif = gc.read_column_sheet_type01(excel_file_name,
                                           excel_sheet_structural_tower,
                                           'TwGJStif')
    TwEAStif = gc.read_column_sheet_type01(excel_file_name,
                                           excel_sheet_structural_tower,
                                           'TwEAStif')
    TwFAIner = gc.read_column_sheet_type01(excel_file_name,
                                           excel_sheet_structural_tower,
                                           'TwFAIner')
    TwSSIner = gc.read_column_sheet_type01(excel_file_name,
                                           excel_sheet_structural_tower,
                                           'TwSSIner')
    TwFAcgOf = gc.read_column_sheet_type01(excel_file_name,
                                           excel_sheet_structural_tower,
                                           'TwFAcgOf')
    TwSScgOf = gc.read_column_sheet_type01(excel_file_name,
                                           excel_sheet_structural_tower,
                                           'TwSScgOf')

    # Define the TOWER
    TowerHt = gc.read_column_sheet_type01(excel_file_name,
                                          excel_sheet_parameters, 'TowerHt')
    Elevation = TowerHt * HtFract

    tower = gc.AeroelasticInformation()
    tower.StructuralInformation.num_elem = len(Elevation) - 2
    tower.StructuralInformation.num_node_elem = 3
    tower.StructuralInformation.compute_basic_num_node()

    # Interpolate excel variables into the correct locations
    node_r, elem_r = create_node_radial_pos_from_elem_centres(
        Elevation, tower.StructuralInformation.num_node,
        tower.StructuralInformation.num_elem,
        tower.StructuralInformation.num_node_elem)

    # Stiffness
    elem_EA = np.interp(elem_r, Elevation, TwEAStif)
    elem_EIz = np.interp(elem_r, Elevation, TwSSStif)
    elem_EIy = np.interp(elem_r, Elevation, TwFAStif)
    elem_GJ = np.interp(elem_r, Elevation, TwGJStif)
    # Stiffness: estimate unknown properties
    cout.cout_wrap.print_file = False
    cout.cout_wrap('WARNING: The poisson cofficient is assumed equal to 0.3',
                   3)
    cout.cout_wrap('WARNING: Cross-section area is used as shear area', 3)
    poisson_coef = 0.3
    elem_GAy = elem_EA / 2.0 / (1.0 + poisson_coef)
    elem_GAz = elem_EA / 2.0 / (1.0 + poisson_coef)

    # Inertia
    elem_mass_per_unit_length = np.interp(elem_r, Elevation, TMassDen)
    elem_mass_iner_y = np.interp(elem_r, Elevation, TwFAIner)
    elem_mass_iner_z = np.interp(elem_r, Elevation, TwSSIner)
    # TODO: check yz axis and Flap-edge
    elem_pos_cg_B = np.zeros((tower.StructuralInformation.num_elem, 3), )
    elem_pos_cg_B[:, 1] = np.interp(elem_r, Elevation, TwSScgOf)
    elem_pos_cg_B[:, 2] = np.interp(elem_r, Elevation, TwFAcgOf)

    # Stiffness: estimate unknown properties
    cout.cout_wrap(
        'WARNING: Using perpendicular axis theorem to compute the inertia around xB',
        3)
    elem_mass_iner_x = elem_mass_iner_y + elem_mass_iner_z

    # Create the tower
    tower.StructuralInformation.create_mass_db_from_vector(
        elem_mass_per_unit_length, elem_mass_iner_x, elem_mass_iner_y,
        elem_mass_iner_z, elem_pos_cg_B)
    tower.StructuralInformation.create_stiff_db_from_vector(
        elem_EA, elem_GAy, elem_GAz, elem_GJ, elem_EIy, elem_EIz)

    coordinates = np.zeros((tower.StructuralInformation.num_node, 3), )
    coordinates[:, 0] = node_r

    tower.StructuralInformation.generate_1to1_from_vectors(
        num_node_elem=tower.StructuralInformation.num_node_elem,
        num_node=tower.StructuralInformation.num_node,
        num_elem=tower.StructuralInformation.num_elem,
        coordinates=coordinates,
        stiffness_db=tower.StructuralInformation.stiffness_db,
        mass_db=tower.StructuralInformation.mass_db,
        frame_of_reference_delta='y_AFoR',
        vec_node_structural_twist=np.zeros(
            (tower.StructuralInformation.num_node, ), ),
        num_lumped_mass=1)

    tower.StructuralInformation.boundary_conditions = np.zeros(
        (tower.StructuralInformation.num_node), dtype=int)
    tower.StructuralInformation.boundary_conditions[0] = 1

    # Read overhang and nacelle properties from excel file
    overhang_len = gc.read_column_sheet_type01(excel_file_name,
                                               excel_sheet_parameters,
                                               'overhang')
    # HubMass = gc.read_column_sheet_type01(excel_file_name, excel_sheet_nacelle, 'HubMass')
    NacelleMass = gc.read_column_sheet_type01(excel_file_name,
                                              excel_sheet_parameters,
                                              'NacMass')
    # NacelleYawIner = gc.read_column_sheet_type01(excel_file_name, excel_sheet_nacelle, 'NacelleYawIner')

    # Include nacelle mass
    tower.StructuralInformation.lumped_mass_nodes = np.array(
        [tower.StructuralInformation.num_node - 1], dtype=int)
    tower.StructuralInformation.lumped_mass = np.array([NacelleMass],
                                                       dtype=float)

    tower.AerodynamicInformation.set_to_zero(
        tower.StructuralInformation.num_node_elem,
        tower.StructuralInformation.num_node,
        tower.StructuralInformation.num_elem)

    # Assembly overhang with the tower
    # numberOfBlades = gc.read_column_sheet_type01(excel_file_name, excel_sheet_parameters, 'NumBl')
    tilt = gc.read_column_sheet_type01(excel_file_name, excel_sheet_parameters,
                                       'ShftTilt') * deg2rad
    # cone = gc.read_column_sheet_type01(excel_file_name, excel_sheet_parameters, 'Cone')*deg2rad

    overhang = gc.AeroelasticInformation()
    overhang.StructuralInformation.num_node = 3
    overhang.StructuralInformation.num_node_elem = 3
    overhang.StructuralInformation.compute_basic_num_elem()
    node_pos = np.zeros((overhang.StructuralInformation.num_node, 3), )
    node_pos[:, 0] += tower.StructuralInformation.coordinates[-1, 0]
    node_pos[:, 0] += np.linspace(0., overhang_len * np.sin(tilt * deg2rad),
                                  overhang.StructuralInformation.num_node)
    node_pos[:, 2] = np.linspace(0., -overhang_len * np.cos(tilt * deg2rad),
                                 overhang.StructuralInformation.num_node)
    # TODO: change the following by real values
    # Same properties as the last element of the tower
    cout.cout_wrap(
        "WARNING: Using the structural properties of the last tower section for the overhang",
        3)
    oh_mass_per_unit_length = tower.StructuralInformation.mass_db[-1, 0, 0]
    oh_mass_iner = tower.StructuralInformation.mass_db[-1, 3, 3]
    oh_EA = tower.StructuralInformation.stiffness_db[-1, 0, 0]
    oh_GA = tower.StructuralInformation.stiffness_db[-1, 1, 1]
    oh_GJ = tower.StructuralInformation.stiffness_db[-1, 3, 3]
    oh_EI = tower.StructuralInformation.stiffness_db[-1, 4, 4]
    overhang.StructuralInformation.generate_uniform_sym_beam(
        node_pos,
        oh_mass_per_unit_length,
        oh_mass_iner,
        oh_EA,
        oh_GA,
        oh_GJ,
        oh_EI,
        num_node_elem=3,
        y_BFoR='y_AFoR',
        num_lumped_mass=0)

    overhang.StructuralInformation.boundary_conditions = np.zeros(
        (overhang.StructuralInformation.num_node), dtype=int)
    overhang.StructuralInformation.boundary_conditions[-1] = -1

    overhang.AerodynamicInformation.set_to_zero(
        overhang.StructuralInformation.num_node_elem,
        overhang.StructuralInformation.num_node,
        overhang.StructuralInformation.num_elem)

    tower.assembly(overhang)
    tower.remove_duplicated_points(tol_remove_points)

    ######################################################################
    ##  WIND TURBINE
    ######################################################################
    # Assembly the whole case
    wt = tower.copy()
    hub_position = tower.StructuralInformation.coordinates[-1, :]
    rotor.StructuralInformation.coordinates += hub_position
    wt.assembly(rotor)

    # Redefine the body numbers
    wt.StructuralInformation.body_number *= 0
    wt.StructuralInformation.body_number[tower.StructuralInformation.
                                         num_elem:wt.StructuralInformation.
                                         num_elem] += 1

    ######################################################################
    ## MULTIBODY
    ######################################################################
    # Define the boundary condition between the rotor and the tower tip
    LC1 = gc.LagrangeConstraint()
    LC1.behaviour = 'hinge_node_FoR_constant_vel'
    LC1.node_in_body = tower.StructuralInformation.num_node - 1
    LC1.body = 0
    LC1.body_FoR = 1
    LC1.rot_axisB = np.array([1., 0., 0.0])
    LC1.rot_vel = -rotation_velocity

    LC = []
    LC.append(LC1)

    # Define the multibody infromation for the tower and the rotor
    MB1 = gc.BodyInformation()
    MB1.body_number = 0
    MB1.FoR_position = np.zeros((6, ), )
    MB1.FoR_velocity = np.zeros((6, ), )
    MB1.FoR_acceleration = np.zeros((6, ), )
    MB1.FoR_movement = 'prescribed'
    MB1.quat = np.array([1.0, 0.0, 0.0, 0.0])

    MB2 = gc.BodyInformation()
    MB2.body_number = 1
    MB2.FoR_position = np.array([
        rotor.StructuralInformation.coordinates[0, 0],
        rotor.StructuralInformation.coordinates[0, 1],
        rotor.StructuralInformation.coordinates[0, 2], 0.0, 0.0, 0.0
    ])
    MB2.FoR_velocity = np.array([0., 0., 0., 0., 0., rotation_velocity])
    MB2.FoR_acceleration = np.zeros((6, ), )
    MB2.FoR_movement = 'free'
    MB2.quat = algebra.euler2quat(np.array([0.0, tilt, 0.0]))

    MB = []
    MB.append(MB1)
    MB.append(MB2)

    ######################################################################
    ## RETURN
    ######################################################################
    return wt, LC, MB
    #                          'rollup_tolerance': 1e-4,
    #                          'velocity_field_generator': 'SteadyVelocityField',
    #                          'velocity_field_input': {'u_inf': u_inf,
    #                                                   'u_inf_direction': [1., 0, 0]},
    #                          '0rho': rho},
    'max_iter': 200,
    'n_load_steps': 1,
    'tolerance': 1e-12,
    'relaxation_factor': 0.2
}

SimInfo.with_forced_vel = False
SimInfo.with_dynamic_forces = False

# Create the BC file
LC1 = gc.LagrangeConstraint()
LC1.behaviour = 'hinge_FoR'
LC1.body_FoR = 0
LC1.rot_axis_AFoR = np.array([0.0, 1.0, 0.0])
LC = []
LC.append(LC1)

MB1 = gc.BodyInformation()
MB1.body_number = 0
MB1.FoR_position = np.zeros((6, ), )
MB1.FoR_velocity = np.zeros((6, ), )
MB1.FoR_acceleration = np.zeros((6, ), )
MB1.FoR_movement = 'free'
# MB1.quat = algebra.euler2quat_ag(euler)
MB1.quat = np.array([1.0, 0.0, 0.0, 0.0])
MB = []
Ejemplo n.º 5
0
    def setUp(self):

        nodes_per_elem = 3

        # beam1: uniform and symmetric with aerodynamic properties equal to zero
        nnodes1 = 11
        length1  = 10.
        mass_per_unit_length = 0.1
        mass_iner = 1e-4
        EA = 1e9
        GA = 1e9
        GJ = 1e3
        EI = 1e4

        # Create beam1
        beam1 = gc.AeroelasticInformation()
        # Structural information
        beam1.StructuralInformation.num_node = nnodes1
        beam1.StructuralInformation.num_node_elem = nodes_per_elem
        beam1.StructuralInformation.compute_basic_num_elem()
        beam1.StructuralInformation.set_to_zero(beam1.StructuralInformation.num_node_elem, beam1.StructuralInformation.num_node, beam1.StructuralInformation.num_elem)
        node_pos = np.zeros((nnodes1, 3), )
        node_pos[:, 0] = np.linspace(0.0, length1, nnodes1)
        beam1.StructuralInformation.generate_uniform_sym_beam(node_pos, mass_per_unit_length, mass_iner, EA, GA, GJ, EI, num_node_elem = 3, y_BFoR = 'y_AFoR', num_lumped_mass=2)
        beam1.StructuralInformation.boundary_conditions[0] = 1
        beam1.StructuralInformation.boundary_conditions[-1] = -1
        beam1.StructuralInformation.lumped_mass_nodes = np.array([0, nnodes1-1], dtype=int)
        beam1.StructuralInformation.lumped_mass = np.array([2., 1.])
        beam1.StructuralInformation.lumped_mass_inertia = np.zeros((2, 3, 3),)
        beam1.StructuralInformation.lumped_mass_position = np.zeros((2, 3),)

        # Aerodynamic information
        airfoil = np.zeros((1, 20, 2),)
        airfoil[0, :, 0] = np.linspace(0., 1., 20)
        beam1.AerodynamicInformation.create_one_uniform_aerodynamics(
            beam1.StructuralInformation,
            chord=1.,
            twist=0.,
            sweep=0.,
            num_chord_panels=4,
            m_distribution='uniform',
            elastic_axis=0.5,
            num_points_camber=20,
            airfoil=airfoil)

        # SOLVER CONFIGURATION
        SimInfo = gc.SimulationInformation()
        SimInfo.set_default_values()

        SimInfo.define_uinf(np.array([0.0,1.0,0.0]), 10.)

        SimInfo.solvers['SHARPy']['flow'] = ['BeamLoader',
                                             'AerogridLoader',
                                             'StaticCoupled',
                                             'DynamicCoupled']
        self.name = 'fix_node_velocity_wrtG'
        SimInfo.solvers['SHARPy']['case'] = self.name
        SimInfo.solvers['SHARPy']['write_screen'] = 'off'
        SimInfo.solvers['SHARPy']['route'] = folder + '/'
        SimInfo.set_variable_all_dicts('dt', 0.1)
        SimInfo.set_variable_all_dicts('rho', 0.0)
        SimInfo.set_variable_all_dicts('velocity_field_input', SimInfo.solvers['SteadyVelocityField'])
        SimInfo.set_variable_all_dicts('folder', folder + '/output/')

        SimInfo.solvers['BeamLoader']['unsteady'] = 'on'

        SimInfo.solvers['AerogridLoader']['unsteady'] = 'on'
        SimInfo.solvers['AerogridLoader']['mstar'] = 2
        SimInfo.solvers['AerogridLoader']['wake_shape_generator'] = 'StraightWake'
        SimInfo.solvers['AerogridLoader']['wake_shape_generator_input'] = {'u_inf':10.,
                                                                           'u_inf_direction': np.array([0., 1., 0.]),
                                                                           'dt': 0.1}


        SimInfo.solvers['NonLinearStatic']['print_info'] = False

        SimInfo.solvers['StaticCoupled']['structural_solver'] = 'NonLinearStatic'
        SimInfo.solvers['StaticCoupled']['structural_solver_settings'] = SimInfo.solvers['NonLinearStatic']
        SimInfo.solvers['StaticCoupled']['aero_solver'] = 'StaticUvlm'
        SimInfo.solvers['StaticCoupled']['aero_solver_settings'] = SimInfo.solvers['StaticUvlm']

        SimInfo.solvers['WriteVariablesTime']['structure_nodes'] = np.array([0,  int((nnodes1-1)/2), -1], dtype = int)
        SimInfo.solvers['WriteVariablesTime']['structure_variables'] = ['pos']

        SimInfo.solvers['BeamPlot']['include_FoR'] = True

        SimInfo.solvers['NonLinearDynamicMultibody']['relaxation_factor'] = 0.0
        SimInfo.solvers['NonLinearDynamicMultibody']['min_delta'] = 1e-5
        SimInfo.solvers['NonLinearDynamicMultibody']['max_iterations'] = 200
        SimInfo.solvers['NonLinearDynamicMultibody']['newmark_damp'] = 1e-3
        # SimInfo.solvers['NonLinearDynamicMultibody']['gravity_on'] = 'off'

        SimInfo.solvers['NonLinearDynamicMultibody']['relaxation_factor'] = 0.0

        SimInfo.solvers['DynamicCoupled']['structural_solver'] = 'NonLinearDynamicMultibody'
        SimInfo.solvers['DynamicCoupled']['structural_solver_settings'] = SimInfo.solvers['NonLinearDynamicMultibody']
        SimInfo.solvers['DynamicCoupled']['aero_solver'] = 'StepUvlm'
        SimInfo.solvers['DynamicCoupled']['aero_solver_settings'] = SimInfo.solvers['StepUvlm']
        SimInfo.solvers['DynamicCoupled']['postprocessors'] = ['WriteVariablesTime', 'BeamPlot', 'AerogridPlot']
        SimInfo.solvers['DynamicCoupled']['postprocessors_settings'] = {'WriteVariablesTime': SimInfo.solvers['WriteVariablesTime'],
                                                                        'BeamPlot': SimInfo.solvers['BeamPlot'],
                                                                        'AerogridPlot': SimInfo.solvers['AerogridPlot']}

        ntimesteps = 10

        SimInfo.define_num_steps(ntimesteps)

        # Define dynamic simulation
        SimInfo.with_forced_vel = False
        SimInfo.with_dynamic_forces = False

        LC2 = gc.LagrangeConstraint()
        LC2.behaviour = 'lin_vel_node_wrtG'
        LC2.velocity = np.zeros((ntimesteps, 3))
        LC2.velocity[:int(ntimesteps/2),1] = 0.5
        LC2.velocity[int(ntimesteps/2):,1] = -0.5
        LC2.body_number = 0
        LC2.node_number = int((nnodes1-1)/2)

        LC = []
        # LC.append(LC1)
        LC.append(LC2)

        # Define the multibody infromation for the tower and the rotor
        MB1 = gc.BodyInformation()
        MB1.body_number = 0
        MB1.FoR_position = np.zeros((6,),)
        MB1.FoR_velocity = np.zeros((6,),)
        MB1.FoR_acceleration = np.zeros((6,),)
        MB1.FoR_movement = 'free'
        MB1.quat = np.array([1.0,0.0,0.0,0.0])

        MB = []
        MB.append(MB1)


        gc.clean_test_files(
            SimInfo.solvers['SHARPy']['route'],
            SimInfo.solvers['SHARPy']['case'])
        SimInfo.generate_solver_file()
        SimInfo.generate_dyn_file(ntimesteps)
        beam1.generate_h5_files(
            SimInfo.solvers['SHARPy']['route'],
            SimInfo.solvers['SHARPy']['case'])
        gc.generate_multibody_file(LC,
                                   MB,SimInfo.solvers['SHARPy']['route'],
                                   SimInfo.solvers['SHARPy']['case'])
Ejemplo n.º 6
0
    def setUp(self):
        import sharpy.utils.generate_cases as gc

        deg2rad = np.pi/180.

        # Structural properties
        mass_per_unit_length = 1.
        mass_iner = 1e-4
        EA = 1e9
        GA = 1e9
        GJ = 1e9
        EI = 1e9

        # Beam1
        global nnodes1
        nnodes1 = 11
        l1 = 1.0
        m1 = 1.0
        theta_ini1 = 90.*deg2rad

        # Beam2
        nnodes2 = nnodes1
        l2 = l1
        m2 = m1
        theta_ini2 = 00.*deg2rad

        # airfoils
        airfoil = np.zeros((1,20,2),)
        airfoil[0,:,0] = np.linspace(0.,1.,20)

        # Simulation
        numtimesteps = 10
        dt = 0.01

        # Create the structure
        beam1 = gc.AeroelasticInformation()
        r1 = np.linspace(0.0, l1, nnodes1)
        node_pos1 = np.zeros((nnodes1,3),)
        node_pos1[:, 0] = r1*np.sin(theta_ini1)
        node_pos1[:, 2] = -r1*np.cos(theta_ini1)
        beam1.StructuralInformation.generate_uniform_sym_beam(node_pos1, mass_per_unit_length, mass_iner, EA, GA, GJ, EI, num_node_elem = 3, y_BFoR = 'y_AFoR', num_lumped_mass=1)
        beam1.StructuralInformation.body_number = np.zeros((beam1.StructuralInformation.num_elem,), dtype = int)
        beam1.StructuralInformation.boundary_conditions[0] = 1
        beam1.StructuralInformation.boundary_conditions[-1] = -1
        beam1.StructuralInformation.lumped_mass_nodes = np.array([nnodes1-1], dtype = int)
        beam1.StructuralInformation.lumped_mass = np.ones((1,))*m1
        beam1.StructuralInformation.lumped_mass_inertia = np.zeros((1,3,3))
        beam1.StructuralInformation.lumped_mass_position = np.zeros((1,3))
        beam1.AerodynamicInformation.create_one_uniform_aerodynamics(
                                            beam1.StructuralInformation,
                                            chord = 1.,
                                            twist = 0.,
                                            sweep = 0.,
                                            num_chord_panels = 4,
                                            m_distribution = 'uniform',
                                            elastic_axis = 0.25,
                                            num_points_camber = 20,
                                            airfoil = airfoil)

        beam2 = gc.AeroelasticInformation()
        r2 = np.linspace(0.0, l2, nnodes2)
        node_pos2 = np.zeros((nnodes2,3),)
        node_pos2[:, 0] = r2*np.sin(theta_ini2) + node_pos1[-1, 0]
        node_pos2[:, 2] = -r2*np.cos(theta_ini2) + node_pos1[-1, 2]
        beam2.StructuralInformation.generate_uniform_sym_beam(node_pos2, mass_per_unit_length, mass_iner, EA, GA, GJ, EI, num_node_elem = 3, y_BFoR = 'y_AFoR', num_lumped_mass=1)
        beam2.StructuralInformation.body_number = np.zeros((beam1.StructuralInformation.num_elem,), dtype = int)
        beam2.StructuralInformation.boundary_conditions[0] = 1
        beam2.StructuralInformation.boundary_conditions[-1] = -1
        beam2.StructuralInformation.lumped_mass_nodes = np.array([nnodes2-1], dtype = int)
        beam2.StructuralInformation.lumped_mass = np.ones((1,))*m2
        beam2.StructuralInformation.lumped_mass_inertia = np.zeros((1,3,3))
        beam2.StructuralInformation.lumped_mass_position = np.zeros((1,3))
        beam2.AerodynamicInformation.create_one_uniform_aerodynamics(
                                            beam2.StructuralInformation,
                                            chord = 1.,
                                            twist = 0.,
                                            sweep = 0.,
                                            num_chord_panels = 4,
                                            m_distribution = 'uniform',
                                            elastic_axis = 0.25,
                                            num_points_camber = 20,
                                            airfoil = airfoil)

        beam1.assembly(beam2)

        # Simulation details
        SimInfo = gc.SimulationInformation()
        SimInfo.set_default_values()

        SimInfo.define_uinf(np.array([0.0,1.0,0.0]), 1.)

        SimInfo.solvers['SHARPy']['flow'] = ['BeamLoader',
                                'AerogridLoader',
                                # 'InitializeMultibody',
                                'DynamicCoupled']
        global name
        name = 'double_pendulum_geradin'
        SimInfo.solvers['SHARPy']['case'] = 'double_pendulum_geradin'
        SimInfo.solvers['SHARPy']['write_screen'] = 'off'
        SimInfo.solvers['SHARPy']['route'] = os.path.abspath(os.path.dirname(os.path.realpath(__file__))) + '/'
        SimInfo.solvers['SHARPy']['log_folder'] = os.path.abspath(os.path.dirname(os.path.realpath(__file__))) + '/'
        SimInfo.set_variable_all_dicts('dt', dt)
        SimInfo.define_num_steps(numtimesteps)
        SimInfo.set_variable_all_dicts('rho', 0.0)
        SimInfo.set_variable_all_dicts('velocity_field_input', SimInfo.solvers['SteadyVelocityField'])
        SimInfo.set_variable_all_dicts('output', os.path.abspath(os.path.dirname(os.path.realpath(__file__))) + '/output/')

        SimInfo.solvers['BeamLoader']['unsteady'] = 'on'

        SimInfo.solvers['AerogridLoader']['unsteady'] = 'on'
        SimInfo.solvers['AerogridLoader']['mstar'] = 2

        SimInfo.solvers['WriteVariablesTime']['FoR_number'] = np.array([0, 1], dtype = int)
        SimInfo.solvers['WriteVariablesTime']['FoR_variables'] = ['mb_quat']
        SimInfo.solvers['WriteVariablesTime']['structure_nodes'] = np.array([nnodes1-1, nnodes1+nnodes2-1], dtype = int)
        SimInfo.solvers['WriteVariablesTime']['structure_variables'] = ['pos']

        SimInfo.solvers['NonLinearDynamicMultibody']['gravity_on'] = True
        SimInfo.solvers['NonLinearDynamicMultibody']['newmark_damp'] = 0.15

        SimInfo.solvers['BeamPlot']['include_FoR'] = True

        SimInfo.solvers['DynamicCoupled']['structural_solver'] = 'NonLinearDynamicMultibody'
        SimInfo.solvers['DynamicCoupled']['structural_solver_settings'] = SimInfo.solvers['NonLinearDynamicMultibody']
        SimInfo.solvers['DynamicCoupled']['aero_solver'] = 'StepUvlm'
        SimInfo.solvers['DynamicCoupled']['aero_solver_settings'] = SimInfo.solvers['StepUvlm']
        SimInfo.solvers['DynamicCoupled']['postprocessors'] = ['WriteVariablesTime', 'BeamPlot', 'AerogridPlot']
        SimInfo.solvers['DynamicCoupled']['postprocessors_settings'] = {'WriteVariablesTime': SimInfo.solvers['WriteVariablesTime'],
                                                                        'BeamPlot': SimInfo.solvers['BeamPlot'],
                                                                        'AerogridPlot': SimInfo.solvers['AerogridPlot']}

        SimInfo.solvers['DynamicCoupled']['postprocessors_settings']['WriteVariablesTime']['folder'] = os.path.abspath(os.path.dirname(os.path.realpath(__file__))) + '/output/'
        SimInfo.solvers['DynamicCoupled']['postprocessors_settings']['BeamPlot']['folder'] = os.path.abspath(os.path.dirname(os.path.realpath(__file__))) + '/output/'
        SimInfo.solvers['DynamicCoupled']['postprocessors_settings']['AerogridPlot']['folder'] = os.path.abspath(os.path.dirname(os.path.realpath(__file__))) + '/output/'
        SimInfo.with_forced_vel = False
        SimInfo.with_dynamic_forces = False

        # Create the MB and BC files
        LC1 = gc.LagrangeConstraint()
        LC1.behaviour = 'hinge_FoR'
        LC1.body_FoR = 0
        LC1.rot_axis_AFoR = np.array([0.0,1.0,0.0])

        LC2 = gc.LagrangeConstraint()
        LC2.behaviour = 'hinge_node_FoR'
        LC2.node_in_body = nnodes1-1
        LC2.body = 0
        LC2.body_FoR = 1
        LC2.rot_axisB = np.array([0.0,1.0,0.0])

        LC = []
        LC.append(LC1)
        LC.append(LC2)

        MB1 = gc.BodyInformation()
        MB1.body_number = 0
        MB1.FoR_position = np.zeros((6,),)
        MB1.FoR_velocity = np.zeros((6,),)
        MB1.FoR_acceleration = np.zeros((6,),)
        MB1.FoR_movement = 'free'
        MB1.quat = np.array([1.0,0.0,0.0,0.0])

        MB2 = gc.BodyInformation()
        MB2.body_number = 1
        MB2.FoR_position = np.array([node_pos2[0, 0], node_pos2[0, 1], node_pos2[0, 2], 0.0, 0.0, 0.0])
        MB2.FoR_velocity = np.zeros((6,),)
        MB2.FoR_acceleration = np.zeros((6,),)
        MB2.FoR_movement = 'free'
        MB2.quat = np.array([1.0,0.0,0.0,0.0])

        MB = []
        MB.append(MB1)
        MB.append(MB2)

        # Write files
        gc.clean_test_files(SimInfo.solvers['SHARPy']['route'], SimInfo.solvers['SHARPy']['case'])
        SimInfo.generate_solver_file()
        SimInfo.generate_dyn_file(numtimesteps)
        beam1.generate_h5_files(SimInfo.solvers['SHARPy']['route'], SimInfo.solvers['SHARPy']['case'])
        gc.generate_multibody_file(LC, MB,SimInfo.solvers['SHARPy']['route'], SimInfo.solvers['SHARPy']['case'])