Skip to main content

7.12) Setup PV Installations


To do that we use the if statement with a condition of 0.1% done as a random-float 1 > 0.001. If this statement is true we set the patch PV variable true, set their PV-age and set the turtles build-in variable color to red to see the houses with PV installed.

At the end of the create-turtles (crt) statement in the setup procedure insert the following code:

if random-float 1 < 0.001
       [set PV true
        set PV-age random PV-lifetime
        set color red]

Click the Check button to check syntax and you will get an error message since we have nothing defined with the name PV-lifetime. We want to define that as a global variable to observe how diffusion changes with changing technology lifetime. To do so we add a slider in the interface name the variable PV-lifetime, set the range from 0-40 with an increment of 1 and a value of 20 years. If you press the setup button on the Interface you should get a few red turtles on the view, check in the agent monitor the variables of patches with red turtles.

Question: Try to find the average PV-age of all PV installations with the command centre

Answer: show mean [PV-age] of patches with [PV]