Skip to content

Commit 3f7b419

Browse files
committed
added simple wind turbine controller configuration
1 parent 9562f3f commit 3f7b419

File tree

20 files changed

+4872
-184
lines changed

20 files changed

+4872
-184
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*~
2+
build

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ project (OpenDiscon)
55
set( CONFIGURATION "CL-Windcon" CACHE STRING
66
"Choose a configuration.\n\
77
Available configurations are:\n\
8+
simple\n\
89
CL-Windcon" )
910

1011
# run configuration-specific cmake script

CONFIGURATION/simple/CMakeLists.txt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# choose a distribution
2+
set( DISTRIBUTION "DISCON" CACHE STRING
3+
"Choose a distribution.\n\
4+
Available distributions are:\n\
5+
DISCON\n\
6+
S-Function" )
7+
8+
# OpenDiscon include directories
9+
set (OPENDISCON_INCLUDE_DIRS ${OPENDISCON_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/CONFIGURATION/${CONFIGURATION}/src/ikSimpleWTCon/)
10+
set (OPENDISCON_INCLUDE_DIRS ${OPENDISCON_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/CONFIGURATION/${CONFIGURATION}/src/ikSimpleWTConfig/)
11+
set (OPENDISCON_INCLUDE_DIRS ${OPENDISCON_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/CONFIGURATION/${CONFIGURATION}/src/ikTpman/)
12+
set (OPENDISCON_INCLUDE_DIRS ${OPENDISCON_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/CONFIGURATION/${CONFIGURATION}/src/ikPowman/)
13+
14+
# OpenDiscon source files
15+
set (OPENDISCON_SOURCES ${OPENDISCON_SOURCES} ${PROJECT_SOURCE_DIR}/CONFIGURATION/${CONFIGURATION}/src/ikTpman/ikTpman.c)
16+
set (OPENDISCON_SOURCES ${OPENDISCON_SOURCES} ${PROJECT_SOURCE_DIR}/CONFIGURATION/${CONFIGURATION}/src/ikPowman/ikPowman.c)
17+
set (OPENDISCON_SOURCES ${OPENDISCON_SOURCES} ${PROJECT_SOURCE_DIR}/CONFIGURATION/${CONFIGURATION}/src/ikSimpleWTConfig/ikSimpleWTConfig.c)
18+
set (OPENDISCON_SOURCES ${OPENDISCON_SOURCES} ${PROJECT_SOURCE_DIR}/CONFIGURATION/${CONFIGURATION}/src/ikSimpleWTCon/ikSimpleWTCon.c)
19+
20+
# OpenWitcon include directories
21+
set (OPENWITCON_INCLUDE_DIRS ${OPENWITCON_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/OpenWitcon/src/ikConLoop)
22+
set (OPENWITCON_INCLUDE_DIRS ${OPENWITCON_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/OpenWitcon/src/ikLinCon)
23+
set (OPENWITCON_INCLUDE_DIRS ${OPENWITCON_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/OpenWitcon/src/ikLutbl)
24+
set (OPENWITCON_INCLUDE_DIRS ${OPENWITCON_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/OpenWitcon/src/ikNotchList)
25+
set (OPENWITCON_INCLUDE_DIRS ${OPENWITCON_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/OpenWitcon/src/ikRegionSelector)
26+
set (OPENWITCON_INCLUDE_DIRS ${OPENWITCON_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/OpenWitcon/src/ikSlti)
27+
set (OPENWITCON_INCLUDE_DIRS ${OPENWITCON_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/OpenWitcon/src/ikStpgen)
28+
set (OPENWITCON_INCLUDE_DIRS ${OPENWITCON_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/OpenWitcon/src/ikTfList)
29+
set (OPENWITCON_INCLUDE_DIRS ${OPENWITCON_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/OpenWitcon/src/ikVfnotch)
30+
31+
# OpenWitcon source files
32+
set (OPENDISCON_SOURCES ${OPENDISCON_SOURCES} ${PROJECT_SOURCE_DIR}/OpenWitcon/src/ikConLoop/ikConLoop.c)
33+
set (OPENDISCON_SOURCES ${OPENDISCON_SOURCES} ${PROJECT_SOURCE_DIR}/OpenWitcon/src/ikLinCon/ikLinCon.c)
34+
set (OPENDISCON_SOURCES ${OPENDISCON_SOURCES} ${PROJECT_SOURCE_DIR}/OpenWitcon/src/ikLutbl/ikLutbl.c)
35+
set (OPENDISCON_SOURCES ${OPENDISCON_SOURCES} ${PROJECT_SOURCE_DIR}/OpenWitcon/src/ikNotchList/ikNotchList.c)
36+
set (OPENDISCON_SOURCES ${OPENDISCON_SOURCES} ${PROJECT_SOURCE_DIR}/OpenWitcon/src/ikRegionSelector/ikRegionSelector.c)
37+
set (OPENDISCON_SOURCES ${OPENDISCON_SOURCES} ${PROJECT_SOURCE_DIR}/OpenWitcon/src/ikSlti/ikSlti.c)
38+
set (OPENDISCON_SOURCES ${OPENDISCON_SOURCES} ${PROJECT_SOURCE_DIR}/OpenWitcon/src/ikStpgen/ikStpgen.c)
39+
set (OPENDISCON_SOURCES ${OPENDISCON_SOURCES} ${PROJECT_SOURCE_DIR}/OpenWitcon/src/ikTfList/ikTfList.c)
40+
set (OPENDISCON_SOURCES ${OPENDISCON_SOURCES} ${PROJECT_SOURCE_DIR}/OpenWitcon/src/ikVfnotch/ikVfnotch.c)
41+
42+
# run distribution-specific cmake script
43+
include( ${PROJECT_SOURCE_DIR}/CONFIGURATION/${CONFIGURATION}/DISTRIBUTION/${DISTRIBUTION}/CMakeLists.txt )
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
set (OPENDISCON_SOURCES ${OPENDISCON_SOURCES} ${PROJECT_SOURCE_DIR}/CONFIGURATION/${CONFIGURATION}/src/discon/discon.c)
2+
3+
# shared OpenDiscon library
4+
include_directories ("${OPENDISCON_INCLUDE_DIRS}")
5+
include_directories ("${OPENWITCON_INCLUDE_DIRS}")
6+
include_directories ("${PROJECT_BINARY_DIR}")
7+
include (GenerateExportHeader)
8+
add_library (OpenDiscon SHARED ${OPENDISCON_SOURCES})
9+
GENERATE_EXPORT_HEADER (OpenDiscon
10+
BASE_NAME OpenDiscon
11+
EXPORT_MACRO_NAME OpenDiscon_EXPORT
12+
EXPORT_FILE_NAME OpenDiscon_EXPORT.h
13+
STATIC_DEFINE OpenDiscon_BUILT_AS_STATIC
14+
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
set (OPENDISCON_SOURCES ${OPENDISCON_SOURCES} ${PROJECT_SOURCE_DIR}/CONFIGURATION/${CONFIGURATION}/src/sfunc/sfunc.c)
2+
3+
string (REPLACE ";" " -I" OPENDISCON_INCLUDE_DIRS "${OPENDISCON_INCLUDE_DIRS}")
4+
string (REPLACE ";" " " OPENDISCON_SOURCES "${OPENDISCON_SOURCES}")
5+
6+
string (REPLACE ";" " -I" OPENWITCON_INCLUDE_DIRS "${OPENWITCON_INCLUDE_DIRS}")
7+
string (REPLACE ";" " " OPENWITCON_SOURCES "${OPENWITCON_SOURCES}")
8+
9+
configure_file (${PROJECT_SOURCE_DIR}/CONFIGURATION/${CONFIGURATION}/src/sfunc/makeOpenDiscon.m ${PROJECT_BINARY_DIR}/)
10+
configure_file (${PROJECT_SOURCE_DIR}/CONFIGURATION/${CONFIGURATION}/src/sfunc/OpenDiscon_block.mdl ${PROJECT_BINARY_DIR}/)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
Copyright (C) 2017, 2021 IKERLAN
3+
4+
This file is part of OpenDiscon.
5+
6+
OpenDiscon is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
OpenDiscon is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with OpenDiscon. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
#define NINT(a) ((a) >= 0.0 ? (int) ((a)+0.5) : ((a)-0.5))
21+
22+
#include "ikSimpleInputMod.h"
23+
#include "ikSimpleWTConfig.h"
24+
#include "OpenDiscon_EXPORT.h"
25+
#include <stdio.h>
26+
27+
void OpenDiscon_EXPORT DISCON(float *DATA, int FLAG, const char *INFILE, const char *OUTNAME, char *MESSAGE) {
28+
int err;
29+
static ikSimpleWTCon con;
30+
31+
if (NINT(DATA[0]) == 0) {
32+
ikSimpleWTConParams param;
33+
ikSimpleWTCon_initParams(&param);
34+
setParams(&param);
35+
ikSimpleWTCon_init(&con, &param);
36+
}
37+
38+
con.in.externalMaximumTorque = 230.0; /* kNm */
39+
con.in.externalMinimumTorque = 0.0; /* kNm */
40+
con.in.externalMaximumPitch = 90.0; /* deg */
41+
con.in.externalMinimumPitch = 0.0; /* deg */
42+
con.in.generatorSpeed = (double) DATA[19]; /* rad/s */
43+
con.in.maximumSpeed = 480.0/30*3.1416; /* rpm to rad/s */
44+
45+
ikSimpleWTCon_step(&con);
46+
47+
DATA[46] = (float) (con.out.torqueDemand*1.0e3); /* kNm to Nm */
48+
DATA[41] = (float) (con.out.pitchDemand/180.0*3.1416); /* deg to rad */
49+
DATA[42] = (float) (con.out.pitchDemand/180.0*3.1416); /* deg to rad */
50+
DATA[43] = (float) (con.out.pitchDemand/180.0*3.1416); /* deg to rad */
51+
DATA[44] = (float) (con.out.pitchDemand/180.0*3.1416); /* deg to rad (collective pitch angle) */
52+
53+
}
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*
2+
Copyright (C) 2017 IK4-IKERLAN
3+
4+
This file is part of OpenDiscon.
5+
6+
OpenDiscon is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
OpenDiscon is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with OpenDiscon. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
/**
21+
* @file ikPowman.c
22+
*
23+
* @brief Class ikPowman implementation
24+
*/
25+
26+
/* @cond */
27+
28+
#include <stdlib.h>
29+
#include <string.h>
30+
31+
#include "ikPowman.h"
32+
33+
int ikPowman_init(ikPowman *self, const ikPowmanParams *params) {
34+
int err;
35+
36+
/* register rated power */
37+
self->ratedPower = params->ratedPower;
38+
39+
/* register efficiency */
40+
if (0 == params->efficiency) return -1;
41+
self->efficiency = params->efficiency;
42+
43+
/* initialise look-up tables */
44+
ikLutbl_init(&(self->lutblKopt));
45+
err = ikLutbl_setPoints(&(self->lutblKopt), params->belowRatedTorqueGainTableN, params->belowRatedTorqueGainTableX, params->belowRatedTorqueGainTableY);
46+
if (err) return -2;
47+
48+
ikLutbl_init(&(self->lutblPitch));
49+
err = ikLutbl_setPoints(&(self->lutblPitch), params->minimumPitchTableN, params->minimumPitchTableX, params->minimumPitchTableY);
50+
if (err) return -3;
51+
52+
return 0;
53+
}
54+
55+
void ikPowman_initParams(ikPowmanParams *params) {
56+
/* set power to 0 */
57+
params->ratedPower = 0.0;
58+
59+
/* set efficiency to 1 */
60+
params->efficiency = 1.0;
61+
62+
/* make the below rated torque gain 0 */
63+
params->belowRatedTorqueGainTableN = 1;
64+
params->belowRatedTorqueGainTableX[0] = 0.0;
65+
params->belowRatedTorqueGainTableY[0] = 0.0;
66+
67+
/* make the minimum pitch 0 */
68+
params->minimumPitchTableN = 1;
69+
params->minimumPitchTableX[0] = 0.0;
70+
params->minimumPitchTableY[0] = 0.0;
71+
}
72+
73+
double ikPowman_step(ikPowman *self, double deratingRatio, double maxSpeed, double measuredSpeed) {
74+
/* register inputs */
75+
self->deratingRatio = deratingRatio;
76+
self->maxSpeed = maxSpeed;
77+
self->measuredSpeed = measuredSpeed;
78+
79+
/* calculate maximum torque */
80+
self->maximumTorque = (1-deratingRatio)*self->ratedPower/maxSpeed/self->efficiency;
81+
82+
/* calculate below rated torque */
83+
self->belowRatedTorque = ikLutbl_eval(&(self->lutblKopt), deratingRatio)*measuredSpeed*measuredSpeed;
84+
85+
/* calculate minimum pitch */
86+
self->minimumPitch = ikLutbl_eval(&(self->lutblPitch), deratingRatio);
87+
88+
/* return the maximum torque */
89+
return self->maximumTorque;
90+
}
91+
92+
int ikPowman_getOutput(const ikPowman *self, double *output, const char *name) {
93+
/* pick up the signal names */
94+
if (!strcmp(name, "derating ratio")) {
95+
*output = self->deratingRatio;
96+
return 0;
97+
}
98+
if (!strcmp(name, "maximum speed")) {
99+
*output = self->maxSpeed;
100+
return 0;
101+
}
102+
if (!strcmp(name, "measured speed")) {
103+
*output = self->measuredSpeed;
104+
return 0;
105+
}
106+
if (!strcmp(name, "maximum torque")) {
107+
*output = self->maximumTorque;
108+
return 0;
109+
}
110+
if (!strcmp(name, "below rated torque")) {
111+
*output = self->belowRatedTorque;
112+
return 0;
113+
}
114+
if (!strcmp(name, "minimum pitch")) {
115+
*output = self->minimumPitch;
116+
return 0;
117+
}
118+
119+
return -1;
120+
}
121+
122+
/* @endcond */

0 commit comments

Comments
 (0)