As you have defined the modes of your system, let's now explore a bit 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 overtime or propellant mass overtime, etc. In this tutorial, we will simulate 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 OFF mode

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

  • During the 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 Enter the name of the time sequence(eg: Office_UseCase)

2. Adding Modes to the Modelists

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

  • Click on the + on the extreme right bottom corner to have the option Add modelist. Click on the Add Modelists and Select the Fan.States modes from the list.

  • Please note that there is an option for initial modewhich is automatically set to OFF mode. For this scenario, we would 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 if you want to see how your child modes change with respect to Fan.states modes, you can add them and see how it changes.

3. Defining Nodes

First, we set our modes, now we will define nodes that can either change a mode, change its formula or implement a delay in its activation. For this example, we will use “change mode. We are going to use change mode to simulate the following scenario

  • The Initial state of the fan is OFF mode

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

  • During the 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, it does not need to create a node for OFF condition as the system is in OFF state.

  • This 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 setting up the time sequence, 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 gonna compute our simulation for 24 hours, we will set up our run settings. Click on the Run 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 hours

  • Storage time step = 1 hours

Once you define the run settings, click on the > Run (1) to compute the value. After running you would get a similar timeline below( with different color codes)

5. Adding Variable to compute the scenario

Since our goal of the tutorial is to calculate how much power is consumed by our ValiFan for 24 hours. We have added the simulation steps in our previous steps. 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. So 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 as 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 had 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, 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

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

So, for the above condition, we will use this() and an exit rule to do our calculation. so 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 use the previous simulation value for the next calculated value in the simulation. This allows you 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 formula this() - PowerConsumption/Fan.PowerConsumption (don't forget to use “$” while selecting the mode-dependent vali). So what we are doing here is that 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 clearly see that the battery consumption is happening even after it goes to zero. Therefore, we will define now the exit rule to stop the simulation. To add the exit rule,

  • 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 timesequence module.

You can see the time at which the exit rule occurs in the variable as well as the run settings.

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

Want to improve your time sequences, Try the following options

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

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