Beispiel #1
0
def cdce_min(cdce):

        cd, ce = cdce
        iop.flat_file_write("check_Eos.don",["Run..."],par=True,ptype='a+')
        iop.flat_file_write("check_Eos.don",["cd : "+str(cd),"ce : "+str(ce)],par=True,ptype='a+')
         
        input_lines = iop.flat_file_grab("sample_input.txt",scrub = True)
        parline_Dict, numline_Dict = vmd.mat_parline_parse(input_lines)    
        parline_Dict = vmd.mat_parline_dict(auto_Load = parline_Dict, cde = [cd,ce])
        parlines, numlines = vmd.mat_parline_dict_to_lines(parline_Dict,numline_Dict) 
        iop.flat_file_replace("sample_input.txt",numlines,parlines)  
          
        run_matter = "./xtest"
        subp.call(run_matter,shell=True)
            
        input_Eos = iop.flat_file_intable("matched_Eos.don")
        test_Eos = iop.flat_file_intable("test.txt")


        input_ea = input_Eos[1]
        test_ea = test_Eos[1]

        iop.flat_file_write("check_Eos.don",[str(ea) for ea in test_ea],par=True,ptype='a+')

        outval = eos_match(input_ea,test_ea)
        return outval
Beispiel #2
0
def partial_eos(file_name=None, lines=None):

    ptline = '\de/a\(mev\)\s*-*\d*\.*\d*\s*-*\d*\.*\d*\s*'

    start = '\de/a\(mev\)'
    space = '\s*'
    digit = '-*\d*\.*\d*'
    cgl = space + digit

    line = start + 7 * cgl
    v_line = re.compile(line)

    fail = False

    if (isinstance(file_name, str)):
        try:
            lines = iop.flat_file_grab(file_name)
        except:
            fail = True
            print("[partial_eos] Error: could not open file: " + file_name)
    elif (isinstance(lines, (list, tuple))):
        for i in range(len(lines)):
            if (not isinstance(lines[i], str)):
                fail = True
                print("[partial_eos] Error: line number " + str(i) +
                      " is not a string")
    else:
        fail = True

    if (fail):
        try:
            lines = iop.flat_file_grab('test1.txt')
        except:
            print("[partial_eos] Error: could not parse input or input files")
            return False

    match_lines = []
    for i in lines:
        bg = v_line.findall(i)
        if (len(bg) != 0):
            match_lines.append(bg[0])

    return match_lines
Beispiel #3
0
def get_contribs():

    # Get path of file storing the contribs
    success, file_path_list = cmv.cmd("dir contribs.txt")

    if (success == False):
        print("[vmed][get_contribs] Error: could not find 'contribs.txt'")
        return False

    file_path_list = file_path_list[0]

    lines_list = iop.flat_file_grab(file_path_list, scrub=True)
    return lines_list
Beispiel #4
0
    def get_logs(self, **kwargs):
        '''
        Reads 'OPTFILE' data from the internal pathway.
        This function should only be called once.
        '''

        if (self.LOGPATH_SET == False or self.LOGPATH_ERROR == True):
            return self.__err_print__("pathway was not properly initialized",
                                      varID=self.LOGFILE,
                                      **kwargs)

        lines = iop.flat_file_grab(self.LOGPATH, scrub=True, **kwargs)
        return lines
Beispiel #5
0
import subprocess
import re

from pmod import ioparse as iop

from pmod import vmed as vf  # not a standard pmod file; must be added for compatability with all vmed scripts

cmd = "f90 $F90FLAGS -o xl -s -w cpot.f eff3nfn3lo1.f $LINK_FNL"
subprocess.call(cmd, shell=True)  # Comment out if already compiled
subprocess.call("./xl", shell=True)  # Comment out if already excecuted

flines = iop.flat_file_grab('pot.d')

val_table_12, val_table_13 = vf.gen_table_12_13(flines)

iop.flat_file_write('fig_12_vals.txt', val_table_12, par=True)
iop.flat_file_write('fig_13_vals.txt', val_table_13, par=True)
Beispiel #6
0
if ('vincp' not in cml.var_path_contain):
    cml.cmd('mkdir vincp')
    exist = False
else:
    cml.cmd('rmdir vincp')
    cml.cmd('mkdir vincp')
    exist = True

### Group V contribs by number
numgroup, ngroup = vf.v_group()

# Go back to working directory and grab input file data
success, in_path_list = cml.cmd("dir sample_input.txt")
in_path = in_path_list[0]

lines_list = iop.flat_file_grab(in_path, [])
demark = lines_list[-1]

if (strl.str_space_clean(demark.strip('\n').strip('\r')) == ''):
    j = 0
    while (strl.str_space_clean(lines_list[-1 +
                                           j].strip('\n').strip('\r')) == ''):
        j += -1
    demark = lines_list[-1 + j]
    lines_list = lines_list[:j]

if (demark != "end param."):
    print("Warning: the end line in 'sample_input.txt' is not 'end param.'")

sum_failure = False
Beispiel #7
0
def tabulate_vmed_all(jv_list,
                      group_by_vindex=True,
                      momenta=None,
                      print_lines=True,
                      momenta_units='invfm',
                      pot_units='invmev2',
                      round_value=None,
                      digits=3,
                      espace=3,
                      pyver='2.6'):
    '''
    Inputs:

        jv_list : 'jv' formatted list

        group_by_vindex : (True) If True, output table automatically arranged by vmed number (lowest to highest)

        momenta : (None), if momenta is an array of integers, these momenta values used in jsl search

        print_lines : (True), If true, outlines are printed to a file, either way the list of strings is returned

        momenta_units : ('invfm'), options are 'invfm' or 'mev' corrosponding to Inverse Fermi and MeV^2 respectively

        pot_units : ('fm'), options are 'fm' or 'invmev2' corrosponding to Fermi and MeV respectively

    '''

    #Initialize internal command-line
    print("")
    cml = cmd.PathParse('linux')
    if (cml == False):
        return False

    # Get contents of vincp (contains the eff. potentials in question) Must run 'vmed_all.py' first!
    if ('vincp' not in cml.varPath_Folders):
        print("Error: no instance of 'vincp' in current (path) directory")
        return False
    vincp_path = cml.joinNode(cml.varPath, 'vincp')
    vincp_content = cml.contentPath(
        vincp_path,
        objType='file',
    )

    # group by v# in order, set 'group_by_vindex = False' to ignore this command
    if (group_by_vindex):
        vincp_content = map(
            lambda x: (vmed_index_finder.findall(x.split('.')[0])[0], x),
            vincp_content)
        vincp_content.sort(key=lambda x: int(x[0]))

    # Set momenta values
    if (momenta == None):
        plist = strl.array_nth_index(vf.pf_vals_20, 5)
    elif (isinstance(momenta, (list, tuple))):
        plist = momenta
    else:
        print("Error: input variable, 'momenta', not recognized")
        return False

    jsl_list = []
    for jv in jv_list:
        j = str(jv[0])
        t = str(jv[1])
        for p in plist:
            jsl_list.append(vf.jsl_entry(j, p, p, t))

    outlines = []

    if (isinstance(momenta_units, str)):
        if (momenta_units.lower() == 'invfm'):
            plist = map(lambda x: str(round(float(x) / vf.hc, 2)), plist)

    pstring = ''
    for entry in plist:
        pstring = pstring + mops.space_format(entry, 12, adjust='right')
    pline = mops.space_format('p', 14, adjust='right')

    heading = pline + pstring + '\n'
    outlines.append(heading)
    outlines.append('\n')

    for entry in vincp_content:
        vval = entry[0]
        filename = entry[1]
        filepath = cml.joinNode(vincp_path, filename)
        filetext = iop.flat_file_grab(filepath)
        matching_values = vf.grab_jsl(filetext, jsl_list, round_form=1)
        if (isinstance(matching_values, (list, tuple))
                and isinstance(pot_units, str)):
            if (pot_units.lower() == 'invmev2'):
                pass
            else:
                if (not isinstance(round_value, int)):
                    matching_values = map(lambda x: str(float(x) * vf.vmhc),
                                          matching_values)
                else:
                    if (round_value > 2):
                        matching_values = map(
                            lambda x: str(
                                round(float(x) * vf.vmhc, round_value)),
                            matching_values)
            matching_values = mops.sci_space_format(matching_values,
                                                    digi=digits,
                                                    spacing=espace,
                                                    pyver=pyver)
            outline = strl.array_to_str(matching_values, spc=' ')
            out_heading = 'vmed ' + str(vval)
            out_heading = mops.space_format(out_heading, 9, adjust='right')
            outline = out_heading + "  " + outline + '\n'
            outlines.append(outline)
        elif (matching_values == False or matching_values == None):
            print('    ' + "Error: parsing partial wave value failed\n")
            continue
        else:
            print('    ' + "Error: unknown error when parsing partial wave\n")
            continue

    if (print_lines):
        iop.flat_file_write('table_vincp', outlines)
    return outlines
Beispiel #8
0
import pmod.vmed as vf

# Get V groupings
tstart = time.time()
numgroup, ngroup = vf.v_group()

cmv = cml.PathParse('linux')
success, in_path_list = cmv.cmd("dir dpot1.d")
if (not success):
    print(
        "CMDError: an error occured when searching for 'dpot1.d' file pathway")
    sys.exit("The python script 'vmed_all.py' has been terminated.")

in_path = in_path_list[0]

lines_list = iop.flat_file_grab(in_path)
original_lines = list(lines_list)
if (lines_list == False):
    print(
        "CMDError: an error occured when reading file at pathway: str(in_path)"
    )
    sys.exit("The python script 'vmed_all.py' has been terminated.")

demark = lines_list[-1]
lines_list = lines_list[:-1]

cmd = "f90 $F90FLAGS -o xl -s -w cpot.f eff3nfn3lo1.f $LINK_FNL"
try:
    subp.call(cmd, shell=True)  # Comment out if already compiled
except:
    print(
Beispiel #9
0
# MAIN PROGRAM----------------------------------------------------------------------------------------------------------

reset = 1
counter = 0

temp_list = []
mu_list = []
T = []

i_list = [1]
j_list = [1]

tstart = time.time()

par_grab = iop.flat_file_grab("par.don")
par_grab = par_grab[0]

par_str = ""
for i in range(len(par_grab) - 2):
    par_str = par_str + str(par_grab[i]) + " "

m = int(par_grab[0])
n = int(par_grab[3])
mat = int(par_grab[1])

ti = float(par_grab[4])
tf = float(par_grab[5])

for i in range(n):
    t_val = ti + float(i) * tf
Beispiel #10
0
for i in xrange(len(nqftest_list)):
    if (getsf):
        for j in xrange(len(cqfi_list)):
            clist = [
                cqfi_txt + cqfi_list[j] + '\n',
                nqftest_txt + str(nqftest_list[i]) + '\n'
            ]

            iop.flat_file_replace('eff3nfn3lo1.f', nlines, clist)
            subp.call(
                "f90 $F90FLAGS -o xl -s -w cpot.f eff3nfn3lo1.f $LINK_FNL",
                shell=True)
            subp.call("./xl", shell=True)

            lines = iop.flat_file_grab('pot.d', scrub=True)
            vals = vf.grab_jsl(lines, jsls, 1)
            for k in xrange(len(vals)):
                vals[k] = str(
                    mops.round_uniform(float(vals[k]) * vf.vmhc, pyver='2.6'))
            gp_vals.append(
                str(cqfi_list[j]) + '  ' + strl.array_to_str(vals, spc='  '))
        mx_vals.append(gp_vals)
        gp_vals = []
    else:
        clist = [nqftest_txt + str(nqftest_list[i]) + '\n']

        iop.flat_file_replace('eff3nfn3lo1.f', [nlines[1]], clist)
        subp.call("f90 $F90FLAGS -o xl -s -w cpot.f eff3nfn3lo1.f $LINK_FNL",
                  shell=True)
        subp.call("./xl", shell=True)
Beispiel #11
0
from pmod import vmed as vf

#
tstart = time.time()

f12n = 'fig12_v'
f13n = 'fig13_v'

# Get V groupings
numgroup, ngroup = vf.v_group()

cmv = cml.path_parse('linux')
success, in_path_list = cmv.cmd("dir dpot1.d")
in_path = in_path_list[0]

lines_list = iop.flat_file_grab(in_path)
demark = lines_list[-1]
lines_list = lines_list[:-1]

cmd = "f90 $F90FLAGS -o xl -s -w cpot.f eff3nfn3lo1.f $LINK_FNL"
subp.call(cmd, shell=True)  # Comment out if already compiled

# Run P loop

if ('vincp' not in cmv.var_path_contain):
    cmv.cmd('mkdir vincp')
    exist = False
else:
    cmv.cmd('rmdir vincp')
    cmv.cmd('mkdir vincp')
    exist = True