Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Kenneth-T-Moore/1b420c28c7561f35079b8955fcbe60f4 to your computer and use it in GitHub Desktop.
Save Kenneth-T-Moore/1b420c28c7561f35079b8955fcbe60f4 to your computer and use it in GitHub Desktop.
Problem with src_indices dissapearing from _var_abs2meta.
import numpy as np
import openmdao.api as om
class RHS(om.Group):
def initialize(self):
self.options.declare('size', 1)
def setup(self):
size = self.options['size']
self.add_subsystem('comp1', om.ExecComp(['y1=x*2'], y1=np.ones(size), x=np.ones(size)),
promotes_inputs=['*'], promotes_outputs=['*'])
# Works if you comment out this comp.
self.add_subsystem('comp2', om.ExecComp(['y2=x*2'], y2=np.ones(size), x=np.ones(size)),
promotes_inputs=['*'], promotes_outputs=['*'])
class Phase(om.Group):
def setup(self):
self.add_subsystem('rhs', RHS(size=4))
def configure(self):
self.promotes('rhs', inputs=[('x', 'design:x')],
src_indices=[0, 0, 0, 0], flat_src_indices=True)
self.set_input_defaults('design:x', 75.3)
class Traj(om.Group):
def setup(self):
self.add_subsystem('src', om.ExecComp(['q = b*3']))
self.add_subsystem('phase', Phase())
self.connect('src.q', 'phase.design:x')
prob = om.Problem(model=Traj())
prob.setup()
prob.run_model()
# builtins.ValueError: Traj (<model>): The source and target shapes do not match or are ambiguous for the connection 'src.q' to 'phase.rhs.comp2.x'. The source shape is (1,) but the target shape is (4,).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment