Esempio n. 1
0
    def configure(self):

        if False:  ## testing
            cid = self.add('driver', CaseIteratorDriver())
            self.add('runner', PGrafSubComponent())
            cid.workflow.add('runner')
            cid.sequential = True  #False
            # uncomment to keep simulation directories for debugging purposes
            #import os
            #os.environ['OPENMDAO_KEEPDIRS'] = '1'

            cid.add_parameter('runner.inputs')

            cid.case_inputs.runner.inputs = [
                PGrafObject(num) for num in range(4)
            ]

        if True:  ## real thing
            print "configuring dispatcher:"
            super(CaseAnalyzer, self).configure()

            cid = self.add('driver', CaseIteratorDriver())
            #            self.add('runner', PGrafSubComponent())
            #            print self.aerocode
            #            self.add('runner', openAeroCode())
            self.add('runner', self.aerocode)
            cid.workflow.add('runner')
            #            cid.sequential = True #False

            self.setup_cases()

            # comment this line out to run sequentially
            cid.sequential = not self.run_parallel
            # uncomment to keep simulation directories for debugging purposes
            #        os.environ['OPENMDAO_KEEPDIRS'] = '1'

            # apparently a workaround for an openmdao bug:
            cid.ignore_egg_requirements = True

            if (self.openmdao_version < 0.1):
                cid.iterator = ListCaseIterator(self.runcases)
            else:
                cid.add_parameter('runner.inputs')
                #            cid.case_inputs.runner.inputs = [PGrafObject(num) for num in range(4)]
                #            cid.case_inputs.runner.inputs = [GenericRunCase("acase", ['x','y'], [num, num*2]) for num in range(4)]
                cid.case_inputs.runner.inputs = self.studycases

        print "dispatcher configured\n-------------------------------------------\n"
    def test_subassembly(self):
        logging.debug('')
        logging.debug('test_subassembly')

        top = set_as_top(Assembly())
        sub = top.add('sub', Assembly())
        sub.force_execute = True
        top.driver.workflow.add('sub')

        sub.add('driver', CaseIteratorDriver())
        sub.add('comp1', TracedComponent())
        sub.add('comp2', TracedComponent())
        sub.driver.workflow.add(('comp1', 'comp2'))

        cases = []
        for i in range(3):
            cases.append(
                Case(label=str(i),
                     inputs=(('comp1.inp', i), ('comp2.inp', i)),
                     outputs=(('comp1.itername', 'comp2.itername'))))
        # Sequential.
        sub.driver.iterator = ListCaseIterator(cases)
        top.run()
        self.verify_itername(sub.driver.evaluated, subassembly=True)

        # Concurrent.
        sub.driver.sequential = False
        sub.driver.iterator = ListCaseIterator(cases)
        top.run()
        self.verify_itername(sub.driver.evaluated, subassembly=True)
Esempio n. 3
0
    def configure(self):
        print "configuring dispatcher:"
        super(CaseAnalyzer, self).configure()

        if (self.run_dakota):
            from opendakota import DakotaParamStudy, DakotaSamplingStudy
            #            driver = DakotaParamStudy(

            driver = DakotaSamplingStudy()
            driver.samples = 5
            driver.tabular_graphics_data = True  ### special flag to turn on graphics, don't just write into strategy field!
        else:
            driver = CaseIteratorDriver()
        self.add('ws_driver', driver)
        self.driver.workflow.add(['ws_driver'])

        self.add('runner', self.aerocode)
        #        self.add('runner', MyCode() )   # for testing
        self.ws_driver.workflow.add('runner')
        #self.runner.force_execute = True

        self.setup_cases()

        # comment this line out to run sequentially
        self.ws_driver.sequential = not self.run_parallel
        # uncomment to keep simulation directories for debugging purposes
        #        os.environ['OPENMDAO_KEEPDIRS'] = '1'

        print "dispatcher configured\n-------------------------------------------\n"
Esempio n. 4
0
    def configure(self):
        cid = self.add('driver', CaseIteratorDriver())
        self.add('runner', PGrafSubComponent())
        cid.workflow.add('runner')
        cid.sequential = True  #False
        # uncomment to keep simulation directories for debugging purposes
        #import os
        #os.environ['OPENMDAO_KEEPDIRS'] = '1'

        cid.add_parameter('runner.obj')
        cid.add_parameter('runner.num')
        cid.add_response('runner.result')

        cid.case_inputs.runner.obj = [PGrafObject(num) for num in range(4)]
        cid.case_inputs.runner.num = [num for num in range(4)]
    def configure(self):
        self.add('c0', C0_vt())
        self.add('c1', C1_vt())

        self.add('parallel_driver', CaseIteratorDriver())
        self.driver.workflow.add(['c0', 'parallel_driver'])

        N = 10
        self.c0.N = N

        self.parallel_driver.iterator = \
            ListCaseIterator([Case(inputs=[('c1.i', l)]) for l in range(N)])
        self.parallel_driver.workflow.add(['c1'])
        self.parallel_driver.recorders.append(ListCaseRecorder())
        self.parallel_driver.printvars = ['c1.val']

        self.connect('c0.vt', 'c1.vt')
    def test_connections(self):
        logging.debug('')
        logging.debug('test_connections')

        top = Assembly()
        top.add('generator', Generator())
        top.add('cid', CaseIteratorDriver())
        top.add('driven', DrivenComponent())
        top.add('verifier', Verifier())

        top.driver.workflow.add(('generator', 'cid', 'verifier'))
        top.cid.workflow.add('driven')
        top.cid.printvars = ['driven.extra']

        top.connect('generator.cases', 'cid.iterator')
        top.connect('cid.evaluated', 'verifier.cases')

        top.run()
Esempio n. 7
0
    def configure(self):
        self.add('driver', CaseIteratorDriver())
        self.add('runner', PGrafSubComponent())
        self.driver.workflow.add('runner')
        self.driver.sequential = False
        # uncomment to keep simulation directories for debugging purposes
        #import os
        #os.environ['OPENMDAO_KEEPDIRS'] = '1'

        cases = []
        for num in range(4):
            cases.append(
                Case(inputs=[('runner.obj', PGrafObject(num)),
                             ('runner.num', num)],
                     outputs=['runner.result']))

        self.driver.iterator = ListCaseIterator(cases)
        self.driver.recorders = [ListCaseRecorder()]
Esempio n. 8
0
    def configure(self):
        """Configures an assembly for running with the CaseIteratorDriver"""

        self._logger.info("configuring dispatcher")

        self.add('case_driver', CaseIteratorDriver())
        self.driver.workflow.add(['case_driver'])

        self.add('runner', FUSEDIECBase())
        #        self.add('runner', openAeroCode())
        #       self.add('runner', FUSEDAssembly())
        self.case_driver.workflow.add('runner')

        # Boolean for running sequentially or in parallel
        self.create_passthrough('case_driver.sequential')
        self.recorders.append(ListCaseRecorder())

        # component for postprocessing results # 4/28/2015 kld: recorders not seen in graph - won't connect, should be an attribute of assembly
        #self.add('post', PostprocessIECCasesBase())
        #self.driver.workflow.add('post')
        #self.connect('cases', 'post.cases')

        self._logger.info("dispatcher configured")
Esempio n. 9
0
    def configure_old(self):
        print "configuring dispatcher:"
        super(CaseAnalyzer, self).configure()

        driver = CaseIteratorDriver()
        #        driver = ConnectableCaseIteratorDriver()
        self.add('ws_driver', driver)
        self.driver.workflow.add(['ws_driver'])

        self.add('runner', self.aerocode)
        #        self.add('runner', MyCode() )   # for testing
        self.ws_driver.workflow.add('runner')

        self.setup_cases()

        # comment this line out to run sequentially
        self.ws_driver.sequential = not self.run_parallel
        # uncomment to keep simulation directories for debugging purposes
        #        os.environ['OPENMDAO_KEEPDIRS'] = '1'
        # apparently a workaround for an openmdao bug:
        self.ws_driver.ignore_egg_requirements = True

        print "dispatcher configured\n-------------------------------------------\n"
def _get_driver():
    return CaseIteratorDriver()