Exemplo n.º 1
0
 def run_driver(name, driver):
     pb = SellarProblem()
     case_recorder_filename = "test_openturns_doe_{}.sqlite".format(name)
     recorder = SqliteRecorder(case_recorder_filename)
     pb.driver = driver
     pb.driver.add_recorder(recorder)
     pb.setup()
     pb.run_driver()
     pb.cleanup()
     return pb, case_recorder_filename
    def assert_case_generation(self, n, driver):
        pb = SellarProblem()
        pb.driver = driver
        case_recorder_filename = "test_smt_doe_driver_{}.sqlite".format(n)
        recorder = SqliteRecorder(case_recorder_filename)
        pb.driver.add_recorder(recorder)
        pb.setup()
        pb.run_driver()
        pb.cleanup()

        reader = CaseReader(case_recorder_filename)
        cases = reader.list_cases("driver")
        os.remove(case_recorder_filename)
        self.assertEqual(len(cases), n)
Exemplo n.º 3
0
    def test_auto_ivc_case(self):
        prob = SellarProblem(SellarDerivativesGrouped)

        prob.driver = om.ScipyOptimizeDriver(tol=1e-9, disp=False)
        prob.driver.add_recorder(self.recorder)

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

        cr = om.CaseReader(self.filename)
        first_case = cr.list_cases()[0]

        data_dict = _get_viewer_data(self.filename, case_id=first_case)

        vals = data_dict['tree']['children'][0]['children']
        ivc_0_val = vals[0]['value']
        ivc_1_val = vals[1]['value']

        self.assertEqual(ivc_0_val, [5., 2])
        self.assertEqual(ivc_1_val, np.array([1.]))