question

Gabriela Gomes avatar image
1 Like"
Gabriela Gomes asked Gabriela Gomes commented

How can I use probability distributions in the FloWorks source?

I tried to insert the variability of the fluid amount in the trigger “On Output Amount”-> “Set Flow Trigger Interval” and also the “Change Max. Flow Rate”, but I believe it’s not working, because the Output Rate continues the same. How can I add a stochastic measure to represent a variable inflow rate?imagem-2023-10-03-180117537.png

FlexSim 23.1.1
sourceFloWorksprobability distribution
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Kavika F avatar image
0 Likes"
Kavika F answered Gabriela Gomes commented

Hey @Gabriela Gomes, you can set the flowrate of a Source by setting the source's output maxRate through FlexScript.

  1. FlowObject source = Model.find("Flow Source1");
  2. source.output.maxRate = uniform(1, 100, getstream(source));

I made a simple model with this script that demonstrates this behavior.

source-output.fsm

You can apply this script to a ProcessFlow that spawns a token every X seconds to run a custom code with this script so the flow will change periodically without your input needed.


source-output.fsm (37.0 KiB)
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Mischa Spelt avatar image
1 Like"
Mischa Spelt answered Gabriela Gomes commented

Hi Gabriela,

The "On Output Amount" trigger is meant to be used together with a "Set output trigger". For example, in the On Reset event or another event, you can set

  1. source.output.triggerAmount = 1000; // (1)
  2. // or
  3. source.output.triggerInterval = 1000; // (2)

And then FloWorks will run the code in the On Output Amount event after the source has released 1000 units of flow. If you use option (1) the event will only fire once, option (2) will continue firing it after output of 1000, 2000, 3000, etc. Instead of using code, you can also use the Set flow trigger Process Flow activity to set the trigger amount, then use a Wait for Event or Event Triggered Source to wait for the amount.

So this is useful if you want to switch rates each time after a certain amount of flow. To switch after a certain amount of time you can use the solution that @Kavika F provided. Note that you don't even have to write code, you can use the Set Maximum Flow activity that FloWorks provides:

1696842543931.png



1696842543931.png (33.4 KiB)
· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.