Skip to content

Commit

Permalink
0929
Browse files Browse the repository at this point in the history
  • Loading branch information
tian50 committed Sep 29, 2021
1 parent b9728aa commit 0c68e9f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions msgpi/dakota/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def __init__(self):
self.das = {}
self.sgs = {}

self.dakota_params_file = ''
self.dakota_results_file = ''


def initialize(self, fn_json_args):

Expand All @@ -49,18 +52,18 @@ def initialize(self, fn_json_args):
# ------------------------------------------------------------

try:
dakota_params_file = self.settings['dakota_parameters_file']
self.dakota_params_file = self.settings['dakota_parameters_file']
except KeyError:
dakota_params_file = 'input.in'
self.dakota_params_file = 'input.in'

try:
dakota_results_file = self.settings['dakota_results_file']
self.dakota_results_file = self.settings['dakota_results_file']
except KeyError:
dakota_results_file = 'output.out'
self.dakota_results_file = 'output.out'

try:
dakota_params, dakota_results = di.read_parameters_file(
dakota_params_file, dakota_results_file
self.dakota_params_file, self.dakota_results_file
)

self.evid = int(dakota_params.eval_id)
Expand Down Expand Up @@ -152,7 +155,7 @@ def writeOutput(self, status):
with open('interim.out', 'w') as fo:
json.dump(self.outputs['interim'], fo, indent=4)

with open(self.settings['dakota_results_file'], 'w') as fo:
with open(self.dakota_results_file, 'w') as fo:
for r in self.outputs['final']:
fo.write(f'{r[1]:24.16E} {r[0]}\n')

Expand All @@ -161,7 +164,7 @@ def writeOutput(self, status):
elif status == 1:
# Fail
self.logger.info(f'{self.log_prompt} failed')
with open(self.settings['dakota_results_file'], 'w') as fo:
with open(self.dakota_results_file, 'w') as fo:
fo.write('FAIL')

e = tb.format_exc()
Expand Down

0 comments on commit 0c68e9f

Please sign in to comment.