/home/runner/work/kynema-fmb/kynema-fmb/kynema-fmb/src/interfaces/components/controller.hpp Source File

Kynema-FMB API: /home/runner/work/kynema-fmb/kynema-fmb/kynema-fmb/src/interfaces/components/controller.hpp Source File
Kynema-FMB API
A flexible multibody structural dynamics code for wind turbines
Loading...
Searching...
No Matches
controller.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <functional>
5#include <string>
6
8#include "controller_io.hpp"
10
12
16public:
19 explicit Controller(const ControllerInput& input);
20
22 void CallController();
23
25 [[nodiscard]] double PitchAngleCommand() const { return this->pitch_angle_command_; }
26
28 [[nodiscard]] std::array<double, 3> PitchAngleCommandIndividual() const {
29 return {
32 };
33 }
34
36 [[nodiscard]] double GeneratorTorqueCommand() const { return this->generator_torque_command_; }
37
39 [[nodiscard]] double YawAngleCommand() const { return this->yaw_angle_command_; }
40
42 void SetStatusInit() { this->io.status = 0; }
43
45 void SetStatusOperating() { this->io.status = 1; }
46
48 void SetStatusWriteCheckpoint() { this->io.status = -8; }
49
51 void SetStatusReadCheckpoint() { this->io.status = -9; }
52
54 void SetSimulationTime(double simulation_time) { this->io.time = simulation_time; }
55
57 void SetSimulationTimeStep(double simulation_time_step) { this->io.dt = simulation_time_step; }
58
60 void SetYawAngle(double yaw_angle) { this->io.yaw_angle_actual = yaw_angle; }
61
63 void SetRotorSpeed(double rotor_speed) { this->io.rotor_speed_actual = rotor_speed; }
64
66 void SetGeneratorSpeed(double generator_speed) {
67 this->io.generator_speed_actual = generator_speed;
68 }
69
71 void SetGeneratorTorque(double generator_torque) {
72 this->io.generator_torque_actual = generator_torque;
73 }
74
76 void SetGeneratorPower(double generator_power) {
77 this->io.generator_power_actual = generator_power;
78 }
79
81 void SetWindSpeed(double wind_speed) { this->io.horizontal_wind_speed = wind_speed; }
82
84 void SetRotorAzimuth(double rotor_azimuth) { this->io.azimuth_angle = rotor_azimuth; }
85
87 void SetBladePitch(double blade_pitch_collective) {
88 this->io.pitch_blade1_actual = blade_pitch_collective;
89 this->io.pitch_blade2_actual = blade_pitch_collective;
90 this->io.pitch_blade3_actual = blade_pitch_collective;
91 }
92
94 void SetBladePitch(std::array<double, 3> blade_pitch) {
95 this->io.pitch_blade1_actual = blade_pitch[0];
96 this->io.pitch_blade2_actual = blade_pitch[1];
97 this->io.pitch_blade3_actual = blade_pitch[2];
98 }
99
101 void SetOutOfPlaneRootBendingMoment(std::array<double, 3> root_moment) {
102 this->io.out_of_plane_root_bending_moment_blade1 = root_moment[0];
103 this->io.out_of_plane_root_bending_moment_blade2 = root_moment[1];
104 this->io.out_of_plane_root_bending_moment_blade3 = root_moment[2];
105 }
106
107private:
109 ControllerIO io;
110
111 bool pitch_control_enabled_{false}; //< Flag to enable pitch control
112 bool torque_control_enabled_{false}; //< Flag to enable torque control
113 bool yaw_control_enabled_{false}; //< Flag to enable yaw control
114
115 double generator_torque_command_{0.0}; //< Commanded torque (Nm)
116 double pitch_angle_command_{0.0}; //< Commanded pitch angle (rad)
117 double yaw_angle_command_{0.0}; //< Commanded yaw angle (rad) integrated from yaw rate command
118
119 std::string input_file_path_; //< Path to the input file
120 std::string output_file_path_; //< Path to the output file
121 std::string shared_lib_path_; //< Path to shared library
122 std::string controller_function_name_; //< Name of the controller function in the shared library
123
124 util::dylib lib_; //< Handle to the shared library
125 std::function<void(float*, int*, const char* const, const char* const, char* const)>
126 controller_function_; //< Function pointer to the controller function
127};
128
129} // namespace kynema_fmb::interfaces::components
void SetYawAngle(double yaw_angle)
Set the measured yaw angle (rad)
Definition controller.hpp:60
void SetStatusReadCheckpoint()
Set the controller status to read checkpoint file (only valid for ROSCO controller)
Definition controller.hpp:51
void SetGeneratorTorque(double generator_torque)
Set the measured generator torque (Nm)
Definition controller.hpp:71
void SetRotorSpeed(double rotor_speed)
Set the measured rotor speed (rad/s)
Definition controller.hpp:63
void SetStatusInit()
Set the controller status to initialization.
Definition controller.hpp:42
void SetStatusOperating()
Set the controller status to operating.
Definition controller.hpp:45
void SetGeneratorPower(double generator_power)
Set measured generator power (W)
Definition controller.hpp:76
void SetSimulationTimeStep(double simulation_time_step)
Set the simulation time step (s)
Definition controller.hpp:57
void SetBladePitch(double blade_pitch_collective)
Set measured blade pitch angle (rad)
Definition controller.hpp:87
void SetStatusWriteCheckpoint()
Set the controller status to write checkpoint file (only valid for ROSCO controller)
Definition controller.hpp:48
void SetGeneratorSpeed(double generator_speed)
Set the measured generator speed (rad/s)
Definition controller.hpp:66
double PitchAngleCommand() const
Get the collective commanded pitch angle (rad)
Definition controller.hpp:25
void CallController()
Method to call the controller function from the shared library.
Definition controller.cpp:58
void SetSimulationTime(double simulation_time)
Set the simulation time (s)
Definition controller.hpp:54
void SetWindSpeed(double wind_speed)
Set measured wind speed at hub (m/s)
Definition controller.hpp:81
std::array< double, 3 > PitchAngleCommandIndividual() const
Get the commanded individual pitch angle (rad)
Definition controller.hpp:28
double YawAngleCommand() const
Get the commanded yaw angle (rad) integrated from yaw rate command.
Definition controller.hpp:39
void SetOutOfPlaneRootBendingMoment(std::array< double, 3 > root_moment)
Set measured out-of-plane root bending moment for each blade (Nm)
Definition controller.hpp:101
void SetRotorAzimuth(double rotor_azimuth)
Set the rotor azimuth angle (rad)
Definition controller.hpp:84
double GeneratorTorqueCommand() const
Get the commanded generator torque (Nm)
Definition controller.hpp:36
void SetBladePitch(std::array< double, 3 > blade_pitch)
Set measured blade pitch angle (rad)
Definition controller.hpp:94
C++ cross-platform wrapper around dynamic loading of shared libraries.
Definition aerodynamics.cpp:5
double generator_torque_actual
Definition controller_io.hpp:20
double pitch_blade1_actual
Definition controller_io.hpp:15
double pitch_blade3_command
Definition controller_io.hpp:38
double rotor_speed_actual
Definition controller_io.hpp:19
double dt
Definition controller_io.hpp:14
double out_of_plane_root_bending_moment_blade1
Definition controller_io.hpp:24
double generator_power_actual
Definition controller_io.hpp:17
double out_of_plane_root_bending_moment_blade2
Definition controller_io.hpp:26
double generator_speed_actual
Definition controller_io.hpp:18
double time
Definition controller_io.hpp:13
int status
Definition controller_io.hpp:12
double pitch_blade2_actual
Definition controller_io.hpp:30
double azimuth_angle
Definition controller_io.hpp:49
double pitch_blade2_command
Definition controller_io.hpp:37
double horizontal_wind_speed
Definition controller_io.hpp:22
double out_of_plane_root_bending_moment_blade3
Definition controller_io.hpp:28
double yaw_angle_actual
Definition controller_io.hpp:34
double pitch_blade1_command
Definition controller_io.hpp:36
double pitch_blade3_actual
Definition controller_io.hpp:31
Configuration parameters for a DISCON-style turbine controller.
Definition controller_input.hpp:26