Electrical Grids and Load Shedding

No preview image

1 collaborator

Default-person Jane Antonas (Author)

Tags

electricity 

Tagged by Jane Antonas 10 months ago

electricity utilities 

Tagged by Jane Antonas 10 months ago

grid 

Tagged by Jane Antonas 10 months ago

power generation 

Tagged by Jane Antonas 10 months ago

transmission, generations 

Tagged by Jane Antonas 10 months ago

Visible to everyone | Changeable by the author
Model was written in NetLogo 6.3.0 • Viewed 101 times • Downloaded 4 times • Run 0 times
Download the 'Electrical Grids and Load Shedding' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Info tab cannot be displayed because of an encoding error

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

breed [houses house]
breed [generators generator]
breed [Hz a-Hz]
breed [frowns frown]

undirected-link-breed [ cables cable ]
undirected-link-breed [ roads road ]

globals [potential poweredhouses unpoweredhouses poweredhousesfreq]

houses-own [frequency capacity]
Hz-own [location]

to setup
  ca
  ask patches [ ;;make background white
    set pcolor white
  ]
  create-generators 1
  ask generators [ ;;make generator
    set size 6
    set shape "factory"
    set color black
  ]
  create-houses num-houses ;;make amount of houses according to slider
  set-default-shape houses "house efficiency"
  ask houses [
    set size 7
    set color 5
  ]
  ask houses [ create-roads-with other generators ] ;;create links between houses and generator
  layout-radial houses roads (generator 0) ;;layout houses in a circle with generator in the center (need "road" links for this primitive)
  create-Hz 1 [ ;;places a Hz on the generator for visual representation of power generation
    set color yellow
    set shape "lightning"
    set size 3
    set location generator 0
    move-to location
  ]
  ask houses [ ;;change pcolor of house patches to red
    if pcolor = white [
      set pcolor red
    ]
  ]
  ask roads [set thickness 0] ;;make roads less visible (only needed them for layout-radial)
  reset-ticks
end 

to go
  if ticks < 4 [ ;;don't allow "go" to be repeated without setting up again
  normal-operations
  generator-failure
  tick ;;represents reaction time of transmission operator or
  tick ;;automatic fail-safe procedures
  load-shed
  stabilize
  ]
end 

to normal-operations
  ask Hz [ die ] ;;get rid of Hz
  ask houses [
    set pcolor red ;;here AND in setup so users don't have to click setup between load-shed back to normal operations
  ]
   ask houses [
    set capacity (60 * num-houses) ;;capacity of generator during normal operations should allow it to supply 60 Hz to all customers
  ]                                ;;so capacity depends on number of customers
  ask houses [
    set frequency (capacity / num-houses) ;;frequency of houses is an even distribution of generator capacity
  ]
  ask patches with [ pcolor = red ] [ ;;all houses sprout a Hz
    sprout-Hz 1 [
      set size 3
      set color yellow
      set shape "lightning"
    ]
  ]
  ask roads [ ;;links between houses and generator change color to indicate houses being powered
    set thickness 0.5
    set color yellow ;;yellow roads represent transmission of target frequency
  ]
  change-color ;;update visuals
  tick
end 

to generator-failure
  ask Hz [ die ] ;;get rid of Hz
  ask patches with [ pcolor = red ] [ ;;only powered houses have Hz
   sprout-Hz 1
  ]
  ask Hz [
   set size 3
   set color red ;red Hz represent frequency too low
   set shape "lightning"
  ]
  ask houses [
    set capacity (generator-capacity * (60 * num-houses)) ;;capacity of generator is a percentage (based on slider) of the frequency it should be able to provide
    set frequency (capacity / num-houses) ;;change frequency of houses based on new diminished capacity
  ]
  change-color ;;adjust visuals
  tick ;;plot frequency
end 

to load-shed
  ask Hz [ die ] ;;get rid of Hz
  ask houses [
    set capacity (generator-capacity * (60 * num-houses)) ;;change generator capacity based on slider
    if capacity < 60 [ ;;can't power any houses if capacity is less than 60 Hz
      set capacity 0
      set frequency 0
      set color red] ;;red houses aren't powered
    ]
  ask houses [
    set potential (capacity / 60) ;;how many houses can be fully powered (60Hz) with decreased capacity
    show potential]
  ask houses with [ who <= (potential) ] [ ;;turns a number of houses green according to potential
    set color green
    set pcolor red ]
  ask houses with [ who > (potential) ] [ ;;turns the rest of houses red
    set color red
    set pcolor cyan ]
  ask houses [
    set poweredhouses (count houses with [color = green] ) ;;green houses get power
    set unpoweredhouses (count houses with [color = red] ) ] ;;red houses get a blackout
  ask houses [
    if color = green [
      set frequency ( capacity / (count houses with [color = green] )) ;;frequency of powered houses is an equal distribution of available generator capacity
    ]                                                                  ;;note: this value will be greater than 60 Hz, creating a peak on frequency graph
  ]
  ask houses [
    if color = red [ ;;red houses are unpowered and therefore have a frequency of 0
      set frequency 0 ]
  ]
  ask patches [
    if pcolor = red [ ;;change visuals based on whether house is powered or unpowered
    sprout-Hz 2
    ]
    if pcolor = cyan [
    sprout-frowns 1
    ]
  ]
  ask frowns [ ;;unpowered houses get a frowny face :(
    set shape "face sad"
    set size 2
    set color white
  ]
  ask Hz [
    set color blue
    set shape "lightning"
    set size 3
  ]
  ask Hz [ ;;create links between Hz and generator
    create-cables-with generators ]
  ask cables [ ;;blue cables represent frequency being too high
    set color blue
    set thickness 0.5
  ]
  ask roads [die] ;;roads no longer necessary
  tick
end 

to stabilize ;;transmission operator decreases generation to only what is necessary to power as many houses as possible given maximum capacity
  ask houses [ ;;set frequency of unpowered houses to whatever remains after fully powering as many houses as possible
    if color = red [ ;;however, for purposes of the plotter, red houses are treated as if having 0 frequency and are not counted in average frequency
      set frequency ( (capacity - (60 * poweredhouses)) / (unpoweredhouses) ) ;;this is only for demonstration purposes to show how little the frequency of these houses
    ]                                                                        ;;would be without stabilization
    if color = green [
      set frequency 60
    ]
  ]
  ask cables [ ;;yellow cables represent transmission of target frequency
    set color yellow
  ]
  ask Hz [
    set color yellow
  ]
  tick
end 

to change-color
  ask houses [
    if frequency = 60 [ ;;fully powered houses are green with yellow roads
      set color green
      ask roads [
        set color yellow]
    ]
    if frequency < 60 and frequency > 0 [ ;;houses that are only partially-powered (experiencing interruptions) are yellow
      set color yellow
      ask roads [
        set color red] ;;red roads indicate power interruption
    ]
  ]
end 

There is only one version of this model, created 10 months ago by Jane Antonas.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.