示例#1
0
import numpy as np
import sys

sys.path.append('../NTS')

# my code
from NTSenergyPrediction import EnergyPrediction

profiles = []

for i in range(0, 1000):
    profiles.append([0.0] * 1440)

i = 0

run = EnergyPrediction('3', '7', regionType='3')

vehicleProfiles = run.returnDumbChargingProfiles(1000, 3.5)
#vehicleProfilesPO = run.returnPsuedoOptimalChargingProfiles(1000,3.5)

#'''
with open('../../Documents/vehicle_demand_pool.csv', 'w') as csvfile:
    writer = csv.writer(csvfile)
    for profile in vehicleProfiles:
        writer.writerow(profile)
'''
with open('../../Documents/vehicle_demand_poolPO.csv','w') as csvfile:
    writer = csv.writer(csvfile)
    for profile in vehicleProfilesPO:
        writer.writerow(profile)
'''
# packages
import matplotlib.pyplot as plt
import numpy as np
import csv
import random
# my code
from vehicleModelCopy import Drivecycle, Vehicle
from NTSenergyPrediction import EnergyPrediction, NationalEnergyPrediction

day = '3'
month = '2'


run = EnergyPrediction(day)
dumbProfile = run.getDumbChargingProfile(3.5,tmax=36*60,logOutofCharge=True,
                                         highUseWorkCharging=False,
                                         highUseHomeCharging=False,
                                         highUseShopCharging=False)

print float(run.nOutOfCharge)*100/run.nVehicles,
print '% out of charge in scenario 1'


run = EnergyPrediction(day)
dumbProfile = run.getDumbChargingProfile(3.5,tmax=36*60,logOutofCharge=True,
                                         highUseWorkCharging=False,
                                         highUseHomeCharging=True,
                                         highUseShopCharging=False)

print float(run.nOutOfCharge)*100/run.nVehicles,
print '% out of charge in scenario 2'
energy = [0] * 200

for region in regionBreakdown:
    population = regionBreakdown[region] * totalPopulation
    simulation = Simulation(region, month, day, population, 1)

    for i in simulation.fleet.fleet:
        total = 0
        #print i
        #print simulation.fleet.fleet[i]
        for j in i.energyLog:
            total += j[1]

        energy[int(total)] += numbers[region]

run2 = EnergyPrediction('3', '1', model='linear')
energy3 = run2.plotEnergyConsumption(returnResults=True,
                                     newFigure=False,
                                     wait=True)

# normalise
nEnergy3 = []
for i in range(0, len(energy3)):
    nEnergy3.append(float(energy3[i]) / sum(energy3))

# normalise
nEnergy = []
for i in range(0, len(energy)):
    nEnergy.append(float(energy[i]) / sum(energy))

run = EnergyPrediction('3', '1')
示例#4
0
# packages
import matplotlib.pyplot as plt
import numpy as np
import csv
import random
# my code
from vehicleModelCopy import Drivecycle, Vehicle
from NTSenergyPrediction import EnergyPrediction, NationalEnergyPrediction

nHours = 36
pointsPerHour = 10

run = EnergyPrediction('3', '2')
dumb = run.getDumbChargingProfile(3.5, nHours * 60)
baseLoad = []

for i in range(0, pointsPerHour * nHours):
    baseLoad.append(random.random() * 6000)

smartProfiles = run.getOptimalChargingProfiles(7.0,
                                               baseLoad,
                                               pointsPerHour=pointsPerHour)

smart = [0.0] * nHours * pointsPerHour
for vehicle in smartProfiles:
    for i in range(0, nHours * pointsPerHour):
        smart[i] += smartProfiles[vehicle][i]

plt.figure(1)
plt.plot(dumb)
plt.plot(range(0, 36 * 60, 60 / pointsPerHour), smart)
示例#5
0
import csv
import matplotlib.pyplot as plt
from NTSenergyPrediction import EnergyPrediction, NationalEnergyPrediction

run = EnergyPrediction('3', '5')
energy = run.plotEnergyConsumption(returnResults=True, wait=True)
plt.xlim(0, 60)
'''
run2 = EnergyPrediction('3','5',car='tesla')
energy2 = run2.plotEnergyConsumption(returnResults=True, wait=True)
'''
plt.figure(2)
plt.subplot(2, 1, 1)
plt.bar(range(0, 24), energy[:24], color='b')
plt.bar(range(24, len(energy)), energy[24:], color='r')
plt.xlim(-0.5, 80)
plt.text(60,
         500,
         str(float(int(float(sum(energy[24:]) * 10000) / sum(energy))) / 100) +
         '%',
         fontsize=15)
plt.title('Nissan Leaf')
'''
plt.subplot(2,1,2)
plt.bar(range(0,60),energy2[:60],color='b')
plt.bar(range(60,len(energy2)),energy[60:],color='r')
plt.xlim(-0.5,80)
plt.text(60,500,str(float(int(float(sum(energy2[60:])*10000)/sum(energy2)))/100)+'%',fontsize=15)
plt.title('Tesla 60S')
'''
plt.show()
示例#6
0
# packages
import matplotlib.pyplot as plt
import numpy as np
import csv
# my code
from vehicleModelCopy import Drivecycle, Vehicle
from NTSenergyPrediction import EnergyPrediction, BaseLoad

day = '3'
month = '7'

run = EnergyPrediction(day, month, region='7')

runBase = BaseLoad(day, month, 36, unit='k')
base = runBase.getLoad(population=0.1 * run.nPeople)

profiles = run.getOptimalChargingProfiles(4, base, chargeAtWork=True)

profiles2 = run.getOptimalChargingProfiles(4, base, chargeAtWork=False)

summed = [0.0] * 36
summed2 = [0.0] * 36

for vehicle in profiles:
    for i in range(0, 36):
        summed[i] += profiles[vehicle][i]
for vehicle in profiles2:
    for i in range(0, 36):
        summed2[i] += profiles2[vehicle][i]

t = np.linspace(0, 36, num=36 * 60)
示例#7
0
# my code
from vehicleModelCopy import Drivecycle, Vehicle
from NTSenergyPrediction import EnergyPrediction

nissanLeaf = Vehicle(1521.0, 29.92, 0.076, 0.02195, 0.86035, 24.0)

regionTypes = {
    '1': 'Urban Conurbation',
    '2': 'Urban City and Town',
    '3': 'Rural Town',
    '4': 'Rural Village'
}

for rt in regionTypes:
    offset = float(int(rt) - 1) / 4
    test = EnergyPrediction('3', '5', nissanLeaf, regionType=rt)
    #test.plotMileage(wait=True)
    plt.figure(1)
    test.plotEnergyConsumption(newFigure=False,
                               wait=True,
                               label=regionTypes[rt],
                               normalise=True,
                               offset=offset,
                               width=0.25)

    plt.figure(2)
    test.plotEnergyConsumption(newFigure=False,
                               wait=True,
                               label=regionTypes[rt],
                               normalise=False,
                               offset=offset,
示例#8
0
import csv
import matplotlib.pyplot as plt
import numpy as np
import math
from NTSenergyPrediction import EnergyPrediction

y = []

for r in range(1, 5):
    run = EnergyPrediction('3', regionType=str(r))
    energy = 0
    n = 0
    print len(run.energy)
    for vehicle in run.energy:
        energy += run.energy[vehicle]
        n += 1

    energy = float(energy) / n

    y.append(energy)

plt.figure(1)
plt.rcParams["font.family"] = 'serif'
x_ticks = [
    'Urban\n Conurbation', 'Urban City\n & Town', 'Rural\n Town &\n Fringe',
    'Rural\n Village,\n Hamlet &\n Isolated Dwelling'
]
plt.bar(range(1, 5), y)
plt.xticks(range(1, 5), x_ticks)
plt.ylabel('average predicted \n consumption (kWh)')
# packages
import matplotlib.pyplot as plt
import numpy as np
import csv
# my code
from NTSenergyPrediction import EnergyPrediction, BaseLoad

day = '3'
month = '1'

run = EnergyPrediction(day,month,region='1')

base = BaseLoad(day,month,36,unit='k')
baseload = base.getLoad(population=int(150.0*65/28))

profiles = run.getPsuedoOptimalProfile(4,baseload,weighted=False,
                                       returnIndividual=True,
                                       allowOverCap=False,
                                       deadline=12)

vehicles = []

for vehicle in profiles[1]:
    vehicles.append(vehicle)

profiles2 = run.getDumbChargingProfile(3.5,36*60,individuals=vehicles,
                                       highUseHomeCharging=False,
                                       highUseWorkCharging=False,
                                       highUseShopCharging=False)
profiles3 = run.getOptimalChargingProfiles(3.5,baseload,individuals=vehicles,
                                           sampleScale=False,allowOverCap=False)
import numpy as np
# my code
from vehicleModelCopy import Drivecycle, Vehicle
from NTSenergyPrediction import EnergyPrediction

nissanLeaf = Vehicle(1521.0, 29.92, 0.076, 0.02195, 0.86035, 24.0)

days = {
    '1': 'Monday'
}  #,'2':'Tuesday','3':'Wednesday','4':'Thursday','5':'Friday',
#'6':'Saturday','7':'Sunday'}
t = np.linspace(0, 48, 48 * 60)

plt.figure(1)
for i in days:
    test = EnergyPrediction(i, '5', nissanLeaf, regionType='2')
    profile = test.getDumbChargingProfile(3.5, 48 * 60, scalePerVehicle=True)
    plt.plot(t, profile, label=days[i])

x = np.linspace(4, 36, num=9)
plt.grid()
my_xticks = [
    '04:00 \n Day 1', '08:00', '12:00', '16:00', '20:00', '0:00',
    '04:00 \n Day 2', '08:00', '12:00'
]
plt.xticks(x, my_xticks)
plt.xlim(0, 40)
plt.xlabel('time')
plt.ylabel('power per household (kW)')
plt.title('Dumb Charging in May')
plt.legend()
import csv
import matplotlib.pyplot as plt
import numpy as np
import math
from NTSenergyPrediction import EnergyPrediction

y = []

for day in range(1, 8):
    run = EnergyPrediction(str(day), month='2')
    energy = 0
    n = 0
    for vehicle in run.energy:
        energy += run.energy[vehicle]
        n += 1

    energy = float(energy) / n

    y.append(energy)

plt.figure(1)
plt.rcParams["font.family"] = 'serif'
plt.subplot(2, 1, 1)
x_ticks = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
plt.bar(range(1, 8), y)
plt.xticks(range(1, 8), x_ticks)
plt.ylabel('average predicted \n consumption (kWh)')

y = []

for mo in range(1, 13):