Ejemplo n.º 1
0
def AddGridPoints():
    global gridpoints

    os.system('cp POPI_in0.dat POPI_in.dat')
    os.system(f'echo {gridpoints} | ./changegrid')
    os.system('cp POPI_in_newgrid.dat POPI_in0.dat')
    os.system('cp POPI_in1.dat POPI_in.dat')
    os.system(f'echo {gridpoints} | ./changegrid')
    os.system('cp POPI_in_newgrid.dat POPI_in1.dat')
    os.system('rm POPI_in_newgrid.dat')
    gridpoints += 2
    setup[3] = f' N_X = {gridpoints},'
    frameInfo[2] = f' boundR = {gridpoints},'
    data.WriteSetup(setup, 'setup.in')
    data.WriteFrameInfo(frameInfo, 'frameinfo.in')
Ejemplo n.º 2
0
def AddGridPoints(gridpoints, setup, frameInfo):
    print(gridpoints)
    os.system('cp out.dat POPI_in.dat')
    os.system(f'echo {gridpoints} | ./changegrid')
    os.system('cp POPI_in_newgrid.dat out.dat')
    os.system('cp out_old.dat POPI_in.dat')
    os.system(f'echo {gridpoints} | ./changegrid')
    os.system('cp POPI_in_newgrid.dat out_old.dat')
    os.system('rm POPI_in_newgrid.dat')
    gridpoints += 2
    setup[3] = f' N_X = {gridpoints},'
    frameInfo[2] = f' boundR = {gridpoints},'
    data.WriteSetup(setup, 'setup.in')
    data.WriteFrameInfo(frameInfo, 'frameinfo.in')
    return gridpoints
Ejemplo n.º 3
0
def main():
    setup = []
    frameInfo = []
    guess = []
    nextGuess = []
    guessOut = []
    guessOutOld = []
    trackInfo = []
    gridpoints = 0
    i_L = 0
    complete = False
    data.ReadSetup(setup, 'Tracking/Input/setup0.in')
    data.ReadFrameInfo(frameInfo, 'Tracking/Input/frameinfo0.in')
    data.ReadTrackIn(trackInfo, 'Tracking/Input/trackL.in')
    stepS = trackInfo[1]
    dirName = trackInfo[3]
    gridpoints0 = int(numerateString(setup[3]))
    for i_s in range(400):
        dirNameS = dirName + f'/{i_s}'
        gridpoints = gridpoints0
        setup[3] = f' N_X = {gridpoints},'
        frameInfo[2] = f' boundR = {gridpoints},'
        guess.clear()
        if i_s == 0:
            data.ReadGuess(guess, 'Tracking/Input/guess0.in')
            os.system('cp Tracking/Input/POPI_in0.dat POPI/Input/POPI_in.dat')
        elif i_s == 1:
            data.ReadGuess(guess, 'Tracking/Input/guess1.in')
            os.system('cp Tracking/Input/POPI_in1.dat POPI/Input/POPI_in.dat')
        else:
            os.system(
                'cp Tracking/Output/out_oldL.dat Tracking/Output/out_old.dat')
            os.system('cp Tracking/Output/outL.dat Tracking/Output/out.dat')
            guessOut = list(guessOutL)
            guessOutOld = list(guessOutOldL)
            Interpolate(stepS, 0, guessOut, guessOutOld, nextGuess)
            guess = list(nextGuess)
            print(guessOut)
            print(guessOutOld)
            print(nextGuess)

        dL = -0.05

        for i_L in range(1):
            L = 5.0 + 0.05 * i_L
            dL = dL + 0.05
            #            if round(dL*100) >= 50:
            #                print(dL)
            #                print(gridpoints)
            #                gridpoints = AddGridPoints(gridpoints, setup, frameInfo)
            #                dL = 0.0
            if (i_L >= 2):
                Interpolate(1.0, 1, guessOut, guessOutOld, nextGuess)
                guessOutOld = list(guessOut)
                os.system(
                    'cp Tracking/Output/out.dat Tracking/Output/out_old.dat')
            elif (i_L == 0):
                nextGuess = list(guess)
            elif (i_L == 1):
                nextGuess = list(guessOut)
                guessOutOld = list(guessOut)
                os.system('cp Tracking/Output/out.dat POPI/Input/POPI_in.dat')
                os.system(
                    'cp Tracking/Output/out.dat Tracking/Output/out_old.dat')

            dirNameL = str(dirNameS + '/' + outName(L))
            setup[1] = f" NAME ='{dirNameL}',"
            setup[7] = f' L = {L},'

            if not os.path.exists(f'Tracking/Data/{dirNameL}'):
                if not os.path.exists(f'Tracking/Data/{dirNameS}'):
                    if not os.path.exists(f'Tracking/Data/{dirName}'):
                        os.mkdir(f'Tracking/Data/{dirName}')
                    os.mkdir(f'Tracking/Data/{dirNameS}')
                os.mkdir(f'Tracking/Data/{dirNameL}')

            print(nextGuess)
            CleanUpGuess(nextGuess)
            data.WriteGuess(nextGuess, 'POPI/Input/guess.in')
            data.WriteSetup(setup, 'Input/setup.in')
            data.WriteFrameInfo(frameInfo, 'POPI/Input/frameinfo.in')
            Run()

            guessOut.clear()
            data.ReadGuess(guessOut, 'POPI/Output/guess.out')
            if (IsConverged(guessOut)):
                print(guessOut)
                os.system('python Tracking/plotTrack.py')
                copyfile('POPI/Output/out.dat', f'Tracking/Output/out.dat')
                if os.path.exists(f'Tracking/Data/{dirNameL}/Input/'):
                    rmtree(f'Tracking/Data/{dirNameL}/Input/')
                if os.path.exists(f'Tracking/Data/{dirNameL}/Output/'):
                    rmtree(f'Tracking/Data/{dirNameL}/Output/')
                copytree('POPI/Output/', f'Tracking/Data/{dirNameL}/Output/')
                copytree('POPI/Input/', f'Tracking/Data/{dirNameL}/Input/')
                if i_L == 0:
                    if i_s != 0:
                        os.system(
                            'cp Tracking/Output/outL.dat Tracking/Output/out_oldL.dat'
                        )
                        guessOutOldL = list(guessOutL)
                    os.system(
                        'cp Tracking/Output/out.dat Tracking/Output/outL.dat')
                    guessOutL = list(guessOut)
                continue
            else:
                if (i_L == 0):
                    complete = True
                    break

        if complete == True:
            break

    trackInfo[3] = 'test'

    data.WriteTrackIn(trackInfo, 'Tracking/Input/trackL.in'
                      )  #Rewrite trackL.in to avoid inadvertent overwrites!
    if os.path.exists(f'Tracking/Data/{dirName}/Input/'):
        rmtree(f'Tracking/Data/{dirName}/Input')
    copytree('Tracking/Input/', f'Tracking/Data/{dirName}/Input')
Ejemplo n.º 4
0
def main():
    setup = []
    frameInfo = []
    guess = []
    nextGuess = []
    guessOut = []
    guessOutOld = []
    trackInfo = []
    gridpoints = 0
    i_L = 0

    data.ReadSetup(setup, 'setup0.in')
    data.ReadFrameInfo(frameInfo, 'frameinfo0.in')
    data.ReadTrackIn(trackInfo, 'trackL.in')
    stepS = trackInfo[1]
    dirName = './Tracking/' + trackInfo[3]
    gridpoints0 = int(numerateString(setup[3]))
    for i_s in range(3):
        dirNameS = dirName + f'/{i_s}'
        gridpoints = gridpoints0
        setup[3] = f' N_X = {gridpoints},'
        frameInfo[2] = f' boundR = {gridpoints},'
        guess.clear()
        if i_s == 0:
            data.ReadGuess(guess, 'guess0.in')
            os.system('cp POPI_in0.dat POPI_in.dat')
        elif i_s == 1:
            data.ReadGuess(guess, 'guess1.in')
            os.system('cp POPI_in1.dat POPI_in.dat')
        else:
            os.system('cp out_oldL.dat out_old.dat')
            os.system('cp outL.dat out.dat')
            guessOut = list(guessOutL)
            guessOutOld = list(guessOutOldL)
            Interpolate(stepS, 0, guessOut, guessOutOld, nextGuess)
            guess = list(nextGuess)
            print(guessOut)
            print(guessOutOld)
            print(nextGuess)

        dL = -0.01

        for i_L in range(200):
            L = 5.0 + 0.01 * i_L
            dL = dL + 0.01
            if round(dL * 100) >= 50:
                print(dL)
                print(gridpoints)
                gridpoints = AddGridPoints(gridpoints, setup, frameInfo)
                dL = 0.0
            if (i_L >= 2):
                Interpolate(1.0, 1, guessOut, guessOutOld, nextGuess)
                guessOutOld = list(guessOut)
                os.system('cp out.dat out_old.dat')
            elif (i_L == 0):
                nextGuess = list(guess)
            elif (i_L == 1):
                nextGuess = list(guessOut)
                guessOutOld = list(guessOut)
                os.system('cp out.dat POPI_in.dat')
                os.system('cp out.dat out_old.dat')

            dirNameL = str(dirNameS + '/' + outName(L))
            setup[1] = f" NAME ='{dirNameL}',"
            setup[7] = f' L = {L},'

            if not os.path.exists(dirNameL):
                if not os.path.exists(dirNameS):
                    if not os.path.exists(dirName):
                        os.mkdir(dirName)
                    os.mkdir(dirNameS)
                os.mkdir(dirNameL)

            print(nextGuess)
            CleanUpGuess(nextGuess)
            data.WriteGuess(nextGuess, 'guess.in')
            data.WriteSetup(setup, 'setup.in')
            data.WriteFrameInfo(frameInfo, 'frameinfo.in')
            Run()

            guessOut.clear()
            data.ReadGuess(guessOut, 'guess.out')
            if (IsConverged(guessOut)):
                os.system('python plot2.py')
                if i_L == 0:
                    if i_s != 0:
                        os.system('cp outL.dat out_oldL.dat')
                        guessOutOldL = list(guessOutL)
                    os.system('cp out.dat outL.dat')
                    guessOutL = list(guessOut)
                continue
            else:
                break
        if (i_L == 0):
            break