forked from FEAST-SEDLab/FEAST_PtE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tutorial_helper.py
153 lines (137 loc) · 5.37 KB
/
tutorial_helper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import feast
import numpy as np
import copy
comp_fug = feast.EmissionSimModules.infrastructure_classes.Component(
name='Fugitive emitters',
emission_data_path='ExampleData/DataObjectInstances/production_emissions.p',
emission_per_comp=0.00231, # Fraction of components expected to be emitting at the beginning of the simulation.
# emission_production_rate is set to about 5 new emissions per well per year
emission_production_rate=5.4 / 650 / 365, # number of new emissions per component per day
repair_cost_path='ExampleData/DataObjectInstances/fernandez_leak_repair_costs_2006.p',
base_reparable=True
)
wells_per_site = 2
comps_per_well = 650
basic_site = feast.EmissionSimModules.infrastructure_classes.Site(
name='basic site',
comp_dict={
# ------ The number of components is proportional to the number of wells, ind2
'Fugitive ': {'number': comps_per_well * wells_per_site,
'parameters': copy.deepcopy(comp_fug)},
},
)
time = feast.EmissionSimModules.simulation_classes.Time(delta_t=1, end_time=365)
site_dict = {
'basic site': {
'number': 100, # The number of basic_site instances to simulate in the gas_field
'parameters': basic_site
}
# If additional site types are needed, they should be added here as separate dict entries
}
gas_field = feast.EmissionSimModules.infrastructure_classes.GasField(
sites=site_dict,
time=time,
met_data_path='ExampleData/TMY-DataExample.csv'
)
rep3 = feast.DetectionModules.repair.Repair(repair_delay=3)
def make_ogi(dispatch_obj):
points = np.array([0.5, 1, 2, 3, 7]) * 0.01157 # g/s
probs = np.array([0, 0.25, 0.5, 0.75, 1])
ogi = feast.DetectionModules.comp_survey.CompSurvey(
time,
survey_interval=180, # days
survey_speed=500, # comps/hr
ophrs={'begin': 8, 'end': 17},
labor=400, # $/hr
detection_variables={'flux': 'mean'},
detection_probability_points=points, # g/s
detection_probabilities=probs,
dispatch_object=copy.deepcopy(dispatch_obj),
site_queue=[],
)
return ogi
# An OGI-like example that does not automatically survey components but can be dispatched
def make_ogi_no_survey(dispatch_obj):
points = np.array([0.5, 1, 2, 3, 7]) * 0.01157 # g/s
probs = np.array([0, 0.25, 0.5, 0.75, 1])
ogi_no_survey = feast.DetectionModules.comp_survey.CompSurvey(
time,
survey_interval=None, # days
survey_speed=500, # comps/hr
ophrs={'begin': 8, 'end': 17},
labor=400, # $/hr
detection_variables={'flux': 'mean'},
detection_probability_points=points, # g/s
detection_probabilities=probs,
dispatch_object=copy.deepcopy(dispatch_obj),
site_queue=[],
)
return ogi_no_survey
def make_plane_survey(dispatch_obj):
points = np.array([25, 50, 100, 200, 400]) * 0.01157 # g/s
probs = np.array([0, 0.25, 0.5, 0.75, 1])
plane_survey = feast.DetectionModules.site_survey.SiteSurvey(
time,
survey_interval=180, # days
sites_per_day=200,
site_cost=100, # $/site
detection_variables={'flux': 'mean'},
detection_probability_points=points,
detection_probabilities=probs,
dispatch_object=copy.deepcopy(dispatch_obj),
site_queue=[],
ophrs={'begin': 8, 'end': 17}
)
return plane_survey
def make_cont_monitor(dispatch_obj):
points = [[0.5, 1],
[1.0, 1],
[1.1, 1],
[0.5, 5],
[1.0, 5],
[1.1, 5],
[0.5, 5.1],
[1.0, 5.1],
[1.1, 5.1]]
time_to_detect_days = [np.infty, 1, 0, np.infty, 5, 0, np.infty, np.infty, np.infty]
cont_monitor = feast.DetectionModules.site_monitor.SiteMonitor(
time,
time_to_detect_points=points,
time_to_detect_days=time_to_detect_days,
detection_variables={'flux': 'mean', 'wind speed': 'mean'},
site_queue=list(range(gas_field.n_sites)),
dispatch_object=copy.deepcopy(dispatch_obj),
ophrs={'begin': 8, 'end': 17}
)
return cont_monitor
def make_iteration(ind):
print("Currently evaluating iteration number {:0.0f}".format(ind))
time = feast.EmissionSimModules.simulation_classes.Time(delta_t=1, end_time=365)
gas_field = feast.EmissionSimModules.infrastructure_classes.GasField(
sites=site_dict,
time=time,
met_data_path='ExampleData/TMY-DataExample.csv'
)
ogi = make_ogi(rep3)
ogi_no_survey = make_ogi_no_survey(rep3)
plane_survey = make_plane_survey(ogi_no_survey)
# LDAR programs
ogi_survey = feast.DetectionModules.ldar_program.LDARProgram(
copy.deepcopy(gas_field), {'ogi': ogi},
)
# tiered survey
tech_dict = {
'plane': plane_survey,
'ogi': plane_survey.dispatch_object
}
plane_ogi_survey = feast.DetectionModules.ldar_program.LDARProgram(
copy.deepcopy(gas_field), tech_dict,
)
ldar_dict = {
'ogi': ogi_survey,
'plane': plane_ogi_survey
}
scenario = feast.EmissionSimModules.simulation_classes.Scenario(time=time,
gas_field=gas_field,
ldar_program_dict=ldar_dict)
scenario.run(dir_out='TutorialResults-MC', display_status=False, save_method='pickle')