Skip to main content
Skip table of contents

Octave Engine

Introduction

The octave engine (open-source MatLab compatible/tool) within the Scripting Module allows users to perform complex calculations within Valispace that are not very easy to perform/calculate in the Components Module. You can reference the Valis needed for the calculations as input Valis and the result as output Valis. Some common examples of such calculation involve solving non-linear equations, matrix multiplication or conditional cases.

Scripting flow for Octave engine scripts

The typical workflow of using the Scripting Module within Valispace is shown below. Each step is explained in each sub-sections.

1. Creating a New Octave Script

To create a new octave script in your project , hover over to the simulations module (1) and select “+ Script” (2). Upon clicking, a popup window opens; enter the name and select “Octave engine (Matlab compatibilite)” (3) click on “Create”. See image Creating Octave Script.

image-20240409-065900.png

Creating Octave Script - You can easily create an octave script in the scripting module to perform more complex calculations.

2. Inputs and Outputs

The user can add the input and output Valis. For example, when the user references the Vali within the inputs or outputs, the user can provide a short name for the Vali, which will then be used in your octave calculation code.

Example:

If you are using a Vali called “PowerConsumption.CRUISE” from your component module, you can simply assign an abbreviation of the variable such as “cruise“ (1). Once the Vali is referenced in the inputs, Valispace automatically adds the values along with the units (2).

The user can also change the simulation unit. e.g. the defined PowerConsumption for cruise in the components module is in W but for the simulation kW is used, which is defined in the “simulation unit” column (3). See image Setting up Valis.

image-20240409-070648.png

Setting up Valis - Valis can be defined as inputs or outputs for the octave script.

You can use any Vali from the Components Module either as an input or output, but not simultaneously as both.

3. Calculation/Octave code

As mentioned earlier, Valispace’s simulation module uses an octave engine that allows you to use Octave syntax. It is similar to and has excellent compatibility with Matlab, so you won’t have to familiarize yourself with a new framework to create complex calculations inside Valispace. You can read the GNU Octave Documentation Page if you need further information.

The users have to write the octave code in the “main.m” file(1). The instructions are written in the coding area on how the user can define the inputs and outputs (2). See Figure Octave Script for more info.

image-20240409-071350.png

Octave Script - Accessing the main.m file and defining the inputs and outputs in the script.

Once the code is added to the main.m file, the user can save the script by clicking on “Save”(3).

4. Run Simulations/Results

Once you are completed with your script, you can click on the play button, which can be found in the lower-left corner as shown in Figure Running Script.

image-20240409-071734.png

Running Script - By clicking on the play button in the lower right-hand corner the script is executed.

Once the simulation is completed, Valispace automatically updates the output values. As a result, the output Valis in the component modules get automatically updated by Valispace. If the output Valis are being used as constants in formulas to compute other Valis, Valispace automatically recalculates every Vali associated to the output Vali.

5. Scripting + Automation Use case

If any input values are being changed in the Components Module, the user has to rerun the simulation to recalculate the output values.

To avoid running simulations after every change in the input values, a link can be created between the Automations and the Scripting Module. Indeed, new automations with a constant trigger can be set to automatically rerun every simulation affected by a Vali’s change, as shown in the short clip below.

In this specific case the flight time of our Valicopter is adjusted from 15 min to 10 min, which automatically triggers a recalculation for the total necessary battery capacity. Since the total power subsystem mass is calculated based on the necessary battery capacity (how many batteries we need), with less flight time and thus less required battery capacity, the power subsystem mass is also recalculated and reduced.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.