WISDEM / FLORISSE

DEPRECATED. The latest floris is at https://github.com/nrel/floris
8 stars 16 forks source link

Optimization examples fail on develop branch #21

Open petebachant opened 7 years ago

petebachant commented 7 years ago

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 commented 7 years ago

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.