Skip to content

Commit

Permalink
1116
Browse files Browse the repository at this point in the history
  • Loading branch information
tian50 committed Nov 17, 2020
1 parent 1957cfa commit 2c74b8d
Show file tree
Hide file tree
Showing 29 changed files with 469 additions and 70 deletions.
Binary file modified __init__.pyc
Binary file not shown.
Binary file removed __pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/analysis.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/cross_section.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/presg.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/sg.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/utils.cpython-37.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def solve(sg_xml, analysis, ppcmd, solver, scrnout=True):
"""

# Preprocess
sg_in, smdim = psg.preSG(sg_xml, analysis, ppcmd, solver)
sg_in, smdim = psg.preSG(sg_xml, analysis, ppcmd, solver, scrnout=scrnout)

# Solve
run(sg_in, analysis, solver, smdim, scrnout)
Expand Down
Binary file modified analysis.pyc
Binary file not shown.
102 changes: 102 additions & 0 deletions dakota_interface.py
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 added dakota_interface.pyc
Binary file not shown.
Binary file modified doc/build/doctrees/analysis.doctree
Binary file not shown.
Binary file modified doc/build/doctrees/environment.pickle
Binary file not shown.
Binary file modified doc/build/doctrees/presg.doctree
Binary file not shown.
Binary file modified doc/build/doctrees/sg.doctree
Binary file not shown.
3 changes: 2 additions & 1 deletion doc/build/html/analysis.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ <h1>analysis Module<a class="headerlink" href="#analysis-module" title="Permalin
</div>
<dl class="function">
<dt id="msgpi.analysis.solve">
<code class="descclassname">msgpi.analysis.</code><code class="descname">solve</code><span class="sig-paren">(</span><em>sg_xml</em>, <em>analysis</em>, <em>solver</em>, <em>scrnout=True</em><span class="sig-paren">)</span><a class="headerlink" href="#msgpi.analysis.solve" title="Permalink to this definition"></a></dt>
<code class="descclassname">msgpi.analysis.</code><code class="descname">solve</code><span class="sig-paren">(</span><em>sg_xml</em>, <em>analysis</em>, <em>ppcmd</em>, <em>solver</em>, <em>scrnout=True</em><span class="sig-paren">)</span><a class="headerlink" href="#msgpi.analysis.solve" title="Permalink to this definition"></a></dt>
<dd><p>Solve</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
Expand All @@ -183,6 +183,7 @@ <h1>analysis Module<a class="headerlink" href="#analysis-module" title="Permalin
<li>fi - initial failure indices and strength ratios</li>
</ul>
</li>
<li><strong>ppcmd</strong> (<em>str</em>) – Preprocessor command.</li>
<li><strong>solver</strong> (<em>str</em>) – Format of the generated input file (‘vabs’ or ‘swiftcomp’).</li>
<li><strong>scrnout</strong> (<em>bool</em><em>, </em><em>default True</em>) – Switch of printing solver messages.</li>
</ul>
Expand Down
14 changes: 10 additions & 4 deletions doc/build/html/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ <h2 id="F">F</h2>
<h2 id="G">G</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="sg.html#msgpi.sg.MaterialSection.getBeamProperty">getBeamProperty() (msgpi.sg.MaterialSection method)</a>
</li>
<li><a href="sg.html#msgpi.sg.StructureGene.global_displacements">global_displacements (msgpi.sg.StructureGene attribute)</a>
</li>
<li><a href="sg.html#msgpi.sg.StructureGene.global_loads">global_loads (msgpi.sg.StructureGene attribute)</a>
Expand Down Expand Up @@ -333,13 +335,15 @@ <h2 id="M">M</h2>
</li>
<li><a href="sg.html#msgpi.sg.StructureGene.materials">materials (msgpi.sg.StructureGene attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="sg.html#msgpi.sg.MaterialSection">MaterialSection (class in msgpi.sg)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="beam.html#msgpi.ms.beam.Beam.max_iteration">max_iteration (msgpi.ms.beam.Beam attribute)</a>
</li>
<li><a href="beam.html#msgpi.ms.beam.Beam.mconditions">mconditions (msgpi.ms.beam.Beam attribute)</a>
</li>
<li><a href="sg.html#msgpi.sg.MaterialSection.mmoi">mmoi (msgpi.sg.MaterialSection attribute)</a>
</li>
<li><a href="sg.html#msgpi.sg.StructureGene.mocombos">mocombos (msgpi.sg.StructureGene attribute)</a>
</li>
Expand Down Expand Up @@ -485,12 +489,14 @@ <h2 id="S">S</h2>
<h2 id="T">T</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="ioutils.html#msgpi.io.utils.textToMatrix">textToMatrix() (in module msgpi.io.utils)</a>
<li><a href="sg.html#msgpi.sg.MaterialSection.tension_center">tension_center (msgpi.sg.MaterialSection attribute)</a>
</li>
<li><a href="sg.html#msgpi.sg.StructureGene.trans_element">trans_element (msgpi.sg.StructureGene attribute)</a>
<li><a href="ioutils.html#msgpi.io.utils.textToMatrix">textToMatrix() (in module msgpi.io.utils)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="sg.html#msgpi.sg.StructureGene.trans_element">trans_element (msgpi.sg.StructureGene attribute)</a>
</li>
<li><a href="beam.html#msgpi.ms.beam.BeamSegment.twist">twist (msgpi.ms.beam.BeamSegment attribute)</a>
</li>
<li><a href="sg.html#msgpi.sg.MaterialSection.type">type (msgpi.sg.MaterialSection attribute)</a>
Expand Down
Binary file modified doc/build/html/objects.inv
Binary file not shown.
3 changes: 2 additions & 1 deletion doc/build/html/presg.html
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ <h1>presg Module<a class="headerlink" href="#presg-module" title="Permalink to t

<dl class="function">
<dt id="msgpi.presg.preSG">
<code class="descclassname">msgpi.presg.</code><code class="descname">preSG</code><span class="sig-paren">(</span><em>sg_xml</em>, <em>analysis</em>, <em>solver='swiftcomp'</em>, <em>write_input=True</em>, <em>scrnout=True</em><span class="sig-paren">)</span><a class="headerlink" href="#msgpi.presg.preSG" title="Permalink to this definition"></a></dt>
<code class="descclassname">msgpi.presg.</code><code class="descname">preSG</code><span class="sig-paren">(</span><em>sg_xml</em>, <em>analysis</em>, <em>ppcmd='prevabs'</em>, <em>solver='swiftcomp'</em>, <em>write_input=True</em>, <em>scrnout=True</em><span class="sig-paren">)</span><a class="headerlink" href="#msgpi.presg.preSG" title="Permalink to this definition"></a></dt>
<dd><p>Preprocessor of a structure gene.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
Expand All @@ -214,6 +214,7 @@ <h1>presg Module<a class="headerlink" href="#presg-module" title="Permalink to t
<li>fi - initial failure indices and strength ratios</li>
</ul>
</li>
<li><strong>ppcmd</strong> (<em>str</em><em>, </em><em>default 'prevabs'</em>) – Preprocessor command.</li>
<li><strong>solver</strong> (<em>str</em><em>, </em><em>default 'swiftcomp'</em>) – Format of the generated input file (‘vabs’ or ‘swiftcomp’)</li>
<li><strong>write_input</strong> (<em>bool</em>) – Whether to write input file.</li>
<li><strong>scrnout</strong> (<em>bool</em>) – Whether to print messages to the screen.</li>
Expand Down
2 changes: 1 addition & 1 deletion doc/build/html/searchindex.js

Large diffs are not rendered by default.

77 changes: 75 additions & 2 deletions doc/build/html/sg.html
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,55 @@ <h2>Material Section<a class="headerlink" href="#material-section" title="Permal
</table>
</dd></dl>

<dl class="method">
<dt id="msgpi.sg.MaterialSection.getBeamProperty">
<code class="descname">getBeamProperty</code><span class="sig-paren">(</span><em>label</em><span class="sig-paren">)</span><a class="headerlink" href="#msgpi.sg.MaterialSection.getBeamProperty" title="Permalink to this definition"></a></dt>
<dd><p>Get beam properties using specific labels.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>label</strong> (<em>str</em>) – <p>Label of the property that will be returned.</p>
<p>Mass</p>
<ul class="simple">
<li>msijo - Entry (i, j) of the 6x6 mass matrix at the origin</li>
<li>msijc - Entry (i, j) of the 6x6 mass matrix at the mass center</li>
<li>mpl - Mass per unit length</li>
<li>mmoi1/mmoi2/mmoi3 - Mass moment of inertia about x1/x2/x3 axis</li>
</ul>
<p>Stiffness</p>
<ul class="simple">
<li>stfijc - Entry (i, j) of the 4x4 classical stiffness matrix</li>
<li>stfijr - Entry (i, j) of the 6x6 refined stiffness matrix</li>
<li>eac/ear - Axial stiffness of the classical/refined model</li>
<li>gjc/gjr - Torsional stiffness of the classical/refined model</li>
<li>ei2c/eifc/ei2r/eifr - Bending stiffness around x2 (flapwise) of the classical/refined model</li>
<li>ei3c/eicc/ei3r/eicr - Bending stiffness around x3 (chordwise or lead-lag) of the classical/refined model</li>
</ul>
<p>Compliance</p>
<ul class="simple">
<li>cmpijc - Entry (i, j) of the 4x4 classical compliance matrix</li>
<li>cmpijr - Entry (i, j) of the 6x6 refined compliance matrix</li>
</ul>
<p>Centers</p>
<ul class="simple">
<li>mcy - y (or x2) component of the mass center</li>
<li>mcz - z (or x3) component of the mass center</li>
<li>tcy - y (or x2) component of the tension center</li>
<li>tcz - z (or x3) component of the tension center</li>
<li>scy - y (or x2) component of the shear center</li>
<li>scz - z (or x3) component of the shear center</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt id="msgpi.sg.MaterialSection.mass_center">
<code class="descname">mass_center</code><em class="property"> = None</em><a class="headerlink" href="#msgpi.sg.MaterialSection.mass_center" title="Permalink to this definition"></a></dt>
<dd><p>Mass center.</p>
<dd><p>Mass center. [x1, x2, x3]</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
Expand Down Expand Up @@ -312,6 +357,20 @@ <h2>Material Section<a class="headerlink" href="#material-section" title="Permal
</table>
</dd></dl>

<dl class="attribute">
<dt id="msgpi.sg.MaterialSection.mmoi">
<code class="descname">mmoi</code><em class="property"> = None</em><a class="headerlink" href="#msgpi.sg.MaterialSection.mmoi" title="Permalink to this definition"></a></dt>
<dd><p>Mass moments of inertia.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Type:</th><td class="field-body">list of floats</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt id="msgpi.sg.MaterialSection.name">
<code class="descname">name</code><em class="property"> = None</em><a class="headerlink" href="#msgpi.sg.MaterialSection.name" title="Permalink to this definition"></a></dt>
Expand All @@ -329,7 +388,7 @@ <h2>Material Section<a class="headerlink" href="#material-section" title="Permal
<dl class="attribute">
<dt id="msgpi.sg.MaterialSection.shear_center">
<code class="descname">shear_center</code><em class="property"> = None</em><a class="headerlink" href="#msgpi.sg.MaterialSection.shear_center" title="Permalink to this definition"></a></dt>
<dd><p>(beam model) Shear center.</p>
<dd><p>(beam model) Elastic axis/Shear center. [x1, x2, x3]</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
Expand Down Expand Up @@ -396,6 +455,20 @@ <h2>Material Section<a class="headerlink" href="#material-section" title="Permal
</table>
</dd></dl>

<dl class="attribute">
<dt id="msgpi.sg.MaterialSection.tension_center">
<code class="descname">tension_center</code><em class="property"> = None</em><a class="headerlink" href="#msgpi.sg.MaterialSection.tension_center" title="Permalink to this definition"></a></dt>
<dd><p>(beam model) Neutral axes/Tension center. [x1, x2, x3]</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Type:</th><td class="field-body">list of floats</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt id="msgpi.sg.MaterialSection.type">
<code class="descname">type</code><em class="property"> = None</em><a class="headerlink" href="#msgpi.sg.MaterialSection.type" title="Permalink to this definition"></a></dt>
Expand Down
76 changes: 76 additions & 0 deletions galaxy_interface.py
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])
Loading

0 comments on commit 2c74b8d

Please sign in to comment.