def test_cell_centered(self):

        calculated_midpoints = np.array([2.1, 4.3, 6.5, 8.7, 10.9])

        dist = cell_centered(5, start=1.0, end=12.0)

        assert_array_almost_equal(calculated_midpoints, dist)
Ejemplo n.º 2
0
    def setup(self):
        num_nodes = self.options['num_nodes']
        num_cp = self.options['num_cp']
        num_radial = self.options['num_radial']

        comp = BEMTMeshComp(num_nodes=num_nodes, num_radial=num_radial)
        self.add_subsystem('mesh_comp', comp, promotes=['*'])

        x_cp = np.linspace(0.0, 1.0, num_cp)
        x_interp = cell_centered(num_radial)
        akima_options = {'delta_x': 0.1}
        comp = SplineComp(method='akima',
                          interp_options=akima_options,
                          x_cp_val=x_cp,
                          x_interp_val=x_interp,
                          vec_size=num_nodes)
        comp.add_spline(y_cp_name='chord_dv',
                        y_interp_name='chord',
                        y_units='m')
        comp.add_spline(y_cp_name='theta_dv',
                        y_interp_name='theta',
                        y_units='rad')
        self.add_subsystem('akima_comp',
                           comp,
                           promotes_inputs=['chord_dv', 'theta_dv'],
                           promotes_outputs=['chord', 'theta'])
Ejemplo n.º 3
0
    def test_small_akima_spline_bug(self):
        # Fixes a bug that only occure for a 4 point spline.
        prob = om.Problem()

        num_cp = 4
        num_radial = 11
        comp = om.IndepVarComp()
        comp.add_output("chord_cp",
                        units="m",
                        val=np.array([0.1, 0.2, 0.3, 0.15]))
        comp.add_output("theta_cp",
                        units="rad",
                        val=np.array([1.0, 0.8, 0.6, 0.4]))
        prob.model.add_subsystem("inputs_comp", comp, promotes=["*"])

        x_cp = np.linspace(0.0, 1.0, num_cp)
        x_interp = cell_centered(num_radial, start=0.0, end=1.0)
        akima_options = {'delta_x': 0.1}
        comp = om.SplineComp(method='akima',
                             interp_options=akima_options,
                             x_cp_val=x_cp,
                             x_interp_val=x_interp)
        comp.add_spline(y_cp_name='chord_cp',
                        y_interp_name='chord_interp',
                        y_units='m')
        comp.add_spline(y_cp_name='theta_cp',
                        y_interp_name='theta_interp',
                        y_units='rad')
        prob.model.add_subsystem(
            'akima_comp',
            comp,
            promotes_inputs=['chord_cp', 'theta_cp'],
            promotes_outputs=['chord_interp', 'theta_interp'])
        prob.setup()

        # Make sure we don't get an exception
        prob.run_model()