MATLAB DAE (UDLS Version)


Required Environment

Required Solver

  • fsolve (preinstalled with MATLAB)
  • Any ODE solver (preinstalled with MATLAB)

User Options

  • NleTolFun: MATLAB’s option to set the convergence criterion for fsolve. For more information refer to MATLAB’s documentation.
  • NleMaxIter: MATLAB’s option to set the maximum number of iterations for fsolve. For more information refer to MATLAB’s documentation.
  • NleDisplayIter: MATLAB’s option to set whether intermediate steps of iterations for fsolve appear on the screen. For more information refer to MATLAB’s documentation.
  • OdeSolver: Option to set the solver used to solve the DAE system. For more information refer to MATLAB’s documentation.
  • PlotType: Option to set the plot type of the the results.
    • 0: Plot the variables into individual figures.
    • 1: Plot into sub figures.
    • 2: Plot all selected into one figure.

Usage for Simulation

  1. Open an DAE Evaluation in MOSAIC.
  2. Set the variable specs to obtain a degree of freedom of zero.
  3. Select the User-defined Lang Spec “MATLAB DAE (UDLS Version)” via Library > User-Defined Language Specification > DAE – Differential Algebraic Equation Systems.
  4. Choose the Code Generator and Solver Properties in accordance with the User Options above.
  5. Press Generate Code.
  6. Copy everything from the View Code tab and paste it to a new m-file inside MATLAB’s IDE.
  7. Save the new m-file.
  8. Press run inside MATLAB’s IDE.
  9. After completion the results appear in MATLAB’s command line window.
  10. Copy the lines containing the variable names and their final values and paste them into the Import tab of MOSAIC’s evaluation environment.
  11. Select the Predefined Language Specification “MATLAB DAE” and press Import.
  12.  The results will automatically update the Initial values in the Variable Specification tab and can be saved for future use by pressing Save As.