Skip to content

Commit 4123960

Browse files
author
weilixu
committed
Merge remote-tracking branch 'upstream/master'
2 parents 7fd74f0 + 0faa056 commit 4123960

1 file changed

Lines changed: 63 additions & 33 deletions

File tree

README.md

Lines changed: 63 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[![Twitter Follow](https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow)](https://twitter.com/buildsimhub)
33

44
**This library allows you to quickly and easily use the BuildSimHub Web API v1 via Python.**
5-
This library represents the beginning of the Cloud Simulation function on BuildSimHub. Please browse the rest of this README for further detail.
5+
This library represents the beginning of the Cloud Simulation function on BuildSimHub. We want this library to be community driven and BuildSimHub led. We need your help to realize this goal. To help, make sure we are building the right things in the right order, we ask that you create [issues](https://github.com/weilix88/buildsimhub_python_api/issues) and [pull requests](https://github.com/weilix88/buildsimhub_python_api/pulls) or simply upvote or comment on existing issues or pull requests.
66
We appreciate your continued support, thank you!
77

88
# Table of Contents
@@ -44,20 +44,22 @@ The following is the minimum needed code to initiate a regular simulation with t
4444
### With SimulationJob Class
4545
```python
4646
from BuildSimHubAPI import buildsimhub
47-
bsh = buildsimhub.BuildSimHubAPIClient()
48-
49-
#this key can be found under your project folder
50-
folder_key="0ade3a46-4d07-4b99-907f-0cfeece321072"
47+
#this key can be found under an energy model
48+
model_key="0ade3a46-4d07-4b99-907f-0cfeece321072"
5149

5250
#absolute directory to the energyplus model
5351
file_dir = "/Users/weilixu/Desktop/5ZoneAirCooled.idf"
5452

55-
newSJ = bsh.newSimulationJob(folder_key)
56-
response = newSj.createModel(file_dir)
53+
###############NOW, START THE CODE########################
54+
55+
bsh = buildsimhub.BuildSimHubAPIClient()
56+
newSJ = bsh.new_simulation_job(model_key)
57+
response = newSj.create_model(file_dir)
5758

58-
#print success means the simulation job has successfully
59-
#started a simulation, if there is an error, then
60-
#you will receive the correspondent error message
59+
############### WE DONE! #################################
60+
61+
#You can print the responses to verify whether the simulation
62+
#is success or not.
6163
print (response)
6264
```
6365
The `BuildSimHubAPIClient` creates a [portal object](https://github.com/weilix88/buildsimhub_python_api/blob/master/BuildSimHubAPI/buildsimhub.py) that manages simulation workflow.
@@ -69,17 +71,17 @@ from BuildSimHubAPI import buildsimhub
6971
bsh = buildsimhub.BuildSimHubAPIClient()
7072

7173
#this key can be found under your project folder
72-
folder_key="0ade3a46-4d07-4b99-907f-0cfeece321072"
74+
model_key="0ade3a46-4d07-4b99-907f-0cfeece321072"
7375

7476
#absolute directory to the energyplus model
7577
file_dir = "/Users/weilixu/Desktop/5ZoneAirCooled.idf"
7678

77-
newSJ = bsh.newSimulationJob(folder_key)
78-
response = newSj.createModel(file_dir)
79+
newSJ = bsh.new_simulation_job(model_key)
80+
response = newSj.create_model(file_dir)
7981

8082
######BELOW ARE THE CODE TO TRACK SIMULATION#########
8183
if(response == 'success'):
82-
while newSJ.trackSimulation():
84+
while newSJ.track_simulation():
8385
print (newSJ.trackStatus)
8486
time.sleep(5)
8587
```
@@ -91,24 +93,24 @@ from BuildSimHubAPI import buildsimhub
9193
bsh = buildsimhub.BuildSimHubAPIClient()
9294

9395
#this key can be found under your project folder
94-
folder_key="0ade3a46-4d07-4b99-907f-0cfeece321072"
96+
model_key="0ade3a46-4d07-4b99-907f-0cfeece321072"
9597

9698
#absolute directory to the energyplus model
9799
file_dir = "/Users/weilixu/Desktop/5ZoneAirCooled.idf"
98100

99-
newSJ = bsh.newSimulationJob(folder_key)
100-
response = newSj.createModel(file_dir)
101+
newSJ = bsh.new_simulation_job(model_key)
102+
response = newSj.create_model(file_dir)
101103

102104
if(response == 'success'):
103-
while newSJ.trackSimulation():
105+
while newSJ.track_simulation():
104106
print (newSJ.trackStatus)
105107
time.sleep(5)
106108

107109
######BELOW ARE THE CODE TO RETRIEVE SIMULATION RESULTS#########
108-
response = newSJ.getSimulationResults('html')
110+
response = newSJ.get_simulation_results('html')
109111
print(response)
110112
```
111-
If the Job is completed, you can get results by calling `getSimulationResults(type)` function.
113+
If the Job is completed, you can get results by calling `get_simulation_results(type)` function.
112114

113115
<a name="functions"></a>
114116

@@ -123,7 +125,7 @@ The `folder_key` can be found under each folder of your project
123125
## simulationType
124126
[SimulationType](https://github.com/weilix88/buildsimhub_python_api/blob/master/BuildSimHubAPI/helpers/simulationType.py) class helps you configure the cloud simulation. There are two simulation types: `regular` and `fast`. Also, ou can increase the number of agent by calling the `increaseAgents()` function.
125127
```python
126-
simulationType = bsh.getSimulationType()
128+
simulationType = bsh.get_simulation_type()
127129
numOfAgents = simulationType.increaseAgents();
128130
print (numOfAgents)
129131
```
@@ -132,37 +134,65 @@ It should be noted that the maximum number of agents working on one simulation j
132134
## SimulationJob
133135
A simulation job manages one type of cloud simulation. It contains three main functions which are listed below:
134136

135-
### createdModel
136-
The `createModel()` function has in total 4 parameters.
137+
### create_model
138+
The `create_model()` function has in total 4 parameters.
137139
1. `file_dir` (required): the absolute local directory of your EnergyPlus / OpenStudio model (e.g., "/Users/weilixu/Desktop/5ZoneAirCooled.idf")
138140
2. `comment`(optional): The description of the model version that will be uploaded to your folder. The default message is `Upload through Python API`
139-
3. `simulationType` (optional): The simulation Type should be generated from [SimulationType](https://github.com/weilix88/buildsimhub_python_api/blob/master/BuildSimHubAPI/helpers/simulationType.py) class. This class manages the simulation type as well as how many agents you want to assign to this simulation job. Default is `regular` simulation which uses 1 agent to do the cloud simulation.
141+
3. `simulationType` (optional): The simulation Type should be generated from [SimulationType](https://github.com/weilix88/buildsimhub_python_api/blob/master/BuildSimHubAPI/helpers/simulationType.py) class. This class manages the simulation type as well as how many agents you want to assign to this simulation job. **It should be noted that if this parameter is not used, then create_model method will not run simulation**
140142
4. `agent` (optional): The agent number is a property of [SimulationType](https://github.com/weilix88/buildsimhub_python_api/blob/master/BuildSimHubAPI/helpers/simulationType.py) class. If fast simulation is selected, then the default of agent will be 2.
141143

142144
This method returns two types of information:
143145
If sucess: `success`
144146
or error message states what was wrong in your request.
145147

146-
### trackSimulation
147-
The `trackSimulation()` function does not require any parameters. However, it is required that a successful cloud simulation is created and running on the cloud. Otherwise, you will receive this message by calling this function:
148+
### run_simulation
149+
The `run_simulation()` function can be called inside a simulation job if the simulation is not conducted. The function has two parameters:
150+
1. `simulationType` (optional): The simulation Type should be generated from [SimulationType](https://github.com/weilix88/buildsimhub_python_api/blob/master/BuildSimHubAPI/helpers/simulationType.py) class. This class manages the simulation type as well as how many agents you want to assign to this simulation job. **It should be noted that if this parameter is not used, then create_model method will not run simulation**
151+
2. `agent` (optional): The agent number is a property of [SimulationType](https://github.com/weilix88/buildsimhub_python_api/blob/master/BuildSimHubAPI/helpers/simulationType.py) class. If fast simulation is selected, then the default of agent will be 2.
152+
153+
### track_simulaiton
154+
The `track_simulation()` function does not require any parameters. However, it is required that a successful cloud simulation is created and running on the cloud. Otherwise, you will receive this message by calling this function:
148155
`No simulation is running or completed in this Job - please start simulation using createModel method.`
149156
If there is a simulation running on the cloud for this simulationJob, then, this function will return `true` and you can retrieve the simulation status by get the class parameter `trackStatus`. Example code is below:
150157
```python
151-
if(newSimulationJob.trackSimulation()):
158+
if(newSimulationJob.track_simulation()):
152159
print(newSimulationJob.trackStatus)
153160
```
154-
### getSimulationResults
155-
The `getSimulationResults(type)` function requires 1 parameter, the result type. Currently, you can retrieve three types of results: the error file (`err`), eso file (`eso`) and html file (`html`), generated from EnergyPlus simulation.
161+
### get_simulation_results
162+
The `get_simulation_results(type)` function requires 1 parameter, the result type. Currently, you can retrieve three types of results: the error file (`err`), eso file (`eso`) and html file (`html`), generated from EnergyPlus simulation.
156163

157164
```python
158-
response = newSimulationJob.getSimulationResults('err')
165+
response = newSimulationJob.get_simulation_results('err')
159166
print (response)
160167
```
168+
## Model
169+
The model class contains a set of methods that provides the model information and results (after simulation)
170+
### Pre-simulation methods
171+
1. *num_total_floor()*: can be called before simulation is completed. It returns the number of floors, or -1 if there is an error.
172+
2. *num_zones()*: can be called before simulation is completed. It returns the total number of thermal zones, or -1 if there is an error.
173+
3. *num_condition_zones()*: can be called before simulation is completed. It returns the total number of conditioned zones, or -1 if there is an error.
174+
4. *conditioned_floor_area (unit)*: can be called before simulation is completed. It returns the floor areas of conditioned spaces, or -1 if there is an error. This method has an optional input: unit. If you wish to get ft2 unit, then you need to specify 'ip' for the unit parameter:
175+
` m.condition_floor_area("ip")
176+
`
177+
5. *gross_floor_area(unit)*: can be called before simulation is completed. It returns the total floor areas (including plenum spaces), or -1 if there is an error. This method has an optional input: unit. If you wish to get ft2 unit, then you need to specify 'ip' for the unit parameter:
178+
` m.gross_floor_area("ip")
179+
`
180+
6. *window_wall_ratio()*: can be called before simulation is completed. It returns the total window to wall ratio (above floor surface area) or -1 if there is an error.
181+
182+
### Post-simulation methods
183+
1. *new_site_eui()*: It returns the net site eui of the simulation (includes generators such as PV). The unit should be based on model specification: SI (kWh/m2 or MJ/m2), IP(kWh/m2).
184+
2. *total_site_eui()*: It returns the total site eui of the simulation. The unit should be based on model specification: SI (kWh/m2 or MJ/m2), IP(kWh/m2).
185+
3. *not_met_hour_cooling()*: returns the time sepoint not met hours during cooling condition period. unit: hour
186+
4. *not_met_hour_heating()*: returns the time sepoint not met hours during heating condition period. unit: hour
187+
5. *not_met_hour_total()*: returns the time sepoint not met hours during heating and cooling condition period. unit: hour
188+
6. *total_end_use_electricity()*: returns the total electricity consumption of the design. unit: kWh or GJ, IP is kBtu
189+
7. *total_end_use_naturalgas()*: returns the total natural gas consumption of the design. unit: kWh or GJ, IP is kBtu
190+
191+
161192
<a name="roadmap"></a>
162193
# Roadmap
163-
1. Certainly, the first thing is to get the project into Pip to enable `pip install` command.
164-
2. We are also working on an HTML compiler, which let users to retrieve any values from the html output
165-
3. If you are interested in the future direction of this project, please take a look at our open [issues](https://github.com/weilix88/buildsimhub_python_api/issues) and [pull requests](https://github.com/weilix88/buildsimhub_python_api/pulls). We would love to hear your feedback.
194+
1. We are also working on APIs for results retrieving, which let users to get simulation results for post-processing.
195+
2. If you are interested in the future direction of this project, please take a look at our open [issues](https://github.com/weilix88/buildsimhub_python_api/issues) and [pull requests](https://github.com/weilix88/buildsimhub_python_api/pulls). We would love to hear your feedback.
166196

167197

168198
<a name="about"></a>

0 commit comments

Comments
 (0)