Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Kenneth-T-Moore/08674a0c0f41dd380978ba72f2f72efb to your computer and use it in GitHub Desktop.
Save Kenneth-T-Moore/08674a0c0f41dd380978ba72f2f72efb to your computer and use it in GitHub Desktop.
This should raise an exception.
import numpy as np
import openmdao.api as om
class ControlInterpComp(om.ExplicitComponent):
def setup(self):
self.add_output('x', shape=(3, 1))
def compute(self, inputs, outputs):
pass
def compute_partials(self, inputs, partials):
pass
class CollocationComp(om.ExplicitComponent):
def setup(self):
self.add_input('x', shape=(1, 2))
def compute(self, inputs, outputs):
pass
def compute_partials(self, inputs, partials):
pass
class Phase(om.Group):
def setup(self):
self.add_subsystem('comp1', ControlInterpComp())
self.add_subsystem('comp2', CollocationComp())
self.connect('comp1.x', 'comp2.x', src_indices=[1])
p = om.Problem()
p.model.add_subsystem('phase', Phase())
# An error should be raised trying to connect a (1, 2) to a (3, 1) with src_indices [1]
# the shape of the source indices does not match the shape of the target input.
p.setup()
p.run_model()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment