Phase 1. Creating electrode batches

First, we will create a simple model where we will simulate how to manufacture the electrodes, cover them with special paste, and collect them into batches.

Create a new model

  1. Click the New toolbar button. The New Model dialog box is displayed.

  2. Specify the name of the model. In the Model name edit box, type Lead Acid Battery Production.

  1. Specify the location where you want to store your model files. Browse for the existing folder using the Browse button or type the name of the folder you want to create in the Location edit box.

  2. Leave seconds selected as the Model time units.

  3. Click Finish to complete the process.

New model is created. It already has one agent type called Main and one experiment called Simulation. Agents are the main building blocks of AnyLogic model. In our case the Main agent will serve as the place where will define all the logic of the model: here we will draw the production line and define the battery manufacturing process using a flowchart.

In the center of the workspace you will see the graphical editor. It shows the diagram of the Main agent.

To the left of the graphical editor you can see the Projects view and the Palette view sharing the same area. The Projects view provides access to AnyLogic models currently opened in the workspace. The workspace tree provides easy navigation throughout the models. The Palette view contains all graphical elements, which you can add onto the graphical editor of your agent just by drag'n'drop. Model elements are grouped by categories in a number of palettes.

On the right side of the workspace you can see the Properties view. The Properties view is used to view and modify the properties of a currently selected model element(s). When you select something – e.g., in the Projects view or in the graphical editor – the Properties view displays the properties of the selected item.

Now we can start developing the model.

Adding layout

We will use the following layout:

Save the layout image to your computer

  1. Right-click the image above, click Save picture as and select the model folder as the location for the file.
Now we can add this image to our model's canvas.

Place the layout on the canvas

  1. Drag the Image element from the Presentation palette on the graphical diagram. You can use the Image shape to add images in several graphic formats – including PNG, JPEG, GIF, and BMP – to your presentation.
  2. Choose the image file to be displayed by this shape. The file browser will open automatically. Browse to the model folder where you just saved the layout image file, select it, and then click Open in the dialog box. You will see the drawing displayed in the graphical editor.

    Alternatively, you can drag the image directly from the folder and drop in on the graphical editor.

  3. Make sure that the upper left corner of the image matches the axis origin.

  4. In the Properties view, select the Lock check box to lock the image.

    Locking shapes

Drawing the conveyor

Our next step is to draw the conveyor, which transfers electrodes from the point of their generation to the pasting machine and after that - to the storage location, using the space markup elements.

Material Handling Library markup is not only a set of instruments to define the layout of the model. Such elements as Conveyor, Station, Jib Crane also serve to define the logic of the model: the speed of material item movement, use of resources, etc.

Draw the conveyor

  1. Open the Space Markup palette. In the Material Handling section double-click the Conveyor element to activate its drawing mode. The icon of the element will change to .
  2. Draw the conveyor as displayed in the image below by clicking the graphic diagram once to place the starting point of the conveyor and then double-clicking to place its ending point. Note, that the direction of the conveyor movement will follow the placement of these points.

  3. In the Position and size section of conveyor's Properties specify the Z: 20.

Congratulations! We have finished drawing the first element of our production line. Now, let's build the flowchart to define the model logic behind this step.

Creating the flowchart

This flowchart will be composed from the Process Modeling Library and Material Handling Library blocks. Each block will define an operation performed on the electrodes in the course of production.

In AnyLogic you can create flowcharts by adding the blocks from the library palette to the graphical diagram, connecting the blocks to each other in the necessary order and tuning their parameters according to your modeling needs.

Create the model flowchart

  1. Drag the Source element from the Process Modeling Library palette to the Main diagram. We will use it to generate electrodes.

    Place the block at some distance below the layout, since the flowchart will expand with each step of the tutorial not only vertically but also horizontally, and you want to leave enough space to fit all the blocks.

  2. In the source block's Properties configure the parameters as displayed in the image below to make sure that the block will generate 200 electrodes every 1.5 hour and the electrodes will exit the block smoothly one by one:

    a. In the Arrivals defined by parameter select Interarrival time.
    b. In the Interarrival time box type 1.5 and select hours from the time units drop-down list.
    c. In the First arrival occurs parameter select At model start.
    d. Select the Multiple agents per arrival check box.
    e. In the Agents per arrival box type 200.
    f. In the Advanced section of the properties deselect Forced pushing check box.
    g. In the Agents that can't exit parameter select wait in this block from the drop-down list.

  3. To model the transfer of the electrodes by the conveyor, drag the Convey element from the Material Handling Library palette to the Main graphical diagram and place it next to the source block so that they are automatically connected as displayed in the image below:

    This is the single block of the Material Handling Library that controls the movement of the material items in the conveyor network. By default, it selects the shortest route from the starting point to the destination, but you can also specify the precise sequence of conveyors which should make up the route or use Avoid conveyors and Include conveyors options to customize it.

  4. In the convey block's Properties specify the Source conveyor: conveyor and Target conveyor: conveyor.

    There are two ways to refer to model elements from the block's parameters:
  5. Next, select the Leave conveyor on exit check box.

  6. Add a Sink block. It disposes of agents and is usually the last block in the flowchart.

We have finished building a simple flowchart and now can run the model and see how the electrodes move along the conveyor.

Start the model

  1. Click the Run toolbar button and choose the experiment you want to run from the drop-down list. Your simulation experiment is called Lead Acid Battery Production / Simulation.

In our case this model is the only one opened in the workspace at the moment, as a result you will be prompted to run this particular experiment. Later, on pressing this button you will start the previously launched experiment. To run any other experiment, right-click (Mac OS: Ctrl click) the experiment in the Projects view and choose Run from the context menu.

On starting the model, you will see the presentation of your top-level agent type (by default it's Main). The model will launch immediately. Observe the process dynamics. You will see how electrodes move along the conveyor in 2D animation, over the layout image.

If needed, adjust the execution speed to your needs using slow down and speed up controls.

Creating electrodes

You must have observed that the electrodes on the conveyor that we have just modeled didn't look much like real electrodes. To correct this, we will create a new agent that will represent them in our flowchart.

Create a new material item type
  1. Drag the Material Item Type element from the Material Handling Library palette on the Main graphical diagram.

  2. The New agent wizard will pop up automatically.
  3. On the first page of the wizard specify the Agent type name: Electrode.
  4. Click Next to proceed.

  5. The next step offers to choose the animation for the material item of this type. Since we will create the custom animation, select None and click Finish.

    AnyLogic will automatically open the graphical diagram of the new agent type.

  6. In the Properties view of the Electrode agent type expand the Dimensions and movement section and change the length, width, and height of the Electrode agent type according to the image below.

    The Properties view is context-sensitive: it always displays the properties of the currently selected item. You can select the item by clicking on it either in the model tree (in the Projects view) or in the graphical editor.

  7. Now, let's adjust the agent's scale. Pan the canvas of the Electrode agent graphical diagram down by clicking on the diagram and scrolling up until the Scale element comes into view. In the scale's properties set the Ruler length corresponds to: 1 meter. Note how the placeholder for the animation (located at the axis origin) has changed its size.

  8. Add the animation figure. Drag the Rectangle element from the Presentation palette on the Electrode graphical diagram and place it at the axis origin.
  9. In the Appearance section of the rectangle's properties leave the default Fill color unchanged.
  10. In the Line color drop-down menu select the No color option.
  11. In the Position and size section of the properties adjust the settings as displayed in the image below. Now the size of the rectangle will fit the animation placeholder exactly.

Now that we have finished creating the new agent, let's make some adjustments so that everything fits together properly:
  1. Go to the Main graphical diagram. Pan the canvas of the graphical diagram until the the scale element comes into view.
  2. In the scale element's properties, specify the Ruler length corresponds to: 5 meters.
  3. In the properties of the conveyor set the Width to 0.5 meter.
Now, we have to let our markup element (conveyor) and the flowchart know that the material item is represented by the Electrode agent.
  1. Open the conveyor properties and select Electrode as the Material item type:

  2. In the flowchart, select the the source block.
  3. In the block's properties, select Electrode from the New agent drop-down list.
Run the model now and observe how the animation have changed.

Pasting process

The lead grates must be covered with special paste that will become an active material which plays an important role in the electrochemical reactions of the battery's charging and discharging processes.

Add the pasting station

  1. Drag the Station element from the Space Markup palette to the Main graphical editor and place it on the conveyor we have drawn previously.

  2. In the station's Properties specify the following:

    a. Name: pastingMachine
    b. Process time: 1 second
    c: Offset from conveyor start: 80
    d: Length: 0.5 meter.

Dynamic color change

After going through the pasting machine, the electrodes change color. To define this change during the animation, we will introduce a variable.

  1. Drag the Variable element from the Agent palette on the Electrode graphical diagram.
  2. Call it color.
  3. In the Properties view of the variable specify:

    a. Type: Color
    b. Initial value: white

    Note, that white here is the name of a Java constant used to define the color.


  4. Go to the Appearance section of the rectangle properties. We want to use the dynamic value for the shape's Fill color that will allow our model to use the previously created color variable to determine the color of the electrode at runtime.

    a. Click the static property icon next to the Fill color field. After the icon changes to the dynamic property, a box will appear next to it.
    b. Type color in this box to link this property to the previously created variable of the same name.

  5. Expand the Actions section of the pastingMachine properties and type the following line of code in the On process finished field:

    With the help of this code we address each electrode (agent) that goes through the station and assign a new value (peru) to its color parameter at the moment when the station has just finished processing this agent (On process finished). When we run the model, we'll see how the electrodes change their color after passing through the pasting machine.

    You can use the Code Completion Master to simplify and streamline your work. Place the cursor where you want to enter the line of code, type the first letter of the word and press Ctrl Space. The wizard listing all the model variables and available functions will appear, and all the elements that begin with the letter you've typed will be listed at the top.

    Double-click the necessary entry and the wizard will complete it for you.
  6. Run the model and see how the grates change color after leaving the pasting station!

Batching process

The electrodes must be collected into batches to be transferred to the curing oven. Let's model this process.

Add the batch storage location

  1. Double-click the Rectangular node element in the Space Markup palette to switch to the drawing mode. The element's icon will change to . Click the Main graphical diagram at the ending point of the conveyor to place the starting point (corner) of the node and move the mouse until the node obtains the intended shape. At this point click the graphical editor again to finish the drawing. Here the electrode batches will be stored before transfer to the drying chamber.
  2. In the Properties view specify the following:

    a. Name: platesBuffer
    b. Visible: no
    c. Location layout: arranged.

  3. Expand the Advanced section of the node's properties and select Show in: 2D only.

Add the batch block to the flowchart
  1. Drag the sink block to the right in order to have some free space in the flowchart where you can place the new block.
  2. Drag the Batch block from the Process Modeling Library and place in on the flowchart before the sink block. The connection between blocks will be established automatically.
  3. In the batch block's Properties make the following adjustments:

    a. Specify the Batch size: 100. The block will accumulate 100 agents of Electrode type before releasing them as a single batch.
    b. In the Agent location parameter select the platesBuffer node.
    c. In the Location of batch parameter select Network/GIS node from the drop-down list.
    d. In the Node parameter select the platesBuffer node.

  4. Now, create a new material item type which will represent the electrode batches.

  5. Specify its Name: PlatesBatch.

  6. In the New agent wizard, during Step 2. Agent animation, leave the 3D option selected, expand the Warehouse and Container Terminals section and select the Pallet element. Click Finish.

  7. In the PlatesBatch properties specify:

    a. Length: 1.2 meter
    b. Width: 1.2 meter

  8. Select the scale element situated on the graphical editor of the PlatesBatch agent.
  9. Specify the Ruler length corresponds to: 1 meter.

  10. Drag the Rectangle element from the Presentation palette to the PlatesBatch graphical diagram. We will use this element to create the animation of the complete batch on the pallet.
  11. In the properties of the rectangle specify the following:

    a. Fill color: peru,
    b. Width: 100
    c. Height: 100
    d. Z-Height: 30

  12. Place the rectangle over the pallet as displayed in the image below:

  13. Go back to the Main agent graphical editor.
  14. Open the properties of the batch block and select PlatesBatch in the New batch parameter.

  15. Run the model again to see how the grates pass through the pasting machine, change color, and fill the storage area before disappearing.

Adding 3D animation

Now that logic of the first phase is complete, let's enhance our model with 3D animation.

The first step is placing the 3D window on the diagram of the agent type. 3D window plays the role of a placeholder for the 3D animation. It defines the area on the presentation where the 3D animation will be displayed at runtime.

Add 3D window

  1. Drag the 3D Window element from the 3D section of the Presentation palette to the Main graphical editor.
  2. The grey area will appear. Place it where you want your 3D presentation to be displayed at the model runtime:

Navigate through 3D animation

Now you can run your model and observe simple 3D animation.

  1. When you create a 3D window, AnyLogic adds a view area that allows you to easily navigate to the 3D view at runtime. To switch to this 3D view while the model is running, open the developer panel by clicking the Developer panel control in the right corner of the control panel. In the developer panel, expand the select view area to navigate list and select [window3d] from the list.

  2. Navigate through the 3D scene using the commands described below:

    In order to

    Use the mouse like described here

    Move the scene

    1. Press the left mouse button in the 3D view and hold the mouse button pressed.
    2. Move the mouse in the required direction.

    Rotate the scene

    1. Press Alt key (Mac OS: Option key) and hold it pressed.
    2. Click in the 3D scene window and, while holding Alt and the left mouse button down.
    3. Move the mouse in the required rotation direction.

    Zoom in/out the scene

    1. Scroll the mouse wheel in the 3D window away from / towards you.

If you run the model now, you will see that the conveyor, electrodes, and batches are animated in 3D, but the pasting machine and the walls are absent. Let's fix that!

Add the pasting station

  1. First, select the pastingMachine and in its properties switch the Visible option to no. This way the default animation of the station will not be displayed during the model run and won't interfere with the 3D animation figure.
  2. Go to the 3D objects palette in the Palette view.
  3. Drag the Pasting Machine 3D object from the Manufacturing section of the palette to the Main graphical diagram and place it over the pastingMachine.
  4. AnyLogic will display the Auto scale 3D object dialog window.

    Since we have changed the default scale of the model, the scale of the 3D objects added from the palette should be adjusted accordingly to look natural on runtime.

  5. In the dialog window, click the Yes button.

Draw the walls

  1. Double-click the Wall element in the Pedestrian section of the Space Markup palette to activate the drawing mode.
  2. Click at the point where the wall segment begins and place the next click at the corner of the wall. Double-click at the point where the wall segment ends.

    In the layout there are several segments of identical size. Instead of drawing them one by one, you can copy them. To do this, draw a single segment and then Ctrl drag it to the intended place. Repeat the action as many times as neccessary.

    To adjust the placement of a segment, select it and use the Shift arrow keys combination.

  3. Use the Rectangular Wall element to draw the shaded rectangular area. The drawing principles of this element are the same as the Rectangular node.
  4. Ctrl click all the walls you've drawn and the properties view will display the Multiple selection.
  5. In the Appearance section specify the Color: gray.
  6. In the Position and size section specify the Z-Height: 20.

  7. Run the model and enjoy the 3D animation!

Note that there are several reference models available that represent the milestones of the editing. You can use them if you experience any difficulties creating a model and you would like to compare your model with the reference file. Below you can see the link opening the reference model corresponding to this phase.

Reference model: Lead Acid Battery Production - Phase 1

Lead Acid Battery Production Tutorial

Phase 2. Modeling the free space transporters