Exemple #1
0
def runALL(seed,
           thetaStep,
           outputFolder="",
           compress=False,
           silence=False,
           echo=True):
    try:
        logpath = "~/Eolien/Parameters/Python/DLC1.3/log"
        with utils.cd("~/Eolien/Parameters/NREL_5MW_Onshore/Wind/DLC1.3/"):
            turb.get_turbulence(seed, logpath, silence,
                                echo)  # generate TurbSim
        DLC.get_DLC13(seed, outputFolder, silence, echo)  # run FAST
        with utils.cd("~/Eolien/Parameters/NREL_5MW_Onshore/Output/DLC1.3/"):
            filebase = "{}_{}mps_{}".format(seed[0], seed[1], seed[2])
            life.get_stress_fatigue(filebase,
                                    datarow=6009,
                                    gages=[1, 2, 3, 4, 5, 6, 7, 8, 9],
                                    thetaStep=thetaStep,
                                    lifetime=20 * 365 * 24 * 6,
                                    echo=echo)  # calculate Stress and Fatigue
    except:
        raise
    else:
        with utils.cd("~/Eolien/Parameters/NREL_5MW_Onshore/Output/DLC1.3/"):
            if compress:
                utils.compress(filename=filebase + ".out", removeSource=True)
        return seed
Exemple #2
0
 def _fast(self, silence=False):            
     with utils.cd('~/Eolien/FAST'):
         command = './{0} {1}{2}'.format(self._fastName, self.inputPath, self.fastFile)
         if silence:
             subprocess.check_output([command], shell=True)
         else:
             subprocess.call([command], shell=True)
Exemple #3
0
def main():
    # Load seeds
    with utils.cd('~/Eolien/Parameters/NREL_5MW_Onshore/DLC'):
        with open('6seeds.json', 'r') as f:
            seeds = json.loads(f.read())
    liste = []
    [liste.append(s) for s in seeds if s[0] == 'NTM']
    seeds = liste
    # generate a list of file basenames (i.e. filename without extension)
    filelist = []
    for seed in seeds:
        file = '{}_{}mps_{}'.format(seed[0], seed[1], seed[2])
        filelist.append(file)

    channels = [
        'YawBrTDxt', 'YawBrTDyt', 'YawBrFxp', 'YawBrFyp', 'YawBrMyp',
        'YawBrMzp', 'RootMxc1', 'RootMyc1', 'TipDxc1', 'TipDyc1'
    ]
    TIK = time.time()

    # # ----- Running on single processor
    # for file in filelist:
    #     amplitude.find_peak_valley(file, header=7, datarow=6009, startline=12,
    #                                channels=channels)

    # ----- Running on multi processor
    amplitude.find_peak_valley_multiprocess(filelist, 7, 6009, 12, channels)

    TOK = time.time()
    print('|- Total time :', TOK - TIK, 's')
Exemple #4
0
def main():
    # Load Seeds ===============================================================
    # with utils.cd('~/aster1/Wind'):
    #     with open('10000seeds.json', 'r') as f:
    #         seeds = json.loads(f.read())
    # liste = [s for s in seeds if s[0] == "NTM" and s[1] == "19"]
    # seeds = liste

    # Recalculate TurbSim + FAST + Stress
    #* aster1
    with utils.cd("~/aster1/Wind"):
        with open("recomputeALL.json", "r") as f:
            seeds = json.loads(f.read())
    #     #with open("failedRunsStress.json", "r") as f:
    #     #    seeds2 = json.loads(f.read())
    # with open("failedRunsFAST.json", "r") as f:
    #     seeds3 = json.loads(f.read())
    # #seeds1.extend(seeds2)

    #* lmn-cs
    # with utils.cd("~/lmn-cs/Wind"):
    #     with open("recomputeALL.json", "r") as f:
    #         seeds = json.loads(f.read())
    #     with open("failedRunsFAST.json", "r") as f:
    #         seeds5 = json.loads(f.read())

    #* lofims
    # with utils.cd("~/lofims/Wind/"):
    #     with open("recomputeALL.json", "r") as f:
    #         seeds = json.loads(f.read())

    # seeds = seeds1
    seeds = [
        ["NTM", "21", "-800757005"],
    ]

    # Run ======================================================================
    mac = server.Aster1(
        inputSeeds=seeds,
        windPath="~/Eolien/Parameters/NREL_5MW_Onshore/Wind/DLC1.1",
        outputPath="~/Eolien/Parameters/NREL_5MW_Onshore/Output/DLC1.1",
        echo=False)
    mac.seeds = seeds  # set list of seeds manually

    runMode = 2
    if runMode == 1:
        # All-In-One: TurbSim + FAST + Stress + Fatigue ------------------------
        mac.run(runALL_multiprocess, 10, "", False)  # thetaStep, outputFolder,
        # compress, silence, echo

    if runMode == 2:
        # TurbSim --------------------------------------------------------------
        mac.run(runTurbSim_multiprocess, False, True)  # silence, echo
        # time.sleep(5)

        # FAST -----------------------------------------------------------------
        mac.run(runFAST_multiprocess, False, True)  # silence, echo
        time.sleep(5)
Exemple #5
0
def main():
    # Check CPU usage ==========================================================
    if psutil.cpu_percent() >= 60: return

    # Load Seeds ===============================================================
    with utils.cd('~/aster1/Wind'):
        with open('10000seeds.json', 'r') as f:
            seeds = json.loads(f.read())
    liste = [s for s in seeds if s[0] == "ETM" and s[1] == "17"]
    seeds = liste

    # Recalculate TurbSim + FAST + Stress
    # with utils.cd("~/lmn-cs/Wind"):
    #     #with open("failedRunsFAST.json", "r") as f:
    #     #    seeds1 = json.loads(f.read())
    #     #with open("failedRunsStress.json", "r") as f:
    #     #    seeds2 = json.loads(f.read())
    #     with open("recomputeALL.json", "r") as f:
    #         seeds3 = json.loads(f.read())
    # #seeds1.extend(seeds2)
    # seeds = seeds3
 
    # Run ======================================================================
    lofims = server.Aster1(inputSeeds=seeds,
                    windPath="~/Eolien/Parameters/NREL_5MW_Onshore/Wind/DLC1.3",
                outputPath="~/Eolien/Parameters/NREL_5MW_Onshore/Output/DLC1.3",
                           echo=False)
    lofims.seeds = seeds # set list of seeds manually

    runMode = 1
    if runMode == 1:
        # All-In-One: TurbSim + FAST + Stress + Fatigue ------------------------
        lofims.run(runALL_multiprocess, 10, "", False) # thetaStep, outputFolder,
                                                      # compress, silence, echo

    if runMode == 2:
        # TurbSim --------------------------------------------------------------
        lofims.run(runTurbSim_multiprocess, True, False) # silence, echo
        time.sleep(5)

        # FAST -----------------------------------------------------------------
        lofims.run(runFAST_multiprocess, True, False) # silence, echo
        time.sleep(5)
        
        # Stress + Fatigue -----------------------------------------------------
        lofims.run(runStressFatigue_multiprocess, 10, False) # thetaStep, echo
        # lofims.resume('Fatigue', inputFileSize=85*1024**2,
        #               outputFileSize=20*1024, compress=True)
        time.sleep(5)

        # TurbSim + FAST + Stress + Fatigue ------------------------------------
        # [ATTENTION] This will only overwrite recomputeALL.json
        # lofims.resume("ALL", outputFileSize=20*1024)

    lofims.finalcheck(btsFileSize=70*1024**2, outFileSize=85*1024**2,
                      tgzFileSize=20*1024**2, damFileSize=20*1024)
Exemple #6
0
def main():
    # Load seeds
    with utils.cd('~/Eolien/Parameters/NREL_5MW_Onshore/Wind'):
        with open('6seeds.json', 'r') as f:
            seeds = json.loads(f.read())
    liste = [s for s in seeds if s[0] == "NTM"]
    seeds = liste

    # get_turbulence(seeds[0])
    get_turbulence_multiprocess(seeds[:2])
Exemple #7
0
def find(path, pattern, size=None):
    ''' size: minimum size in bytes (1 GB = 1024 MB = 1024^2 KB = 1024^3 Bytes) [num]
    '''
    with utils.cd(path):
        p = Path().expanduser()
        matched = sorted(p.glob(pattern))
        if size is None:
            result = [x.stem for x in matched]
        else:
            result = [x.stem for x in matched if x.stat().st_size >= size]
    return result
Exemple #8
0
def main():
    # mydata = Stress(filebase='DLC1.2_NTM_25mps', datarow=6009, gages=[1,9], thetaStep=30,
    #                 echo=False)
    # get_stress('DLC1.2_NTM_25mps', 6009, [1,2,3,4,5,6,7,8,9], 'a', saveToDisk=True, echo=False)
    # get_stress_multiprocess(['DLC1.2_NTM_25mps',], 6009, [1,9], thetaStep=30,
    #                         saveToDisk=False, echo=True)

    # Test error control
    seeds = ['NTM_3mps_-544599383', 'NTM_5mps_1571779345']
    with utils.cd('~/Eolien/Parameters/NREL_5MW_Onshore/Output/DLC1.1/'):
        get_stress(seeds[1], 6009, [1,2,3,4,5,6,7,8,9], 'a', saveToDisk=False, echo=True)
Exemple #9
0
def runStressFatigue_multiprocess(seeds, thetaStep, echo=True):
    ''' Run Stress and Fatigue in same time
    '''
    list_filebase = ["{}_{}mps_{}".format(s[0], s[1], s[2]) for s in seeds]
    with utils.cd("~/Eolien/Parameters/NREL_5MW_Onshore/Output/DLC1.3/"):
        life.get_stress_fatigue_multiprocess(list_filebase,
                                             datarow=6009,
                                             gages=[1, 2, 3, 4, 5, 6, 7, 8, 9],
                                             thetaStep=thetaStep,
                                             lifetime=20 * 365 * 24 * 6,
                                             echo=echo)
Exemple #10
0
def main():
    # Load seeds
    with utils.cd('~/Eolien/Parameters/NREL_5MW_Onshore/Wind'):
        with open('6seeds.json', 'r') as f:
            seeds = json.loads(f.read())

    liste = []
    [liste.append(s) for s in seeds if s[0] == "NTM"]
    seeds = liste[:1]

    # ----- Running on multi processor
    runFAST_multiprocess(seeds)
Exemple #11
0
 def _iecwind(self, silence):
     """ Call IECWind program
     """
     command = "{} IEC.IPT".format(self._iecwindName)
     try:
         with utils.cd(str(self._windPath)):
             if silence:
                 output = subprocess.check_output([command], shell=True)
             else:
                 output = subprocess.call([command], shell=True)
     except Exception as e:
         raise e  #TODO IECWind don't handle errors !
     else:
         wrong = False
Exemple #12
0
def main():
    # Load Seeds ===============================================================
    # Initiation
    with utils.cd("~/aster1/Wind"):
        with open("10000seeds.json", 'r') as f:
            seeds = json.loads(f.read())
    liste = [s for s in seeds if s[0] == "ETM" and s[1] == "5"]
    seeds = liste

    # Re-run
    # with utils.cd('~/aster1/Wind'):
    #     with open('failedRunsFAST.json', 'r') as f:
    #         seeds1 = json.loads(f.read())
    #     with open('failedRunsStress.json', 'r') as f:
    #         seeds2 = json.loads(f.read())
    #     with open('recomputeALL.json', 'r') as f:
    #         seeds3 = json.loads(f.read())
    #     with open('recomputeTurbSim.json', 'r') as f:
    #         seeds4 = json.loads(f.read())
    # ----- Rerun failed cases
    # seeds1.extend(seeds2)
    # seeds = seeds1
    # ----- Rerun recomputed cases
    # seeds = seeds3
    # seeds = seeds4
    # seeds = [['NTM', '3', '-544599383'], ['NTM', '5', '1571779345']]

    # Some Tests ===============================================================
    # runTurbSim_multiprocess(seeds, silence=1, echo=1)
    # runFAST_multiprocess(seeds, silence=1, echo=1)
    # # runStress_multiprocess(seeds, echo=0)
    # # runFatigue_multiprocess(seeds, echo=0)
    # runStressFatigue_multiprocess(seeds, 10, echo=0)
    # return

    # Initiate/Resume Tasks ====================================================
    # Distribute tasks ---------------------------------------------------------
    computers = distribute.LMN("~/aster1/Wind/DLC1.3")
    computers.deactivate("PC-LMN-9020")  # Shubiao WANG
    # computers.setEqually(seeds)
    computers.setAutomatically(seeds)
    # computers.show()

    # TurbSim ------------------------------------------------------------------
    computers.resume("TurbSim")
    computers.run(runTurbSim_multiprocess,
                  "~/Eolien/Parameters/Python/DLC1.3/log", True,
                  False)  # logpath="...", silence=True, echo=False
Exemple #13
0
def main():
    # Check CPU usage ==========================================================
    if psutil.cpu_percent() >= 60: return

    # Load Seeds ===============================================================
    with utils.cd('~/Eolien/Parameters/NREL_5MW_Onshore/Wind'):
        with open('10000seeds.json', 'r') as f:
            seeds = json.loads(f.read())
    liste = [s for s in seeds if s[0] == "ETM" and s[1] == "5"]
    seeds = liste

    # Run ======================================================================
    aster1 = server.Aster1(
        inputSeeds=seeds,
        windPath='~/Eolien/Parameters/NREL_5MW_Onshore/Wind/DLC1.3',
        outputPath='~/Eolien/Parameters/NREL_5MW_Onshore/Output/DLC1.3',
        echo=False)

    # TurbSim + FAST + Stress + Fatigue ----------------------------------------
    # [ATTENTION] This will only overwrite recomputeALL.json
    # aster1.resume('ALL', outputFileSize=20*1024)

    # TurbSim ------------------------------------------------------------------
    # [ATTENTION] This will only overwrite recomputeTurbSim.json
    # aster1.resume('TurbSim', outputFileSize=70*1024**2)

    # FAST ---------------------------------------------------------------------
    aster1.resume('FAST', inputFileSize=70 * 1024**2)
    aster1.run(runFAST_multiprocess, True, False)  #silence, echo
    time.sleep(5)

    # Stress -------------------------------------------------------------------
    # aster1.resume('Stress',inputFileSize=90*1024**2,outputFileSize=204*1024**2)
    # aster1.run(runStress_multiprocess, 10, False) # thetaStep=90, echo
    # time.sleep(5)

    # Stress + Fatigue ---------------------------------------------------------
    aster1.resume('Fatigue',
                  inputFileSize=85 * 1024**2,
                  outputFileSize=20 * 1024,
                  compress=True)
    aster1.run(runStressFatigue_multiprocess, 10, False)  # thetaStep, echo
    aster1.resume('Fatigue',
                  inputFileSize=85 * 1024**2,
                  outputFileSize=20 * 1024,
                  compress=True)
    time.sleep(5)
Exemple #14
0
def main():
    # Load seeds
    with utils.cd('~/Eolien/Parameters/NREL_5MW_Onshore/Wind'):
        with open('100seeds.json', 'r') as f:
            seeds = json.loads(f.read())

    liste = []
    [liste.append(s) for s in seeds if s[0] == "NTM"]
    seeds = liste

    test = sensibility.Analysis(seeds=seeds, folder='theta=30', echo=True)

    test.damageOnSpot()
    exit()
    # test.plotDamageOnSpot('3','TwHt1@0')
    test.plotDamageForAllSpeeds()

    # test.meanDamageOnGage('3')
    test.meanDamageForAllSpeeds()
    # test.plotMeanDamageOnGage('3','1')
    test.plotMeanDamageForAllSpeeds()
Exemple #15
0
def main():
    # Load seeds
    with utils.cd('~/Eolien/Parameters/NREL_5MW_Onshore/DLC'):
        with open('6seeds.json', 'r') as f:
            seeds = json.loads(f.read())

    liste = []
    [liste.append(s) for s in seeds if s[0] == "ETM"]
    seeds = liste

    # ----- Running on multi processor
    TIK = time.time()    

    pool = multiprocessing.Pool() # define number of worker (= numbers of processor by default)
    # [pool.apply_async(run_multiprocess, args=(wind, t)) for t in timerange] # map/apply_async: submit all processes at once and retrieve the results as soon as they are finished
    pool.map(run_multiprocess, seeds)
    pool.close() # close: call .close only when never going to submit more work to the Pool instance
    pool.join() # join: wait for the worker processes to terminate

    TOK = time.time()
    print("|- Total time :", TOK-TIK, "s")
Exemple #16
0
def main():
    testCase = 3
    if testCase == 1:  # simple case
        with utils.cd(
                "~/Eolien/Parameters/NREL_5MW_Onshore/Output/DLC2.3/withoutTRD/EOGO"
        ):
            # bande of grid loss
            filelist = [str(t) for t in utils.frange(74.0, 76.1, 0.1)]

            channels = [
                'YawBrTDxt', 'YawBrTDyt', 'YawBrFxp', 'YawBrFyp', 'TwHt4FLxt',
                'TwHt4FLyt', 'TwrBsFxt', 'TwrBsFyt', 'TwrBsMxt', 'TwrBsMyt'
            ]

            # # ----- Running on single processor
            # for file in filelist:
            #     amplitude.find_peak_valley(file, header=7, datarow=6009,
            #                                startline=12, channels=channels)

            # ----- Running on multi processor
            amp.find_peak_valley_multiprocess(filelist, 7, 6009, 12, channels)

    wind = 'EOG'
    speedRange = utils.frange(3.0, 25.1, 0.1)  # wind speed [m/s]
    timeRange = utils.frange(70.0, 80.1, 0.1)  # grid loss time [s]
    channels = [
        'YawBrTDxt',
    ]
    if testCase == 2:  # complex case
        with utils.cd("~/Eolien/Parameters/NREL_5MW_Onshore/Output/DLC2.3"):
            # find peak and valley
            filelist = [
                "{}_{}_{}".format(wind, v, t) for v in speedRange
                for t in timeRange
            ]
            amp.find_peak_valley_multiprocess(list_filebase=filelist,
                                              header=7,
                                              datarow=6009,
                                              startline=12,
                                              channels=channels)
            # find maximum amplitude
            all_files = []
            for v in speedRange:
                temp = ["{}_{}_{}".format(wind, v, t) for t in timeRange]
                all_files.append(temp)

            all_results = []
            for f in all_files:
                resu = amp.Amplitude.max_p2p_amplitude(f, channels, '.ext',
                                                       True)
                all_results.extend(resu)
            # save to file/print to screen
            output = amp.Amplitude.print(all_results, channels,
                                         'max_amplitude.amp')
            # compress files
            output_files = [
                elem["File"] + ".out" for elem in output[channels[0]]
            ]
            pool = multiprocessing.Pool()
            [
                pool.apply_async(utils.compress,
                                 args=(filename, True),
                                 error_callback=utils.handle_error)
                for filename in output_files
            ]
            pool.close()
            pool.join()

    # get maxi amplitude for all time range and all speed
    if testCase == 3:
        with utils.cd("."):
            all_files = [
                "{}_{}_{}".format(wind, v, t) for v in speedRange
                for t in timeRange
            ]
            all_results = []
            for f in all_files:
                resu = amp.Amplitude.max_p2p_amplitude(f, channels, '.ext',
                                                       True)
                all_results.extend(resu)
            output = amp.Amplitude.print(all_results, channels,
                                         'max_amplitude_ALL.amp')

    # For testing ...
    if testCase == 4:
        with utils.cd("~/Eolien/Parameters/Python/DLC2.3/Output/DLC2.3"):
            # find peak and valley
            filelist = ["{}_O_{}".format(wind, t) for t in timeRange]
            amp.find_peak_valley_multiprocess(list_filebase=filelist,
                                              header=7,
                                              datarow=6009,
                                              startline=12,
                                              channels=channels)
            # find maximum amplitude
            all_files = []
            all_files.append(filelist)

            all_results = []
            for f in all_files:
                resu = amp.Amplitude.max_p2p_amplitude(f, channels, '.ext',
                                                       False)
                all_results.extend(resu)
            # save to file/print to screen
            output = amp.Amplitude.print(all_results, channels,
                                         'max_amplitudeO.amp')

    # To verifiy if .out file contains NaN
    if testCase == 5:
        with utils.cd("."):
            list_filebase = utils.find(".", "*.out")
            option = 1
            # Option 1: through multiprocessing
            if option == 1:
                amp.find_peak_valley_multiprocess(list_filebase=list_filebase,
                                                  header=7,
                                                  datarow=6009,
                                                  startline=12,
                                                  channels=channels,
                                                  peak=False,
                                                  valley=False,
                                                  saveToFile=False)
            # Option 2: one by one
            if option == 2:
                for f in list_filebase:
                    try:
                        utils.readcsv("./" + f + ".out")
                    except:
                        print("[ERROR] {} has an error during reading, please "
                              "check this file".format(f))
                        raise
Exemple #17
0
def testHao():
    with utils.cd("/home/wilsonveloz/Documents/Hao_Data/Wind"):
        # data = utils.readcsv("NTM_11mps_-1029744777.sum", delimiter="\s", header=112, datarow=130, endrow=145, ncols=2)
        # print(data)
        pass
Exemple #18
0
def runTurbSim_multiprocess(seeds, logpath="", silence=False, echo=True):
    with utils.cd("~/Eolien/Parameters/NREL_5MW_Onshore/Wind/DLC1.3/"):
        turb.get_turbulence_multiprocess(seeds,
                                         logpath=logpath,
                                         silence=silence,
                                         echo=echo)
Exemple #19
0
def send_mail(receiver, debug=False):
    with utils.cd('~/Eolien/Parameters/Python/site-packages/tools'):
        send(receiver=receiver, debug=debug)