91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 15KB
    文件類型: .c
    金幣: 1
    下載: 0 次
    發布日期: 2021-06-03
  • 語言: Matlab
  • 標簽: FAS??v8??S_function??

資源簡介

FAST v8 版本S_function 的資源,可以在Simulink中利用NREL的FAST code 進行風力機的仿真

資源截圖

代碼片段和文件信息

/*
?*??TEMPLATE?File:?sfuntmpl_gate_fortran.c
?*??TEMPLATE?Copyright?1990-2013?The?MathWorks?Inc.
?*
?*?Modified?by?B.?Jonkman?National?Renewable?Energy?Laboratory
?*???for?use?with?FAST?v8
?*???20-Jan-2015
?*/


/*
?*?You?must?specify?the?S_FUNCTION_NAME?as?the?name?of?your?S-function
?*?(i.e.?replace?sfungate?with?the?name?of?your?S-function?which?has
?*?to?match?the?name?of?the?final?mex?file?e.g.?if?the?S_FUNCTION_NAME
?*?is?my_sfuntmpl_gate_fortran?the?mex?filename?will?have?to?be?
?*?my_sfuntmpl_gate_fortran.mexXXX?where?XXX?is?the?3?letter?
?*?mex?extension?code?for?your?platform).
?*/

#define?S_FUNCTION_LEVEL?2
#define?S_FUNCTION_NAME??FAST_SFunc

/*
?*?Need?to?include?simstruc.h?for?the?definition?of?the?SimStruct?and
?*?its?associated?macro?definitions.
?*/
#include?“simstruc.h“
#include?“mex.h“?????//?for?mexPutVariable
#include?“matrix.h“??//?for?mxCreateDoubleScalar
#include?“FAST_Library.h“


#define?PARAM_FILENAME?0
#define?PARAM_TMAX?1
#define?PARAM_ADDINPUTS?2
#define?NUM_PARAM?3

//?two?DWork?arrays:
#define?WORKARY_OUTPUT?0
#define?WORKARY_INPUT?1


static?double?dt?=?0;
static?double?TMax?=?0;
static?int?NumInputs?=?NumFixedInputs;
static?int?NumAddInputs?=?0;??//?number?of?additional?inputs
static?int?NumOutputs?=?1;
static?int?ErrStat?=?0;
static?char?ErrMsg[INTERFACE_STRING_LENGTH];????????//?make?sure?this?is?the?same?size?as?IntfStrLen?in?FAST_Library.f90
static?char?InputFileName[INTERFACE_STRING_LENGTH];?//?make?sure?this?is?the?same?size?as?IntfStrLen?in?FAST_Library.f90
static?int?n_t_global?=?-2;??//?counter?to?determine?which?fixed-step?simulation?time?we?are?at?currently?(start?at?-2?for?initialization)

//?function?definitions
static?int?checkError(SimStruct?*S);
static?void?mdlTerminate(SimStruct?*S);?//?defined?here?so?I?can?call?it?from?checkError
static?void?getInputs(SimStruct?*S?double?*InputAry);
static?void?setOutputs(SimStruct?*S?double?*OutputAry);


/*?Error?handling
*?--------------
*
*?You?should?use?the?following?technique?to?report?errors?encountered?within
*?an?S-function:
*
*???????ssSetErrorStatus(S“Error?encountered?due?to?...“);
*???????return;
*
*?Note?that?the?2nd?argument?to?ssSetErrorStatus?must?be?persistent?memory.
*?It?cannot?be?a?local?variable.?
*/
static?int
checkError(SimStruct?*S){

???if?(ErrStat?>=?AbortErrLev){
??????ssPrintf(“\n“);
??????ssSetErrorStatus(S?ErrMsg);
??????mdlTerminate(S);??//?terminate?on?error?(in?case?Simulink?doesn‘t?do?so?itself)
??????return?1;
???}
???else?if?(ErrStat?>=?ErrID_Warn){
??????ssPrintf(“\n“);
??????ssWarning(S?ErrMsg);
???}
???else?if?(ErrStat?!=?ErrID_None){
??????ssPrintf(“\n%s\n“?ErrMsg);
???}
???return?0;

}

static?void
getInputs(SimStruct?*S?double?*InputAry){

???int?????k;
???InputRealPtrsType?uPtrs?=?ssGetInputPortRealSignalPtrs(S?0);

???for?(k?=?0;?k???????InputAry[k]?=?(double)(

評論

共有 條評論