From a893d0890177e7bc3d1a590ae5a2fca178106371 Mon Sep 17 00:00:00 2001 From: dzalkind Date: Fri, 1 Dec 2023 16:34:56 -0700 Subject: [PATCH] Put test in function --- tests/test_omdao_VolturnUS-S.py | 45 ++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/tests/test_omdao_VolturnUS-S.py b/tests/test_omdao_VolturnUS-S.py index d62f760..94af579 100644 --- a/tests/test_omdao_VolturnUS-S.py +++ b/tests/test_omdao_VolturnUS-S.py @@ -16,30 +16,35 @@ # ----------------------------------- # OMDAO # ----------------------------------- -this_dir = os.path.dirname(__file__) -# Load options directly generated in WEIS -with open(os.path.join(this_dir,'test_data',weis_options_file)) as file: - opt = yaml.load(file, Loader=yaml.FullLoader) +def test_omdao_raft(): + this_dir = os.path.dirname(__file__) -prob = om.Problem() -prob.model = RAFT_Group(modeling_options=opt['modeling_options'], - analysis_options=opt['analysis_options'], - turbine_options=opt['turbine_options'], - mooring_options=opt['mooring_options'], - member_options=opt['member_options']) -prob.setup() + # Load options directly generated in WEIS + with open(os.path.join(this_dir,'test_data',weis_options_file)) as file: + opt = yaml.load(file, Loader=yaml.FullLoader) -# ------------------------- -# inputs -# ------------------------- -# Load options directly generated in WEIS -with open(os.path.join(this_dir,'test_data',weis_inputs_file)) as file: - inputs = yaml.load(file, Loader=yaml.FullLoader) + prob = om.Problem() + prob.model = RAFT_Group(modeling_options=opt['modeling_options'], + analysis_options=opt['analysis_options'], + turbine_options=opt['turbine_options'], + mooring_options=opt['mooring_options'], + member_options=opt['member_options']) + prob.setup() -for key, val in inputs.items(): - prob[key] = val + # ------------------------- + # inputs + # ------------------------- + # Load options directly generated in WEIS + with open(os.path.join(this_dir,'test_data',weis_inputs_file)) as file: + inputs = yaml.load(file, Loader=yaml.FullLoader) + for key, val in inputs.items(): + prob[key] = val -prob.run_model() + + prob.run_model() + +if __name__=="__main__": + test_omdao_raft()