Skip to content

Commit

Permalink
Use more descriptive names and documentation for wfc_interface
Browse files Browse the repository at this point in the history
  • Loading branch information
abhineet-gupta committed Aug 9, 2024
1 parent c3c2296 commit 84de003
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
15 changes: 13 additions & 2 deletions Examples/17a_zeromq_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,28 @@ def run_zmq(logfile=None):
network_address = "tcp://*:5555"
server = wfc_zmq_server(network_address, timeout=60.0, verbose=False, logfile=logfile)

# Provide the wind farm control algorithm as the wfc_controller method of the server
# Provide the wind farm control algorithm as the wfc_controller subclass of the server
server.wfc_controller = wfc_controller()

# Run the server to receive measurements and send setpoints
server.runserver()

class wfc_controller():
"""
Users needs to define this class to implement wind farm controller.
This class should contain a method named update_setpoints that
should take as argument the turbine id, the current time and current
measurements and return the setpoints for the particular turbine for
the current time. It should ouput the setpoints as a dictionary whose
keys should be as defined in wfc_zmq_server.wfc_interface.
The wfc_controller subclass of the wfc_zmq_server should be overwriten
with this class, otherwise, an exception is raised and the simulation stops.
"""

def __init__(self):
return None

def update(self, id,current_time,measurements):
def update_setpoints(self, id,current_time,measurements):
if current_time <= 10.0:
yaw_setpoint = 0.0
else:
Expand Down
25 changes: 13 additions & 12 deletions Examples/17b_zeromq_multi_openfast.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,29 @@ def run_zmq(logfile=None):
network_address = "tcp://*:5555"
server = wfc_zmq_server(network_address, timeout=60.0, verbose=False, logfile = logfile)

# Provide the wind farm control algorithm as the wfc_controller method of the server
# Provide the wind farm control algorithm as the wfc_controller subclass of the server
server.wfc_controller = wfc_controller()

# Run the server to receive measurements and send setpoints
server.runserver()


class wfc_controller():
"""
Users needs to define this class to implement wind farm controller.
This class should contain a method named update_setpoints that
should take as argument the turbine id, the current time and current
measurements and return the setpoints for the particular turbine for
the current time. It should ouput the setpoints as a dictionary whose
keys should be as defined in wfc_zmq_server.wfc_interface.
The wfc_controller subclass of the wfc_zmq_server should be overwriten
with this class, otherwise, an exception is raised and the simulation stops.
"""

def __init__(self):
return None

def update(self, id, current_time, measurements):
"""
Users needs to define this function to implement wind farm controller.
The user defined function should take as argument the turbine id, the
current time and current measurements and return the setpoints
for the particular turbine for the current time. It should ouput the
setpoints as a dictionary whose keys should be as defined in
wfc_zmq_server.wfc_interface. The wfc_controller method of the wfc_zmq_server
should be overwriten with this fuction, otherwise, an exception is raised and
the simulation stops.
"""
def update_setpoints(self, id, current_time, measurements):
if current_time <= 10.0:
YawOffset = 0.0
col_pitch_command = 0.0
Expand Down
2 changes: 1 addition & 1 deletion rosco/toolbox/control_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def _get_setpoints(self, id, measurements):
logger.debug(
f"Asking wfc_controller for setpoints at time = {current_time} for id = {id}"
)
setpoints = self.wfc_controller.update(id, current_time, measurements)
setpoints = self.wfc_controller.update_setpoints(id, current_time, measurements)
logger.info(f"Received setpoints {setpoints} from wfc_controller for time = {current_time} and id = {id}")

for s in self.wfc_interface["setpoints"]:
Expand Down

0 comments on commit 84de003

Please sign in to comment.