How to Implement Multi Microgrid in ns2
To implement the multi-microgrid systems using the simulation tool ns2 (Network Simulator 2) that not straightforward, as ns2 is mainly created for emulating the network protocols instead of power systems or microgrids. But, we can estimated the concept of multi-microgrids by mimicking the communication network among the microgrid controllers and distributed energy resources (DERs) contained in the microgrids.
Step-by-Step Implementations:
Conceptual Overview
In a multi-microgrid system:
- Microgrids: Every single microgrid has contains of a set of DERs, loads, and probably a local microgrid controller.
- Communication Network: The communication network that intersects the microgrids and their controllers, permitting them to interchange the information and coordinate operations.
- Control Messages: To mimic the exchange of control messages among the microgrid controllers to organise the power distribution, load balancing, or islanding operations.
Step 1: Conceptualize the Multi-Microgrid Network
We can model each microgrid as a collections of nodes that denoting DERs, loads, and controllers are related by communication links. The network microgrids can be intersected to make a larger network that emulates the communication infrastructure essential for their operation.
Step 2: Create the Tcl Script
Given below is an instance Tcl script that mimic a simple communication network for a multi-microgrid system in the simulation ns2.
Example Tcl Script for Simulating Multi-Microgrid Communication in ns2
# Create a simulator object
set ns [new Simulator]
# Define the topography object (for a small area representing multiple microgrids)
set topo [new Topography]
$topo load_flatgrid 1000 1000 # 1km x 1km area
# Create the General Operations Director (GOD) for wireless simulations
create-god 10 # Number of nodes (3 microgrids with multiple nodes each)
# Configure the nodes (representing DERs, loads, and controllers)
$ns node-config -adhocRouting DSDV \
-llType LL \
-macType Mac/802_11 \
-ifqType Queue/DropTail/PriQueue \
-ifqLen 50 \
-antType Antenna/OmniAntenna \
-propType Propagation/TwoRayGround \
-phyType Phy/WirelessPhy \
-channelType Channel/WirelessChannel \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace OFF
# Open trace and NAM files for recording the simulation
set tracefile [open multi_microgrid_out.tr w]
$ns trace-all $tracefile
set namfile [open multi_microgrid_out.nam w]
$ns namtrace-all-wireless $namfile 1000 1000
# Define a finish procedure to close files and end the simulation
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam multi_microgrid_out.nam &
exit 0
}
# Microgrid 1 nodes (Controller, DERs, Loads)
set mg1_ctrl [$ns node]
set mg1_der1 [$ns node]
set mg1_der2 [$ns node]
set mg1_load1 [$ns node]
# Microgrid 2 nodes (Controller, DERs, Loads)
set mg2_ctrl [$ns node]
set mg2_der1 [$ns node]
set mg2_der2 [$ns node]
set mg2_load1 [$ns node]
# Microgrid 3 nodes (Controller, DERs, Loads)
set mg3_ctrl [$ns node]
set mg3_der1 [$ns node]
set mg3_der2 [$ns node]
set mg3_load1 [$ns node]
# Set positions for microgrid nodes
$mg1_ctrl set X_ 100.0
$mg1_ctrl set Y_ 200.0
$mg1_ctrl set Z_ 0.0
$mg1_der1 set X_ 150.0
$mg1_der1 set Y_ 250.0
$mg1_der1 set Z_ 0.0
$mg1_der2 set X_ 100.0
$mg1_der2 set Y_ 300.0
$mg1_der2 set Z_ 0.0
$mg1_load1 set X_ 200.0
$mg1_load1 set Y_ 200.0
$mg1_load1 set Z_ 0.0
$mg2_ctrl set X_ 400.0
$mg2_ctrl set Y_ 200.0
$mg2_ctrl set Z_ 0.0
$mg2_der1 set X_ 450.0
$mg2_der1 set Y_ 250.0
$mg2_der1 set Z_ 0.0
$mg2_der2 set X_ 400.0
$mg2_der2 set Y_ 300.0
$mg2_der2 set Z_ 0.0
$mg2_load1 set X_ 500.0
$mg2_load1 set Y_ 200.0
$mg2_load1 set Z_ 0.0
$mg3_ctrl set X_ 700.0
$mg3_ctrl set Y_ 200.0
$mg3_ctrl set Z_ 0.0
$mg3_der1 set X_ 750.0
$mg3_der1 set Y_ 250.0
$mg3_der1 set Z_ 0.0
$mg3_der2 set X_ 700.0
$mg3_der2 set Y_ 300.0
$mg3_der2 set Z_ 0.0
$mg3_load1 set X_ 800.0
$mg3_load1 set Y_ 200.0
$mg3_load1 set Z_ 0.0
# Define communication links within each microgrid (e.g., controllers to DERs and loads)
$ns duplex-link $mg1_ctrl $mg1_der1 1Mb 10ms DropTail
$ns duplex-link $mg1_ctrl $mg1_der2 1Mb 10ms DropTail
$ns duplex-link $mg1_ctrl $mg1_load1 1Mb 10ms DropTail
$ns duplex-link $mg2_ctrl $mg2_der1 1Mb 10ms DropTail
$ns duplex-link $mg2_ctrl $mg2_der2 1Mb 10ms DropTail
$ns duplex-link $mg2_ctrl $mg2_load1 1Mb 10ms DropTail
$ns duplex-link $mg3_ctrl $mg3_der1 1Mb 10ms DropTail
$ns duplex-link $mg3_ctrl $mg3_der2 1Mb 10ms DropTail
$ns duplex-link $mg3_ctrl $mg3_load1 1Mb 10ms DropTail
# Define inter-microgrid communication links (e.g., controllers communicating)
$ns duplex-link $mg1_ctrl $mg2_ctrl 512Kb 20ms DropTail
$ns duplex-link $mg2_ctrl $mg3_ctrl 512Kb 20ms DropTail
$ns duplex-link $mg1_ctrl $mg3_ctrl 512Kb 20ms DropTail
# Define traffic for control messages within Microgrid 1
set tcp1 [new Agent/TCP]
$ns attach-agent $mg1_ctrl $tcp1
set sink1 [new Agent/TCPSink]
$ns attach-agent $mg1_der1 $sink1
$ns connect $tcp1 $sink1
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
$ftp1 start
# Define traffic for control messages within Microgrid 2
set tcp2 [new Agent/TCP]
$ns attach-agent $mg2_ctrl $tcp2
set sink2 [new Agent/TCPSink]
$ns attach-agent $mg2_der1 $sink2
$ns connect $tcp2 $sink2
set ftp2 [new Application/FTP]
$ftp2 attach-agent $tcp2
$ftp2 start
# Define traffic for control messages within Microgrid 3
set tcp3 [new Agent/TCP]
$ns attach-agent $mg3_ctrl $tcp3
set sink3 [new Agent/TCPSink]
$ns attach-agent $mg3_der1 $sink3
$ns connect $tcp3 $sink3
set ftp3 [new Application/FTP]
$ftp3 attach-agent $tcp3
$ftp3 start
# Define inter-microgrid communication (e.g., coordination between controllers)
set udp1 [new Agent/UDP]
$ns attach-agent $mg1_ctrl $udp1
set null1 [new Agent/Null]
$ns attach-agent $mg2_ctrl $null1
$ns connect $udp1 $null1
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
$cbr1 set packetSize_ 500
$cbr1 set rate_ 64Kb
$cbr1 start
# Schedule the end of the simulation
$ns at 50.0 “finish”
# Run the simulation
$ns run
Step 3: Run the Tcl Script
We can save the script including a .tcl extension, for instance, multi_microgrid_simulation.tcl. Next, we run the script using the below command in the terminal:
ns multi_microgrid_simulation.tcl
Step 4: Visualize the Simulation
We can visualise the simulation, open the created NAM file using:
nam multi_microgrid_out.nam
Script Explanation
- Microgrid Nodes: Each microgrid is denoted by a collections of nodes such as controller, DERs, loads. Microgrid nodes are intersected contained by a microgrid and including other microgrids.
- Communication Links: These script is describes communication links both in each microgrid that for internal control and data exchange and among the microgrids which for coordination among the microgrid controllers.
- Traffic Generation: Various kinds of traffic such as FTP over TCP, CBR over UDP are used to mimic the communication among the controllers and DERs, along with among the microgrid controllers.
Customization
- Multiple DERs and Loads: We append more DERs and loads to each microgrid to emulate a further difficult scenario.
- Different Traffic Patterns: We can investigate with various traffic patterns to mimic numerous control and monitoring scenarios.
- Mobility Models: To execute the mobility models if we need to imitate the mobile DERs or devices contained by the microgrids.
- QoS Parameters: To adjust the QoS settings like delay, bandwidth to mimic various communication scenarios in and among microgrids.
Limitations
- Simplified Approximation: These simulation is delivers a high-level estimate of multi-microgrid communication and it does not encapsulate the physical power system dynamics or comprehensive microgrid control mechanisms.
- No Power System Simulation: This script does not emulate the electrical performance of microgrids, like power flows, voltage levels, or grid stability.
- Limited Microgrid-Specific Features: The simulation tool ns2 is not created for power system simulations. Thus the simulation is limited to communication aspects only.
We systematically carried out a detailed process on Multi Microgrid, with implementation and analysis done via the simulation tool ns2. We plan to offer more informations on this subject through the appropriate simulation tools as required.
Do you want to use Multi Microgrid with the ns2 tool? Reach out to ns2project.com for great results. We specialize in communication networks for your project.