-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from dnv-innersource/feature/7-move-example-fmus
Move ML FMU examples into examples folder
- Loading branch information
Showing
8 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<fmiModelDescription fmiVersion="2.0" modelName="WindToPower" guid="@FMU_UUID@" version="0.0.1" generationDateAndTime="2024-03-06T15:52:41+00:00" variableNamingConvention="structured" generationTool="MLFMU 0.1.6" description="A Machine Learning based FMU that outputs the estimated power output of a windmill given the wind speed and direction."> | ||
<CoSimulation modelIdentifier="WindToPower" canHandleVariableCommunicationStepSize="true" /> | ||
<ModelVariables> | ||
<ScalarVariable name="windSpeed" valueReference="0" causality="input" description="Noise to be added to the change in wind speed" variability="continuous"> | ||
<Real start="0" /> | ||
</ScalarVariable> | ||
<ScalarVariable name="windDirection" valueReference="1" causality="input" description="Noise to be added to the change in wind direction" variability="continuous"> | ||
<Real start="0" /> | ||
</ScalarVariable> | ||
<ScalarVariable name="power" valueReference="2" causality="output" description="The estimated windmill power output" variability="continuous"> | ||
<Real /> | ||
</ScalarVariable> | ||
</ModelVariables> | ||
</fmiModelDescription> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "model_definitions.h" | ||
#include "fmu-uuid.h" | ||
#include <cppfmu_cs.hpp> | ||
#include <onnxFmu.hpp> | ||
|
||
|
||
class WindToPower : public OnnxFmu{ | ||
public: | ||
WindToPower(cppfmu::FMIString fmuResourceLocation) : OnnxFmu(fmuResourceLocation){} | ||
private: | ||
}; | ||
|
||
|
||
cppfmu::UniquePtr<cppfmu::SlaveInstance> CppfmuInstantiateSlave( | ||
cppfmu::FMIString /*instanceName*/, cppfmu::FMIString fmuGUID, cppfmu::FMIString fmuResourceLocation, | ||
cppfmu::FMIString /*mimeType*/, cppfmu::FMIReal /*timeout*/, cppfmu::FMIBoolean /*visible*/, | ||
cppfmu::FMIBoolean /*interactive*/, cppfmu::Memory memory, cppfmu::Logger /*logger*/) | ||
{ | ||
if (std::strcmp(fmuGUID, FMU_UUID) != 0) { | ||
throw std::runtime_error("FMU GUID mismatch"); | ||
} | ||
return cppfmu::AllocateUnique<WindToPower>(memory, fmuResourceLocation); | ||
} |
20 changes: 20 additions & 0 deletions
20
examples/wind_to_power/WindToPower/sources/model_definitions.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#define NUM_FMU_VARIABLES 3 | ||
|
||
#define NUM_ONNX_INPUTS 2 | ||
#define NUM_ONNX_FMU_INPUTS 2 | ||
#define NUM_ONNX_OUTPUTS 1 | ||
#define NUM_ONNX_FMU_OUTPUTS 1 | ||
#define NUM_ONNX_STATES 0 | ||
#define NUM_ONNX_STATES_OUTPUTS 0 | ||
|
||
#define ONNX_INPUT_VALUE_REFERENCES 0, 0, 1, 1 | ||
#define ONNX_OUTPUT_VALUE_REFERENCES 0, 2 | ||
#define ONNX_STATE_OUTPUT_INDEXES | ||
|
||
#define ONNX_USE_TIME_INPUT false | ||
|
||
#define ONNX_INPUT_NAME "args_0" | ||
#define ONNX_OUTPUT_NAME "output_1" | ||
#define ONNX_STATE_NAME "" | ||
#define ONNX_TIME_INPUT_NAME "" | ||
#define ONNX_FILENAME L"example.onnx" |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "WindToPower", | ||
"description": "A Machine Learning based FMU that outputs the estimated power output of a windmill given the wind speed and direction.", | ||
"inputs": [ | ||
{ | ||
"name": "windSpeed", | ||
"description": "Noise to be added to the change in wind speed", | ||
"agentInputIndexes": [ | ||
"0" | ||
] | ||
}, | ||
{ | ||
"name": "windDirection", | ||
"description": "Noise to be added to the change in wind direction", | ||
"agentInputIndexes": [ | ||
"1" | ||
] | ||
} | ||
], | ||
"parameters": [], | ||
"outputs": [ | ||
{ | ||
"name": "power", | ||
"description": "The estimated windmill power output", | ||
"agentOutputIndexes": [ | ||
"0" | ||
] | ||
} | ||
], | ||
"states": { | ||
"agentOutputIndexes": [] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters