Skip to content

Commit

Permalink
0723
Browse files Browse the repository at this point in the history
  • Loading branch information
Su Tian committed Jul 23, 2021
1 parent cebeb86 commit f1d1414
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
12 changes: 8 additions & 4 deletions msgpi/cross_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,21 @@ class CrossSection(object):
def __init__(self, name):
self.name = name

self.name_template = '' #: Base name of the main input file template
self.fn_vabs_in = self.name + '.sg' #: File name of the VABS input
self.fn_sc_in = self.name + '.sg' #: File name of the SwiftComp input
self.fn_design_tmp = ''
self.fn_design_xml = ''
self.fn_sg = ''
# self.fn_vabs_in = self.name + '.sg' #: File name of the VABS input
# self.fn_sc_in = self.name + '.sg' #: File name of the SwiftComp input
# self.fn_gmsh_msh = self.name + '.msh' #: File name of the Gmsh mesh file

self.sg = None # Structure gene
self.bp = None # Beam property
self.props = None # Beam property

# Design
self.params = {}

# ------------------------------------------------------------

self.name_baseline = '' #: Base name of the base lines file
self.name_layup = '' #: Base name of the layups file

Expand Down
33 changes: 17 additions & 16 deletions msgpi/interface.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import platform
import msgpi.cross_section as mcs
import msgpi.analysis as sga
import msgpi.logger as mlog
import dakota.interfacing as di


class CrossSectionJob():

def __init__(self, name="", design={}, job_args={}, logger=None):
self.name = name
self.design = design
def __init__(self, cs: mcs.CrossSection, inputs={}, job_args={}, logger=None):
self.cs = cs
self.job_args = job_args

if logger is None:
self.logger = mlog.initLogger(__name__)
else:
self.logger = logger

self.bp = None
self.result = {}
self.inputs = inputs
self.outputs = {}




def run(self):
self.logger.info(f'running analysis job for {self.name}...')
self.logger.info(f'running analysis job for {self.cs.name}...')

analysis = self.job_args['analysis']

Expand All @@ -44,30 +44,31 @@ def run(self):
scrnout = self.job_args['scrnout']



# preVABS/VABS
fn_main = self.design['fn_cs_main']
# fn_main = self.design['fn_cs_main']
# fn_design_xml = self.cs.name + '.xml'

# print('\ncs_params')
# pprt.pprint(cs_params)
# print('\n')

# Substitute parameters
di.dprepro(
template=self.design['fn_cs_temp'], output=fn_main,
include=self.design
)
if self.cs.fn_design_xml == '':
self.cs.fn_design_xml = self.cs.name + '.xml'
di.dprepro(
template=self.cs.fn_design_tmp, output=self.cs.fn_design_xml,
include=self.inputs
)

# Solve
self.bp = sga.solve(
fn_main, analysis, ppcmd, solver, integrated,
self.cs.props = sga.solve(
self.cs.fn_design_xml, analysis, ppcmd, solver, integrated,
timeout=timeout, scrnout=scrnout, logger=self.logger
)

# Extract beam properties
self.logger.debug('extracting beam properties...')
for n in self.job_args['beam_properties']:
self.result[n] = self.bp.get(n)
self.outputs[n] = self.cs.props.get(n)


# self.cs_data['props'] = self.results
Expand Down

0 comments on commit f1d1414

Please sign in to comment.