def configure(self):

        self.add('d1', Discipline1_WithDerivatives())
        self.d1.x1 = 1.0
        self.d1.y1 = 1.0
        self.d1.y2 = 1.0
        self.d1.z1 = 5.0
        self.d1.z2 = 2.0

        self.add('d2', Discipline2_WithDerivatives())
        self.d2.y1 = 1.0
        self.d2.y2 = 1.0
        self.d2.z1 = 5.0
        self.d2.z2 = 2.0

        self.add('P1', Paraboloid())
        self.add('P2', Paraboloid())

        self.connect('d1.y1', 'd2.y1')
        self.connect('P1.f_xy', 'd1.x1')
        self.connect('d1.y1', 'P2.x')
        self.connect('d2.y2', 'P2.y')

        self.add('driver', SimpleDriver())
        self.add('driver2', Driver())
        self.add('subdriver', NewtonSolver())
        self.driver.workflow.add(['P1', 'subdriver', 'P2'])
        self.subdriver.workflow.add(['d1', 'd2'])

        self.subdriver.add_parameter('d1.y2', low=-1e99, high=1e99)
        self.subdriver.add_constraint('d1.y2 = d2.y2')

        self.driver.add_parameter('P1.x', low=-1e99, high=1e99)
        self.driver.add_constraint('P2.f_xy < 0')
Ejemplo n.º 2
0
    def test_newton_nested(self):
        # Make sure derivatives across the newton-solved system are correct.

        top = set_as_top(Assembly())
        top.add('driver', SimpleDriver())

        top.add('d1', Discipline1_WithDerivatives())
        top.d1.x1 = 1.0
        top.d1.y1 = 1.0
        top.d1.y2 = 1.0
        top.d1.z1 = 5.0
        top.d1.z2 = 2.0

        top.add('d2', Discipline2_WithDerivatives())
        top.d2.y1 = 1.0
        top.d2.y2 = 1.0
        top.d2.z1 = 5.0
        top.d2.z2 = 2.0

        top.connect('d1.y1', 'd2.y1')

        top.add('solver', NewtonSolver())
        top.solver.atol = 1e-9
        top.solver.workflow.add(['d1', 'd2'])
        top.solver.add_parameter('d1.y2', low=-1e99, high=1e99)
        top.solver.add_constraint('d1.y2 = d2.y2')

        top.driver.workflow.add(['solver'])
        top.driver.add_parameter('d1.z1', low=-100, high=100)
        top.driver.add_objective('d1.y1 + d1.y2')

        top.run()

        J = top.driver.calc_gradient(mode='forward')
        print J
        assert_rel_error(self, J[0][0], 10.77542099, 1e-5)

        J = top.driver.calc_gradient(mode='adjoint')
        print J
        assert_rel_error(self, J[0][0], 10.77542099, 1e-5)

        top.driver.gradient_options.fd_step = 1e-7
        top.driver.gradient_options.fd_form = 'central'
        J = top.driver.calc_gradient(mode='fd')
        print J
        assert_rel_error(self, J[0][0], 10.77542099, 1e-5)
    def configure(self):

        self.add('d1', Discipline1_WithDerivatives())
        self.d1.x1 = 1.0
        self.d1.y1 = 1.0
        self.d1.y2 = 1.0
        self.d1.z1 = 5.0
        self.d1.z2 = 2.0

        self.add('d2', Discipline2_WithDerivatives())
        self.d2.y1 = 1.0
        self.d2.y2 = 1.0
        self.d2.z1 = 5.0
        self.d2.z2 = 2.0

        self.connect('d1.y1', 'd2.y1')
        self.connect('d2.y2', 'd1.y2')

        self.add('driver', FixedPointIterator())
        self.driver.workflow.add(['d1', 'd2'])
Ejemplo n.º 4
0
    def configure(self):

        self.add('d1', Discipline1())
        self.d1.x1 = 1.0
        self.d1.y1 = 1.0
        self.d1.y2 = 1.0
        self.d1.z1 = 5.0
        self.d1.z2 = 2.0

        self.add('d2', Discipline2_WithDerivatives())
        self.d2.y1 = 1.0
        self.d2.y2 = 1.0
        self.d2.z1 = 5.0
        self.d2.z2 = 2.0

        self.connect('d1.y1', 'd2.y1')
        self.connect('d2.y2', 'd1.y2')

        self.add('driver', NewtonSolver())
        self.driver.workflow.add(['d1', 'd2'])
Ejemplo n.º 5
0
    def configure(self):

        self.add('d1', Discipline1())
        self.d1.x1 = 1.0
        self.d1.y1 = 1.0
        self.d1.y2 = 1.0
        self.d1.z1 = 5.0
        self.d1.z2 = 2.0

        self.add('d2', Discipline2_WithDerivatives())
        self.d2.y1 = 1.0
        self.d2.y2 = 1.0
        self.d2.z1 = 5.0
        self.d2.z2 = 2.0

        self.connect('d1.y1', 'd2.y1')
        #self.connect('d2.y2', 'd1.y2')

        self.add('driver', NewtonSolver())
        self.driver.workflow.add(['d1', 'd2'])
        self.driver.add_parameter('d1.y2', low=-1e99, high=1e99)
        self.driver.add_constraint('d1.y2 = d2.y2')