-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.cpp
More file actions
299 lines (214 loc) · 8.59 KB
/
main.cpp
File metadata and controls
299 lines (214 loc) · 8.59 KB
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
/*
* This file is part of the ResOpt project.
*
* Copyright (C) 2011-2012 Aleksander O. Juell <aleksander.juell@ntnu.no>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*!@mainpage ResOpt Documentation
\section sec_intro Introduction
This is the documentation for the Reservoir Optimization Framework (ResOpt). ResOpt is a framework for model integration and optimization.
The core functionallity of ResOpt is to connect a reservoir simulator to a simple pipe network, and to do optimization on the resulting model.
\section sec_pri Setting up resopt_libs.pri
A .pri include file containing paths to libraries and headers for the external libraries ResOpt use must be present.
Example of the .pri file:
@code
# bonmin libraries:
LIBS += -L/home/aleksaju/bonmin/Bonmin-1.5.3/build/lib -lbonmin -lipopt -lCbc -lCgl -lOsiClp -lOsi -lClp -lCoinUtils
# ipopt libraries (from ipopt_addlibs_cpp.txt):
LIBS += -L/home/aleksaju/bonmin/Bonmin-1.5.3/build/lib -L/usr/lib/gcc/x86_64-linux-gnu/4.6.1 -L/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../.. -lipopt -ldl -lcoinmumps -lpthread -lcoinlapack -lcoinblas -lgfortran -lm -lgcc_s -lquadmath
# cgl libraries (from cgl_addlibs.txt):
LIBS += -L/home/aleksaju/bonmin/Bonmin-1.5.3/build/lib -L/usr/lib/gcc/x86_64-linux-gnu/4.6.1 -L/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../.. -lCgl -lOsiClp -lClp -lOsi -lcoinmumps -lpthread -lCoinUtils -lcoinlapack -lcoinblas -lgfortran -lm -lgcc_s -lquadmath
# osi libraries (from osi_addlibs.txt):
LIBS += -L/home/aleksaju/bonmin/Bonmin-1.5.3/build/lib -L/usr/lib/gcc/x86_64-linux-gnu/4.6.1 -L/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../.. -lOsi -lCoinUtils -lcoinlapack -lcoinblas -lgfortran -lm -lgcc_s -lquadmath
# clp libraries (from clp_addlibs.txt):
LIBS += -L/home/aleksaju/bonmin/Bonmin-1.5.3/build/lib -L/usr/lib/gcc/x86_64-linux-gnu/4.6.1 -L/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../.. -lClp -lcoinmumps -lpthread -lCoinUtils -lcoinlapack -lcoinblas -lgfortran -lm -lgcc_s -lquadmath
# coinutils libraries (from coinutils_addlibs.txt):
LIBS += -L/home/aleksaju/bonmin/Bonmin-1.5.3/build/lib -L/usr/lib/gcc/x86_64-linux-gnu/4.6.1 -L/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../.. -lCoinUtils -lcoinlapack -lcoinblas -lgfortran -lm -lgcc_s -lquadmath
# NOMAD library
LIBS += /home/aleksaju/nomad/nomad.3.5.1/lib/nomad.a
# bonmin header files
INCLUDEPATH += /home/aleksaju/bonmin/Bonmin-1.5.3/build/include/coin
#NOMAD header files
INCLUDEPATH += /home/aleksaju/nomad/nomad.3.5.1/src
@endcode
\section sec_running Running the framework
ResOpt is run from the command line like this:
@code
ResOpt 'driver file'
@endcode
\section sec_ex Example driver file
@code
!-------------------------------------------------------------------
! Driver file for ResOpt
!-------------------------------------------------------------------
!---------------- Optimization Algorithm ---------------------------
START OPTIMIZER
TYPE RUNONCE !BONMIN, RUNONCE
ITERATIONS 60
PERTURBATION 0.05
PARALLELRUNS 1 !integer, or "IDEAL" for the ideal number of parallel runs on this machine
END OPTIMIZER
!----------------- Reservoir Definition ----------------------------
START RESERVOIR
NAME RES1
FILE res_spe1.in
TIME 3650
PHASES 1 1 1 ! gas oil water
DENS 0.06054 49.1 64.79 ! gas oil water
END RESERVOIR
!------------------- Master Schedule -------------------------------
START MASTERSCHEDULE
100
300
3650
END MASTERSCHEDULE
!-------------------- Well: prod1 ----------------------------------
START WELL
NAME prod1
TYPE P
GROUP grp1
BHPLIMIT 100 ! Only used when well is on rate control
START OUTLETPIPES
! pipe# fraction
1 1.0
2 0.0
END OUTLETPIPES
START CONNECTIONS
299 9410
END CONNECTIONS
START SCHEDULE
! t_end value max min type
100 2000 2100 1800 BHP !BHP, GAS, OIL, WAT
300 1950 2100 1800 BHP
3650 1900 2100 1800 BHP
END SCHEDULE
END WELL
!-------------------- Well: inj1 -----------------------------------
START WELL
NAME inj1
TYPE I
GROUP grp1
BHPLIMIT 1000000 ! Only used when well is on rate control
BHPINJ GAS ! Only used for injectors, the injected phase when well is on BHP control (WATER, GAS)
START CONNECTIONS
0 100000
END CONNECTIONS
START SCHEDULE
! t_end value max min type
100 5000 8000 1000 BHP
300 5000 8000 1000 BHP
3650 5000 8000 1000 BHP
END SCHEDULE
END WELL
!------------------- Objective definition -------------------------
START OBJECTIVE
TYPE CUMOIL !NPV, CUMOIL, CUMGAS
! these keywords are only needed for NPV:
DCF 10
OILPRICE 100
GASPRICE 5
WATERPRICE -10
END OBJECTIVE
!----------------------- Pipe 1 -----------------------------------
START PIPE
NUMBER 1
FILE pipe1.dat
START OUTLETPIPES
! pipe# fraction
3 1.0
END OUTLETPIPES
END PIPE
!----------------------- Pipe 1 -----------------------------------
START PIPE
NUMBER 2
FILE pipe2.dat
START OUTLETPIPES
! pipe# fraction
3 1.0
END OUTLETPIPES
END PIPE
!----------------------- Pipe 2 -----------------------------------
START PIPE
NUMBER 3
FILE pipe3.dat
OUTLETPRESSURE 200
END PIPE
!------------------- Separator: sep1 ------------------------------
START CAPACITY
NAME cap1
PIPES 3
WATER 10000
GAS 1e6
! OIL 1000
! LIQ 10000
END CAPACITY
EOF
@endcode
*/
#include <QtCore>
#include <QtWidgets/QApplication>
#include <iostream>
#include "runner.h"
#include "gui/mainwindow.h"
//#include "par/masterrunner.h"
using namespace ResOpt;
using namespace ResOptGui;
using std::cout;
using std::endl;
int main(int argc, char *argv[])
{
QCoreApplication *a = 0;
Runner *r = 0;
if(argc == 2)
{
a = new QCoreApplication(argc, argv);
r = new Runner(argv[1]);
QObject::connect(r,SIGNAL(optimizationFinished()), a, SLOT(quit()));
QTimer::singleShot(0, r, SLOT(run()));
}
else if(argc == 1)
{
// to launch in GUI mode
//*
a = new QApplication(argc, argv);
MainWindow *p_mw = new MainWindow();
//p_mw->show();
p_mw->showMaximized();
//*/
// to launch in console mode with default driver file name
/*
a = new QCoreApplication(argc, argv);
r = new Runner("/home/aleksaju/Work/postdoc/ResOpt/build-ResOpt-Desktop_Qt_5_0_2_GCC_64bit-Release/eirik_1day/driver.dat");
QObject::connect(r,SIGNAL(runnerFinished(Runner*, Case*)), a, SLOT(quit()));
QTimer::singleShot(0, r, SLOT(run()));
*/
// to launch MasterRunner
/*
a = new QCoreApplication(argc, argv);
//r = new Runner("/home/aleksaju/Work/postdoc/ResOpt/build-ResOpt-Desktop_Qt_5_0_2_GCC_64bit-Release/eirik_1day/driver.dat");
MasterRunner *mr = new MasterRunner("/home/aleksaju/Work/postdoc/ResOpt/build-ResOpt-Desktop_Qt_5_0_2_GCC_64bit-Release/par_test/driver.dat", 2);
QObject::connect(mr,SIGNAL(optimizationFinished()), a, SLOT(quit()));
QTimer::singleShot(0, mr, SLOT(run()));
*/
}
else
{
cout << "Wrong input arguments!" << endl
<< "Correct usage: .\\ResOpt driver_file" << endl;
a->exit(1);
}
return a->exec();
}