###################################################################################################################### 
 # MBDyn is a free and open-source general purpose multi-body dynamics software. See https://www.mbdyn.org/ for details. 
 # This input file was automatically generated by the FreeCAD "MBD workbench". 
 # To learn more about MBDyn input files, you can visit the website: https://www.sky-engin.jp/en/MBDynTutorial/index.html 
 # Details about the structure of input files can be studied in the input file manuals: https://www.mbdyn.org/?Software_Download 
 # Although MBDyn has already reached a mature stage and is used by several industries, 
 # the FreeCAD dynamics workbench is still under development, and it is likely to have bugs. 
 # Please be aware of this fact before you use this input file for any critical application. 
 # If you think you have found a bug or have any suggestion, please send your comments to Jose Egas: 
 # josegegas@gmail.com 
 ###################################################################################################################### 

 #-----------------------------------------------------------------------------
 # [Data Block]

 begin: data;
     problem: initial value;
 end: data;

 #-----------------------------------------------------------------------------
 # [Problem Block]

 begin: initial value;
     initial time: 0.0;
     final time: 8.0;
     time step: 0.1;
     max iterations: 100;
     tolerance: 1e-06;
     derivatives tolerance: 0.0001;
     derivatives max iterations: 100;
     derivatives coefficient: auto;
 end: initial value;

 #-----------------------------------------------------------------------------
 # [Control Data Block]

 begin: control data;
     max iterations: 1000;
     default orientation: euler321;
     omega rotates: no;
     print: none;
     initial stiffness: 1.0, 1.0;
     structural nodes: 4;
     rigid bodies: 3;
     joints: 7;
 end: control data;

 #-----------------------------------------------------------------------------
 # [Design Variables]

     #Generic bodies

         #body: 2
             set: integer body_2 = 2; #body label
             set: real mass_2 = 1.4486361883511716; #mass [kg]
             set: real volume_2 = 0.0001833716694115407; #volume [m^3]

         #body: 3
             set: integer body_3 = 3; #body label
             set: real mass_3 = 2.85294865570677; #mass [kg]
             set: real volume_3 = 0.00036113274122870505; #volume [m^3]

         #body: 4
             set: integer body_4 = 4; #body label
             set: real mass_4 = 10.859427202622147; #mass [kg]
             set: real volume_4 = 0.0013746110383066007; #volume [m^3]

     #Nodes

         #node: 1
             set: integer structural_node_1 = 1; #node label

         #node: 2
             set: integer structural_node_2 = 2; #node label

         #node: 3
             set: integer structural_node_3 = 3; #node label

         #node: 4
             set: integer structural_node_4 = 4; #node label

     #Joints

         #joint: 1
             set: integer joint_1 = 1; #joint label

         #joint: 2
             set: integer joint_2 = 2; #joint label

         #joint: 3
             set: integer joint_3 = 3; #joint label

         #joint: 4
             set: integer joint_4 = 4; #joint label

         #joint: 5
             set: integer joint_5 = 5; #joint label

         #joint: 6
             set: integer joint_6 = 6; #joint label

         #joint: 7
             set: integer joint_7 = 7; #joint label

     #Nodes: initial conditions

         #node: 1
             set: real Px_1 = -0.121; #X component of the absolute position [m]
             set: real Py_1 = -8.796847998598882e-19; #Y component of the absolute position [m]
             set: real Pz_1 = -0.08; #Z component of the absolute position [m]

             set: real Vx_1 = 0.0; #X component of the absolute velocity [m/s]
             set: real Vy_1 = 0.0; #Y component of the absolute velocity [m/s]
             set: real Vz_1 = 0.0; #Z component of the absolute velocity [m/s]

             set: real Wx_1 = 0.0; #X component of the absolute angular velocity [rad/s]
             set: real Wy_1 = 0.0; #Y component of the absolute angular velocity [rad/s]
             set: real Wz_1 = 0.0; #Z component of the absolute angular velocity [rad/s]

         #node: 2
             set: real Px_2 = -0.015; #X component of the absolute position [m]
             set: real Py_2 = 0.092; #Y component of the absolute position [m]
             set: real Pz_2 = 0.008; #Z component of the absolute position [m]

             set: real Vx_2 = 0.0; #X component of the absolute velocity [m/s]
             set: real Vy_2 = 0.0; #Y component of the absolute velocity [m/s]
             set: real Vz_2 = 0.0; #Z component of the absolute velocity [m/s]

             set: real Wx_2 = 0.0; #X component of the absolute angular velocity [rad/s]
             set: real Wy_2 = 0.0; #Y component of the absolute angular velocity [rad/s]
             set: real Wz_2 = 0.0; #Z component of the absolute angular velocity [rad/s]

         #node: 3
             set: real Px_3 = 0.088; #X component of the absolute position [m]
             set: real Py_3 = -0.055; #Y component of the absolute position [m]
             set: real Pz_3 = 0.05; #Z component of the absolute position [m]

             set: real Vx_3 = 0.0; #X component of the absolute velocity [m/s]
             set: real Vy_3 = 0.0; #Y component of the absolute velocity [m/s]
             set: real Vz_3 = 0.0; #Z component of the absolute velocity [m/s]

             set: real Wx_3 = 0.0; #X component of the absolute angular velocity [rad/s]
             set: real Wy_3 = 0.0; #Y component of the absolute angular velocity [rad/s]
             set: real Wz_3 = 0.0; #Z component of the absolute angular velocity [rad/s]

         #node: 4
             set: real Px_4 = 0.3200000010688326; #X component of the absolute position [m]
             set: real Py_4 = 1.4796688528733327e-10; #Y component of the absolute position [m]
             set: real Pz_4 = 0.04999999225971574; #Z component of the absolute position [m]

             set: real Vx_4 = 0.0; #X component of the absolute velocity [m/s]
             set: real Vy_4 = 0.0; #Y component of the absolute velocity [m/s]
             set: real Vz_4 = 0.0; #Z component of the absolute velocity [m/s]

             set: real Wx_4 = 0.0; #X component of the absolute angular velocity [rad/s]
             set: real Wy_4 = 0.0; #Y component of the absolute angular velocity [rad/s]
             set: real Wz_4 = 0.0; #Z component of the absolute angular velocity [rad/s]

 #-----------------------------------------------------------------------------
 # [Intermediate Variables]

     #Moments of inertia and relative center of mass

         #body 2: 
             set: real Ixx_2 = 0.0012769356301204219; #moment of inertia [kg*m^2]
             set: real Ixy_2 = 4.67e-20; #moment of inertia [kg*m^2]
             set: real Ixz_2 = -0.0009495625871945231; #moment of inertia [kg*m^2]

             set: real Iyx_2 = 4.67e-20; #moment of inertia [kg*m^2]
             set: real Iyy_2 = 0.0028717510150978666; #moment of inertia [kg*m^2]
             set: real Iyz_2 = 4.4900000000000004e-20; #moment of inertia [kg*m^2]

             set: real Izx_2 = -0.0009495625871945231; #moment of inertia [kg*m^2]
             set: real Izy_2 = 4.4900000000000004e-20; #moment of inertia [kg*m^2]
             set: real Izz_2 = 0.002296471669735477; #moment of inertia [kg*m^2]

             set: real Rx_2 = -0.03260146715730948; #X component of the relative center of mass [m]
             set: real Ry_2 = 0.0; #Y component of the relative center of mass [m]
             set: real Rz_2 = -0.028286762255221056; #Z component of the relative center of mass [m]

         #body 3: 
             set: real Ixx_3 = 0.0019563103180210077; #moment of inertia [kg*m^2]
             set: real Ixy_3 = -7.580852e-16; #moment of inertia [kg*m^2]
             set: real Ixz_3 = 5.386829000000001e-16; #moment of inertia [kg*m^2]

             set: real Iyx_3 = -7.580852e-16; #moment of inertia [kg*m^2]
             set: real Iyy_3 = 0.03371514809951082; #moment of inertia [kg*m^2]
             set: real Iyz_3 = -4.95494e-17; #moment of inertia [kg*m^2]

             set: real Izx_3 = 5.386829000000001e-16; #moment of inertia [kg*m^2]
             set: real Izy_3 = -4.95494e-17; #moment of inertia [kg*m^2]
             set: real Izz_3 = 0.03383792198797204; #moment of inertia [kg*m^2]

             set: real Rx_3 = 7.87281351222191e-15; #X component of the relative center of mass [m]
             set: real Ry_3 = 1.0302869668521452e-15; #Y component of the relative center of mass [m]
             set: real Rz_3 = -0.024999999999998045; #Z component of the relative center of mass [m]

         #body 4: 
             set: real Ixx_4 = 0.07706742098795094; #moment of inertia [kg*m^2]
             set: real Ixy_4 = 8.01291908309e-10; #moment of inertia [kg*m^2]
             set: real Ixz_4 = -1.2135214817691901e-08; #moment of inertia [kg*m^2]

             set: real Iyx_4 = 8.01291908309e-10; #moment of inertia [kg*m^2]
             set: real Iyy_4 = 0.06635181579849883; #moment of inertia [kg*m^2]
             set: real Iyz_4 = -3.32678908792e-11; #moment of inertia [kg*m^2]

             set: real Izx_4 = -1.2135214817691901e-08; #moment of inertia [kg*m^2]
             set: real Izy_4 = -3.32678908792e-11; #moment of inertia [kg*m^2]
             set: real Izz_4 = 0.06179235045624136; #moment of inertia [kg*m^2]

             set: real Rx_4 = 0.045580834634119355; #X component of the relative center of mass [m]
             set: real Ry_4 = 2.0299354041266675e-10; #Y component of the relative center of mass [m]
             set: real Rz_4 = -1.2562251448855477e-08; #Z component of the relative center of mass [m]

 #-----------------------------------------------------------------------------
 # [Nodes Block]

 begin: nodes;

     structural: structural_node_1,
                 static,
                 Px_1, Py_1, Pz_1, #<absolute_position> [m]
                 3, 0.0, 0.0, 1.0, 2, 0.0, 1.0, 0.0, #<absolute_orientation_matrix>
                 Vx_1, Vy_1, Vz_1, #<absolute_velocity> [m/s]
                 Wx_1, Wy_1, Wz_1; #<absolute_angular_velocity> [rad/s]

     structural: structural_node_2,
                 dynamic,
                 Px_2, Py_2, Pz_2, #<absolute_position> [m]
                 3, 0.0, 0.0, 1.0, 2, 0.0, 1.0, 0.0, #<absolute_orientation_matrix>
                 Vx_2, Vy_2, Vz_2, #<absolute_velocity> [m/s]
                 Wx_2, Wy_2, Wz_2; #<absolute_angular_velocity> [rad/s]

     structural: structural_node_3,
                 dynamic,
                 Px_3, Py_3, Pz_3, #<absolute_position> [m]
                 3, 0.0, 0.0, 1.0, 2, 0.0, 1.0, 0.0, #<absolute_orientation_matrix>
                 Vx_3, Vy_3, Vz_3, #<absolute_velocity> [m/s]
                 Wx_3, Wy_3, Wz_3; #<absolute_angular_velocity> [rad/s]

     structural: structural_node_4,
                 dynamic,
                 Px_4, Py_4, Pz_4, #<absolute_position> [m]
                 3, 0.0, 0.0, 1.0, 2, 0.0, 1.0, 0.0, #<absolute_orientation_matrix>
                 Vx_4, Vy_4, Vz_4, #<absolute_velocity> [m/s]
                 Wx_4, Wy_4, Wz_4; #<absolute_angular_velocity> [rad/s]

 end: nodes;

 #-----------------------------------------------------------------------------
 # [Elements Block]

 begin: elements;

     #-----------------------------------------------------------------------------
     # [Bodies]

         #IMPORTANT NOTE: FreeCAD provides the inertia matrix in the global reference frame,
         #while by default, MBDyn assumes it to be in the reference frame of the node,
         #thus, the matrix of inertia must be rotated, using the inverse of the placement
         #matrix of the node. This is done using the inertial keyword and the following
         #orientation matrix.

         body: body_2,
               structural_node_2, #<node_label> 
               mass_2, #<mass> [kg]
               Rx_2, Ry_2, Rz_2, #<relative_center_of_mass> [m]
               Ixx_2, Ixy_2, Ixz_2, #<inertia_matrix> [kg*m^2]
               Iyx_2, Iyy_2, Iyz_2,
               Izx_2, Izy_2, Izz_2,
               orientation, 3, 0.0, 0.0, 1.0, 2, 0.0, 1.0, 0.0; 

         body: body_3,
               structural_node_3, #<node_label> 
               mass_3, #<mass> [kg]
               Rx_3, Ry_3, Rz_3, #<relative_center_of_mass> [m]
               Ixx_3, Ixy_3, Ixz_3, #<inertia_matrix> [kg*m^2]
               Iyx_3, Iyy_3, Iyz_3,
               Izx_3, Izy_3, Izz_3,
               orientation, 3, 0.0, 0.0, 1.0, 2, 0.0, 1.0, 0.0; 

         body: body_4,
               structural_node_4, #<node_label> 
               mass_4, #<mass> [kg]
               Rx_4, Ry_4, Rz_4, #<relative_center_of_mass> [m]
               Ixx_4, Ixy_4, Ixz_4, #<inertia_matrix> [kg*m^2]
               Iyx_4, Iyy_4, Iyz_4,
               Izx_4, Izy_4, Izz_4,
               orientation, 3, 0.0, 0.0, 1.0, 2, 0.0, 1.0, 0.0; 

     #-----------------------------------------------------------------------------
     # [Joints]

     joint: joint_1,
         clamp,
         structural_node_1, #<node_label>
             -0.121, -8.796847998598882e-19, -0.08, #<absolute_pin_position> [m]
             3, 0.0, 0.0, 1.0, 2, 0.0, 1.0, 0.0; #<absolute_orientation_matrix> 

     joint: joint_2,
         spherical hinge,
         structural_node_1, #<node_1_label>
         0.0, 0.0, 0.0, #<relative_pin_position_1> [m]
         structural_node_2, #<node_2_label>
         -0.07, 0.0, -0.055; #<relative_pin_position_2> [m]

     joint: joint_3,
            revolute hinge,
     structural_node_2, #<node_1_label>
     0.0, 0.0, 0.0, #<relative_position_1> [m]
     orientation, 3, 0.0, 0.0, 1.0, 2, 0.0, 1.0, 0.0, #<relative_pin_orientation_matrix_1>
     structural_node_3, #<node_2_label>
                -0.14, 0.0, -0.024999999999999998, #<relative_position_2> [m]
                orientation, 3, 0.0, 0.0, 1.0, 2, guess; #<relative_pin_orientation_matrix_2>

     joint: joint_4,
         drive hinge,
         structural_node_1, #<node_1_label>
         orientation, 3, 0.0, 0.0, 1.0, 2, 0.0, 1.0, 0.0, #<relative_orientation_matrix_1>
         structural_node_2, #<node_2_label>
         orientation, 3, 0.0, 0.0, 1.0, 2, 0.0, 1.0, 0.0, #<relative_orientation_matrix_2>
         single, 0., 0., 1., #<hinge_orientation>
         string, "0"; #<hinge_orientation> [rad]

     joint: joint_5,
         in line,
         structural_node_4, #<node_1_label>
             0.0, 0.0, 0.0, #<relative_line_position> [m]
             3, 0.0, 0.0, 1.0, 2, 0.0, 1.0, 0.0, #<relative_orientation>
         structural_node_3, #<node_2_label>
             offset, 0.14, 0.0, -0.024999999999999998; #<relative_offset> [m]

     joint: joint_6,
         prismatic,
         structural_node_1, #<node_1_label>
             orientation, 3, 0.0, 0.0, 1.0, 2, 0.0, 1.0, 0.0, #relative_orientation_matrix_1>
         structural_node_4, #<node_2_label>
             orientation, 3, 0.0, 0.0, 1.0, 2, 0.0, 1.0, 0.0; #relative_orientation_matrix_2>

     joint: joint_7,
         in line,
         structural_node_1, #<node_1_label>
             0.0, 8.796847998604521e-19, 0.08, #<relative_line_position> [m]
             3, 1.0, -2.220446049250313e-16, 2.220446049250313e-16, 2, -2.220446049250313e-16, 0.0, 1.0, #<relative_orientation>
         structural_node_4, #<node_2_label>
             offset, 0.0, 0.0, 0.0; #<relative_offset> [m]

 end: elements;

