Skip to content

Commit

Permalink
added FMIImport doc to FMI.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
0815Creeper committed Sep 29, 2023
1 parent f93ebd4 commit ac6ec42
Show file tree
Hide file tree
Showing 6 changed files with 276 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ docs/site/
# It records a fixed state of all packages used by the project. As such, it should not be
# committed for packages, but should be committed for applications that require a static
# environment.
docs/Manifest.toml
Manifest.toml
LocalPreferences.toml

Expand Down
5 changes: 5 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
FMI = "14a09403-18e3-468f-ad8a-74f8dda2d9ac"
FMICore = "8af89139-c281-408e-bce2-3005eb87462f"
FMIExport = "31b88311-cab6-44ed-ba9c-fe5a9abbd67a"
FMIImport = "9fcbc62e-52a0-44e9-a616-1359a0008194"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"

[compat]
julia = "1.6"
10 changes: 7 additions & 3 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
# Licensed under the MIT license. See LICENSE file in the project root for details.
#

using Documenter, FMI
using Documenter, FMI, Plots, FMIImport
using Documenter: GitHubActions

makedocs(sitename="FMI.jl",
#modules = [FMI,FMIImport],
format = Documenter.HTML(
collapselevel = 1,
sidebar_sitename = false,
edit_link = nothing
edit_link = nothing,
size_threshold_ignore = ["fmi2_library.md"]
),
pages= Any[
"Introduction" => "index.md"
Expand All @@ -26,7 +28,9 @@ makedocs(sitename="FMI.jl",
"Multithreading" => "examples/multithreading.md"
"Multiprocessing" => "examples/multiprocessing.md"
]
"Library Functions" => "library.md"
"Developer Level API" => "fmi2_library.md"
#"" => "fmi3_library.md"
"User Level API" => "library.md"
"Related Publication" => "related.md"
"Contents" => "contents.md"
]
Expand Down
256 changes: 256 additions & 0 deletions docs/src/fmi2_library.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@

# [FMI2 Library Functions](@id library)

## FMI2 Common Concepts for Model Exchange and Co-Simulation
In both cases, FMI defines an input/output block of a dynamic model where the distribution of the block, the
platform dependent header file, several access functions, as well as the schema files are identical.

```@docs
FMU2
FMU2Component
fmi2Struct
```

### Reading the model description
This section documents functions to inquire information about the model description of an FMU.

#### Load/Parse the FMI model description
```@docs
fmi2LoadModelDescription
```
#### Get value functions
```@docs
fmi2GetDefaultStartTime
fmi2GetDefaultStopTime
fmi2GetDefaultTolerance
fmi2GetDefaultStepSize
fmi2GetModelName
fmi2GetGUID
fmi2GetGenerationTool
fmi2GetGenerationDateAndTime
fmi2GetVariableNamingConvention
fmi2GetNumberOfEventIndicators
fmi2GetNumberOfStates
fmi2IsCoSimulation
fmi2IsModelExchange
```

#### Information functions


```@docs
fmi2DependenciesSupported
fmi2DerivativeDependenciesSupported
fmi2GetModelIdentifier
fmi2CanGetSetState
fmi2CanSerializeFMUstate
fmi2ProvidesDirectionalDerivative
fmi2GetValueReferencesAndNames
fmi2GetNames
fmi2GetModelVariableIndices
fmi2GetInputValueReferencesAndNames
fmi2GetInputNames
fmi2GetOutputValueReferencesAndNames
fmi2GetOutputNames
fmi2GetParameterValueReferencesAndNames
fmi2GetParameterNames
fmi2GetStateValueReferencesAndNames
fmi2GetStateNames
fmi2GetDerivateValueReferencesAndNames
fmi2GetDerivativeNames
fmi2GetNamesAndDescriptions
fmi2GetNamesAndUnits
fmi2GetNamesAndInitials
fmi2GetInputNamesAndStarts
fmi2GetVersion
fmi2GetTypesPlatform
fmi2GetSolutionDerivative
```

### Creation, Destruction and Logging of FMU Instances
This section documents functions that deal with instantiation, destruction and logging of FMUs.

```@docs
fmi2Instantiate!
fmi2FreeInstance!
fmi2SetDebugLogging
```

### Initialization, Termination, and Resetting an FMU
This section documents functions that deal with initialization, termination, resetting of an FMU.

```@docs
fmi2SetupExperiment
fmi2EnterInitializationMode
fmi2ExitInitializationMode
fmi2Terminate
fmi2Reset
```
### Getting and Setting Variable Values
All variable values of an FMU are identified with a variable handle called “value reference”. The handle is
defined in the modelDescription.xml file (as attribute “valueReference” in element
“ScalarVariable”). Element “valueReference” might not be unique for all variables. If two or more
variables of the same base data type (such as fmi2Real) have the same valueReference, then they
have identical values but other parts of the variable definition might be different [(for example, min/max
attributes)].

```@docs
fmi2Get
fmi2Get!
fmi2Set
fmi2GetReal
fmi2GetReal!
fmi2GetInteger
fmi2GetInteger!
fmi2GetBoolean
fmi2GetBoolean!
fmi2GetString
fmi2GetString!
fmi2SetReal
fmi2SetInteger
fmi2SetBoolean
fmi2SetString
```


### Getting and Setting the Complete FMU State
The FMU has an internal state consisting of all values that are needed to continue a simulation. This internal state consists especially of the values of the continuous-time states, iteration variables, parameter values, input values, delay buffers, file identifiers, and FMU internal status information. With the functions of this section, the internal FMU state can be copied and the pointer to this copy is returned to the environment. The FMU state copy can be set as actual FMU state, in order to continue the simulation from it.

```@docs
fmi2GetFMUstate
fmi2GetFMUstate!
fmi2SetFMUstate
fmi2FreeFMUstate!
fmi2SerializedFMUstateSize
fmi2SerializedFMUstateSize!
fmi2SerializeFMUstate
fmi2SerializeFMUstate!
fmi2DeSerializeFMUstate
fmi2DeSerializeFMUstate!
```

### Getting Partial Dervatives
It is optionally possible to provide evaluation of partial derivatives for an FMU. For Model Exchange, this
means computing the partial derivatives at a particular time instant. For Co-Simulation, this means to
compute the partial derivatives at a particular communication point. One function is provided to compute
directional derivatives. This function can be used to construct the desired partial derivative matrices.


```@docs
fmi2GetDirectionalDerivative!
fmi2SetRealInputDerivatives
fmi2GetRealOutputDerivatives!
fmi2SampleJacobian
fmi2SampleJacobian!
```

## FMI for Model Exchange

This chapter contains the interface description to access the equations of a dynamic system from a C
program.

### Providing Independent Variables and Re-initialization of Caching
Depending on the situation, different variables need to be computed. In order to be efficient, it is important that the interface requires only the computation of variables that are needed in the present context. The state derivatives shall be reused from the previous call. This feature is called “caching of variables” in the sequel. Caching requires that the model evaluation can detect when the input arguments, like time or states, have changed.

```@docs
fmi2SetTime
fmi2SetContinuousStates
```

### Evaluation of Model Equations
This section contains the core functions to evaluate the model equations.


```@docs
fmi2EnterEventMode
fmi2NewDiscreteStates
fmi2NewDiscreteStates!
fmi2EnterContinuousTimeMode
fmi2CompletedIntegratorStep
fmi2CompletedIntegratorStep!
fmi2GetDerivatives
fmi2GetDerivatives!
fmi2GetEventIndicators
fmi2GetEventIndicators!
fmi2GetContinuousStates
fmi2GetContinuousStates!
fmi2GetNominalsOfContinuousStates
fmi2GetNominalsOfContinuousStates!
```

## FMI for Co-Simulation
This chapter defines the Functional Mock-up Interface (FMI) for the coupling of two or more simulation
models in a Co-Simulation environment (FMI for Co-Simulation). Co-Simulation is a rather general
approach to the simulation of coupled technical systems and coupled physical phenomena in
engineering with focus on instationary (time-dependent) problems.


### Transfer of Input / Output Values and Parameters
In order to enable the slave to interpolate the continuous real inputs between communication steps, the
derivatives of the inputs with respect to time can be provided. Also, higher derivatives can be set to allow
higher order interpolation.

```@docs
fmi2GetRealOutputDerivatives
```

### Computation
The computation of time steps is controlled by the following function.

```@docs
fmi2DoStep
fmi2CancelStep
```

### Retrieving Status Information from the Slave
Status information is retrieved from the slave by the following functions:

```@docs
fmi2GetStatus!
fmi2GetRealStatus!
fmi2GetIntegerStatus!
fmi2GetBooleanStatus!
fmi2GetStringStatus!
```

## additional functions
These new functions, that are useful, but not part of the FMI-spec. (example: `fmi2Load`, `fmi2SampleJacobian`)

### Opening and closing FMUs
```@docs
fmi2Unzip
fmi2Unload
fmi2Load
fmi2Reload
```
### Conversion functions

```@docs
fmi2StringToValueReference
fmi2ModelVariablesForValueReference
fmi2ValueReferenceToString
fmi2GetSolutionState
fmi2GetSolutionValue
fmi2GetSolutionTime
```

### External/Additional functions

```@docs
fmi2GetJacobian
fmi2GetJacobian!
fmi2GetFullJacobian
fmi2GetFullJacobian!
fmi2GetStartValue
fmi2GetUnit
fmi2GetDeclaredType
fmi2GetInitial
fmi2GetSimpleTypeAttributeStruct
```


## All functions

```@index
```
3 changes: 3 additions & 0 deletions docs/src/fmi3_library.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# [FMI3 Library Functions](@id library)

## FMI2 Common Concepts for Model Exchange and Co-Simulation
13 changes: 4 additions & 9 deletions docs/src/library.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# Library Functions

Many of the functions in this library are based on already defined functions of the [FMIImport.jl](https://github.com/ThummeTo/FMIImport.jl) library. Within this library, a distinction is made between the FMI-standards (FMI2 and FMI3), which is why the links to both function collections are provided in the following.
- FMI2Standard: [https://thummeto.github.io/FMIImport.jl/dev/fmi2_library/](https://thummeto.github.io/FMIImport.jl/dev/fmi2_library/)
- FMI3Standard: [https://thummeto.github.io/FMIImport.jl/dev/fmi3_library/](https://thummeto.github.io/FMIImport.jl/dev/fmi3_library/)

In this collection only the essential and not in the standard defined functions are listed.

Many of the functions in this library are based on already defined functions of the [FMIImport.jl](https://github.com/ThummeTo/FMIImport.jl) library.

# Simulate FMUs

Expand All @@ -17,20 +12,20 @@ fmiLoad
fmiUnload
fmiReload
```
### Conversion functions
# Conversion functions

```@docs
fmiStringToValueReference
```

### External/additional functions
# External/additional functions

```@docs
fmiGetDependencies
fmiInfo
```

### Visualize simulation results
# Visualize simulation results

```@docs
fmiPlot
Expand Down

0 comments on commit ac6ec42

Please sign in to comment.