diff --git a/msgpi/dakota/interface.py b/msgpi/dakota/interface.py index 19eaf4c..569819c 100644 --- a/msgpi/dakota/interface.py +++ b/msgpi/dakota/interface.py @@ -23,6 +23,8 @@ def __init__(self): self.log_prompt = '' self.logger = None self.das = {} + self.sgs = {} + self.sg_names = [] def initialize(self, fn_json_args): diff --git a/msgpi/design_analysis.py b/msgpi/design_analysis.py index d245ce4..4d6c127 100644 --- a/msgpi/design_analysis.py +++ b/msgpi/design_analysis.py @@ -2,6 +2,7 @@ import pprint # import platform # import msgpi.sg.cross_section as mcs +import msgpi.utils.container as utcnt import msgpi.utils.logger as mlog # import dakota.interfacing as di @@ -10,7 +11,7 @@ class DesignAnalysis(metaclass=abc.ABCMeta): class_name = '' - def __init__(self, inputs={}, outputs={}, settings={}, prepros=[], postpros=[], analyses=[], logger=None): + def __init__(self, inputs={}, outputs={}, settings={}, prepros=[], postpros=[], analyses=[], logger=None, parent=None): # self.object = object self.name = '' self.design = None @@ -42,6 +43,10 @@ def __init__(self, inputs={}, outputs={}, settings={}, prepros=[], postpros=[], self.analyses = analyses + self.parent: DesignAnalysis = parent + self.sg_names = [] + self.sgs = {} + def summary(self, title=''): pp = pprint.PrettyPrinter(indent=1, width=-1) @@ -57,10 +62,12 @@ def summary(self, title=''): pp.pprint(self.prepros) print('\npostpros') pp.pprint(self.postpros) - print('\nanalyses') - for da in self.analyses: - if isinstance(da, DesignAnalysis): - da.summary() + print('\nsg names') + pp.pprint(self.sg_names) + # print('\nanalyses') + # for da in self.analyses: + # if isinstance(da, DesignAnalysis): + # da.summary() print('\n----------') @@ -76,6 +83,10 @@ def updateData(self, inputs={}, outputs={}, settings={}, prepros=[], postpros=[] return + # def updateData(self, to, data, ignore=[]): + + + def pullInputs(self, other_da, ignore_keywords=[]): assert isinstance(other_da, DesignAnalysis) @@ -99,6 +110,12 @@ def pullInputs(self, other_da, ignore_keywords=[]): pass + # def pushData(self, source, target, depth=-1, ignore=[]): + # assert (type(source).__name__ == type(target).__name__) + + + + def pushInputs(self, other_da, structured=True): assert isinstance(other_da, DesignAnalysis) diff --git a/msgpi/ms/bda.py b/msgpi/ms/bda.py new file mode 100644 index 0000000..11984a0 --- /dev/null +++ b/msgpi/ms/bda.py @@ -0,0 +1,65 @@ +import msgpi.ms.blade as msb +from msgpi.design_analysis import DesignAnalysis +import dakota.interfacing as di + + +class BladeDesignAnalysis(DesignAnalysis): + + class_name = 'blade' + + def __init__(self, name='', inputs={}, outputs={}, settings={}, prepros=[], postpros=[], analyses=[], logger=None, parent=None): + DesignAnalysis.__init__(self, inputs, outputs, settings, prepros, postpros, analyses, logger, parent) + + self.name = name + + self.blade = None + + self.sg_names = [] + + + def generateDesign(self): + return + + + def run(self): + self.logger.info(f'running design analysis for {self.name}...') + + # Pre-process data + # ---------------- + self.preprocess() + + # Substitute parameters + # --------------------- + try: + di.dprepro( + template=self.inputs['template'], + output=self.inputs['input_file'], + include=self.inputs + ) + except KeyError: + pass + + # Create a blade object + # --------------------- + if not self.blade: + self.blade = msb.readBladeInput(self.inputs['input_file']) + + self.blade.summary() + + if self.settings['analysis'] == 1: + self.inputs['cs'] = {} + # Generate cross-sectional designs + for k, bs in self.blade.segments.items(): + for i, cs_name in enumerate(bs.css): + cs_name, cs_params = self.blade.genCrossSectionDesign(k, i) + self.inputs['cs'][cs_name] = cs_params + self.sg_names.append(cs_name) + + + + # Post-process data + # ----------------- + self.postprocess() + + return + diff --git a/msgpi/ms/blade.py b/msgpi/ms/blade.py index 6a2f30e..1825961 100644 --- a/msgpi/ms/blade.py +++ b/msgpi/ms/blade.py @@ -207,8 +207,8 @@ def genCrossSectionDesign(self, segi, csj): # cs_params = copy.deepcopy(params) cs_params = {} cs_params['r'] = bs.coords[csj][0] - cs_params['fn_cs_temp'] = bs.cs_template[csj] - cs_params['fn_cs_main'] = cs_name + '.xml' + cs_params['template'] = bs.cs_template[csj] + cs_params['input_file'] = cs_name + '.xml' # 2. Add parameters calculated from distribution functions for param, func in self.distributions.items(): diff --git a/msgpi/utils/container.py b/msgpi/utils/container.py new file mode 100644 index 0000000..1213519 --- /dev/null +++ b/msgpi/utils/container.py @@ -0,0 +1,7 @@ +def updateDict(source:dict, target:dict, ignore:list=[]): + + for k, v in source.items(): + if not k in ignore: + target[k] = v + + return