Skip to content
This repository has been archived by the owner on May 9, 2019. It is now read-only.

Optimization examples fail on develop branch #21

Open
petebachant opened this issue Sep 15, 2017 · 1 comment
Open

Optimization examples fail on develop branch #21

petebachant opened this issue Sep 15, 2017 · 1 comment

Comments

@petebachant
Copy link

I'm getting this error when running exampleOptimizationAEP.py:

python exampleOptimizationAEP.py 10
/home/pete/anaconda3/envs/py27/lib/python2.7/site-packages/florisse/OptimizationGroups.py:110: DeprecationWarning: fd_options is deprecated. Use deriv_options instead.
  self.fd_options['force_fd'] = force_fd
/home/pete/anaconda3/envs/py27/lib/python2.7/site-packages/openmdao/util/options.py:292: UserWarning: Also, the 'force_fd' option has been removed. To force finite difference now, set the 'type' option to 'fd'.
  warnings.warn(msg)
/home/pete/anaconda3/envs/py27/lib/python2.7/site-packages/florisse/OptimizationGroups.py:111: DeprecationWarning: fd_options is deprecated. Use deriv_options instead.
  self.fd_options['form'] = 'forward'
Traceback (most recent call last):
  File "exampleOptimizationAEP.py", line 90, in <module>
    minSpacing=minSpacing, differentiable=True, use_rotor_components=False))
  File "/home/pete/anaconda3/envs/py27/lib/python2.7/site-packages/florisse/OptimizationGroups.py", line 121, in __init__
    self.add('spacing_comp', SpacingComp(nTurbines=nTurbines), promotes=['*'])
  File "/home/pete/anaconda3/envs/py27/lib/python2.7/site-packages/florisse/GeneralWindFarmComponents.py", line 345, in __init__
    self.add_output('wtSeparationSquared', val=np.zeros((nTurbines-1.)*nTurbines/2.),
TypeError: 'float' object cannot be interpreted as an index
@Bartdoekemeijer
Copy link

Bartdoekemeijer commented Sep 16, 2017

I haven't encountered the problem myself, but the command np.zeros takes integers as input. The current definition

val=np.zeros((nTurbines-1.)*nTurbines/2.)

sends the float (nTurbines-1.)*nTurbines/2. to np.zeros. Which should be a round number for any integer number nTurbines, but is forced as a float due the latter part of the equation (nTurbines/2.). You can do something like

import math
val=np.zeros(int(math.round((nTurbines-1.)*nTurbines/2.)))

to round it off back to an integer. This is, ofcourse, assuming that this is only a float-integer problem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants