Page 1 of 1

Time of day in Ventity

Posted: Mon Oct 18, 2021 9:27 am
by cobleg
Is there explicit recognition of the time of day in Ventity? For example, is there a Get Time Value function?

Re: Time of day in Ventity

Posted: Mon Oct 18, 2021 1:53 pm
by tomfid
You can get the date somponents with SimulationDay() etc.

We don't have the equivalent for time of day, but you can use Modulo. When calendar time is active, Time starts at 0 and increments by time step. So, with a time step of an hour (or some fraction thereof),

Time of Day = Modulo(time, hours per day) ~ hours
Hours per day = 24 ~ hours/day

Re: Time of day in Ventity

Posted: Tue Oct 19, 2021 3:59 am
by cobleg
Thanks. I also need to work with higher frequency time intervals, e.g. every half-hour. Is there a way of integrating that with calendar time too? For example, instead of showing hourly subdivision for each day (see below) is it possible to show 48 subdivisions in DateTime to show the half-hour intervals?
DateTime hours in Ventity.png
DateTime hours in Ventity.png (45.56 KiB) Viewed 7413 times

Re: Time of day in Ventity

Posted: Tue Oct 19, 2021 12:50 pm
by tomfid
I'm pretty sure just setting time step to 0.5 hour will do that.

Re: Time of day in Ventity

Posted: Tue Oct 19, 2021 9:46 pm
by cobleg
Ok, thanks. Seems obvious now that you pointed that out. I managed to get what I needed - namely a repeating index to use in a lookup table. :D
To achieve that for a 48 interval day with each interval being 30 minutes, I dialled in these settings:
1. Run Control: Time Step = 0.02083333 (i.e. 1/48), Unit of Time = 0.5*Hour
2. Defined an auxiliary "Intervals per day", Units = 0.5*Hour, Equation = 48* Time Step
3. Defined an auxiliary "Time of Day", Units = 0.5*Hour, Equation = Modulo(Time, Intervals per day)

Note that using Time Step in 2. was required to get the repeating index.

I have attached my simple example model in case this helps someone else. :mrgreen:

Re: Time of day in Ventity

Posted: Wed Oct 20, 2021 2:28 pm
by tomfid
I think there may be some unintended consequences to this.

0.5*hour isn't understood as a time unit. The calendar algorithm seems to be defaulting to days as a result. (since time = 2 at the end of the 10/21-10/22 interval).

Units checking is likely to have trouble later, because a unit with the * operator in it will be interpreted as (0.5)*(hour) - not sure a "0.5" will be understood.

If you want one time unit to be half an hour you could name it something like HalfHour, but I'm not sure the calendar time algorithm will recognize that.

I would instead set Time Step = 0.5 with time unit "Hour".

Re: Time of day in Ventity

Posted: Wed Oct 20, 2021 2:33 pm
by tomfid
High Frequency 2.zip
(6.96 KiB) Downloaded 547 times

Re: Time of day in Ventity

Posted: Wed Oct 20, 2021 10:30 pm
by cobleg
Thanks for the additional advice. Much appreciated!