-
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
Su Tian
committed
Aug 5, 2021
1 parent
ae725d5
commit 668c2e0
Showing
2 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
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,78 @@ | ||
| import platform | ||
| from msgpi.sgda import SGDesignAnalysis | ||
| import msgpi.cross_section as mcs | ||
| import msgpi.analysis as sga | ||
| import dakota.interfacing as di | ||
|
|
||
|
|
||
| class CrossSectionDesignAnalysis(SGDesignAnalysis): | ||
|
|
||
| def __init__(self, cs: mcs.CrossSection, inputs={}, outputs={}, prepros=[], postpros=[], config={}, logger=None): | ||
| SGDesignAnalysis.__init__(self, cs, inputs, outputs, config, prepros, postpros, logger) | ||
| # self.cs = cs | ||
| # self.job_args = job_args | ||
|
|
||
| # if logger is None: | ||
| # self.logger = mlog.initLogger(__name__) | ||
| # else: | ||
| # self.logger = logger | ||
|
|
||
| # self.inputs = inputs | ||
| # self.outputs = {} | ||
|
|
||
|
|
||
|
|
||
|
|
||
| def run(self): | ||
| self.logger.info(f'running design analysis for {self.cs.name}...') | ||
|
|
||
| analysis = self.config['analysis'] | ||
|
|
||
| if platform.system() == 'Windows': | ||
| ppcmd = self.config['prevabs_cmd_win'] | ||
| elif platform.system() == 'Linux': | ||
| ppcmd = self.config['prevabs_cmd_linux'] | ||
|
|
||
| solver = self.config['solver'] | ||
| integrated = False | ||
| if 'integrated' in self.config.keys(): | ||
| integrated = self.config['integrated'] | ||
| timeout = 30 | ||
| if 'timeout' in self.config.keys(): | ||
| timeout = self.config['timeout'] | ||
| scrnout = False | ||
| if 'scrnout' in self.config.keys(): | ||
| scrnout = self.config['scrnout'] | ||
|
|
||
|
|
||
| # Pre-process data | ||
| # ---------------- | ||
| self.preprocess() | ||
|
|
||
| # Substitute parameters | ||
| # --------------------- | ||
| if self.sg.fn_design_xml == '': | ||
| self.sg.fn_design_xml = self.sg.name + '.xml' | ||
| di.dprepro( | ||
| template=self.sg.fn_design_tmp, output=self.sg.fn_design_xml, | ||
| include=self.inputs | ||
| ) | ||
|
|
||
| # Solve | ||
| # ----- | ||
| self.sg.props = sga.solve( | ||
| self.sg.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.outputs[n] = self.sg.props.get(n) | ||
|
|
||
|
|
||
| # Post-process data | ||
| # ----------------- | ||
| self.postprocess() | ||
|
|
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,31 @@ | ||
| import msgpi.logger as mlog | ||
|
|
||
|
|
||
| class SGDesignAnalysis(): | ||
|
|
||
| def __init__(self, sg, inputs={}, outputs={}, config={}, prepros=[], postpros=[], logger=None): | ||
| self.sg = sg | ||
| self.config = config | ||
|
|
||
| self.inputs = inputs | ||
| self.outputs = outputs | ||
|
|
||
| self.prepros = prepros | ||
| self.postpros = postpros | ||
|
|
||
| if logger is None: | ||
| self.logger = mlog.initLogger(__name__) | ||
| else: | ||
| self.logger = logger | ||
|
|
||
|
|
||
| def preprocess(self): | ||
| self.logger.info('pre-processing...') | ||
| for p in self.prepros: | ||
| p(self.sg, self.inputs, self.outputs, self.config, self.logger) | ||
|
|
||
|
|
||
| def postprocess(self): | ||
| self.logger.info('post-processing...') | ||
| for p in self.postpros: | ||
| p(self.sg, self.inputs, self.outputs, self.config, self.logger) |