As you have defined the modes of your system, let's now explore a bit more advanced feature: the Time Sequence.

In this tutorial, you will be able to simulate your mode-dependent Valis over time. Using time sequences, the user can calculate scenarios such as battery state or propellant’s mass over time, etc. In this tutorial, we will create a scenario to calculate the power consumed by our fan for a day (24 hours) where the modes of the fan are changed linearly.

  • The initial state of the fan is the OFF mode

  • After 8 hours, the state of the fan is in MIN mode (till 12 hours)

  • During lunch, the fan state is back to OFF mode

  • After one hour of lunch break (from 13 hours), the state of the fan is set to MAX mode

  • After 17 hours, the fan is reverted to OFF mode

With these conditions, we will now see how to calculate the power consumption over 24 hours.

(1) Creating a Time Sequence

  • Click on the time sequence module on the left side (1)

  • Upon entering the time sequence module, click on the + Add Time Sequence (2)

  • A new tab opens and you can now enter the name of the time sequence (e.g. Office_UseCase)

(2) Adding Modes to the Modelists

Once the time sequence is created, the next step is to add the modes related to our time sequence. In this tutorial, we will be using the fan_modes. To add the modes to the system:

  • Click on the + on the extreme right bottom corner to have the option Add Modelist. Click on it and select the Fan.States modes from the list

  • Please note that there is an option for an initial mode which is automatically set to OFF mode. For this scenario, we will keep it as it is

  • These steps are demonstrated in the gif below. Upon adding the modes, you can check in the run section if the modes are added

You can also add the modes to the time sequence in the run section. In case you want to see how your child’s modes change with respect to the Fan.states modes, you can add them and see the modifications.

(3) Defining Nodes

First, we have set our modes. Now, we will define nodes that can either change a mode, change its formula or implement a delay in its activation. In this example, we will study the “change mode”. We will use it to simulate the following scenario:

  • The Initial state of the fan is the OFF mode

  • After 8 hours, the state of the fan is in MIN mode (till 12 hours)

  • During lunch, the fan state is back to OFF mode

  • After one hour of lunch break (from 13 hours), the state of the fan is set to MAX mode

  • After 17 hours, the fan is reverted to OFF mode

  • Click on + on the setup page

Note: Since we have initially set that our initial mode is Fan.state.OFF, we don’t need to create a node for the OFF condition as the system is already in the OFF state.

  • Clicking on + on the setup page will open a tab “New Node”. Enter the following details:

    • Node type: Change Mode

    • Mode: Fan.states.Min

    • Start condition: time>=8hours

    • And click on Create

Similarly, create the other three nodes for OFF, MAX, and OFF with the following details:

OFF

MAX

OFF

  • Change Mode

  • Fan.states.OFF

  • time>=12hours

  • Change Mode

  • Fan.states.MAX

  • time>=13hours

  • Change Mode

  • Fan.states.OFF

  • time>=17hours

After completing all the previous steps, the final setup of the time sequence should look like the image below:

(4) Defining the run Settings of the Time Sequences

Since we are going to compute our simulation for 24 hours, we will set up our run settings. Click on the Run button next to the step and with the run, select the setting icon (1). Enter the following information, shown in the gif:

  • Display unit = hours

  • Max execution time = 24 hours

  • Time step = 1 hour

  • Storage time step = 1 hour

Once you have specified the run settings, click on > Run (1) to compute the value. After running the time sequence, you will get a timeline similar to the one below (with different colour codes).

(5) Adding Variables to compute the scenario

Our goal for this tutorial is to calculate how much power is consumed by our ValiFan in 24 hours. We added the simulation steps previously. Now, we have to add the Vali that we would like to calculate overtime. In our case, it is the Power_consumption Vali of the fan. Let's add this Vali to the variable list.

  • Click on the “+” on the bottom right corner and select the option Add Variable

  • On the tab that was opened, enter the name “Power Consumption”

  • In the formula column, you have to choose the mode-dependent Vali, the fan.power_consumption. Type “$”, you will have a list of options, and select the Fan.PowerConsumption Vali

  • Select the option Value over time and Integral and Create

  • Once you have added the variable, Run the time sequences. This would take a few seconds to complete. The above steps are shown in the gif below

While selecting the Vali, select the mode-dependent Vali. Don't select a normal Vali otherwise, it will give errors.

Once the time sequence is computed, two graphs will automatically show the power consumption over time and an integral graph.

(6) Inbuilt functions and Exit Rule

Congratulations on creating your first-time sequences! Let's now add some spice to this calculation. Let's say you want to have a battery attached to your fan and calculate how much time your battery lasts. Note that we want to stop the simulation when the battery power goes to zero.

To respect the above condition we will use this() and an exit rule to do our calculation. Let's use the this() function and then see the results.

The first step would be to create a new variable. Like earlier, click on the “Add Variable”.

  • Once the tab is opened, enter the name “Batterystate_over_time”

  • In the formula, type this(). This() is an in-built function in Valispace. Using the function this( ) we can consider the previous simulation value for the next value calculated in the simulation. This allows you to have the cumulative value of a given variable over time

  • Note that once you add this() in the formula, a new input “Initial Value“ is created. You can either input a Vali from the component module or you can input a number. For our case, we will add the “initial value” as 20W

  • In the formula, add the following “this() - PowerConsumption/Fan.PowerConsumption”. Don't forget to use “$” while selecting the mode-dependent Vali. Here, we are subtracting the value from the initial value

  • Click “Update“ and re-run the time sequences. The result would be similar to the image below:

When you look at the results, you can see that the battery consumption is still running even after it goes to zero. Therefore, we will now define the Exit Rule to stop the simulation. To add the Exit Rule follow these steps:

  • Click on the icon “X” next to the settings menu (1)

  • Upon clicking, a sidebar opens. Click on the “+ Add exit rule”

  • Input the following rule $batterystate_over_time <= 0. Note that when you type “$”, Valispace shows the list of Valis in the project. Make sure to select batterystate_over_time within the Time Sequence module

You can see the time at which the Exit Rule occurs in the variables as well as the run settings.

Wohooo!! Congratulations on your first creation of time sequences and also the completion of the fan tutorials.

Want to improve your time sequences? Try the following options:

  • Add the child’s modes to your time sequence eg: fan motor speed settings, and speed controller speed modes

  • Force a change of your child’s modes despite the mode links and see how your system behaves over time