Fluid To Agent


Converts portions of fluid or bulk matter into agents (discrete items). 

Serves as an interface block between the Fluid Library and the Process Modeling Library (or any other library based on it). The creation of a new agent can be triggered either by a certain amount accumulated at this block, or by a batch completely received (namely, by the next batch appearing at the input). 

Similarly to FluidDispose, this block can accept flow at any rate. When the agent is created, its fluid is deleted, and the new portion starts to accumulate.

FluidToAgent has a Process Modeling Library Source block inside and exposes all its parameters, including the On exit action where the amount in the agent and batch are accessible.

Demo model: FluidToAgent and AgentToFluid

Parameters

Create agent
Here you can choose whether a new agent is created once the specified amount accumulates in this block (Per amount of fluid option), or a new agent is created for each batch (Per each batch), namely, when the new batch comes in after the current batch.
Syntax: boolean agentPerAmount
Fluid in agent [dynamic]
[Visible and applies if Create agent: Per amount of fluid] Determines the amount of fluid needed to create an agent. This is a dynamic parameter reevaluated after creation of each agent.
Type of value: double
New agent [dynamic]
The type of agents generated by block. To make the block generate agents of some custom type, select it from the list. If you have not defined this agent type yet, you can do this by clicking the create a custom type link below.  
Default value: Agent
Local variables: double amount - the amount used to create this agent
                          Object batch - the current batch
Location of agent
Defines the place where the generated agents will be put. There are six alternative options:
Not specified - You do not specify the agents' arrival place.
Network / GIS node - Agents appear in the given network nodeGIS point, or GIS region.
Attractor - Agents appear in the specified attractor.
(x, y, z) - Agents appear in the point with the specified coordinates X, Y, Z.
(latitude, longitude) - Agents appear in the given point on the GIS map with the specified Latitude and Longitude.
Geographic place - Agents appear in the particular location on the GIS map. You define this place using the Name of place parameter below.
Get value: locationType
Set new value at runtime: set_locationType(new value)
Valid values: Source.LOCATION_NOT_SPECIFIED, Source.LOCATION_NODE, Source.LOCATION_ATTRACTOR, Source.LOCATION_XYZ, Source.LOCATION_LATLON, Source.LOCATION_GEO_PLACE
Speed [dynamic]
[Visible if Location of arrival is specified] The speed of the generated agents.
Value type: double
Default value: 10 m/s
Local variable: Agent agent - the agent
X, Y, Z [dynamic]
[Visible if Location of arrival is (x, y, z)] X,Y,Z coordinates of the point where the agents will be put.
Type of value: double
Local variable: Agent agent - the agent
... in the network
[Visible if Location of arrival is (x, y, z)] If the option is selected (true), the agents are added into the network you choose in the parameter Network below.
Syntax:  boolean locationXYZInNetwork
Network [dynamic]
[Visible if ...in network is selected] Network where the agents created by this block are put.
Value type: Network
Local variable: Agent agent - the agent
Node [dynamic]
[Visible if Location of arrival is Network / GIS node] Network nodeGIS point, or GIS region where the agents created by this block are put.
Value type: Node
Local variable: Agent agent - the agent
Attractor [dynamic]
[Visible if Location of arrival is AttractorAttractor where the agent will move.
Value type
: Attractor
Local variable: Agent agent - the agent
Latitude, Longitude [dynamic]
[Visible if Location of arrival is (latitude, longitude)] Latitude and longitude of the point on the GIS map where the agents will be placed.
Type of value: double
Local variable: Agent agent - the agent
Name of place [dynamic]
[Visible if Location of arrival is Geographic place] The name of the particular location on the GIS map, where the agents will get on generation. You specify the name as text put in quotes, e.g. "London". GIS map will search for a location with such name. The first location from the list of GIS search results will be used. 
Type of value: String
Local variable: Agent agent - the agent
Animation
Storage tank
Here you can specify the name of Storage tank space markup shape used to animate FluidToAgent (both in 2D and 3D animation). The storage tank animates the fluid the block currently contains.
Syntax: StorageTank storageTank
Show batches in flowchart
If set, the block icon will display the current batch color.
Syntax: boolean showBatchesInFlowchart
Advanced
Add agents to
Here you specify where the agents created by this block will be stored: in the default population, or in some custom population (specified below in the Population property).
Syntax: boolean addToCustomPopulation
Population [dynamic]
[Visible if Add agents to: custom population] The name of the agent population where the agents created by this block will be stored.
Name: AgentList
Local variable: Agent agent - the agent
Actions
On exit [code]
Action executed when an agent leaves the block. You can access the agent, the amount used to create the agent, and the batch.
Local variables: Agent agent - the agent
                          double amount - the amount used to create this agent
                          Object batch - the batch
On rate change [code]
Action executed when the flow rate changes. Please note that changing something in the action may result in another immediate rate change and immediately following another call of On rate change, so the user can possibly create a livelock.
Local variable:  double inrate - the current input rate

Functions

double amount()- Returns the amount currently accumulated in the block. This amount is less than the total amount required to create an agent.

double amount(AmountUnits units) - Returns the amount of fluid (in given units) currently accumulated in the block. This amount is less than the total amount of fluid required to create an agent.

double amountPassed() - Returns the total amount passed through the in port of the block since the start of the simulation.

double amountPassed(AmountUnits units) - Returns the total amount of fluid (in given units) passed through the in port of the block since the start of the simulation.

void resetStats() - Resets statistics collected for this block, including the statistics collected for its ports.

double currentRate() - Returns the current flow rate of fluid that goes in.

double currentRate(FlowRateUnits units) - Returns the current flow rate (in given units) of fluid at the block input.

Object getBatch()- Returns the batch currently flowing into or having appeared at the block.

Ports

in
The input port.
out
The output port.