Beispiel #1
0
def single_E_calc(gamma, scan, scan_dir, fwd_ic, bwd_ic):

    loadsuf = ["K_{33}", "k_{24}", "\\Lambda", "\\omega", "\\gamma_s"]
    savesuf = ["K_{33}", "k_{24}", "\\Lambda", "\\omega"]

    scan['\\gamma_s'] = str(gamma)

    ic_dict = {}

    if scan_dir == "scanforward":

        ic_dict = fwd_ic

    elif scan_dir == "scanbackward":

        ic_dict = bwd_ic

    scan['Rguess'] = str(ic_dict['Rguess0'])
    scan['Rupper'] = str(ic_dict['Rupper0'])
    scan['Rlower'] = str(ic_dict['Rlower0'])

    scan['etaguess'] = str(ic_dict['etaguess0'])
    scan['etaupper'] = str(ic_dict['etaupper0'])
    scan['etalower'] = str(ic_dict['etalower0'])

    scan['deltaguess'] = str(ic_dict['deltaguess0'])
    scan['deltaupper'] = str(ic_dict['deltaupper0'])
    scan['deltalower'] = str(ic_dict['deltalower0'])

    # read in file name info
    rp = ReadParams(scan=scan, loadsuf=loadsuf, savesuf=savesuf)

    # create a class to do calculations with current parameters in scan.
    run = SingleRun(rp, scan_dir=scan_dir)

    # run C executable.
    run.run_exe()

    # move file written by C executable from temporary data path to true data path
    run.mv_file('observables')

    # load the final values of E, R, eta, delta, and surface twist.
    Ei, Ri, etai, deltai, surftwisti = run.get_all_observables('observables',
                                                               str2float=True)

    run.concatenate_observables(["\\gamma_s"])

    return Ei, Ri, etai, deltai
Beispiel #2
0
            # if Ri is infinite, then the calculation failed.
            # Retry it with a different initial guess.

            print("Ri is NAN, trying again with Rguess = 1.0")

            # remove the current observables file, so that a new one can be written.
            run.remove_file("observables")
            if abs(float(scan['Rguess']) - 1.0) > 1e-10:
                Ri = 1.0
            else:
                break

        else:
            # calculation ran smoothly.
            run.concatenate_observables("\\Lambda")
            i += 1

        Rguess, etaguess, deltaguess = str(Ri), str(etai), str(deltai)

        scan['Rguess'] = Rguess
        scan['Rupper'] = str(1.5 * float(Rguess))
        scan['Rlower'] = str(0.75 * float(Rguess))

        if not np.isnan(float(etaguess)):
            scan['etaguess'] = etaguess
            scan['etaupper'] = str(float(etaguess) + 0.1)
            scan['etalower'] = str(float(etaguess) - 0.02)

        if not (np.isnan(float(deltaguess)) or abs(float(deltaguess)) < 1e-5):
            scan['deltaguess'] = deltaguess
Beispiel #3
0
        elif np.isnan(Ri):

            # if Ri is infinite, then the calculation failed.
            # Retry it with a different initial guess.

            print("Ri is NAN, trying again with Rguess = 1.0")

            run.remove_file("observables")
            if abs(float(Rguess) - 1.0) > 1e-10:
                Ri = 1.0
            else:
                break

        else:
            run.concatenate_observables("\\Lambda", scan_dir="scanforward")
            i += 1

        Rguess, etaguess, deltaguess = str(Ri), str(etai), str(deltai)

        scan['Rguess'] = Rguess
        scan['Rupper'] = str(1.5 * float(Rguess))
        scan['Rlower'] = str(0.75 * float(Rguess))

        if not np.isnan(float(etaguess)):
            scan['etaguess'] = etaguess
            scan['etaupper'] = str(float(etaguess) + 0.1)
            scan['etalower'] = str(float(etaguess) - 0.02)

        if not (np.isnan(float(deltaguess)) or abs(float(deltaguess)) < 1e-5):
            scan['deltaguess'] = deltaguess
Beispiel #4
0
        # move file written by C executable from temporary data path to true data path
        run.mv_file(f'observables')


        # load the final values of E, R, eta, delta, and surface twist.
        Ei,Ri,etai,deltai,surftwisti = run.get_all_observables('observables',str2float=True)

        if i == 0:

            # again, if the strain is zero, then I have just determined the equilibrium
            # inverse d band spacing, which I now need to set (and do so below).

            eta_eq = etai
            R_eq = Ri

        run.concatenate_observables(None,externalparam=u)

        # now just adjust my guess for delta
        
        deltaguess = str(deltai)



        if not (np.isnan(float(deltaguess))
                or abs(float(deltaguess))<1e-5):
            scan['deltaguess'] = deltaguess
            scan['deltaupper'] = '0.818'
            
            if float(deltaguess) < 0.81:
                scan['deltalower'] = str(0.95*float(deltaguess))
            else:
Beispiel #5
0
        run.remove_file(fname="psivsr", strain=strain)

        # load the final values of E, R, eta, delta, and surface twist.
        Ei, Ri, etai, deltai, surftwisti = run.get_all_observables(
            'observables', str2float=True)

        if i == 0:

            # again, if the strain is zero, then I have just determined the equilibrium
            # inverse d band spacing, which I now need to set (and do so below).

            eta_eq = etai
            R_eq = Ri

        run.concatenate_observables(None, externalparam=[u, psiav])

        # now just adjust my guess for delta

        deltaguess = str(deltai)

        if np.abs(deltai) < 1e-5:
            break

        if not (np.isnan(float(deltaguess)) or abs(float(deltaguess)) < 1e-5):
            scan['deltaguess'] = deltaguess
            scan['deltaupper'] = '0.818'

            if float(deltaguess) < 0.81:
                scan['deltalower'] = str(0.95 * float(deltaguess))
            else:
Beispiel #6
0
def single_E_calc(gamma, scan, loadsuf, savesuf, scan_dir):

    scan['\\gamma_s'] = str(gamma)

    if scan_dir == "scanforward":

        Rguess0 = 0.044
        Rlower0 = 0.04
        Rupper0 = 0.05

        etaguess0 = 6.29
        etalower0 = 6.3
        etaupper0 = 6.287

        deltaguess0 = 0.74
        deltalower0 = 0.72
        deltaupper0 = 0.8

    else:

        Rguess0 = 1.5
        Rlower0 = 1.0
        Rupper0 = 2.0

        etaguess0 = 6.4
        etalower0 = 6.38
        etaupper0 = 6.42

        deltaguess0 = 0.815
        deltalower0 = 0.813
        deltaupper0 = 0.816

    scan['Rguess'] = str(Rguess0)
    scan['Rupper'] = str(Rupper0)
    scan['Rlower'] = str(Rlower0)

    scan['etaguess'] = str(etaguess0)
    scan['etaupper'] = str(etaupper0)
    scan['etalower'] = str(etalower0)

    scan['deltaguess'] = str(deltaguess0)
    scan['deltaupper'] = str(deltaupper0)
    scan['deltalower'] = str(deltalower0)

    # read in file name info
    rp = ReadParams(scan=scan, loadsuf=loadsuf, savesuf=savesuf)

    # create a class to do calculations with current parameters in scan.
    run = SingleRun(rp, scan_dir=scan_dir)

    # run C executable.
    run.run_exe()

    # move file written by C executable from temporary data path to true data path
    run.mv_file('observables')

    # load the final values of E, R, eta, delta, and surface twist.
    Ei, Ri, etai, deltai, surftwisti = run.get_all_observables('observables',
                                                               str2float=True)

    run.concatenate_observables(["\\gamma_s"])

    return Ei, Ri
Beispiel #7
0
        run = SingleRun(rp)

        run.run_exe()

        #run.mv_file('psivsr')

        run.mv_file('observables')

        Rguess, etaguess, deltaguess = run.get_xvals()

        scan['Rguess'] = Rguess
        scan['Rupper'] = str(1.5 * float(Rguess))
        scan['Rlower'] = str(0.75 * float(Rguess))

        if not np.isnan(float(etaguess)):
            scan['etaguess'] = etaguess
            scan['etaupper'] = str(float(etaguess) + 0.1)
            scan['etalower'] = str(float(etaguess) - 0.02)

        if not (np.isnan(float(deltaguess)) or abs(float(deltaguess)) < 1e-5):
            scan['deltaguess'] = deltaguess
            scan['deltaupper'] = '0.818'

            if float(deltaguess) < 0.81:
                scan['deltalower'] = str(0.95 * float(deltaguess))
            else:
                scan['deltalower'] = '0.81'

        run.concatenate_observables(["\\Lambda", "\\omega"])
Beispiel #8
0
            # if Ri is infinite, then the calculation failed.
            # Retry it with a different initial guess.

            print("Ri is NAN, trying again with Rguess = 1.0")

            # remove the current observables file, so that a new one can be written.
            run.remove_file("observables")
            if abs(float(scan['Rguess']) - 1.0) > 1e-10:
                Ri = 1.0
            else:
                break

        else:
            # calculation ran smoothly.
            run.concatenate_observables("\\gamma_s")
            i -= 1

        Rguess, etaguess, deltaguess = str(Ri), str(etai), str(deltai)

        if not np.isnan(float(Rguess)):
            scan['Rguess'] = Rguess
            scan['Rupper'] = str(1.5 * float(Rguess))
            scan['Rlower'] = str(0.75 * float(Rguess))

        if not np.isnan(float(etaguess)):
            scan['etaguess'] = etaguess
            scan['etaupper'] = str(float(etaguess) + 0.1)
            scan['etalower'] = str(float(etaguess) - 0.02)

        if not (np.isnan(float(deltaguess)) or abs(float(deltaguess)) < 1e-5):
        run = SingleRun("data/input.dat", scan)

        run.run_exe()

        #run.mv_file('psivsr')

        run.mv_file('observables')

        Rguess, etaguess, deltaguess = run.get_xvals()

        scan['Rguess'] = Rguess
        scan['Rupper'] = str(1.5 * float(Rguess))
        scan['Rlower'] = str(0.75 * float(Rguess))

        if not np.isnan(float(etaguess)):
            scan['etaguess'] = etaguess
            scan['etaupper'] = str(float(etaguess) + 0.1)
            scan['etalower'] = str(float(etaguess) - 0.02)

        if not (np.isnan(float(deltaguess)) or abs(float(deltaguess)) < 1e-5):
            scan['deltaguess'] = deltaguess
            scan['deltaupper'] = '0.818'

            if float(deltaguess) < 0.81:
                scan['deltalower'] = str(0.95 * float(deltaguess))
            else:
                scan['deltalower'] = '0.81'

        run.concatenate_observables(scan_dir='scanforward')
Beispiel #10
0
        #run.mv_file('psivsr')

        run.mv_file('observables')

        
        Rguess,etaguess,deltaguess = run.get_xvals()

        scan['Rguess'] = Rguess
        scan['Rupper'] = str(1.5*float(Rguess))
        scan['Rlower'] = str(0.75*float(Rguess))

        if not np.isnan(float(etaguess)):
            scan['etaguess'] = etaguess
            scan['etaupper'] = str(float(etaguess)+0.1)
            scan['etalower'] = str(float(etaguess)-0.02)

        if not (np.isnan(float(deltaguess))
                or abs(float(deltaguess))<1e-5):
            scan['deltaguess'] = deltaguess
            scan['deltaupper'] = '0.818'
            
            if float(deltaguess) < 0.81:
                scan['deltalower'] = str(0.95*float(deltaguess))
            else:
                scan['deltalower'] = '0.81'


        run.concatenate_observables(scan_dir='scanbackward')


Beispiel #11
0
                # if Ri is infinite, then the calculation failed.
                # Retry it with a different initial guess.

                print("Ri is NAN, trying again with Rguess = 1.0")

                # remove the current observables file, so that a new one can be written.
                run.remove_file("observables")
                if abs(float(scan['Rguess'])-1.0)>1e-10:
                    Ri = 1.0
                else:
                    break

            else:
                # calculation ran smoothly.
                run.concatenate_observables(["\\gamma_s","k_{24}"])
                j+= 1

            Rguess,etaguess,deltaguess = str(Ri),str(etai),str(deltai)

            if not np.isnan(float(Rguess)):
                scan['Rguess'] = Rguess
                scan['Rupper'] = str(1.5*float(Rguess))
                scan['Rlower'] = str(0.9*float(Rguess))

            if not np.isnan(float(etaguess)):
                scan['etaguess'] = etaguess
                scan['etaupper'] = str(float(etaguess)+0.1)
                scan['etalower'] = str(float(etaguess)-0.02)

            if not (np.isnan(float(deltaguess))
Beispiel #12
0
        run = SingleRun(rp)

        run.run_exe()

        #run.mv_file('psivsr')

        run.mv_file('observables')

        Rguess, etaguess, deltaguess = run.get_xvals()

        scan['Rguess'] = Rguess
        scan['Rupper'] = str(1.5 * float(Rguess))
        scan['Rlower'] = str(0.75 * float(Rguess))

        if not np.isnan(float(etaguess)):
            scan['etaguess'] = etaguess
            scan['etaupper'] = str(float(etaguess) + 0.1)
            scan['etalower'] = str(float(etaguess) - 0.02)

        if not (np.isnan(float(deltaguess)) or abs(float(deltaguess)) < 1e-5):
            scan['deltaguess'] = deltaguess
            scan['deltaupper'] = '0.818'

            if float(deltaguess) < 0.81:
                scan['deltalower'] = str(0.95 * float(deltaguess))
            else:
                scan['deltalower'] = '0.81'

        run.concatenate_observables(["\\gamma_s"])
def single_E_calc(gamma,scan,loadsuf,savesuf,scan_dir):

    scan['\\gamma_s'] = str(gamma)

    k240 = 0.33

    k24 = float(scan['k_{24}'])

    t = (k24-k240)/k240

    if scan_dir == "scanforward":

        #Rguess0 = 0.045
        #Rupper0 = 0.6
        #Rlower0 = 0.4

        Rguess0 = lower_Rguess(t)
        Rupper0 = Rguess0*1.1
        Rlower0 = Rguess0*0.9

        etaguess0 = 6.295
        etalower0 = 6.29
        etaupper0 = 6.3

        deltaguess0 = 0.8
        deltalower0 = 0.799
        deltaupper0 = 0.805

    else:

        #Rguess0 = 0.7
        #Rupper0 = 0.9
        #Rlower0 = 0.6

        Rguess0 = upper_Rguess(t)
        Rupper0 = Rguess0*1.1
        Rlower0 = Rguess0*0.9

        etaguess0 = 6.34
        etalower0 = 6.32
        etaupper0 = 6.36

        deltaguess0 = 0.813
        deltalower0 = 0.808
        deltaupper0 = 0.816


    scan['Rguess'] = str(Rguess0)
    scan['Rupper'] = str(Rupper0)
    scan['Rlower'] = str(Rlower0)

    scan['etaguess'] = str(etaguess0)
    scan['etaupper'] = str(etaupper0)
    scan['etalower'] = str(etalower0)

    scan['deltaguess'] = str(deltaguess0)
    scan['deltaupper'] = str(deltaupper0)
    scan['deltalower'] = str(deltalower0)


    # read in file name info
    rp = ReadParams(scan=scan,loadsuf=loadsuf,savesuf=savesuf)

    # create a class to do calculations with current parameters in scan.
    run = SingleRun(rp,scan_dir=scan_dir)

    # run C executable.
    run.run_exe()

    # move file written by C executable from temporary data path to true data path
    run.mv_file('observables')

    # load the final values of E, R, eta, delta, and surface twist.
    Ei,Ri,etai,deltai,surftwisti = run.get_all_observables('observables',str2float=True)

    run.concatenate_observables(["\\gamma_s"])

    return Ei,Ri
Beispiel #14
0
import numpy as np
import subprocess
import sys
sys.path.append('../../gammak24_singlepoint/')
from singlerun import SingleRun

if __name__ == "__main__":

    run = SingleRun("data/input.dat")

    run.run_exe()

    run.mv_file('psivsr')

    run.mv_file('observables')

    run.concatenate_observables()