Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Size of outputs in OpenMDAO

Is it possible to have lists or arrays passed as outputs of components in openMDAO?

Since my problem relies on 6×6 matrices to solve an equation of motion in 6 degrees of freedom, I would like to be able to do the following:

M = np.ones([6, 6])
outputs['M'] = M

However, that results in an error:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

ValueError: cannot reshape array of size 36 into shape (1,)

Is there any way to avoid passing each of 36 values seperately?

>Solution :

Yes, you can declare an output of any size or shape in your component’s setup method by doing the following:

self.add_output('M', shape=(6, 6))

or

self.add_output('M', val=np.ones((6, 6)))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading