Exemplo n.º 1
0
            def setup(self):
                indeps = self.add_subsystem('indeps',
                                            om.IndepVarComp(),
                                            promotes=['*'])
                indeps.add_output('x', 1.0)
                indeps.add_output('z', np.array([5.0, 2.0]))
                cycle = self.add_subsystem('cycle',
                                           om.ParallelGroup(),
                                           promotes=['*'])
                cycle.add_subsystem('d1',
                                    SellarDis1(),
                                    promotes_inputs=['x', 'z', 'y2'],
                                    promotes_outputs=['y1'])
                cycle.add_subsystem('d2',
                                    SellarDis2(),
                                    promotes_inputs=['z', 'y1'],
                                    promotes_outputs=['y2'])

                # Nonlinear Block Gauss Seidel is a gradient free solver
                cycle.nonlinear_solver = om.NonlinearBlockGS()

                self.add_subsystem('obj_cmp',
                                   om.ExecComp(
                                       'obj = x**2 + z[1] + y1 + exp(-y2)',
                                       z=np.array([0.0, 0.0]),
                                       x=0.0),
                                   promotes=['x', 'z', 'y1', 'y2', 'obj'])

                self.add_subsystem('con_cmp1',
                                   om.ExecComp('con1 = 3.16 - y1'),
                                   promotes=['con1', 'y1'])
                self.add_subsystem('con_cmp2',
                                   om.ExecComp('con2 = y2 - 24.0'),
                                   promotes=['con2', 'y2'])
Exemplo n.º 2
0
    def setup(self):
        indeps = self.add_subsystem('indeps', IndepVarComp())
        indeps.add_output('x', 1.0)
        indeps.add_output('z', np.array([5.0, 2.0]))

        cycle = self.add_subsystem('cycle', Group())
        d1 = cycle.add_subsystem('d1', SellarDis1())
        d2 = cycle.add_subsystem('d2', SellarDis2())
        cycle.connect('d1.y1', 'd2.y1')
    
        ######################################
        # This is a "forgotten" connection!!
        ######################################
        #cycle.connect('d2.y2', 'd1.y2')

        # Nonlinear Block Gauss Seidel is a gradient free solver
        cycle.nonlinear_solver = NonlinearBlockGS()

        self.add_subsystem('obj_cmp', ExecComp('obj = x**2 + z[1] + y1 + exp(-y2)',
                                               z=np.array([0.0, 0.0]), x=0.0))

        self.add_subsystem('con_cmp1', ExecComp('con1 = 3.16 - y1'))
        self.add_subsystem('con_cmp2', ExecComp('con2 = y2 - 24.0'))

        self.connect('indeps.x', ['cycle.d1.x', 'obj_cmp.x'])
        self.connect('indeps.z', ['cycle.d1.z', 'cycle.d2.z', 'obj_cmp.z'])
        self.connect('cycle.d1.y1', ['obj_cmp.y1', 'con_cmp1.y1'])        
        self.connect('cycle.d2.y2', ['obj_cmp.y2', 'con_cmp2.y2'])
Exemplo n.º 3
0
            def setup(self):
                cycle = self.add_subsystem('cycle', om.Group(), promotes=['*'])
                cycle.add_subsystem('d1',
                                    SellarDis1(),
                                    promotes_inputs=['x', 'z'])
                cycle.add_subsystem('d2', SellarDis2(), promotes_inputs=['z'])
                cycle.connect('d1.y1', 'd2.y1')
                cycle.connect('d2.y2', 'd1.y2')

                cycle.set_input_defaults('x', 1.0)
                cycle.set_input_defaults('z', np.array([5.0, 2.0]))

                # Nonlinear Block Gauss Seidel is a gradient free solver
                cycle.nonlinear_solver = om.NonlinearBlockGS()

                self.add_subsystem('obj_cmp',
                                   om.ExecComp(
                                       'obj = x**2 + z[1] + y1 + exp(-y2)',
                                       z=np.array([0.0, 0.0]),
                                       x=0.0),
                                   promotes_inputs=['x', 'z'])

                self.add_subsystem('con_cmp1', om.ExecComp('con1 = 3.16 - y1'))
                self.add_subsystem('con_cmp2', om.ExecComp('con2 = y2 - 24.0'))

                self.connect('d1.y1', ['con_cmp1.y1', 'obj_cmp.y1'])
                self.connect('d2.y2', ['con_cmp2.y2', 'obj_cmp.y2'])
Exemplo n.º 4
0
            def setup(self):
                # set up model hierarchy
                cycle = self.add_subsystem('cycle', om.Group())
                cycle.add_subsystem('d1', SellarDis1())
                cycle.add_subsystem('d2', SellarDis2())

                cycle.nonlinear_solver = om.NonlinearBlockGS()

                self.add_subsystem(
                    'obj_cmp',
                    om.ExecComp('obj = x**2 + z[1] + y1 + exp(-y2)',
                                z=np.array([0.0, 0.0]),
                                x=0.0))

                self.add_subsystem('con_cmp1', om.ExecComp('con1 = 3.16 - y1'))
                self.add_subsystem('con_cmp2', om.ExecComp('con2 = y2 - 24.0'))
Exemplo n.º 5
0
            def setup(self):
                cycle = self.add_subsystem('cycle', om.Group(), promotes_inputs=['x', 'z'])
                cycle.add_subsystem('d1', SellarDis1(), promotes_inputs=['x', 'z'])
                cycle.add_subsystem('d2', SellarDis2(), promotes_inputs=['z'])
                cycle.connect('d1.y1', 'd2.y1')

                cycle.nonlinear_solver = om.NonlinearBlockGS()

                self.add_subsystem('obj_cmp', om.ExecComp('obj = x**2 + z[1] + y1 + exp(-y2)',
                                                          z=np.array([0.0, 0.0]), x=0.0),
                                   promotes_inputs=['x', 'z'])

                self.add_subsystem('con_cmp1', om.ExecComp('con1 = 3.16 - y1'))
                self.add_subsystem('con_cmp2', om.ExecComp('con2 = y2 - 24.0'))

                self.connect('cycle.d1.y1', ['obj_cmp.y1', 'con_cmp1.y1'])
                self.connect('cycle.d2.y2', ['obj_cmp.y2', 'con_cmp2.y2'])
Exemplo n.º 6
0
            def setup(self):
                # set up model hierarchy
                indeps = self.add_subsystem('indeps',
                                            om.IndepVarComp(),
                                            promotes=['*'])
                indeps.add_output('x', 1.0)
                indeps.add_output('z', np.array([5.0, 2.0]))

                cycle = self.add_subsystem('cycle', om.Group())
                cycle.add_subsystem('d1', SellarDis1())
                cycle.add_subsystem('d2', SellarDis2())

                cycle.nonlinear_solver = om.NonlinearBlockGS()

                self.add_subsystem(
                    'obj_cmp',
                    om.ExecComp('obj = x**2 + z[1] + y1 + exp(-y2)',
                                z=np.array([0.0, 0.0]),
                                x=0.0))

                self.add_subsystem('con_cmp1', om.ExecComp('con1 = 3.16 - y1'))
                self.add_subsystem('con_cmp2', om.ExecComp('con2 = y2 - 24.0'))