Exemplo n.º 1
0
    def test_ivc_deprecations(self):
        msg = "IndepVarComp (p1): The '{}' argument was used when adding output '{}'. " + \
              "This argument has been deprecated and will be removed in a future version."

        prob = om.Problem()

        indep = prob.model.add_subsystem('p1', om.IndepVarComp())

        # ref, ref0
        with assert_warnings([(DeprecationWarning, msg.format('ref', 'a')),
                              (DeprecationWarning, msg.format('ref0', 'a'))]):
            indep.add_output('a', 12., ref=0.0, ref0=1.)

        # res_units
        with assert_warning(DeprecationWarning, msg.format('res_units', 'b')):
            indep.add_output('b', 12., res_units='m')

        # upper
        with assert_warning(DeprecationWarning, msg.format('upper', 'c')):
            indep.add_output('c', 12., upper=1.)

        # lower
        with assert_warning(DeprecationWarning, msg.format('lower', 'd')):
            indep.add_output('d', 12., lower=1.)

        # res_ref
        with assert_warning(DeprecationWarning, msg.format('res_ref', 'e')):
            indep.add_output('e', 12., res_ref=1.)

        # res_ref
        with assert_warning(DeprecationWarning, msg.format('ref', 'f')):
            indep.add_output('f', 12., ref=2.)
Exemplo n.º 2
0
    def test_regression_bug_fix_issue_2062_sql_meta_file_running_parallel(self):

        from openmdao.test_suite.components.paraboloid import Paraboloid

        prob = om.Problem()

        prob.model.add_subsystem('comp', Paraboloid(), promotes=['x', 'y', 'f_xy'])
        prob.model.add_design_var('x', lower=0.0, upper=1.0)
        prob.model.add_design_var('y', lower=0.0, upper=1.0)
        prob.model.add_objective('f_xy')

        prob.driver = om.DOEDriver(om.FullFactorialGenerator(levels=3))
        prob.driver.options['run_parallel'] = True
        prob.driver.options['procs_per_model'] = 1

        prob.driver.add_recorder(om.SqliteRecorder("cases.sql"))

        prob.setup()
        prob.run_driver()
        prob.cleanup()

        # Run this again. Because of the bug fix for issue 2062, this code should NOT
        #   throw an exception
        prob = om.Problem()

        prob.model.add_subsystem('comp', Paraboloid(), promotes=['x', 'y', 'f_xy'])
        prob.model.add_design_var('x', lower=0.0, upper=1.0)
        prob.model.add_design_var('y', lower=0.0, upper=1.0)
        prob.model.add_objective('f_xy')

        prob.driver = om.DOEDriver(om.FullFactorialGenerator(levels=3))
        prob.driver.options['run_parallel'] = True
        prob.driver.options['procs_per_model'] = 1

        prob.driver.add_recorder(om.SqliteRecorder("cases.sql"))

        prob.setup()

        if prob.comm.rank == 0:
            expected_warnings = [
                                 (UserWarning,
                                  'The existing case recorder metadata file, cases.sql_meta, '
                                  'is being overwritten.'),
                                 (UserWarning,
                                  'The existing case recorder file, cases.sql_0, is being '
                                  'overwritten.'),
                                 ]
        else:
            expected_warnings = [
                                (UserWarning,
                                  'The existing case recorder file, cases.sql_1, is being '
                                  'overwritten.'),
                                 ]
        with assert_warnings(expected_warnings):
            prob.run_driver()

        prob.cleanup()
Exemplo n.º 3
0
    def test_sql_meta_file_exists(self):
        # Check that an existing sql_meta file will be deleted/overwritten
        # if it already exists before a run. (see Issue #2062)
        prob = om.Problem()

        prob.model.add_subsystem('comp', Paraboloid(), promotes=['x', 'y', 'f_xy'])
        prob.model.add_design_var('x', lower=0.0, upper=1.0)
        prob.model.add_design_var('y', lower=0.0, upper=1.0)
        prob.model.add_objective('f_xy')

        prob.driver = om.DOEDriver(om.FullFactorialGenerator(levels=3))
        prob.driver.options['run_parallel'] = True
        prob.driver.options['procs_per_model'] = 1

        prob.driver.add_recorder(om.SqliteRecorder("cases.sql"))

        prob.setup()
        prob.run_driver()
        prob.cleanup()

        # Run this again. It should NOT throw an exception.
        prob = om.Problem()

        prob.model.add_subsystem('comp', Paraboloid(), promotes=['x', 'y', 'f_xy'])
        prob.model.add_design_var('x', lower=0.0, upper=1.0)
        prob.model.add_design_var('y', lower=0.0, upper=1.0)
        prob.model.add_objective('f_xy')

        prob.driver = om.DOEDriver(om.FullFactorialGenerator(levels=3))
        prob.driver.options['run_parallel'] = True
        prob.driver.options['procs_per_model'] = 1

        prob.driver.add_recorder(om.SqliteRecorder("cases.sql"))

        prob.setup()

        if prob.comm.rank == 0:
            expected_warnings = [
                (UserWarning,
                'The existing case recorder metadata file, cases.sql_meta, '
                'is being overwritten.'),
                (UserWarning,
                'The existing case recorder file, cases.sql_0, is being '
                'overwritten.'),
            ]
        else:
            expected_warnings = [
                (UserWarning,
                    'The existing case recorder file, cases.sql_1, is being '
                    'overwritten.'),
            ]
        with assert_warnings(expected_warnings):
            prob.run_driver()

        prob.cleanup()