示例#1
0
 def _read(self):
     #self.xy = np.array(gwb.getTurbPos(self.wkbk, self.owexe, delFiles=True))
     xy, self.ttypes = gwb.getTurbPos(self.wkbk, self.owexe, delFiles=True)
     self.xy = np.array(xy)
     
     if self.debug:
         sys.stderr.write('WTWkbkFile: read array {:} from {:}\n'.format(self.xy.shape, self.wkbk))
         for i in range(self.xy.shape[0]):
             for j in range(self.xy.shape[1]):
                 sys.stderr.write('{:.1f} '.format(self.xy[i][j]))
             sys.stderr.write('\n')
示例#2
0
    def _read(self):
        #self.xy = np.array(gwb.getTurbPos(self.wkbk, self.owexe, delFiles=True))
        xy, self.ttypes = gwb.getTurbPos(self.wkbk, self.owexe, delFiles=True)
        self.xy = np.array(xy)

        if self.debug:
            sys.stderr.write('WTWkbkFile: read array {:} from {:}\n'.format(
                self.xy.shape, self.wkbk))
            for i in range(self.xy.shape[0]):
                for j in range(self.xy.shape[1]):
                    sys.stderr.write('{:.1f} '.format(self.xy[i][j]))
                sys.stderr.write('\n')
def example(owExe):

    debug = False 
    start_once = False
    modify_turbine = False
    
    for arg in sys.argv[1:]:
        if arg == '-debug':
            debug = True
        if arg == '-once':
            start_once = True
        if arg == '-modturb':
            modify_turbine = True
        if arg == '-help':
            sys.stderr.write('USAGE: python openWindAcComponent.py [-once] [-debug] [-modturb]\n')
            exit()

    if not os.path.isfile(owExe):
        sys.stderr.write('OpenWind executable file "{:}" not found\n'.format(owExe))
        exit()

    # set the external optimiser flag to True so that we can use our optimizing routines
    
    acutils.owIniSet(owExe, extVal=True, debug=True)
    
    testPath = '../templates/'
    #workbook_path = testPath + 'VA_test.blb'
    workbook_path = testPath + 'owTestWkbkExtend.blb'
    
    script_file = testPath + 'owacScript.xml' # optimize operation
    if modify_turbine:
        script_file = testPath + 'rtopScript.xml' # replace turbine, optimize
        #script_file = testPath + 'rtecScript.xml' # replace turbine, energy capture
        if debug:
            sys.stderr.write('Turbine will be modified\n')

    if not os.path.isfile(script_file):
        sys.stderr.write('OpenWind script file "{:}" not found\n'.format(script_file))
        exit()
  
    # ----- Run OpenWind once to get initial turbine positions
    
    if debug:
        sys.stderr.write('\n--------- Running OpenWind to get turbine positions --------------\n')
    wt_positions, ttypes = getworkbookvals.getTurbPos(workbook_path, owExe, delFiles=False)
    if debug:
        sys.stderr.write('Initial turbine positions from workbook {:}\n'.format(workbook_path))
        for i in range(len(wt_positions)):
            sys.stderr.write("  Turb{:2d} {:.1f} {:.1f} '{:}'\n".format(i,
              wt_positions[i][0],wt_positions[i][1], ttypes[i]))
        sys.stderr.write('--------- Finished Running OpenWind to get turbine positions --------------\n\n')

    # ----- Create OW_assembly object
    
    #turbine_name = 'Alstom Haliade 150m 6MW' # should match default turbine in workbook
    #machine_rating = 6000000.0 # machine_rating and power_rating are in W
    
    turbine_name = ttypes[0] # should match default turbine in workbook
    # How to get machine_rating for this turbine?
    #   - could search all *owtg files for matching name, then get rating
    fname, machine_rating = turbfuncs.findOWTG(testPath, turbine_name)
    
    # should check for existence of both owExe and workbook_path before
    #   trying to run openwind
    
    owAsy = openwindAC_assembly(owExe, workbook_path, 
                             script_file=script_file,
                             wt_positions=wt_positions,
                             turbine_name=turbine_name, 
                             machine_rating=machine_rating,
                             start_once=start_once,
                             debug=debug) 
    
    #owAsy.configure()
    
    owAsy.updateAssyRptPath('newReport.txt', 'newTestScript.xml')
    #owAsy.updateRptPath('newReport.txt', 'newTestScript.xml')
    
    # Originally, there was a turbine power/ct/rpm definition here, but that's not
    # part of an owAsy, so that code is now in C:/SystemsEngr/test/pcrvtst.py
    
    if True:
        owa = set_as_top(owAsy)
        if debug:
            sys.stderr.write('\n*** Running top-level assembly\n')
        owa.run()
    
    else:
        owAsy.execute() # run the openWind process

    # ----- Summary
    
    print 'openwindAC_assembly results:'
    print '  Gross {:.4f} mWh'.format(owAsy.gross_aep*0.001)
    print '  Net   {:.4f} mWh'.format(owAsy.net_aep*0.001)
    print '  Total losses {:.2f} %'.format(owAsy.total_losses*100.0)
    print '  CF    {:.2f} %'.format(owAsy.capacity_factor*100.0)
    print '  Using {:} turbines with power rating of {:.3f} MW'.format(
          len(owAsy.wt_layout.wt_positions), owAsy.machine_rating/1000000.0)