From 8c789fff8815a827a8e53402931372d5eeb42612 Mon Sep 17 00:00:00 2001 From: misha Date: Tue, 12 Dec 2023 14:25:00 -0700 Subject: [PATCH] Changing helicsport to sidestep bug with not connecting on correct port. --- .../02_amr_wind_dummy_only/amr_input.inp | 2 +- .../02_amr_wind_dummy_only/bash_script.sh | 5 +++-- hercules/dummy_amr_wind.py | 14 ++++++++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) mode change 100644 => 100755 example_case_folders/02_amr_wind_dummy_only/bash_script.sh diff --git a/example_case_folders/02_amr_wind_dummy_only/amr_input.inp b/example_case_folders/02_amr_wind_dummy_only/amr_input.inp index 3815a2b2..27fe02fd 100755 --- a/example_case_folders/02_amr_wind_dummy_only/amr_input.inp +++ b/example_case_folders/02_amr_wind_dummy_only/amr_input.inp @@ -76,7 +76,7 @@ ABL.stats_output_format = netcdf # Whether to use helics helics.activated = true -helics.broker_port =32000 +helics.broker_port = 32000 #¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨# # ADAPTIVE MESH REFINEMENT # diff --git a/example_case_folders/02_amr_wind_dummy_only/bash_script.sh b/example_case_folders/02_amr_wind_dummy_only/bash_script.sh old mode 100644 new mode 100755 index 953181e9..219fe6f1 --- a/example_case_folders/02_amr_wind_dummy_only/bash_script.sh +++ b/example_case_folders/02_amr_wind_dummy_only/bash_script.sh @@ -5,12 +5,13 @@ conda activate hercules # Set the helics port to use: -export HELICS_PORT=32000 +export HELICS_PORT=23404 #make sure you use the same port number in the amr_input.inp and hercules_input_000.yaml files. # Set up the helics broker -helics_broker -f 2 --consoleloglevel=trace --loglevel=debug --local_port=$HELICS_PORT & +helics_broker -t zmq -f 2 --loglevel="debug" --local_port=$HELICS_PORT & +#helics_broker -f 2 --consoleloglevel=trace --loglevel=debug --local_port=$HELICS_PORT >> loghelics & # Need to set this to your hercules folder # cd /home/pfleming/hercules/hercules diff --git a/hercules/dummy_amr_wind.py b/hercules/dummy_amr_wind.py index e51eb814..30bf9ac8 100644 --- a/hercules/dummy_amr_wind.py +++ b/hercules/dummy_amr_wind.py @@ -81,12 +81,18 @@ def read_amr_wind_input(amr_wind_input): for f in line.split()[-3:-1]]) turbine_locations.append(locations) + # Get the helics port + for line in Lines: + if 'helics.broker_port' in line: + broker_port = int(line.split()[2]) + return_dict = { 'dt':dt, 'num_turbines': num_turbines, 'turbine_labels': turbine_labels, 'rotor_diameter': D, - 'turbine_locations': turbine_locations + 'turbine_locations': turbine_locations, + 'helics_port': broker_port, } @@ -238,6 +244,9 @@ def process_subscription_messages(self, msg): def launch_dummy_amr_wind(amr_input_file): + temp = read_amr_wind_input(amr_input_file) + print(temp["helics_port"]) + config = { "name": "dummy_amr_wind", "gridpack": { @@ -253,7 +262,8 @@ def launch_dummy_amr_wind(amr_input_file): ], "endpoints": [ - ] + ], + "helicsport":temp["helics_port"], }, "publication_interval": 1,