Skip to content

Commit

Permalink
1118 updated dakota_interface
Browse files Browse the repository at this point in the history
  • Loading branch information
tian50 committed Nov 18, 2020
1 parent d0e9cc7 commit a2fd8ef
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 95 deletions.
46 changes: 27 additions & 19 deletions dakota_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,27 @@ def interface(fn_json_args):
interface_args = json.load(fo)


# Load data processing module
if 'data_process_functions_file' in interface_args.keys():
fn_dpf = interface_args['data_process_functions_file']
if fn_dpf != '':
import_str = 'import {0} as dpf'.format(fn_dpf)
exec(import_str)


# Read parameters
params, results = di.read_parameters_file(sys.argv[-2], sys.argv[-1])


# Pre-processing of parameters
if 'pre_process' in interface_args.keys():
funcs = interface_args['pre_process']
if len(funcs) > 0:
for func in funcs:
eval('dpf.{0}'.format(func))(params)


# Substitute templates
for fn_t, fn_i in interface_args['template_output'].items():
di.dprepro(template=fn_t, parameters=params, output=fn_i)

Expand All @@ -37,12 +56,6 @@ def interface(fn_json_args):
))


# Processing of parameters


# study = interface_args['study']


try:
# preVABS/VABS
print(' - running cross-sectional analysis...')
Expand All @@ -53,26 +66,21 @@ def interface(fn_json_args):
ms = sga.solve(fn_main, analysis, ppcmd, solver, False)


# Collect beam properties
# responses = interface_args['beam_props']
# for k, v in responses.items():
# if k == 'stiffness_refined':
# for label, index in v.items():
# results[label].function = ms.stiffness_refined[index[0]][index[1]]


# Calculate actual responses
is_post_funcs_imported = False
for k, v in interface_args['post_functions'].items():
# is_post_funcs_imported = False
for k, v in interface_args['post_process'].items():
# print('')
# print('label:', v[0])
bp = ms.getBeamProperty(v[0])
# print('bp:', bp)
if v[1] == 'self':
r = bp
elif v[1] == 'abs_rel_diff':
r = np.abs((bp - v[2]) / v[2])
else:
if not is_post_funcs_imported:
import post_funcs
is_post_funcs_imported = True
# if not is_post_funcs_imported:
# import post_funcs
# is_post_funcs_imported = True
# eval('from post_funcs import {0}'.format(v[1]))
# r = eval(v[1])(bp, v[2])
r = eval('post_funcs.{0}'.format(v[1]))(bp, v[2])
Expand Down
76 changes: 0 additions & 76 deletions galaxy_interface.py

This file was deleted.

0 comments on commit a2fd8ef

Please sign in to comment.