def setup(self):
        surface = self.options['surface']
        ny = surface['num_y']

        if 'spar_thickness_cp' in surface.keys(
        ) or 'skin_thickness_cp' in surface.keys():
            # Add independent variables that do not belong to a specific component
            indep_var_comp = IndepVarComp()

            # Add structural components to the surface-specific group
            self.add_subsystem('indep_vars', indep_var_comp, promotes=['*'])

        if 'spar_thickness_cp' in surface.keys():
            n_cp = len(surface['spar_thickness_cp'])
            # Add bspline components for active bspline geometric variables.
            self.add_subsystem('spar_thickness_bsp',
                               BsplinesComp(in_name='spar_thickness_cp',
                                            out_name='spar_thickness',
                                            num_control_points=n_cp,
                                            num_points=int(ny - 1),
                                            bspline_order=min(n_cp, 4),
                                            distribution='uniform'),
                               promotes_inputs=['spar_thickness_cp'],
                               promotes_outputs=['spar_thickness'])
            indep_var_comp.add_output('spar_thickness_cp',
                                      val=surface['spar_thickness_cp'],
                                      units='m')

        if 'skin_thickness_cp' in surface.keys():
            n_cp = len(surface['skin_thickness_cp'])
            # Add bspline components for active bspline geometric variables.
            self.add_subsystem('skin_thickness_bsp',
                               BsplinesComp(in_name='skin_thickness_cp',
                                            out_name='skin_thickness',
                                            num_control_points=n_cp,
                                            num_points=int(ny - 1),
                                            bspline_order=min(n_cp, 4),
                                            distribution='uniform'),
                               promotes_inputs=['skin_thickness_cp'],
                               promotes_outputs=['skin_thickness'])
            indep_var_comp.add_output('skin_thickness_cp',
                                      val=surface['skin_thickness_cp'],
                                      units='m')

        self.add_subsystem(
            'wingbox_geometry',
            WingboxGeometry(surface=surface),
            promotes_inputs=['mesh'],
            promotes_outputs=['fem_chords', 'fem_twists', 'streamwise_chords'])

        self.add_subsystem('wingbox',
                           SectionPropertiesWingbox(surface=surface),
                           promotes_inputs=[
                               'spar_thickness', 'skin_thickness', 't_over_c',
                               'fem_chords', 'fem_twists', 'streamwise_chords'
                           ],
                           promotes_outputs=[
                               'A', 'Iy', 'Qz', 'Iz', 'J', 'A_enc', 'A_int',
                               'htop', 'hbottom', 'hfront', 'hrear'
                           ])
    def setup(self):
        surface = self.options['surface']
        ny = surface['mesh'].shape[1]

        if 'spar_thickness_cp' in surface.keys() or 'skin_thickness_cp' in surface.keys():
            # Add independent variables that do not belong to a specific component
            indep_var_comp = om.IndepVarComp()

            # Add structural components to the surface-specific group
            self.add_subsystem('indep_vars',
                     indep_var_comp,
                     promotes=['*'])

        if 'spar_thickness_cp' in surface.keys():
            n_cp = len(surface['spar_thickness_cp'])
            # Add bspline components for active bspline geometric variables.
            x_interp = np.linspace(0., 1., int(ny-1))
            comp = self.add_subsystem('spar_thickness_bsp', om.SplineComp(
                method='bsplines', x_interp_val=x_interp,
                num_cp=n_cp,
                interp_options={'order' : min(n_cp, 4)}),
                promotes_inputs=['spar_thickness_cp'], promotes_outputs=['spar_thickness'])
            comp.add_spline(y_cp_name='spar_thickness_cp', y_interp_name='spar_thickness',
                y_units='m')
            indep_var_comp.add_output('spar_thickness_cp', val=surface['spar_thickness_cp'], units='m')

        if 'skin_thickness_cp' in surface.keys():
            n_cp = len(surface['skin_thickness_cp'])
            # Add bspline components for active bspline geometric variables.
            x_interp = np.linspace(0., 1., int(ny-1))
            comp = self.add_subsystem('skin_thickness_bsp', om.SplineComp(
                method='bsplines', x_interp_val=x_interp,
                num_cp=n_cp,
                interp_options={'order' : min(n_cp, 4)}),
                promotes_inputs=['skin_thickness_cp'], promotes_outputs=['skin_thickness'])
            comp.add_spline(y_cp_name='skin_thickness_cp', y_interp_name='skin_thickness',
                y_units='m')
            indep_var_comp.add_output('skin_thickness_cp', val=surface['skin_thickness_cp'], units='m')

        self.add_subsystem('wingbox_geometry',
            WingboxGeometry(surface=surface),
            promotes_inputs=['mesh'],
            promotes_outputs=['fem_chords', 'fem_twists', 'streamwise_chords'])

        self.add_subsystem('wingbox',
            SectionPropertiesWingbox(surface=surface),
            promotes_inputs=['spar_thickness', 'skin_thickness', 't_over_c', 'fem_chords', 'fem_twists', 'streamwise_chords'],
            promotes_outputs=['A', 'Iy', 'Qz', 'Iz', 'J', 'A_enc', 'A_int', 'htop', 'hbottom', 'hfront', 'hrear'])
Exemple #3
0
    def test(self):
        surface = get_default_surfaces()[0]
        

        surface['data_x_upper'] = np.array([0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6], dtype = 'complex128')

        surface['data_x_lower'] = np.array([0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6], dtype = 'complex128')
        surface['data_y_upper'] = np.array([ 0.0447,  0.046,  0.0472,  0.0484,  0.0495,  0.0505,  0.0514,  0.0523,  0.0531,  0.0538, 0.0545,  0.0551,  0.0557, 0.0563,  0.0568, 0.0573,  0.0577,  0.0581,  0.0585,  0.0588,  0.0591,  0.0593,  0.0595,  0.0597,  0.0599,  0.06,    0.0601,  0.0602,  0.0602,  0.0602,  0.0602,  0.0602,  0.0601,  0.06,    0.0599,  0.0598,  0.0596,  0.0594,  0.0592,  0.0589,  0.0586,  0.0583,  0.058,   0.0576,  0.0572,  0.0568,  0.0563,  0.0558,  0.0553,  0.0547,  0.0541], dtype = 'complex128')
        surface['data_y_lower'] = np.array([-0.0447, -0.046, -0.0473, -0.0485, -0.0496, -0.0506, -0.0515, -0.0524, -0.0532, -0.054, -0.0547, -0.0554, -0.056, -0.0565, -0.057, -0.0575, -0.0579, -0.0583, -0.0586, -0.0589, -0.0592, -0.0594, -0.0595, -0.0596, -0.0597, -0.0598, -0.0598, -0.0598, -0.0598, -0.0597, -0.0596, -0.0594, -0.0592, -0.0589, -0.0586, -0.0582, -0.0578, -0.0573, -0.0567, -0.0561, -0.0554, -0.0546, -0.0538, -0.0529, -0.0519, -0.0509, -0.0497, -0.0485, -0.0472, -0.0458, -0.0444], dtype = 'complex128')

        comp = WingboxGeometry(surface=surface)
        
        group = Group()

        indep_var_comp = IndepVarComp()

        indep_var_comp.add_output('mesh', val=surface['mesh'])

        group.add_subsystem('indep_var_comp', indep_var_comp, promotes=['*'])
        group.add_subsystem('wingbox_geometry', comp, promotes=['*'])

        run_test(self, group,  complex_flag=True)