def test_update():
    if is_dakota_installed():
        model = PolynomialChaos()
        model.initialize()
        model.update()
        assert_true(os.path.exists(dakota_files["input"]))
        assert_true(os.path.exists(dakota_files["output"]))
        assert_true(os.path.exists(dakota_files["data"]))
def test_update():
    if is_dakota_installed():
        model = StochasticCollocation()
        model.initialize()
        model.update()
        assert_true(os.path.exists(dakota_files["input"]))
        assert_true(os.path.exists(dakota_files["output"]))
        assert_true(os.path.exists(dakota_files["data"]))
Beispiel #3
0
def test_update():
    if is_dakota_installed():
        model = CenteredParameterStudy()
        model.initialize()
        model.update()
        assert_true(os.path.exists(dakota_files["input"]))
        assert_true(os.path.exists(dakota_files["output"]))
        assert_true(os.path.exists(dakota_files["data"]))
Beispiel #4
0
def test_default_run_with_input_file():
    """Test default object run method with input file."""
    if is_dakota_installed():
        k = Dakota()
        k.write_input_file()
        k.run()
        assert_true(os.path.exists(k.output_file))
        assert_true(os.path.exists(k.environment.data_file))
Beispiel #5
0
def test_update():
    if is_dakota_installed():
        model = BmiDakota()
        model.initialize(None)
        model.update()
        assert_true(os.path.exists(dakota_files["input"]))
        assert_true(os.path.exists(dakota_files["output"]))
        assert_true(os.path.exists(dakota_files["data"]))
Beispiel #6
0
def test_default_run_without_input_file():
    """Test default object run method fails with no input file."""
    if is_dakota_installed():
        if os.path.exists(input_file):
            os.remove(input_file)
        try:
            k = Dakota()
            k.run()
        except CalledProcessError:
            pass
Beispiel #7
0
def test_run_from_config_file():
    """Test running a HydroTrend simulation from a config file."""
    d = Dakota.from_file_like(known_config_file)
    d.run_directory = run_dir
    d.template_file = os.path.join(data_dir, "HYDRO.IN.dtmpl")
    d.auxiliary_files = os.path.join(data_dir, "HYDRO0.HYPS")
    d.serialize(config_file)
    d.write_input_file()
    assert_true(os.path.exists(d.input_file))
    if is_dakota_installed() and is_hydrotrend_installed():
        d.run()
        assert_true(os.path.exists(d.output_file))
Beispiel #8
0
def teardown():
    """Called at end of any test using it @with_setup()"""
    if os.path.exists(config_file):
        os.remove(config_file)
    if os.path.exists("dakota.in"):
        os.remove("dakota.in")
    if os.path.exists("run.log"):
        os.remove("run.log")
    if os.path.exists("stderr.log"):
        os.remove("stderr.log")
    if is_hydrotrend_installed():
        for dname in glob.glob("HYDRO_*"):
            shutil.rmtree(dname)
    if is_dakota_installed():
        for dname in glob.glob("run.*"):
            shutil.rmtree(dname)
        for fname in ["dakota." + ext for ext in ["dat", "out", "rst"]]:
            if os.path.exists(fname):
                os.remove(fname)
Beispiel #9
0
def test_run_by_setting_attributes():
    """Test running a HydroTrend simulation."""
    d = Dakota(method="vector_parameter_study", plugin="hydrotrend")
    d.template_file = os.path.join(data_dir, "HYDRO.IN.dtmpl")
    d.auxiliary_files = os.path.join(data_dir, "HYDRO0.HYPS")
    d.variables.descriptors = [
        "starting_mean_annual_temperature",
        "total_annual_precipitation",
    ]
    d.variables.initial_point = [10.0, 1.5]
    d.method.final_point = [20.0, 2.5]
    d.method.n_steps = 5
    d.responses.response_descriptors = ["Qs_median", "Q_mean"]
    d.responses.response_files = ["HYDROASCII.QS", "HYDROASCII.Q"]
    d.responses.response_statistics = ["median", "mean"]
    d.setup()
    assert_true(os.path.exists(d.input_file))
    if is_dakota_installed() and is_hydrotrend_installed():
        d.run()
        assert_true(os.path.exists(d.output_file))
Beispiel #10
0
def test_changing_parameter_names():
    """Test ability to provide parameter names."""
    run_directory = "looped_runs"
    configuration_file = "an_excellent_yaml.yaml"
    run_log = "run_output_here.log"
    error_log = "no_errors_here.log"
    if is_dakota_installed():
        k = Dakota(
            method="vector_parameter_study",
            run_directory=run_directory,
            configuration_file=configuration_file,
            run_log=run_log,
            error_log=error_log,
        )
        k.write_input_file()
        k.serialize()
        k.run()

        os.remove(configuration_file)
        os.remove(run_log)
        os.remove(error_log)
        teardown_module()
        os.chdir("..")
        os.rmdir(run_directory)
def test_finalize():
    if is_dakota_installed():
        model = PolynomialChaos()
        model.initialize()
        model.update()
        model.finalize()
Beispiel #12
0
def test_finalize():
    if is_dakota_installed():
        model = CenteredParameterStudy()
        model.initialize()
        model.update()
        model.finalize()
Beispiel #13
0
def test_finalize():
    if is_dakota_installed():
        model = PsuadeMoat()
        model.initialize()
        model.update()
        model.finalize()
def test_finalize():
    if is_dakota_installed():
        model = Sampling()
        model.initialize()
        model.update()
        model.finalize()
def test_finalize():
    if is_dakota_installed():
        model = StochasticCollocation()
        model.initialize()
        model.update()
        model.finalize()
Beispiel #16
0
def test_finalize():
    if is_dakota_installed():
        model = BmiDakota()
        model.initialize(None)
        model.update()
        model.finalize()