AnyLogic
Expand
Font size

FluidToAgent

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 Sourceblock 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 Open the model page in AnyLogic Cloud. There you can run the model or download it (by clicking Model source files).

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
[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 re-evaluated after creation of each agent. The amount of fluid cannot be less than the value of Utils.TOLERANCE.
Value type: double
New agent
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
[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
[Visible if Location of arrival is (x, y, z)]
X,Y,Z coordinates of the point where the agents will be put.
Value type: 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
[Visible if ...in the network is selected]
Network where the agents created by this block are put.
Value type: Network
Local variable: Agent agent — the agent
Node
[Visible if Location of arrival is Network / GIS node]
Networknodegis-point, or gis-regionwhere the agents created by this block are put.
Value type: Node
Local variable: Agent agent — the agent
Attractor
[Visible if Location of arrival is AttractorAttractor where the agent will move.
Value type: Attractor
Local variable: Agent agent — the agent
Latitude, Longitude
[Visible if Location of arrival is (latitude, longitude)]
Latitude and longitude of the point on the GIS map where the agents will be placed.
Value type: double
Local variable: Agent agent — the agent
Name of place
[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.
Value type: 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
[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 — the agent

Actions

On exit
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
Action executed when the flow rate changes.
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

Fluid amount
Function Description
double amount() Returns the amount currently accumulated in the block. This amount is less than the total amount required to create an agent. If the amount is less than the value of Utils.TOLERANCE, the function returns 0.
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. If the amount is less than the value of Utils.TOLERANCE, the function returns 0.
double amountPassed() Returns the total amount passed through the input 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 input port of the block since the start of the simulation.
Flow rate
Function Description
double currentRate() Returns the current flow rate of fluid that goes in.
double currentRate(FlowRateUnits units) Returns the current flow rate of fluid (in given units) at the block input.
Agent
Function Description
double flush() Forces the block to create a new agent from the current amount accumulated in the block regardless of the block settings. The further operation mode of the block remains unchanged. If there is no fluid in the block, an exception is thrown.
double fluidInAgent() Returns the amount of fluid in the current agent that is leaving the block. If the amount is less than Utils.TOLERANCE, this function returns 0.
double fluidInAgent(AmountUnits units) Returns the amount of fluid in the current agent that is leaving the block in the specified units. If the amount is less than Utils.TOLERANCE, this function returns 0.
Batch
Function Description
Object getBatch() Returns the batch currently flowing into or having appeared at the block.
Resetting statistics
Function Description
void resetStats() Resets statistics collected for this block, including the statistics collected for its ports.

Ports

in
The input port.
out
The output port.
How can we improve this article?