Reputation: 176
I have a work flow that starts with an array. I got this work-flow working, however there was one funny thing that cause it to break and I do not understand why.
For testing I have an IndepVarComp that provides the vector. It only seems to work when it is initialized with a vector from np.zeros(...).
root.add('input', \
IndepVarComp('top'+':'+'twcxVector', \
np.zeros(TWCXDictArraySize(twcxDict))) \ # <- arange breaks here
,promotes=['*'])
I tried to use something like np.arange(...) to verify that things are populated properly. But then nothing happens at that point.
Just so I understand things more, could someone please explain why something like this causes OpenMDAO to break.
For reference this is the rest of the work-flow:
root.add('obj',Array2TWCXDictOpenMDAO(twcxDict,'top'+':') \
,promotes=['*'])
top.setup()
top.root.list_connections()
top.run()
data = top.check_total_derivatives(out_stream=sys.stdout)
top.run()
data = top.check_partial_derivatives(out_stream=sys.stdout)
Upvotes: 0
Views: 59
Reputation: 176
It seems that OpenMDAO expects numpy arrays of floats. So IndepVarComp needs to be initialized with those types. Some of the methods for creating numpy arrays will create arrays of integers. This is the case when np.arange is passed with just a number. When these arrays are passed to IndepVarComp, then openMDAO assumes that derivatives cannot be taken. Thus check derivatives will not run over these variables. This problem can be fixed by creating arrays with the argument 'dtype=np.float_'
root.add('input', \
IndepVarComp('top'+':'+'twcxVector', \
np.arange(TWCXDictArraySize(twcxDict),dtype=np.float_)) \
,promotes=['*'])
Upvotes: 1