Run Activate cosimulations in batch from Compose

Altair Compose is an excellent automation tool in general, and it can be used for streamlining your engineering workflows. Altair Activate is, on the other hand, a robust solution in which it’s easy to model systems of systems and perform multidomain simulations between Activate and another tool (MotionSolve, Flux, PSIM, etc.), called cosimulations.


In this short article, let’s bring Compose, Activate and MotionSolve together and look at how you can call an Activate – MotionSolve cosimulation in batch from Compose, as many times as you want, changing any desired parameters for each run.


For this, we need three things:



To simplify things, let’s work on a very simple cosimulation example found in the demo browser within Activate. If you want to look at the original version, it can be found at Demo Browser > Activate > Cosimulation > MotionSolve > Antenna.scm. The modified version is attached in this article, and it looks like this:


A computer screen shot of a computerDescription automatically generated


The model was modified to retrieve command line inputs given when executed through Activate Batch using getcmdinput(). Also, input and outputs are stored in a CSV file. This is the full initialization script that showcases these changes:


close all, clear, clc

% Change working directory to file location



% Retrieve command line inputs

Fin = str2num(getcmdinput(1));

outputLoc = getcmdinput(2);


% Save CSV output in desired location

outputName = ['results_', num2str(Fin), '.csv'];

csvFile = [outputLoc, filesep, outputName];


The MotionSolve XML file required for the cosimulation block is attached as well. It’s the same from the demo.


The Compose script is where the real automation occurs, so let’s have a look at it:


The first thing to do is to check if there’s an existing output directory or if it has to be created.


close all, clear, clc


% Define output location for cosimulation results

outputLoc = [cd, filesep, 'Results'];


% Create "Results" output directory if needed

if ~isdir(outputLoc)




Next, let’s define the values we want the input to the system to take (this is the input given from Activate to MotionView). In this case, I want 5 different values from a range between 1 and 7.5. Here I also define the paths to the Activate Batch .bat file and the Activate model.


% Inputs matrix

F = linspace(1, 7.5, 5);


% Activate batch execution command

cmdActivateBatch = 'C:\Program Files\Altair\2022.3\Activate2022.3\Activate_batch';

% Input Activate model

cmdModel = [cd, filesep, 'Antenna cosim.scm'];


I also initialize a figure and edit title and x-axis label accordingly before running the simulations.


% Create figure for displaying all runs


title('MotionSolve - Activate cosimulation results');

xlabel('Time [s]');

hold on

legend on


Now, let’s go over a loop and, for each input value, execute the Activate – MotionSolve simulation from Compose as a system command. The syntax for running this script is simple: My Activate install\Activate_batch -f file to run -i any number of inputs. In this case, the inputs are f and outputLoc. Once the cosimulation is finished, the CSV output is read and data is extracted and plotted.


for f = F


      % System command for Activate batch execution

      command = ['set ALTAIR_HOME=&"', cmdActivateBatch, '" -f "', cmdModel, '" -i ', num2str(f), ' "', outputLoc, '"'];

      system(command, 'sync');


      % Read output file

      outputLog = [outputLoc, filesep, 'results_', num2str(f), '.csv'];

      data = csvread(outputLog);


      % Extract time & response signals

      t = data(:,1);

      r = data(:,3);


      % Plot and set label

      thisLine = plot(t,r);

      set(thisLine, 'displayname', sprintf('F = %g', f));




After running this script, you will be able to visualize the effect that changing f has on the system’s response:


A graph with a white backgroundDescription automatically generated


This is an intentionally simple example to get you started. Go ahead and take your cosimulation workflow to the next level leveraging these automation techniques!