Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…msgpi into 1.3.0
  • Loading branch information
du135 committed Jun 25, 2021
2 parents 4798b5a + 14fd752 commit 1fea1c6
Show file tree
Hide file tree
Showing 26 changed files with 123,103 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
1.3.0

- Added logging and timing functions
- Added a new io function for reading VABS failure analysis results
- Updated the BeamProperty class
- Updated the readVABSOutHomo function for the latest VABS output format

Expand Down
7 changes: 6 additions & 1 deletion msgpi/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ def solve(sg_xml, analysis, ppcmd, solver, timeout=30, scrnout=True, logger=None
logger.info('reading results...')
if timer:
timer.start()
if solver == 'vabs':
return miovabs.readVABSOut(sg_in, analysis, scrnout)

if analysis == 'h':
if solver == 'vabs' or solver == 'integrated':
bp = miovabs.readVABSOutHomo(sg_in + '.K')
Expand Down Expand Up @@ -124,7 +127,7 @@ def run(input_name, analysis, solver, smdim, scrnout=True, logger=None):
Switch of printing solver messages.
"""
if logger is None:
logger = utils.initLogger(__name__)
logger = mlog.initLogger(__name__)

try:
analysis_long = {
Expand All @@ -146,6 +149,8 @@ def run(input_name, analysis, solver, smdim, scrnout=True, logger=None):
if solver == 'vabs':
# solver = solver + 'iii'
cmd = ['VABSIII', input_name]
if analysis == 'fi' or analysis == 3:
cmd.append('3')
elif solver == 'swiftcomp':
cmd = ['SwiftComp', input_name]

Expand Down
10 changes: 0 additions & 10 deletions msgpi/dakota_interface.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
import copy
import csv
import datetime as dt
import json
import os
import platform
import subprocess as sbp
import sys
import traceback as tb
import numpy as np
import xml.etree.ElementTree as et

import msgpi.logger as mlog
import msgpi.timer as mtime
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

def process(fn_json_args, logger=None):
Expand Down
2 changes: 1 addition & 1 deletion msgpi/io/iosc.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ def readSCOutFailure(fn_swiftcomp_in, failure_analysis):
# results.append([int(line[0]), float(line[1]), float(line[2])])
fis.append(float(line[1]))
srs.append(float(line[2]))
return fis, srs
return fis, srs

return results

Expand Down
58 changes: 58 additions & 0 deletions msgpi/io/iovabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,64 @@ def readVABSOutHomo(fn, scrnout=True):
return bp









def readVABSOutStrengthRatio(fn_in):
lines = []
sr_min = None
with open(fn_in, 'r') as fin:
for i, line in enumerate(fin):
if (line.strip() == ''):
continue
lines.append(line)
# initial failure indices and strength ratios
if (line.strip().startswith('The sectional strength ratio is')):
line = line.strip().split()
tmp_id = line.index('existing')
sr_min = float(line[tmp_id - 1])
lines.pop()


# initial failure indices and strength ratios
fis = []
srs = []
for line in lines:
line = line.strip().split()
# results.append([int(line[0]), float(line[1]), float(line[2])])
fis.append(float(line[1]))
srs.append(float(line[2]))
return fis, srs, sr_min









def readVABSOut(fn_in, analysis=0, scrnout=True):
if analysis == 0 or analysis == 'h':
# Read homogenization results
return readVABSOutHomo(fn_in+'.k', scrnout)
elif analysis == 1 or analysis == 2 or analysis == 'd':
pass
elif analysis == 3 or analysis == 'fi':
return readVABSOutStrengthRatio(fn_in+'.fi')









# ====================================================================
#
#
Expand Down
5 changes: 3 additions & 2 deletions tests/test_io/test_io_sc/test_read_sc_failure_out.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import msgpi.io.iosc as miosc

fn = 'box.sg'
r = miosc.readSCOutFailure(fn, 'fi')
fis, srs = miosc.readSCOutFailure(fn, 'fi')

print(r[:10])
print(fis[:10])
print(srs[:10])
Loading

0 comments on commit 1fea1c6

Please sign in to comment.