    

 ## On this page

  

 

 # FMU Class Reference

 Last update: 16.07.2025 

## <a name="pub-methods"></a>Public Member Functions

 [addScalarVariable](class_f_m_u.xhtml#ad17d22fdec61fd737e9563a3f7714a05) (string name, string type, string causality, string variability, string description, number min=0, number max=0, number start=0) Add a scalar variable to the [FMU](class_f_m_u.xhtml), see the FMI documentation at <https://fmi-standard.org> for details on the scalar variable description schema. [More...](#ad17d22fdec61fd737e9563a3f7714a05)  
  [FMU](class_f_m_u.xhtml#afd991456ba917c9eb24f61de4658db22) () Create an [FMU](class_f_m_u.xhtml) 2.0 (Functional Mockup Unit, <https://fmi-standard.org>). [More...](#afd991456ba917c9eb24f61de4658db22)  
 <a id="a325871988fd80bf568d4b628fb2855d6"></a> [setAuthor](class_f_m_u.xhtml#a325871988fd80bf568d4b628fb2855d6) (string author) Set m\_model\_name.   
 <a id="a682461752380b2bbb0339143e5bd5a5e"></a> [setDllPath](class_f_m_u.xhtml#a682461752380b2bbb0339143e5bd5a5e) (string path) Set the path pointing to the SoS libraries. An auto-detection attempt is performed on [FMU](class_f_m_u.xhtml) construction.   
 <a id="a24298d9edfff27ce9f3b41a1c767f9c5"></a> [setModelDescription](class_f_m_u.xhtml#a24298d9edfff27ce9f3b41a1c767f9c5) (string model\_description) Set m\_model\_name.   
 <a id="ab4ad00113667a54fc86a2d648e8190f6"></a> [setModelName](class_f_m_u.xhtml#ab4ad00113667a54fc86a2d648e8190f6) (string model\_name) Set m\_model\_name.   
  [setScript](class_f_m_u.xhtml#af6945a63033b7df33729c5b2f610d409) (string code) Writes the script code to a temporary file and calls [setScriptFile()](class_f_m_u.xhtml#a313630bccd6d99a3c2cabdd1932beabf "Set the absolute path to an existing script file to be included with the .fmu archive. Only use either of setScript or setScriptFile. "). Only use either of setScript or setScriptFile. [More...](#af6945a63033b7df33729c5b2f610d409)  
 <a id="a313630bccd6d99a3c2cabdd1932beabf"></a> [setScriptFile](class_f_m_u.xhtml#a313630bccd6d99a3c2cabdd1932beabf) (string filename) Set the absolute path to an existing script file to be included with the .fmu archive. Only use either of setScript or setScriptFile.   
 bool [writeFMU](class_f_m_u.xhtml#a6938dac8b406b7f3c9d37b6e99bd805e) (string archive, bool includeEntireDatabase=false, bool replace\_files=false) Write the .fmu archive file to disk. [More...](#a6938dac8b406b7f3c9d37b6e99bd805e)  
## Constructor &amp; Destructor Documentation

<a id="afd991456ba917c9eb24f61de4658db22"></a>## [◆ ](#afd991456ba917c9eb24f61de4658db22)FMU()

 [FMU](class_f_m_u.xhtml)  ( ) 

Create an [FMU](class_f_m_u.xhtml) 2.0 (Functional Mockup Unit, <https://fmi-standard.org>).

Usage:

- addScalarVariable to add scalar input and output variables.
- setScript to set code to be executed by the [FMU](class_f_m_u.xhtml) (calls setScriptFile
- setScriptFile to create an [FMU](class_f_m_u.xhtml) from a given script file
- writeFMU to write the .fmu archvive file.





## Member Function Documentation

<a id="ad17d22fdec61fd737e9563a3f7714a05"></a>## [◆ ](#ad17d22fdec61fd737e9563a3f7714a05)addScalarVariable()

 addScalarVariable  ( string  *name*,    string  *type*,    string  *causality*,    string  *variability*,    string  *description*,    number  *min* = `0`,    number  *max* = `0`,    number  *start* = `0`   ) 

Add a scalar variable to the [FMU](class_f_m_u.xhtml), see the FMI documentation at <https://fmi-standard.org> for details on the scalar variable description schema.

Parameters nameVariable name typeVariable type: supporting String or Real causalityFor SoS FMUs this is either "input" or "output". variabilitySoS FMUs support "discrete" variability only. descriptionVariable description. minThe variable's lower bound. maxThe variable's upper bound. startThe variables's default value. 



<a id="af6945a63033b7df33729c5b2f610d409"></a>## [◆ ](#af6945a63033b7df33729c5b2f610d409)setScript()

 setScript  ( string  *code*) 

Writes the script code to a temporary file and calls [setScriptFile()](class_f_m_u.xhtml#a313630bccd6d99a3c2cabdd1932beabf "Set the absolute path to an existing script file to be included with the .fmu archive. Only use either of setScript or setScriptFile. "). Only use either of setScript or setScriptFile.

Parameters codeThe script code to be executed by the [FMU](class_f_m_u.xhtml). 



<a id="a6938dac8b406b7f3c9d37b6e99bd805e"></a>## [◆ ](#a6938dac8b406b7f3c9d37b6e99bd805e)writeFMU()

 bool writeFMU  ( string  *archive*,    bool  *includeEntireDatabase* = `false`,    bool  *replace\_files* = `false`   ) 

Write the .fmu archive file to disk.

Parameters archiveA absolute or relative path to the archive to be written. includeEntireDatabaseIf false, a reduced .sdb database file, containing minimal Information (e.g. no designs), is included with the .fmu archive. replace\_filesIf false, an already existing .fmu archive is not overwritten. Instead an error message is displayed.