From 944a624ee4b3e04ab67d3e7e5ce239c55cc35109 Mon Sep 17 00:00:00 2001 From: wolf Date: Fri, 8 Mar 2019 18:57:53 +0100 Subject: [PATCH] unfinished bugfixes --- .vscode/settings.json | 3 +++ coupled_simulation/coupling.py | 11 ++++++++--- coupled_simulation/geostorage.py | 25 ++++++++++++++++++++++--- run_if.py | 15 +++++++++++++++ 4 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 run_if.py diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c76aeab --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "C:\\Users\\sungw385\\AppData\\Local\\Programs\\Python\\Python37-32\\python.exe" +} \ No newline at end of file diff --git a/coupled_simulation/coupling.py b/coupled_simulation/coupling.py index 6ccb3b8..2868698 100644 --- a/coupled_simulation/coupling.py +++ b/coupled_simulation/coupling.py @@ -42,6 +42,8 @@ def __main__(argv): except getopt.GetoptError: print('test.py -i ') sys.exit(2) + print(opts) + print(argv) for opt, arg in opts: if opt == '-h': print('test.py -i ') @@ -49,6 +51,8 @@ def __main__(argv): elif opt in ("-i", "--ipath"): path = arg + print(path) + if path[0] == "r": path = path[1:] @@ -71,10 +75,11 @@ def __main__(argv): # create instances for power plant and storage geostorage = gs.geo_sto(cd) - #min_well_depth = min(geostorage.well_depths) - min_well_depth = 700 #read this from file later! + min_well_depth = min(geostorage.well_depths) + #min_well_depth = 700 #read this from file later! - powerplant = pp.model(cd, min_well_depth) + powerplant = pp.model(cd, min_well_depth, len(geostorage.well_names), max(geostorage.well_upper_BHP), min(geostorage.well_lower_BHP)) + #powerplant = pp.model(cd, min_well_depth, 9, 80, 40) print('######################################################################') print('Reading input time series...') diff --git a/coupled_simulation/geostorage.py b/coupled_simulation/geostorage.py index 9c3c686..2bc8993 100644 --- a/coupled_simulation/geostorage.py +++ b/coupled_simulation/geostorage.py @@ -35,6 +35,9 @@ def __init__(self, cd): self.working_dir_loc = wdir self.keep_ecl_logs = False + # save the original simulation title in case of eclipse simulation (not needed for e300) + self.simulation_title_orig = self.simulation_title + if self.retain_ecl_logs == "True": self.keep_ecl_logs = True else: @@ -86,6 +89,14 @@ def RunECLIPSE(self, target_flowrate, tstep, iter_step, tstepsize, current_mode) if not current_mode == 'init': + if self.simulator == "ECLIPSE": + print("Resetting simulation title!") + self.simulation_title = self.simulation_title_orig + "_" + str(tstep) + if tstep == 0: + os.rename(self.working_dir_loc + self.simulation_title_orig + '.DATA', self.working_dir_loc + self.simulation_title_orig + "_" + str(tstep) + '.DATA') + else: + os.rename(self.working_dir_loc + self.simulation_title_orig + "_" + str(tstep-1) + '.DATA', self.working_dir_loc + self.simulation_title_orig + "_" + str(tstep) + '.DATA') + print('Running storage simulation:') print(self.working_dir_loc + self.simulation_title + '.DATA') print('Timestep/iteration:\t\t', '%.0f'%tstep, '/', '%.0f'%iter_step) @@ -344,13 +355,21 @@ def GetECLResults(self, timestep, current_op_mode): results = util.getFile(filename) #sort the rsm data to a more uniform dataset reorderd_rsm_data = self.rearrangeRSMDataArray(results) + #print(reorderd_rsm_data) #eleminate additional whitespaces, duplicate entries, etc. well_results = util.contractDataArray(reorderd_rsm_data) - + #print(well_results) + # check number of data entries in well_results: - values = len(well_results) - 4 + + entry_count_temp = 0 + if self.simulator == 'e300': + entry_count_temp = 4 + elif self.simulator == 'ECLIPSE': + entry_count_temp = 5 + values = len(well_results) - entry_count_temp if values > 1: - print('Warning: possible loss of data, expecting one data line in RSM file only') + print('Warning: possible loss of data, too many data lines in RSM file') #data structures to save the flowrates, pressures and names of all individual wells well_pressures = [] diff --git a/run_if.py b/run_if.py new file mode 100644 index 0000000..2347e1a --- /dev/null +++ b/run_if.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +""" + +__author__ = "wtp" + +""" + +import sys + +from coupled_simulation import cp + +print (sys.argv) +cp.__main__(sys.argv[1:])