logo资料库

FMI Toolbox for Matlab/Simulink的安装和使用说明.pdf

第1页 / 共190页
第2页 / 共190页
第3页 / 共190页
第4页 / 共190页
第5页 / 共190页
第6页 / 共190页
第7页 / 共190页
第8页 / 共190页
资料共190页,剩余部分请下载后查看
FMI Toolbox User's Guide 2.7
Table of Contents
Chapter 1. Introduction
1.1. The FMI Toolbox for MATLAB/Simulink
1.2. The Functional Mock-up Interface
Chapter 2. Installation
2.1. Supported platforms
2.2. Prerequisites
2.2.1. MATLAB/Simulink
2.2.1.1. FMU import
2.2.1.2. Simulink Coder/Real-Time Workshop
2.3. Installation procedure
2.3.1. For Windows
2.3.2. For Linux
2.3.3. Set MATLAB path
2.3.4. Unattended installation
2.3.4.1. Windows
2.3.4.2. Linux
2.4. External installation
2.4.1. MinGW-w64 GCC compiler
2.4.1.1. Installation
2.5. License information
2.5.1. Demo mode
2.6. Uninstallation procedure
2.6.1. For Windows
2.6.2. For Linux
2.6.3. Unattended uninstallation
2.6.3.1. Windows
2.6.3.2. Linux
2.7. Support
Chapter 3. Simulation with Simulink
3.1. Introduction
3.2. Getting started
3.3. FMU block properties
3.3.1. Set parameters and variables start values
3.3.2. Input ports
3.3.3. Output ports
3.3.3.1. Direct Feedthrough
3.3.4. FMU model information
3.3.5. Log
3.3.5.1. Create result file
3.3.5.2. Logger
3.3.6. Advanced
3.3.6.1. Block icon and mask
3.3.6.2. Tolerances (Not for FMU CS 1.0)
3.3.6.3. Sample times (FMU CS block only)
3.3.6.4. Reload FMU
3.3.6.5. Find FMU file on Model load
3.3.7. Coder
3.3.8. Scripting FMU block
3.3.9. Load FMU model
3.3.10. Reset an FMU model
3.3.11. Reload FMU model
3.3.12. Add Structured Ports to the FMU Block
3.3.13. Using the filter functions
3.4. FMU block and Simulink Coder
3.5. Examples
3.5.1. Changing start values and using the filter functions
3.5.2. Configure outputs
3.5.3. Configure ports using structural naming
3.5.4. Build target containing an FMU block
3.5.5. Build rti1006.tlc target containing an FMU block
3.5.5.1. Set start values and parameters
Chapter 4. Simulation in MATLAB
4.1. Introduction
4.2. A first example
4.3. Using the FMU model classes
4.3.1. Handle class
4.3.2. Calling functions
4.3.3. Help
4.4. Examples
4.4.1. Set start values and parameters
4.4.2. Simulation with inputs
4.4.3. Simulation with configured output
4.4.3.1. Using custom solver (Model Exchange only)
4.5. Upgrading to FMI 2.0
4.5.1. Converting from FMI 1.0 to FMI 2.0
4.5.2. Using both FMI 1.0 and FMI 2.0 in scripts
Chapter 5. FMU export from Simulink
5.1. Introduction
5.2. Getting started
5.3. Simulink Coder targets for FMU export
5.4. Selecting MEX C compiler
5.5. Co-Simulation export
5.5.1. Synchronization of time
5.5.2. Capability flags
5.5.3. Configuration Parameters
5.5.3.1. Solver
5.5.3.2. Optimization
5.5.3.3. Real-Time Workshop/Code Generation
FMU Export
Report
Comments
Symbols
Custom code
Debug
5.5.4. Support for user defined S-Function blocks
5.6. Model Exchange export
5.6.1. Configuration Parameters
5.6.1.1. Solver
5.6.1.2. Optimization
5.6.1.3. Real-Time Workshop/Code Generation
FMU Export
Report
Comments
Symbols
Custom code
Debug
5.6.2. Support for user defined S-Function blocks
5.7. Parameters
5.8. Internal signals
5.8.1. Test points
5.9. Supported data types
5.10. Supported blocks
5.11. Examples
5.11.1. Using a Simulink model to control a Vehicle model
5.11.1.1. Export Simulink model as FMU
5.11.1.2. Import FMU in vehicle model and simulate it in Dymola
Chapter 6. Design of Experiments
6.1. Introduction
6.1.1. Concepts
6.1.2. Workflow
6.2. Getting started
6.3. Function reference
6.3.1. FMUModelME1
6.3.1.1. trim
6.3.1.2. linearize
6.3.2. FMUDoESetup
6.3.2.1. Constructor
6.3.2.2. DoE methods
qmc - Quasi-Monte Carlo analysis
mc - Monte Carlo analysis
fullfact - Full factorial analysis
custom - User-defined test matrix
6.3.3. FMUDoEResult
6.3.3.1. properties
6.3.3.2. main_effects
6.3.3.3. bode
6.3.3.4. step
6.4. Examples
6.4.1. Mass-Spring system
6.4.1.1. Define the Experiment Setup
6.4.1.2. Run DoE experiments
6.4.1.3. Analyze results
Steady-state
Dynamic analysis
Chapter 7. Tutorial examples
7.1. Stabilization of a Furuta pendulum system
7.1.1. Tutorial
7.1.1.1. Simulate Furuta model with co-simulation block
7.2. Vehicle dynamics model simulated in Simulink with a driver
7.2.1. Tutorial
Chapter 8. Limitations
8.1. Simulink FMU block
8.2. MATLAB FMU Classes
8.3. FMU Export
8.3.1. Common target
8.3.2. Model Export target
8.3.3. Co-Simulation target
Chapter 9. License installation
9.1. Retrieving a license file
9.1.1. Get MAC address
9.2. Install a license
9.2.1. Installing a node-locked license
9.2.1.1. Windows
9.2.1.2. Unix
9.2.1.3. Updating the license
9.2.2. Installing a server license
9.2.2.1. Windows
9.2.2.2. Unix
9.2.2.3. Using the environment variable
9.2.2.4. Updating the license
9.3. Installing a license server
9.3.1. Configure the license file
9.3.2. Installation on Windows
9.3.3. Installation on Unix
9.4. Troubleshooting license installation
9.4.1. Running lmdiag
Chapter 10. Release notes
10.1. Release 2.7
10.2. Release 2.6.4
10.3. Release 2.6.3
10.4. Release 2.6.2
10.5. Release 2.6.1
10.6. Release 2.6
10.7. Release 2.5
10.8. Release 2.4
10.9. Release 2.3.3
10.10. Release 2.3.2
10.11. Release 2.3.1
10.12. Release 2.3
10.13. Release 2.2.1
10.14. Release 2.2
10.15. Release 2.1
10.16. Release 2.0.1
10.17. Release 2.0
10.18. Release 1.9
10.19. Release 1.8.6
10.20. Release 1.8.5
10.21. Release 1.8.4
10.22. Release 1.8.3
10.23. Release 1.8.2
10.24. Release 1.8.1
10.25. Release 1.8
10.26. Release 1.7.2
10.27. Release 1.7.1
10.28. Release 1.7
10.29. Release 1.6.1
10.30. Release 1.6
10.31. Release 1.5
10.32. Release 1.4.6
10.33. Release 1.4.5
10.34. Release 1.4.4
10.35. Release 1.4.3
10.36. Release 1.4.2
10.37. Release 1.4.1
10.38. Release 1.4
10.39. Release 1.3.1
10.40. Release 1.3
10.41. Release 1.2
10.42. Release 1.1
10.43. Release 1.0
Bibliography
FMI Toolbox User's Guide 2.7
FMI Toolbox User's Guide 2.7 Publication date 2019-06-02 Copyright © 2019 Modelon AB Ideon Science Park SE-22370 LUND Self publishing ALL RIGHTS RESERVED. This document contains material protected under International Copyright Laws and Treaties. Any unauthorized reprint or use of this material is prohibited. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, or by any information storage and retrieval system without express written permission from the author / publisher.
Table of Contents 1. Introduction .............................................................................................................................. 1 1.1. The FMI Toolbox for MATLAB/Simulink ........................................................................... 1 1.2. The Functional Mock-up Interface ...................................................................................... 1 2. Installation ................................................................................................................................ 3 2.1. Supported platforms ......................................................................................................... 3 2.2. Prerequisites ................................................................................................................... 3 2.2.1. MATLAB/Simulink ............................................................................................... 3 2.2.1.1. FMU import .............................................................................................. 3 2.2.1.2. Simulink Coder/Real-Time Workshop ............................................................ 4 2.3. Installation procedure ....................................................................................................... 6 2.3.1. For Windows ....................................................................................................... 6 2.3.2. For Linux ............................................................................................................ 7 2.3.3. Set MATLAB path ................................................................................................ 7 2.3.4. Unattended installation ........................................................................................... 7 2.3.4.1. Windows ................................................................................................... 7 2.3.4.2. Linux ....................................................................................................... 8 2.4. External installation ......................................................................................................... 9 2.4.1. MinGW-w64 GCC compiler ................................................................................... 9 2.4.1.1. Installation ................................................................................................. 9 2.5. License information ........................................................................................................ 10 2.5.1. Demo mode ........................................................................................................ 10 2.6. Uninstallation procedure .................................................................................................. 10 2.6.1. For Windows ...................................................................................................... 10 2.6.2. For Linux ........................................................................................................... 11 2.6.3. Unattended uninstallation ...................................................................................... 11 2.6.3.1. Windows ................................................................................................. 11 2.6.3.2. Linux ...................................................................................................... 12 2.7. Support ........................................................................................................................ 12 3. Simulation with Simulink .......................................................................................................... 13 3.1. Introduction .................................................................................................................. 13 3.2. Getting started ............................................................................................................... 13 3.3. FMU block properties ..................................................................................................... 19 3.3.1. Set parameters and variables start values .................................................................. 19 3.3.2. Input ports ......................................................................................................... 22 3.3.3. Output ports ....................................................................................................... 22 3.3.3.1. Direct Feedthrough .................................................................................... 25 3.3.4. FMU model information ....................................................................................... 27 3.3.5. Log ................................................................................................................... 29 3.3.5.1. Create result file ....................................................................................... 30 3.3.5.2. Logger .................................................................................................... 31 iii
FMI Toolbox User's Guide 2.7 3.3.6. Advanced ........................................................................................................... 31 3.3.6.1. Block icon and mask ................................................................................. 32 3.3.6.2. Tolerances (Not for FMU CS 1.0) ................................................................ 33 3.3.6.3. Sample times (FMU CS block only) ............................................................. 33 3.3.6.4. Reload FMU ............................................................................................ 33 3.3.6.5. Find FMU file on Model load ..................................................................... 33 3.3.7. Coder ................................................................................................................ 34 3.3.8. Scripting FMU block ........................................................................................... 35 3.3.9. Load FMU model ................................................................................................ 36 3.3.10. Reset an FMU model ......................................................................................... 37 3.3.11. Reload FMU model ............................................................................................ 37 3.3.12. Add Structured Ports to the FMU Block ................................................................ 37 3.3.13. Using the filter functions ..................................................................................... 37 3.4. FMU block and Simulink Coder ....................................................................................... 38 3.5. Examples ...................................................................................................................... 39 3.5.1. Changing start values and using the filter functions .................................................... 39 3.5.2. Configure outputs ................................................................................................ 41 3.5.3. Configure ports using structural naming ................................................................... 46 3.5.4. Build target containing an FMU block ..................................................................... 51 3.5.5. Build rti1006.tlc target containing an FMU block ...................................................... 55 3.5.5.1. Set start values and parameters .................................................................... 58 4. Simulation in MATLAB ............................................................................................................ 59 4.1. Introduction .................................................................................................................. 59 4.2. A first example ............................................................................................................. 59 4.3. Using the FMU model classes .......................................................................................... 61 4.3.1. Handle class ....................................................................................................... 61 4.3.2. Calling functions ................................................................................................. 61 4.3.3. Help .................................................................................................................. 62 4.4. Examples ...................................................................................................................... 63 4.4.1. Set start values and parameters .............................................................................. 63 4.4.2. Simulation with inputs .......................................................................................... 65 4.4.3. Simulation with configured output .......................................................................... 67 4.4.3.1. Using custom solver (Model Exchange only) .................................................. 69 4.5. Upgrading to FMI 2.0 ..................................................................................................... 69 4.5.1. Converting from FMI 1.0 to FMI 2.0 ...................................................................... 69 4.5.2. Using both FMI 1.0 and FMI 2.0 in scripts .............................................................. 71 5. FMU export from Simulink ........................................................................................................ 72 5.1. Introduction .................................................................................................................. 72 5.2. Getting started ............................................................................................................... 72 5.3. Simulink Coder targets for FMU export ............................................................................. 78 5.4. Selecting MEX C compiler .............................................................................................. 80 5.5. Co-Simulation export ...................................................................................................... 80 iv
FMI Toolbox User's Guide 2.7 5.5.1. Synchronization of time ........................................................................................ 80 5.5.2. Capability flags ................................................................................................... 81 5.5.3. Configuration Parameters ...................................................................................... 82 5.5.3.1. Solver ..................................................................................................... 82 5.5.3.2. Optimization ............................................................................................ 82 5.5.3.3. Real-Time Workshop/Code Generation ......................................................... 82 5.5.4. Support for user defined S-Function blocks .............................................................. 85 5.6. Model Exchange export .................................................................................................. 87 5.6.1. Configuration Parameters ...................................................................................... 87 5.6.1.1. Solver ..................................................................................................... 87 5.6.1.2. Optimization ............................................................................................ 88 5.6.1.3. Real-Time Workshop/Code Generation ......................................................... 88 5.6.2. Support for user defined S-Function blocks .............................................................. 91 5.7. Parameters .................................................................................................................... 92 5.8. Internal signals .............................................................................................................. 92 5.8.1. Test points ......................................................................................................... 94 5.9. Supported data types ...................................................................................................... 95 5.10. Supported blocks .......................................................................................................... 96 5.11. Examples .................................................................................................................. 107 5.11.1. Using a Simulink model to control a Vehicle model ............................................... 107 5.11.1.1. Export Simulink model as FMU ............................................................... 107 5.11.1.2. Import FMU in vehicle model and simulate it in Dymola ............................... 109 6. Design of Experiments ............................................................................................................ 113 6.1. Introduction ................................................................................................................. 113 6.1.1. Concepts .......................................................................................................... 113 6.1.2. Workflow ......................................................................................................... 114 6.2. Getting started ............................................................................................................. 114 6.3. Function reference ........................................................................................................ 117 6.3.1. FMUModelME1 ................................................................................................ 118 6.3.1.1. trim ....................................................................................................... 118 6.3.1.2. linearize ................................................................................................. 119 6.3.2. FMUDoESetup .................................................................................................. 120 6.3.2.1. Constructor ............................................................................................ 120 6.3.2.2. DoE methods .......................................................................................... 123 6.3.3. FMUDoEResult ................................................................................................. 126 6.3.3.1. properties ............................................................................................... 126 6.3.3.2. main_effects ........................................................................................... 127 6.3.3.3. bode ...................................................................................................... 129 6.3.3.4. step ....................................................................................................... 130 6.4. Examples .................................................................................................................... 130 6.4.1. Mass-Spring system ........................................................................................... 130 6.4.1.1. Define the Experiment Setup ..................................................................... 130 v
FMI Toolbox User's Guide 2.7 6.4.1.2. Run DoE experiments .............................................................................. 131 6.4.1.3. Analyze results ....................................................................................... 132 7. Tutorial examples ................................................................................................................... 139 7.1. Stabilization of a Furuta pendulum system ........................................................................ 139 7.1.1. Tutorial ............................................................................................................ 140 7.1.1.1. Simulate Furuta model with co-simulation block ........................................... 147 7.2. Vehicle dynamics model simulated in Simulink with a driver ............................................... 149 7.2.1. Tutorial ............................................................................................................ 150 8. Limitations ............................................................................................................................ 157 8.1. Simulink FMU block .................................................................................................... 157 8.2. MATLAB FMU Classes ................................................................................................ 157 8.3. FMU Export ................................................................................................................ 158 8.3.1. Common target .................................................................................................. 158 8.3.2. Model Export target ........................................................................................... 160 8.3.3. Co-Simulation target .......................................................................................... 160 9. License installation ................................................................................................................. 161 9.1. Retrieving a license file ................................................................................................. 161 9.1.1. Get MAC address .............................................................................................. 161 9.2. Install a license ............................................................................................................ 163 9.2.1. Installing a node-locked license ............................................................................ 163 9.2.1.1. Windows ............................................................................................... 163 9.2.1.2. Unix ..................................................................................................... 163 9.2.1.3. Updating the license ................................................................................ 164 9.2.2. Installing a server license .................................................................................... 164 9.2.2.1. Windows ............................................................................................... 164 9.2.2.2. Unix ..................................................................................................... 165 9.2.2.3. Using the environment variable .................................................................. 166 9.2.2.4. Updating the license ................................................................................ 166 9.3. Installing a license server .............................................................................................. 166 9.3.1. Configure the license file .................................................................................... 166 9.3.2. Installation on Windows ...................................................................................... 167 9.3.3. Installation on Unix ............................................................................................ 168 9.4. Troubleshooting license installation ................................................................................. 169 9.4.1. Running lmdiag ................................................................................................. 169 10. Release notes ....................................................................................................................... 171 10.1. Release 2.7 ................................................................................................................ 171 10.2. Release 2.6.4 ............................................................................................................. 171 10.3. Release 2.6.3 ............................................................................................................. 171 10.4. Release 2.6.2 ............................................................................................................. 172 10.5. Release 2.6.1 ............................................................................................................. 172 10.6. Release 2.6 ................................................................................................................ 172 10.7. Release 2.5 ................................................................................................................ 172 vi
FMI Toolbox User's Guide 2.7 10.8. Release 2.4 ................................................................................................................ 173 10.9. Release 2.3.3 ............................................................................................................. 173 10.10. Release 2.3.2 ............................................................................................................ 173 10.11. Release 2.3.1 ............................................................................................................ 174 10.12. Release 2.3 .............................................................................................................. 174 10.13. Release 2.2.1 ............................................................................................................ 174 10.14. Release 2.2 .............................................................................................................. 174 10.15. Release 2.1 .............................................................................................................. 175 10.16. Release 2.0.1 ............................................................................................................ 175 10.17. Release 2.0 .............................................................................................................. 175 10.18. Release 1.9 .............................................................................................................. 175 10.19. Release 1.8.6 ............................................................................................................ 176 10.20. Release 1.8.5 ............................................................................................................ 176 10.21. Release 1.8.4 ............................................................................................................ 176 10.22. Release 1.8.3 ............................................................................................................ 176 10.23. Release 1.8.2 ............................................................................................................ 176 10.24. Release 1.8.1 ............................................................................................................ 177 10.25. Release 1.8 .............................................................................................................. 177 10.26. Release 1.7.2 ............................................................................................................ 178 10.27. Release 1.7.1 ............................................................................................................ 178 10.28. Release 1.7 .............................................................................................................. 178 10.29. Release 1.6.1 ............................................................................................................ 179 10.30. Release 1.6 .............................................................................................................. 179 10.31. Release 1.5 .............................................................................................................. 179 10.32. Release 1.4.6 ............................................................................................................ 179 10.33. Release 1.4.5 ............................................................................................................ 179 10.34. Release 1.4.4 ............................................................................................................ 179 10.35. Release 1.4.3 ............................................................................................................ 180 10.36. Release 1.4.2 ............................................................................................................ 180 10.37. Release 1.4.1 ............................................................................................................ 180 10.38. Release 1.4 .............................................................................................................. 180 10.39. Release 1.3.1 ............................................................................................................ 180 10.40. Release 1.3 .............................................................................................................. 180 10.41. Release 1.2 .............................................................................................................. 181 10.42. Release 1.1 .............................................................................................................. 181 10.43. Release 1.0 .............................................................................................................. 181 Bibliography .............................................................................................................................. 183 vii
Chapter 1. Introduction 1.1. The FMI Toolbox for MATLAB/Simulink The FMI Toolbox for MATLAB integrates Modelica-based physical modeling into the MATLAB/Simulink envi- ronment. FMI Toolbox offers the following main features: • Simulation of compiled dynamic models, FMUs, in Simulink. FMUs may be generated by an FMI-compliant tool such as SimulationX or Dymola. The Simulink FMU block offers configuration of parameter and start values as well as block outputs. The Simulink import supports FMI version 1.0 and 2.0 for both Model Exchange and Co-Simulation FMUs. • Export of Simulink models to FMUs. FMUs may be simulated in FMI compliant simulation tools such as Sim- ulationX or Dymola. Export is supported for FMI version 1.0 and 2.0 for Model Exchange and Co-Simulation. Requires Simulink Coder and FMI Toolbox Coder add-on. • Simulation of compiled dynamic models, FMUs, using MATLAB's built in integrators (e.g., ode45 and ode15s). This feature makes FMI Toolbox useful also for users without access to Simulink. • Static and dynamic analysis of FMUs through design-of-experiments (DoE) functions for optimization, cali- bration, control design, and robustness analysis. The dynamic analysis features require the MATLAB Control System Toolbox. • The FMI Toolbox supports FMI version 1.0 and 2.0 import in MATLAB for both Model Exchange and for Co- Simulation. DoE analysis is supported for Model Exchange 1.0. • FMU blocks are supported by Simulink Coder/Real-Time Workshop. It is possible to build a Simulink model containing an FMU block and run it on e.g dSPACE´s DS1006 platform for HIL (hardware-in-the-loop) simu- lations. 1.2. The Functional Mock-up Interface The Functional Mock-up Interface is a standard for exchange of compiled dynamic models, and is intended to promote model reuse and tool interoperability. Several tools provide export of Functional Mock-up Units (FMUs), all of which can be used with the FMI Toolbox for MATLAB. FMI provides two different formats for exchange of models: • FMI for Model Exchange (FMI-ME). The FMI-ME specification is based on a continuous-time hybrid Ordinary Differential Equation (ODE) representation. The FMU-ME provides inputs and outputs and exposes functions for setting parameters and computing the derivatives of the ODE. Environments importing FMU-MEs need to provide an integrator, or ODE solver, that integrates the dynamics of the model. 1
分享到:
收藏