So I have a code that calculates emissions for different types of vehicles (old combustion, middle-aged combustion, new combustion, hybrid and electric) in a given study area. I ran behavior space with an emission diffusion variable (0.0 to 1.0, in 0.1 increments) and it gives me the global and differentiated values emitted in the region. I have also exported the final maps as ASCII, transformed them in a series of operations to polygon format so that I can know how many emissions there are in a given municipality. The problem here is that the sum of the municipality emissions aren’t the same (or even close) as the global emissions. For example, for 10 runs of emission diffusion 0.5, Behaviorspace .xls gives me an average for the 10 runs of 1760,49 kg of daily CO2 emissions for the region (final run values are very similar between them). When using the shapefile information, it gives me a total of 201,1 kg of daily CO2 emissions.
It seems to me that either the model is miscalculating the emissions of my cars or that for some reason, patch information is giving me wrong values.
Here is how I calculate total emissions for the cars:
to calculate-total-emissions
; Calculate emissions for each car
ask turtles
[
calculate-emissions self ; self refers to the current turtle
set all-emissions (all-emissions + emissions)
set emissions-turtle [emissions-turtle + emissions] of self
]
; Aggregate total emissions for each car type
ask turtles with [car-type = "ev"]
[
set all-ev-emissions (all-ev-emissions + emissions)
]
ask turtles with [car-type = "hybrid"]
[
set all-hybrid-emissions (all-hybrid-emissions + emissions)
]
ask turtles with [car-type = "ICE-old"]
[
set all-ICE-emissions-old (all-ICE-emissions-old + emissions)
]
ask turtles with [car-type = "ICE-middle"]
[
set all-ICE-emissions-middle (all-ICE-emissions-middle + emissions)
]
ask turtles with [car-type = "ICE-new"]
[
set all-ICE-emissions-new (all-ICE-emissions-new + emissions)
]
end
As for the patch emissions, I think it calculates in the Drive procedure:
to pick-where-to-drive-traffic ;; This is how the cars navigate with traffic
;if road ahead is road and no other cars there, head there
let cars-ahead 0
let target-patch patch-ahead speed
if target-patch != nobody and any? turtles-on target-patch
[
set cars-ahead count turtles-on target-patch
]
; Checks if there are cars ahead
if patch-ahead speed != nobody [
ifelse patch-ahead speed != nobody and [pcolor] of patch-ahead speed >= road and cars-ahead = 0
[
set heading towards patch-ahead speed
]
; Else, if the patch ahead is dirt or has a car,
[
; Then, if the patch of the road ahead and 30 degrees off center to the right is road, and has no cars, head there.
if patch-right-and-ahead 30 speed != nobody
[
set cars-ahead [count turtles-here] of patch-right-and-ahead 30 speed
]
ifelse patch-right-and-ahead 30 speed != nobody and [pcolor] of patch-right-and-ahead 30 speed > road and cars-ahead = 0
[
set heading towards patch-right-and-ahead 30 speed
]
[ ; Else if that isn't road or has a car then, if the road the road left and ahead at 30 degrees is a road, head there instead.
if patch-left-and-ahead 30 speed != nobody [set cars-ahead [count turtles-here] of patch-left-and-ahead 30 speed]
if patch-left-and-ahead 30 speed != nobody and [pcolor] of patch-left-and-ahead 30 speed > road and cars-ahead = 0
[ ; after setting heading towards a patch of road at speed "speed" that doesn't have a car on it
set heading towards patch-left-and-ahead 30 speed
fd speed ;; the cars go forward here, because it merely makes the cars movement "look" more realistic. But it is an arbitrary move that isn't really consistent.
]
]
]
]
; Random turning to get out of stuck states
rt random 25
lt random 25
; if the patch ahead is road and is empty of cars
if patch-ahead speed != nobody
[
set cars-ahead [count turtles-here] of patch-ahead speed
]
if patch-ahead speed != nobody and [pcolor] of patch-ahead speed > road and cars-ahead = 0
[ ;go there, but check if the car is at the edge of the view, and if it is turn around and go another direction.
set heading towards patch-ahead speed ifelse can-move? 1
[
fd speed
set p-emissions emissions
]
[
right 180
]
]
if random 100 < 2
[
right 180
] ;; turn around if at a dead end every 10 ticks. This helps get cars unstuck.
end
Maybe here patch emissions are overwritten every time a new car goes through that patch?
Am I wrong in assuming that the total values should be approximately the same? Or at least in the same ballpark? I appreciate any help I can get.