Example #1
0
def disp2state(MB_beam, MB_tstep, q, dqdt, dqddt):
    """
    disp2state

    Fills the vector of states according to the displacements information

    Longer description

    Args:
        MB_beam (list of beam): each entry represents a body
        MB_tstep (list of StructTimeStepInfo): each entry represents a body
        q(numpy array): Vector of states
    	dqdt(numpy array): Time derivatives of states
        dqddt(numpy array): Second time derivatives of states

    Returns:

    Examples:

    Notes:

    """

    first_dof = 0
    for ibody in range(len(MB_beam)):

        ibody_num_dof = MB_beam[ibody].num_dof.value
        if (MB_beam[ibody].FoR_movement == 'prescribed'):
            xbeamlib.cbeam3_solv_disp2state(MB_beam[ibody], MB_tstep[ibody])
            q[first_dof:first_dof +
              ibody_num_dof] = MB_tstep[ibody].q[:-10].astype(
                  dtype=ct.c_double, order='F', copy=True)
            dqdt[first_dof:first_dof +
                 ibody_num_dof] = MB_tstep[ibody].dqdt[:-10].astype(
                     dtype=ct.c_double, order='F', copy=True)
            dqddt[first_dof:first_dof +
                  ibody_num_dof] = MB_tstep[ibody].dqddt[:-10].astype(
                      dtype=ct.c_double, order='F', copy=True)
            first_dof += ibody_num_dof

        elif (MB_beam[ibody].FoR_movement == 'free'):
            xbeamlib.xbeam_solv_disp2state(MB_beam[ibody], MB_tstep[ibody])
            q[first_dof:first_dof + ibody_num_dof +
              10] = MB_tstep[ibody].q.astype(dtype=ct.c_double,
                                             order='F',
                                             copy=True)
            dqdt[first_dof:first_dof + ibody_num_dof +
                 10] = MB_tstep[ibody].dqdt.astype(dtype=ct.c_double,
                                                   order='F',
                                                   copy=True)
            dqddt[first_dof:first_dof + ibody_num_dof +
                  6] = MB_tstep[ibody].dqddt[:-4].astype(dtype=ct.c_double,
                                                         order='F',
                                                         copy=True)
            dqddt[first_dof + ibody_num_dof + 6:first_dof + ibody_num_dof +
                  10] = MB_tstep[ibody].mb_dqddt_quat[ibody, :].astype(
                      dtype=ct.c_double, order='F', copy=True)
            first_dof += ibody_num_dof + 10
Example #2
0
def disp_and_accel2state(MB_beam, MB_tstep, q, dqdt, dqddt):
    """
    disp2state

    Fills the vector of states according to the displacements information

    Args:
        MB_beam (list(:class:`~sharpy.structure.models.beam.Beam`)): each entry represents a body
        MB_tstep (list(:class:`~sharpy.utils.datastructures.StructTimeStepInfo`)): each entry represents a body
        q(np.ndarray): Vector of states
    	dqdt(np.ndarray): Time derivatives of states
        dqddt(np.ndarray): Second time derivatives of states
    """

    first_dof = 0
    for ibody in range(len(MB_beam)):

        ibody_num_dof = MB_beam[ibody].num_dof.value
        if (MB_beam[ibody].FoR_movement == 'prescribed'):
            xbeamlib.cbeam3_solv_disp2state(MB_beam[ibody], MB_tstep[ibody])
            xbeamlib.cbeam3_solv_accel2state(MB_beam[ibody], MB_tstep[ibody])
            q[first_dof:first_dof +
              ibody_num_dof] = MB_tstep[ibody].q[:-10].astype(
                  dtype=ct.c_double, order='F', copy=True)
            dqdt[first_dof:first_dof +
                 ibody_num_dof] = MB_tstep[ibody].dqdt[:-10].astype(
                     dtype=ct.c_double, order='F', copy=True)
            dqddt[first_dof:first_dof +
                  ibody_num_dof] = MB_tstep[ibody].dqddt[:-10].astype(
                      dtype=ct.c_double, order='F', copy=True)
            first_dof += ibody_num_dof

        elif (MB_beam[ibody].FoR_movement == 'free'):
            dquatdt = MB_tstep[ibody].mb_dquatdt[ibody, :].astype(
                dtype=ct.c_double, order='F', copy=True)
            xbeamlib.xbeam_solv_disp2state(MB_beam[ibody], MB_tstep[ibody])
            xbeamlib.xbeam_solv_accel2state(MB_beam[ibody], MB_tstep[ibody])
            q[first_dof:first_dof + ibody_num_dof +
              10] = MB_tstep[ibody].q.astype(dtype=ct.c_double,
                                             order='F',
                                             copy=True)
            dqdt[first_dof:first_dof + ibody_num_dof +
                 10] = MB_tstep[ibody].dqdt.astype(dtype=ct.c_double,
                                                   order='F',
                                                   copy=True)
            dqddt[first_dof:first_dof + ibody_num_dof +
                  10] = MB_tstep[ibody].dqddt.astype(dtype=ct.c_double,
                                                     order='F',
                                                     copy=True)
            # dqddt[first_dof+ibody_num_dof+6:first_dof+ibody_num_dof+10]=MB_tstep[ibody].mb_dqddt_quat[ibody,:].astype(dtype=ct.c_double, order='F', copy=True)
            dqddt[first_dof + ibody_num_dof + 6:first_dof + ibody_num_dof +
                  10] = dquatdt.astype(dtype=ct.c_double, order='F', copy=True)
            first_dof += ibody_num_dof + 10
    def initialise(self, data, custom_settings=None):
        self.data = data
        if custom_settings is None:
            self.settings = data.settings[self.solver_id]
        else:
            self.settings = custom_settings
        settings.to_custom_types(self.settings, self.settings_types,
                                 self.settings_default)

        # load info from dyn dictionary
        self.data.structure.add_unsteady_information(
            self.data.structure.dyn_dict, self.settings['num_steps'].value)

        # generate q, dqdt and dqddt
        xbeamlib.xbeam_solv_disp2state(self.data.structure,
                                       self.data.structure.timestep_info[-1])
Example #4
0
    def initialise(self, data, custom_settings=None):
        self.data = data
        if custom_settings is None:
            self.settings = data.settings[self.solver_id]
        else:
            self.settings = custom_settings
        settings.to_custom_types(self.settings, self.settings_types, self.settings_default)

        # load info from dyn dictionary
        self.data.structure.add_unsteady_information(self.data.structure.dyn_dict, self.settings['num_steps'].value)

        # add initial speed to RBM
        if self.settings['initial_velocity']:
            new_direction = np.dot(self.data.structure.timestep_info[-1].cag(),
                                   self.settings['initial_velocity_direction'])
            self.data.structure.timestep_info[-1].for_vel[0:3] = new_direction*self.settings['initial_velocity']

        # generate q, dqdt and dqddt
        xbeamlib.xbeam_solv_disp2state(self.data.structure, self.data.structure.timestep_info[-1])
    def create_q_vector(self, tstep=None):
        import sharpy.structure.utils.xbeamlib as xb
        if tstep is None:
            tstep = self.data.structure.timestep_info[-1]

        xb.xbeam_solv_disp2state(self.data.structure, tstep)