Coupling MATLAB using CoTherm

The matrix-based MATLAB language is a natural way to express computational mathematics and as such is a natural solution for many engineering problems. If you are already a CoTherm user, getting started with MATLAB coupling is easy. MATLAB is now seamlessly integrated with CoTherm and includes a new tool, task, and variable as well as MATLAB code integration.

Direct coupling functionality for MATLAB and MATLAB Simulink has been integrated into CoTherm using the C++ Application Programming Interface (API) to get and set variable values from the MATLAB workspace using CoTherm.  In CoTherm, the user can define MATLAB tools, variables, run tasks, and code.  When MATLAB is called the first time, CoTherm opens an instance that continues to run in the background as subsequent tasks call MATLAB.

MATLAB Tool:

  • Requires location of MATLAB installation executable
  • CoTherm launches this tool when required and communicates using API
  • MATLAB continues running in the background and is used by MATLAB tasks

1_MATLAB Tool

MATLAB Variable:

  • Links a MATLAB workspace variable into CoTherm
  • Specified by the variable name
  • Values in CoTherm are updated/tracked using Variable Update Tasks
  • Supports scalar and array data

New symbols allow 2D array access:

  • $MatlabVariable.rowCount
  • $MatlabVariable.columnCount
  • $MatlabVariable[i]
  • $MatlabVariable.at(x,y)

2_MATLAB Variable

MATLAB Run Task:

The MATLAB Run Task allows you to execute its code from CoTherm, whether from a separate file or self-contained in the .pmd file

3_MATLAB Run Task

MATLAB Code Integration:

  • MATLAB code can be called from files on disk or Defined Text Files (contents stored in CoTherm)
  • CoTherm text editor supports MATLAB syntax highlighting & CoTherm symbol references
  • CoTherm symbols in defined text files are likely the most convenient way to pass CoTherm inputs into MATLAB

4_MATLAB Code Integration

These new features allow the power of MATLAB and related technologies (e.g., Simulink) to be easily integrated into any CoTherm process involving coupling, pre-processing, or post-processing. MATLAB variables link the MATLAB workspace with CoTherm variables.  Supported variable types include scalar and array data, and new symbols allow 2D array access to specific rows and columns as specified by the user. MATLAB code can be called from files on disk or using Defined Text Files that are stored in CoTherm. The CoTherm text editor supports MATLAB syntax highlighting.


The CoTherm-MATLAB roundtrip workflow is shown in the figure below.

5_Roundtrip Workflow2

Coupling MATLAB using CoTherm

Coupling MATLAB using CoTherm is a robust way to add transient 3D thermal analysis to script or system-level models in MATLAB and MATLAB Simulink.  These models can be used to simulate results-dependent boundary conditions for TAITherm or CFD (two-way coupling), to provide transient inputs for TAITherm (one-way coupling), to access and couple Simulink models, to plot data using interactive plots, or to link MATLAB and Python functions in support of CAE thermal simulation processes. 

An example CoTherm process of two-way coupling is shown in the figure below. 

6_Coupling

 


The temperatures for the first TAITherm run are initialized, then TAITherm is run to get initial temperatures of all the parts of interest, and then a thermal analysis report is run to read TAITherm results into MATLAB.  Then MATLAB is called to calculate a heat rate, which is read into CoTherm and then passed into TAITherm for the subsequent run.  The loop continues until values stop changing. 

Regulating Cabin Temperatures

This example process is for modeling an HVAC control process to regulate vehicle cabin temperatures to maintain the comfort of the occupants. The Simulink model represents a differential equation solver that solves for the vent outlet temperature as a function of compressor power, which is turned on and off to regulate the temperature of the cabin.  The inputs to the process are initial temperatures, a weather file specifying solar loading and ambient conditions, temperature limits, and heat rate limits for the HVAC system.

A diagram of the coupling process is shown below. 

7_Coupling Process

The cabin is cooled down from 38°C to maintain mean cabin temperatures around 20°C.  The under-shoot and over-shoot can be adjusted using control system parameters. 

7_Coupling Temp VS Time

This proof of concept model shows the functionality that MATLAB Simulink can add to a 3D TAITherm cabin thermal comfort simulation, which is commonly used to determine how comfortable vehicle occupants will be and what type of mechanical systems and controls should be designed and integrated into the vehicle to maintain optimal comfort.

An animation of the cool-down process is shown below. 

The optimal control strategy for cabin temperature regulation is to maintain the comfort of the occupants without expending too much energy, which leads to reduced gas mileage in ICE vehicles and reduced range in EVs.  Using the TAITherm human comfort model in conjunction with a MATLAB Simulink HVAC and controls model offers the best simulation approach for regulating cabin comfort on an energy budget.

Results

System-level/1D models provide complex component and system analysis and allow for interaction between mechanical, thermal, electrical, magnetic, and chemical effects, but they lack accurate temperature prediction when high-resolution 3D geometry is required.  Coupling 1D models with TAITherm empowers engineers to simulate comprehensive, integrated systems using dynamic, realistic thermal behaviors and conditions during long transient cycles. 

System integration sub-models include battery management systems, HVAC, cabin comfort, power electronics, e-motors, and coolant flow.  Many powerful simulation capabilities, such as large-scale simulations and system-level simulations, can be achieved using system models coupled with 3D thermal models, and essential vehicle performance criteria can be evaluated, which include energy consumption and range prediction.

No matter where you are in your simulation journey, we are here to help you take the next step toward more advanced methods. If you want to take the next step toward using MATLAB with CoTherm, contact our technical sales team to discuss how the tool can advance your project.

Request A Demo

Visit our website at suppport.thermoanalytics.com for

  • FAQs
  • Webinars
  • Tutorials

Get help from our technical support team:

1200 x 300px_Logos

 

Share this article on social media

Subscribe and receive a monthly email update of our blogs