AnyLogic
Expand
Font size

FluidToAgent

The FluidToAgent block converts portions of fluid or bulk matter into agents (discrete items).

This block serves as an interface 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 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 properties, 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). Demo model: FluidToAgent and AgentToFluidOpen the model in your AnyLogic desktop installation.

Properties

Create agent
Defines whether a new agent is created once the specified amount accumulates in this block (Per amount of fluid), or a new agent is created for each batch (Per each batch), namely, when the new batch comes in after the current batch.
Name: agentPerAmount
Type: boolean
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 property re-evaluated after creation of each agent. The amount of fluid cannot be less than the value of Utils.TOLERANCE.
Type: double
New agent
The type of agents generated by the block. To make the block generate agents of a custom type, select it from the list. If you have not defined this agent type yet, you can do this by clicking create a custom type 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 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 property below.
Type: locationType
Set new value at runtime: set_locationType(new value)
Valid values:
Source.LOCATION_NOT_SPECIFIED — Not specified
Source.LOCATION_NODE — Network / GIS node
Source.LOCATION_ATTRACTOR — Attractor
Source.LOCATION_XYZ — (x, y, z)
Source.LOCATION_LATLON — (latitude, longitude)
Source.LOCATION_GEO_PLACE — Geographic place
Node
[Visible if Location of arrival: Network / GIS node]
The network nodeGIS point, or GIS region where the agents created by this block are put.
Type: Node
Local variable: Agent agent — the agent
Attractor
[Visible if Location of arrival: Attractor]
The attractor where the agent will move.
Type: Attractor
Local variable: Agent agent — the agent
X, Y, Z
[Visible if Location of arrival: (x, y, z)]
The X, Y, and Z coordinates of the point where the agents will be put.
Type: double
Local variable: Agent agent — the agent
... in the network
[Visible if Location of arrival: (x, y, z)]
If the option is selected (true), the agents are added into the network you select in the Network property below.
Name: locationXYZInNetwork
Type: boolean
Network
[Visible if ...in the network is selected]
Network where the agents created by this block are put.
Type: Network
Local variable: Agent agent — the agent
Latitude, Longitude
[Visible if Location of arrival: (latitude, longitude)]
The latitude and longitude of the point on the GIS map where the agents will be placed.
Type: double
Local variable: Agent agent — the agent
Name of place
[Visible if Location of arrival: Geographic place]
The name of the particular location on the GIS map, where the agents will get on generation. You specify the name as a text put in quotes, for example, "London". The GIS map will search for a location with such name. The first location from the list of GIS search results will be used.
Type: String
Local variable: Agent agent — the agent
Speed
[Visible if Location of arrival is specified]
The speed of the generated agents.
Type: double
Default value: 10 m/s
Local variable: Agent agent — the agent

Animation

Storage tank
The name of the 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.
Name: storageTank
Type: StorageTank
Show batches in flowchart
If set, the block icon will display the current batch color.
Name: showBatchesInFlowchart
Type: boolean

Advanced

Add agents to
Defines where the agents created by this block will be stored: in the default population or in a custom population (specified below in the Population property).
Name: addToCustomPopulation
Type: boolean
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
Type: AgentList
Local variable: Agent agent — the agent

Actions

On exit
The 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
The 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.

units — the amount units
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.

units — the amount units
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.

units — the flow rate units
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.

units — the amount units
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?