Skip to content

Run Full Annual Simulation

Prageeth Jayathissa edited this page Aug 9, 2020 · 5 revisions

This example combines the Hourly Simulation and Radiation Calculation examples with a for loop to run a building simulation for one year

Import Classes

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
from buildingPhysics import Zone #Importing Zone Class
import supplySystem
import emissionSystem
from radiation import Location
from radiation import Window 

Initialise Location

#Initialise the Location with a weather file
Zurich = Location(epwfile_path='Zurich-Kloten_2013.epw')

Initialise Building study

Office=Zone(window_area=4.0,
				 walls_area=15.0,
				 floor_area=35.0,
                                 room_vol=105,
                                 total_internal_area=142.0,
				 lighting_load=11.7,
				 lighting_control = 300.0,
				 lighting_utilisation_factor=0.45,
				 lighting_maintenance_factor=0.9,
				 u_walls = 0.2,
				 u_windows = 1.1,
				 ach_vent=1.5,
				 ach_infl=0.5,
				 ventilation_efficiency=0.6,
				 thermal_capacitance_per_floor_area = 165000,
				 t_set_heating = 20.0,
				 t_set_cooling = 26.0,
				 max_cooling_energy_per_floor_area=-np.inf,
				 max_heating_energy_per_floor_area=np.inf,
				 heatingSupplySystem=supplySystem.OilBoilerMed,
				 coolingSupplySystem=supplySystem.HeatPumpAir,
				 heatingEmissionSystem=emissionSystem.NewRadiators,
				 coolingEmissionSystem=emissionSystem.AirConditioning,)

Define Windows

#Define Windows
SouthWindow = Window(azimuth_tilt=0, alititude_tilt = 90, glass_solar_transmittance=0.7,
				 glass_light_transmittance=0.8, area = 4)

Read an occupancy profile and define some constants

#Read Occupancy Profile
occupancyProfile=pd.read_csv(os.path.join(mainPath,'auxillary','schedules_el_OFFICE.csv'))

#Define constants for the building
gain_per_person = 100 #W per person
appliance_gains= 14 #W per sqm
max_occupancy=3.0
#Starting temperature of the builidng
t_m_prev=20

Loop through all 8760 hours of the year and solve

for hour in range(8760):

	#Occupancy for the time step
	occupancy = occupancyProfile.loc[hour,'People'] * max_occupancy
	#Gains from occupancy and appliances
	internal_gains = occupancy*gain_per_person + appliance_gains*Office.floor_area

	#Extract the outdoor temperature in Zurich for that hour
	t_out = Zurich.weather_data['drybulb_C'][hour]

	Altitude, Azimuth = Zurich.calc_sun_position(latitude_deg=47.480, longitude_deg=8.536, year=2015, HOY=hour)

	SouthWindow.calc_solar_gains(sun_altitude = Altitude, sun_azimuth = Azimuth, 
								normal_direct_radiation= Zurich.weather_data['dirnorrad_Whm2'][hour], 
								horizontal_diffuse_radiation = Zurich.weather_data['difhorrad_Whm2'][hour])

	SouthWindow.calc_illuminance(sun_altitude = Altitude, sun_azimuth = Azimuth, 
								normal_direct_illuminance = Zurich.weather_data['dirnorillum_lux'][hour], 
								horizontal_diffuse_illuminance = Zurich.weather_data['difhorillum_lux'][hour])


	Office.solve_energy(internal_gains=internal_gains, solar_gains=SouthWindow.solar_gains,t_out=t_out, t_m_prev=t_m_prev)

	Office.solve_lighting(illuminance=SouthWindow.transmitted_illuminance, occupancy=occupancy)

	#Set the previous temperature for the next time step
	t_m_prev=Office.t_m_next
Clone this wiki locally