Search code examples
openmdao

Connecting the declared input variables (global) to ExecComp


Is there a way to connect the global input variables i.e.

def initialize(self):
    self.options.declare('num_elements', types=int)

to an execcomp?

prob.model.add_subsystem('paraboloid', ExecComp('f = num_elements*3 + c')) 

Solution

  • There isn't any way to connect to a declared option. The only things you can connect to are variables that were added inside components with add_input or add_output. I think in this case, since num_elements isn't meant to change, you should use a string expression to put the value into the ExecComp -- something like:

    prob.model.add_subsystem('paraboloid', ExecComp('f = %d*3 + c' % num_elements))
    

    where num_elements is a variable in your top level script.