-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
469 additions
and
70 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import os | ||
import sys | ||
import subprocess as sbp | ||
import datetime as dt | ||
import json | ||
import traceback as tb | ||
import numpy as np | ||
import pandas as pd | ||
import xml.etree.ElementTree as et | ||
import msgpi.presg as psg | ||
import msgpi.analysis as sga | ||
import msgpi.io.iosc as miosc | ||
import msgpi.io.iovabs as miovabs | ||
import dakota.interfacing as di | ||
|
||
|
||
# Format string | ||
msgfmt_w_ts = '- [{ts:%H}:{ts:%M}] {msg}' # string format with time stamp | ||
fse = ' x [{0:%H}:{0:%M}:{0:%S}] EVAL {1:d}: {2:s}' | ||
fsi = ' > [{0:%H}:{0:%M}:{0:%S}] EVAL {1:d}: {2:s}' | ||
|
||
|
||
def interface(fn_json_args): | ||
# Load JSON arguments | ||
with open(fn_json_args, 'r') as fo: | ||
interface_args = json.load(fo) | ||
|
||
|
||
# Read parameters | ||
params, results = di.read_parameters_file(sys.argv[-2], sys.argv[-1]) | ||
for fn_t, fn_i in interface_args['template_output'].items(): | ||
di.dprepro(template=fn_t, parameters=params, output=fn_i) | ||
|
||
evid = int(params.eval_id) | ||
print(msgfmt_w_ts.format( | ||
ts=dt.datetime.now(), | ||
msg=' '.join(('eval', str(evid), 'start')) | ||
)) | ||
|
||
|
||
# Processing of parameters | ||
|
||
|
||
# study = interface_args['study'] | ||
|
||
|
||
try: | ||
# preVABS/VABS | ||
print(' - running cross-sectional analysis...') | ||
fn_main = interface_args['fn_main'] | ||
analysis = interface_args['analysis'] | ||
ppcmd = interface_args['prevabs_cmd'] | ||
solver = interface_args['solver'] | ||
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(): | ||
bp = ms.getBeamProperty(v[0]) | ||
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 | ||
# 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]) | ||
results[k].function = r | ||
|
||
|
||
# Write output | ||
results.write() | ||
|
||
print(' - done.') | ||
|
||
return | ||
|
||
except: | ||
results.fail() | ||
with open('results.out', 'w') as fout: | ||
results.write(stream=fout) | ||
print(fse.format(dt.datetime.now(), evid, 'FAIL')) | ||
e = tb.format_exc() | ||
print(e) | ||
return | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
interface(sys.argv[1]) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import os | ||
import sys | ||
import subprocess as sbp | ||
import datetime as dt | ||
import json | ||
import traceback as tb | ||
import numpy as np | ||
import pandas as pd | ||
import xml.etree.ElementTree as et | ||
import msgpi.presg as psg | ||
import msgpi.analysis as sga | ||
import msgpi.io.iosc as miosc | ||
import msgpi.io.iovabs as miovabs | ||
import dakota.interfacing as di | ||
|
||
|
||
# Format string | ||
msgfmt_w_ts = '- [{ts:%H}:{ts:%M}] {msg}' # string format with time stamp | ||
fse = ' x [{0:%H}:{0:%M}:{0:%S}] EVAL {1:d}: {2:s}' | ||
fsi = ' > [{0:%H}:{0:%M}:{0:%S}] EVAL {1:d}: {2:s}' | ||
|
||
|
||
def interface(fn_json_args): | ||
# Load JSON arguments | ||
with open(fn_json_args, 'r') as fo: | ||
interface_args = json.load(fo) | ||
|
||
|
||
# Processing of parameters | ||
|
||
|
||
study = interface_args['study'] | ||
|
||
|
||
try: | ||
# preVABS/VABS | ||
print(' - running cross-sectional analysis...') | ||
fn_main = interface_args['fn_main'] | ||
analysis = interface_args['analysis'] | ||
ppcmd = interface_args['prevabs_cmd'] | ||
solver = interface_args['solver'] | ||
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 | ||
|
||
|
||
|
||
# Write output | ||
results.write() | ||
|
||
print(' - done.') | ||
|
||
return | ||
|
||
except: | ||
results.fail() | ||
with open('results.out', 'w') as fout: | ||
results.write(stream=fout) | ||
print(fse.format(dt.datetime.now(), evid, 'FAIL')) | ||
e = tb.format_exc() | ||
print(e) | ||
return | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
interface(sys.argv[1]) |
Oops, something went wrong.