Skip to content

Commit

Permalink
Fix whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
t-sommer committed Nov 15, 2023
1 parent 9b6deff commit 2aef861
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 76 deletions.
124 changes: 62 additions & 62 deletions StateSpace/FMI3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,72 +5,72 @@
generationTool="Reference FMUs (development build)"
instantiationToken="{D773325B-AB94-4630-BF85-643EB24FCB78}">

<ModelExchange
modelIdentifier="StateSpace"
canGetAndSetFMUState="true"
canSerializeFMUState="true"/>
<ModelExchange
modelIdentifier="StateSpace"
canGetAndSetFMUState="true"
canSerializeFMUState="true"/>

<CoSimulation
modelIdentifier="StateSpace"
canGetAndSetFMUState="true"
canSerializeFMUState="true"
canHandleVariableCommunicationStepSize="true"
providesIntermediateUpdate="true"
canReturnEarlyAfterIntermediateUpdate="true"
fixedInternalStepSize="1"
hasEventMode="true"/>
<CoSimulation
modelIdentifier="StateSpace"
canGetAndSetFMUState="true"
canSerializeFMUState="true"
canHandleVariableCommunicationStepSize="true"
providesIntermediateUpdate="true"
canReturnEarlyAfterIntermediateUpdate="true"
fixedInternalStepSize="1"
hasEventMode="true"/>

<LogCategories>
<Category name="logEvents" description="Log events"/>
<Category name="logStatusError" description="Log error messages"/>
</LogCategories>
<LogCategories>
<Category name="logEvents" description="Log events"/>
<Category name="logStatusError" description="Log error messages"/>
</LogCategories>

<DefaultExperiment startTime="0" stopTime="10"/>
<DefaultExperiment startTime="0" stopTime="10"/>

<ModelVariables>
<Float64 name="time" valueReference="0" causality="independent" variability="continuous" description="Simulation time"/>
<UInt64 name="m" valueReference="1" description="Number of inputs" causality="structuralParameter" variability="tunable" start="3" min="1" max="3"/>
<UInt64 name="n" valueReference="2" description="Number of states" causality="structuralParameter" variability="tunable" start="3" min="1" max="3"/>
<UInt64 name="r" valueReference="3" description="Number of outputs" causality="structuralParameter" variability="tunable" start="3" min="1" max="3"/>
<Float64 name="A" valueReference="4" description="Matrix coefficient A" causality="parameter" variability="tunable" start="1 0 0 0 1 0 0 0 1">
<Dimension valueReference="2"/>
<Dimension valueReference="2"/>
</Float64>
<Float64 name="B" valueReference="5" description="Matrix coefficient B" causality="parameter" variability="tunable" start="1 0 0 0 1 0 0 0 1">
<Dimension valueReference="2"/>
<Dimension valueReference="1"/>
</Float64>
<Float64 name="C" valueReference="6" description="Matrix coefficient C" causality="parameter" variability="tunable" start="1 0 0 0 1 0 0 0 1">
<Dimension valueReference="3"/>
<Dimension valueReference="2"/>
</Float64>
<Float64 name="D" valueReference="7" description="Matrix coefficient D" causality="parameter" variability="tunable" start="1 0 0 0 1 0 0 0 1">
<Dimension valueReference="3"/>
<Dimension valueReference="1"/>
</Float64>
<Float64 name="x0" valueReference="8" description="Initial state vector" causality="parameter" variability="tunable" start="0 0 0">
<Dimension valueReference="2"/>
</Float64>
<Float64 name="u" valueReference="9" description="Input vector" causality="input" start="1 2 3">
<Dimension valueReference="1"/>
</Float64>
<Float64 name="y" valueReference="10" description="Output vector" causality="output">
<Dimension valueReference="3"/>
</Float64>
<Float64 name="x" valueReference="11" description="State vector" causality="local">
<Dimension valueReference="2"/>
</Float64>
<Float64 name="der(x)" valueReference="12" description="Derivative of the state vector" causality="local" derivative="11">
<Dimension valueReference="2"/>
</Float64>
</ModelVariables>
<ModelVariables>
<Float64 name="time" valueReference="0" causality="independent" variability="continuous" description="Simulation time"/>
<UInt64 name="m" valueReference="1" description="Number of inputs" causality="structuralParameter" variability="tunable" start="3" min="1" max="3"/>
<UInt64 name="n" valueReference="2" description="Number of states" causality="structuralParameter" variability="tunable" start="3" min="1" max="3"/>
<UInt64 name="r" valueReference="3" description="Number of outputs" causality="structuralParameter" variability="tunable" start="3" min="1" max="3"/>
<Float64 name="A" valueReference="4" description="Matrix coefficient A" causality="parameter" variability="tunable" start="1 0 0 0 1 0 0 0 1">
<Dimension valueReference="2"/>
<Dimension valueReference="2"/>
</Float64>
<Float64 name="B" valueReference="5" description="Matrix coefficient B" causality="parameter" variability="tunable" start="1 0 0 0 1 0 0 0 1">
<Dimension valueReference="2"/>
<Dimension valueReference="1"/>
</Float64>
<Float64 name="C" valueReference="6" description="Matrix coefficient C" causality="parameter" variability="tunable" start="1 0 0 0 1 0 0 0 1">
<Dimension valueReference="3"/>
<Dimension valueReference="2"/>
</Float64>
<Float64 name="D" valueReference="7" description="Matrix coefficient D" causality="parameter" variability="tunable" start="1 0 0 0 1 0 0 0 1">
<Dimension valueReference="3"/>
<Dimension valueReference="1"/>
</Float64>
<Float64 name="x0" valueReference="8" description="Initial state vector" causality="parameter" variability="tunable" start="0 0 0">
<Dimension valueReference="2"/>
</Float64>
<Float64 name="u" valueReference="9" description="Input vector" causality="input" start="1 2 3">
<Dimension valueReference="1"/>
</Float64>
<Float64 name="y" valueReference="10" description="Output vector" causality="output">
<Dimension valueReference="3"/>
</Float64>
<Float64 name="x" valueReference="11" description="State vector" causality="local">
<Dimension valueReference="2"/>
</Float64>
<Float64 name="der(x)" valueReference="12" description="Derivative of the state vector" causality="local" derivative="11">
<Dimension valueReference="2"/>
</Float64>
</ModelVariables>

<ModelStructure>
<Output valueReference="10"/>
<ContinuousStateDerivative valueReference="12"/>
<InitialUnknown valueReference="10"/>
<InitialUnknown valueReference="11"/>
<InitialUnknown valueReference="12"/>
</ModelStructure>
<ModelStructure>
<Output valueReference="10"/>
<ContinuousStateDerivative valueReference="12"/>
<InitialUnknown valueReference="10"/>
<InitialUnknown valueReference="11"/>
<InitialUnknown valueReference="12"/>
</ModelStructure>

</fmiModelDescription>
14 changes: 7 additions & 7 deletions StateSpace/model.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ Status calculateValues(ModelInstance *comp) {

// der(x) = Ax + Bu
for (size_t i = 0; i < M(n); i++) {

M(der_x)[i] = 0;

for (size_t j = 0; j < M(n); j++) {
M(der_x)[i] += M(A)[i][j] * M(x)[j];
}
Expand All @@ -56,7 +56,7 @@ Status calculateValues(ModelInstance *comp) {
for (size_t i = 0; i < M(r); i++) {

M(y)[i] = 0;

for (size_t j = 0; j < M(n); j++) {
M(y)[i] += M(C)[i][j] * M(x)[j];
}
Expand Down Expand Up @@ -282,9 +282,9 @@ size_t getNumberOfContinuousStates(ModelInstance* comp) {
}

void getContinuousStates(ModelInstance* comp, double x[], size_t nx) {

// TODO: assert nx == M(n)

UNUSED(nx);

for (size_t i = 0; i < M(n); i++) {
Expand All @@ -293,7 +293,7 @@ void getContinuousStates(ModelInstance* comp, double x[], size_t nx) {
}

void setContinuousStates(ModelInstance* comp, const double x[], size_t nx) {

// TODO: assert nx == M(n)

UNUSED(nx);
Expand All @@ -314,4 +314,4 @@ void getDerivatives(ModelInstance* comp, double dx[], size_t nx) {
for (size_t i = 0; i < M(n); i++) {
dx[i] = M(der_x)[i];
}
}
}
14 changes: 7 additions & 7 deletions StateSpace/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
The StateSpace model implements the equation

```
= Ax + Bu
y = Cx + Du
der(x) = Ax + Bu
y = Cx + Du
```

where
where

- `A` is an `n×n` matrix, where `n` is the number of states,
- `B` is an `n×m` matrix, where `m` is the number of inputs,
- `C` is an `r×n` matrix, where `r` is the number of outputs,
- `D` is an `r×m` matrix, and
- `A` is an `n` by `n` matrix, where `n` is the number of states,
- `B` is an `n` by `m` matrix, where `m` is the number of inputs,
- `C` is an `r` by `n` matrix, where `r` is the number of outputs,
- `D` is an `r` by `m` matrix, and
- `x0` is the initial value of `x`

<img src="state-space-matrix.svg" width="150">

0 comments on commit 2aef861

Please sign in to comment.