Ejemplo n.º 1
0
from Manipulate import FindSteps
from Manipulate import IbcLayer
from Manipulate import LowerMantle
from Files import fFileColD
from Files import HzFileColD

Route = "/home/p300/Desktop/SpaImpactOverturn/I420deg60ibc50v1e-3R65c192"
CaseName = "a"
InputFile = "%s/input_solidus_i/in_65moon" % (Route)

ppFile = "%s/post_process" % (Route)
plogfile = '%s/plog' % (Route)
MaxStep = 100001
oRoute = './test'
# read input #
inD = Mread.read_input(InputFile)
# get step list #
Steps = FindSteps(Route, CaseName, MaxStep)
TD = TimeDat(inD, fFileColD, Steps)
ToF = TD.Check(Route)
TD.Read(Route)
timeArray = TD.GetTime()
TD.PlotMachineTime(oRoute)
# horiz_avg file #
IbcCol = HzFileColD['chemical'][2]
VrCol = HzFileColD['vr']
VthCol = HzFileColD['vth']
VCol = [VrCol, VthCol]
rIbc = IbcLayer(inD)
rLM = LowerMantle(inD)
HA = HorizAvg(inD, HzFileColD, Steps, timeArray)
Ejemplo n.º 2
0
def remove_extra_file1(route, case_name, in_dict, time_array, step_tuple,
                       step_start, p_file, plogfile):
    caps = 12
    steps_inter = 30
    nprocz = readf.get_variable(in_dict, 'nprocz', 'int')
    nprocx = readf.get_variable(in_dict, 'nprocx', 'int')
    nprocy = readf.get_variable(in_dict, 'nprocy', 'int')
    nproc = caps * nprocx * nprocy * nprocz

    p_dict = readf.read_input(p_file)
    e_steps = readf.get_variable(p_dict, 'episode_steps', 'int_list')
    steps_in = readf.get_variable(p_dict, 'steps_remain', 'int_list')
    length = len(step_tuple)
    time_at_steps = [time_array[step] for step in step_tuple]
    step_end = step_tuple[len(step_tuple) - 1]
    stime = time_array[step_start]
    ftime = time_array[step_end]
    plog = open(plogfile, 'a')
    #----get time of steps that are worth keeping----#
    time_query = []
    for time in np.linspace(stime, ftime, steps_inter):
        time_query.append(time)
    #----get steps that are worth keeping----#
    for time in time_query:
        n = np.argmin(abs(time_at_steps - time))
        step = step_tuple[n]
        if step not in steps_in:
            steps_in.append(step)
    is_see = input('deleting steps: see steps to keep?(y/n)')
    if is_see:
        print(steps_in)
    input()
    #----delete extra files----#
    for n in range(len(step_tuple)):
        step = step_tuple[n]
        if step < step_start:
            continue

#        bash_command = []
#        bash_command.append('rm %s/%s.proc0.%d.vts'%(route,case_name,step))
#        bash_command.append('rm %s/%s.%d.vtm'%(route,case_name,step))
        if step not in steps_in:
            for proc in range(nproc):
                filename = '%s/%s.proc%d.%d.vts' % (route, case_name, proc,
                                                    step)
                if os.path.isfile(filename):
                    os.remove(filename)
                if proc % nprocz is nprocz - 1:
                    filename = '%s/%s.surf.%d.%d' % (route, case_name, proc,
                                                     step)
                    if os.path.isfile(filename):
                        os.remove(filename)
                    filename = '%s/%s.surf_ori.%d.%d' % (route, case_name,
                                                         proc, step)
                    if os.path.isfile(filename):
                        os.remove(filename)
            filename = '%s/%s.surf_sph.%d' % (route, case_name, step)
            if os.path.isfile(filename):
                os.remove(filename)
            filename = '%s/%s.%d.vtm' % (route, case_name, step)
            if os.path.isfile(filename):
                os.remove(filename)
#            readf.run_bash(bash_command)
            plog.write('remove file at step %d\n' % (step))
    plog.close()
    #----write remain steps to p_file----#
    readf.overwrite_to_file(p_file,
                            'steps_remain',
                            steps_in,
                            vtype='int',
                            vvtype='array')
    input()
Ejemplo n.º 3
0
import os
import sys
sys.path.append('../public')
import imgPP  #self writen module for dealing images
import dataPP  #self writen module dealing with CitcomS output files
import readfiles as Mread

route = "/home/p300/Documents/Research/work/CitcomS2/MgH30V5e20E100L"
#dataRoute = "/home/p300/Desktop/lunar_project/m1t_1"
dataRoute = "/media/p300/Seagate0/mg_project/MgH30V5e20E100L"
caseName = "MgH30V5e20E100L"
pp_file = '%s/post_process' % (dataRoute)
use_eps = 1
pp_dict = Mread.read_input(pp_file)
PVarray = []
MLarray = []
SGarray = []
steparray = []
#image types from paraview goes here
#PVarray.append('volume')
#PVarray.append('slice')
#PVarray.append('composition')
#PVarray.append('cslice0')
PVarray.append('cslice2')
PVarray.append('melting')
#image types from matlab goes here
MLarray.append('temp')
MLarray.append('rho')
MLarray.append('visc')
MLarray.append('velo')
include_field = 1
Ejemplo n.º 4
0
def chemical(in_dict, time_array, step_tuple, column_dict, route, o_dir,
             case_name, pp_file):
    get_end = 1
    split = 6
    init_lower_percent = 0.01
    pi = np.pi
    tiny = 1e-8
    year = 365 * 24 * 3600
    case_dir = Mpf.assign_output_dir("%s/%s" % (o_dir, case_name))
    o_dir = Mpf.assign_output_dir("%s/chemical" % (case_dir))
    if os.path.isfile(pp_file):
        pp_dict = readf.read_input(pp_file)
        try:
            pp_dict['end_time']
        except KeyError:
            get_end = 1
        else:
            get_end = 0
    else:
        get_end = 1
    #----read parameters----#
    cols = column_dict['cols']
    nprocz = readf.get_variable(in_dict, 'nprocz', 'int')
    noz = readf.get_variable(in_dict, 'nodez', 'int')
    Ro = readf.get_variable(in_dict, 'radius', 'float')
    interface = readf.get_variable(in_dict, 'z_interface', 'float_list')
    r_inter = interface[-1]
    r_o = readf.get_variable(in_dict, 'radius_outer', 'float')
    r_in = readf.get_variable(in_dict, 'radius_inner', 'float')
    r_lith = r_o - readf.get_variable(in_dict, 'z_lith', 'float')
    Kappa = readf.get_variable(in_dict, 'thermdiff', 'float')
    r_half = (r_o + r_in) / 2.0
    lnoz = int((noz - 1) / nprocz) + 1
    time_scaling = pow(Ro, 2.0) / Kappa / (1e6 * year)
    total_ibc = 4 * pi / 3 * (pow(r_lith, 3.0) - pow(r_lith - 20e3 / Ro, 3.0))
    #----prepare chemical data----#
    chemical = np.zeros((len(step_tuple), 3))
    time1 = np.zeros(len(step_tuple))
    n = 0
    for step in step_tuple:
        time1[n] = time_array[step]
        print(step, end='\r')
        data_in = readf.read_horig_output(route, case_name, step, nprocz, lnoz,
                                          cols)
        rr = data_in[:, column_dict['radius']]
        C = data_in[:, column_dict['ic']]
        for i in range(noz - 1):
            volume = 4.0 / 3.0 * pi * (pow(rr[i + 1], 3.0) - pow(rr[i], 3.0))
            if rr[i] > r_inter - tiny and rr[i] < r_lith + tiny:
                chemical[n,
                         0] = chemical[n, 0] + (C[i] + C[i + 1]) / 2.0 * volume
            if rr[i] > r_half - tiny:
                chemical[n,
                         1] = chemical[n, 1] + (C[i] + C[i + 1]) / 2.0 * volume
            if rr[i] < r_half + tiny:
                chemical[n,
                         2] = chemical[n, 2] + (C[i] + C[i + 1]) / 2.0 * volume
        n = n + 1
    total_chemical = chemical[0, 1] + chemical[0, 2]
    chemical_low = chemical[:, 2]  #chemical_low is lower chemical percent
    #print(chemical[0,1]+chemical[0,2])
    #print(chemical[:,0]) #debug
    #print(chemical[:,1])
    #print(chemical[:,2])
    #----plot figures----#
    #----figure 1 : retained chemical----#
    fig, ax = plt.subplots()
    line1, = ax.plot(time1 * time_scaling, chemical[:, 0] / chemical[0, 0],
                     'r-')
    ax.set(xlabel='Time [ma]',
           ylabel='Chemical Percent[1]',
           title='Retained Chemicals in Initial Layer')
    fig.savefig("%s/retained_ibc.eps" % (o_dir))
    #plt.show()
    plt.close(fig)
    #----figure 2 : overturned chemical----#
    time2 = time1 * time_scaling
    fig, ax = plt.subplots()
    line1, = ax.plot(time2, chemical_low / total_chemical, 'b-')
    ax.set(xlabel='Time [ma]',
           ylabel='Chemical Percent[1]',
           title='Overturned Chemical')
    fig.savefig("%s/overturned_chemical.eps" % (o_dir))
    #plt.show()
    plt.close(fig)
    #----figure 3 : overturned ibc volume----#
    fig, ax = plt.subplots()
    line1, = ax.plot(time2, chemical_low / total_chemical * total_ibc, 'c-')
    ax.set(xlabel='Time [ma]', ylabel='IBC Volume[1]', title='Overturned IBC')
    fig.savefig("%s/overturned_IBC.eps" % (o_dir))
    if get_end is 1:
        temp = input(
            "input scheme to continue getting end for overturn: 'a(auto)/m(manual):"
        )
        if temp is 'a':
            cid = fig.canvas.mpl_connect('button_press_event', on_press)
            plt.show()
            end_time = get_end_time(Gmc[0], Gmc[1], Gmc[2])
            diff_t = abs(time2 - end_time)
            end_n = np.argmin(diff_t)
            end_c = chemical_low[end_n]
            episode_c = np.linspace(0.0, 1.0, split) * end_c
            episode_c[0] = init_lower_percent * end_c
            episode_steps = []
            for cc in episode_c:
                diff_c = abs(chemical_low - cc)
                tempn = np.argmin(diff_c)
                episode_steps.append(step_tuple[tempn])
            end_c_percent = end_c / total_chemical
            episode_completness = episode_c / end_c
            fig.canvas.mpl_disconnect(cid)
        elif temp is 'm':
            plt.show()
            temp = input('endstep for episode:')
            end_step = int(temp)
            end_time = time_array[end_step] * time_scaling
            diff_t = abs(time2 - end_time)
            end_n = np.argmin(diff_t)
            episode_t = np.linspace(0.0, 1.0, split) * end_time
            end_c = chemical_low[end_n]
            end_c_percent = end_c / total_chemical
            episode_completness = episode_t / end_time
            episode_steps = []
            for tt in episode_t:
                diff_t = abs(time2 - tt)
                tempn = np.argmin(diff_t)
                episode_steps.append(step_tuple[tempn])
        readf.write_to_file(pp_file, 'end_time', end_time, 'float')
        readf.write_to_file(pp_file, 'end_c_percent', end_c_percent, 'float')
        readf.write_to_file(pp_file, 'episode_completness',
                            episode_completness, 'float', 'array')
        readf.write_to_file(pp_file, 'episode_steps', episode_steps, 'int',
                            'array')
    else:
        plt.show()
    plt.close(fig)