Page 1 of 1

Using actions to change stock values

Posted: Fri Nov 29, 2019 9:42 am
by niallmnaidoo
Hi, I see the instructions on how to change attribute values. The manual says that it's also possible to change stock values or the values of flows related to stocks but I'm not clear on how this is done. Specifically, I would like a triggered action to record the value of an external time series data variable in a stock. Stock is preferable to attribute as the value should be numerical not a string. It would be helpful to know how command actions can change both stock values directly and via once-off changes to flows.
Thank you

Re: Using actions to change stock values

Posted: Sat Nov 30, 2019 6:28 pm
by tomfid
1. Drag a copy of the target stock onto the action diagram (using the parent or invoker reference)
2. Add an inflow to the stock.
3. Set the inflow equation for the stock to = newValue-stock

Note that the units on this flow are the same as the stock (unlike a normal dynamic equation where flow = stock/time).