コード例 #1
0
def extremes_density_time(name):
    fig = plt.figure(figsize=(16,8))
    data = vtn.vtrToNumpy(mesh, vtn.loadFromResults(), name)
    arr_min = numpy.min(data[1][temp]-data[0][temp], axis = 0)
    arr_max = numpy.max(data[1][temp]-data[0][temp], axis = 0)
    plt.plot(arr_min, label = 'min')
    plt.plot(arr_max, label = 'max')
    plt.legend()
    plt.show()
コード例 #2
0
def mean_density_time(name, accDensity):
    fig = plt.figure(figsize=(16,8))
    data = vtn.vtrToNumpy(mesh, vtn.loadFromResults(), name)
    data_acc = vtn.vtrToNumpy(mesh, vtn.loadFromResults(), accDensity)
    data = [data_i-data_acc_i for data_i, data_acc_i in zip(data, data_acc)]
    for i in range(len(name)):
        d_loc = [numpy.flatnonzero(data[i][temp,j]) for j in range(numpy.shape(data[i])[1])]
        arr = [numpy.average(data[i][temp[d_loc[j]],j]) for j in range(numpy.shape(data[i])[1])]
        arr = [0 if numpy.isnan(x) else x for x in arr]
        time = numpy.arange(len(data[i][0,:]))*c.P_DT*10/1e-6
        plt.plot(time, arr, label = name[i])

    plt.title(r'\textbf{Average density in domain}', fontsize = 24)
    plt.ylabel(r'\textbf{Density [m$^{-3}$]}', fontsize = 22)
    plt.xlabel(r'\textbf{Time [$\mu$s]}', fontsize = 22)
    plt.tick_params(axis='both', which='major', labelsize=20)
    plt.grid()
    plt.legend(fontsize = 20)
    plt.show()
コード例 #3
0
def approx_velocity_wall(current, accDensity):
    fig = plt.figure(figsize=(16,8))
    data_c = vtn.vtrToNumpy(mesh, vtn.loadFromResults(), current)
    data_acc = vtn.vtrToNumpy(mesh, vtn.loadFromResults(), accDensity)
    loc = numpy.unique(mesh.boundaries[1].location)
    for i in range(len(current)):
        data_acc[i][:,1:] -= data_acc[i][:,:-1]
        d_loc = [numpy.flatnonzero(data_acc[i][loc,j] > 0) for j in range(numpy.shape(data_acc[i])[1])]
        arr = [numpy.average(data_c[i][loc[d_loc[j]],j]/c.QE/data_acc[i][loc[d_loc[j]],j]) for j in range(numpy.shape(data_c[i])[1])]
        arr = [0 if numpy.isnan(x) else abs(x) for x in arr]
        time = numpy.arange(len(data_c[i][0,:]))*c.P_DT*10/1e-6
        plt.plot(time, arr, label = current[i].replace('_','\_'))

    plt.title(r'\textbf{Average impact velocity to/from satellite}', fontsize = 24)
    plt.ylabel(r'\textbf{Velocity [m/s]}', fontsize = 22)
    plt.xlabel(r'\textbf{Time [$\mu$s]}', fontsize = 22)
    plt.tick_params(axis='both', which='major', labelsize=20)
    plt.grid()
    plt.yscale('log')
    plt.legend(fontsize = 20)
    plt.show()
コード例 #4
0
def uploading_data(mesh, data_r=None):
    if data_r is None:
        data_r = []
    data = {}
    results = vtn.vtrToNumpy(mesh, vtn.loadFromResults(files_id=mesh.id),
                             names)
    for name, array in zip(names, results):
        data[name] = array
    data_r.append(data)
    for child in mesh.children:
        uploading_data(child, data_r=data_r)
    return data_r
コード例 #5
0
def mean_vel_time(name, density, accDensity, ind = None):
    fig = plt.figure(figsize=(16,8))
    data = vtn.vtrToNumpy(mesh, vtn.loadFromResults(), name)
    data_d = vtn.vtrToNumpy(mesh, vtn.loadFromResults(), density)
    data_acc = vtn.vtrToNumpy(mesh, vtn.loadFromResults(), accDensity)
    data_d = [data_i-data_acc_i for data_i, data_acc_i in zip(data_d, data_acc)]
    for i in range(len(name)):
        if ind is None:
            ind = temp
        d_loc = [numpy.flatnonzero(data_d[i][ind,j]) for j in range(numpy.shape(data_d[i])[-1])]
        arr = [numpy.average(numpy.linalg.norm(data[i][ind[d_loc[j]],:,j], axis = 1)) for j in range(numpy.shape(data[i])[-1])]
        arr = [0 if numpy.isnan(x) else x for x in arr]
        time = numpy.arange(len(data[i][0,0,:]))*c.P_DT*10/1e-6
        plt.plot(time, arr, label = name[i])

    plt.title(r'\textbf{Average velocity in domain}', fontsize = 24)
    plt.ylabel(r'\textbf{Velocity [m/s]}', fontsize = 22)
    plt.xlabel(r'\textbf{Time [$\mu$s]}', fontsize = 22)
    plt.yscale('log')
    plt.tick_params(axis='both', which='major', labelsize=20)
    plt.grid()
    plt.legend(fontsize = 20)
    plt.show()
コード例 #6
0
def wall_density_diff(name):
    fig = plt.figure(figsize=(16,8))
    data = vtn.vtrToNumpy(mesh, vtn.loadFromResults(), name)
    data = data[1]-data[0]
    top = numpy.unique(mesh.boundaries[1].top)
    left = numpy.unique(mesh.boundaries[1].left)
    right = numpy.unique(mesh.boundaries[1].right)
    bottom = numpy.unique(mesh.boundaries[1].bottom)
    plt.plot(numpy.arange(len(top)), data[top,-1], label = 'top')
    plt.plot(numpy.arange(len(top)), data[left,-1], label = 'left')
    plt.plot(numpy.arange(len(top)), data[right,-1], label = 'right')
    plt.plot(numpy.arange(len(top)), data[bottom,-1], label = 'bottom')
    plt.legend()
    plt.show()
コード例 #7
0
def out_in_currents_collected_time(name_out, name_in):
    fig = plt.figure(figsize=(16,8))
    data_out = vtn.vtrToNumpy(mesh, vtn.loadFromResults(), name_out)
    data_in = vtn.vtrToNumpy(mesh, vtn.loadFromResults(), name_in)
    loc = numpy.unique(mesh.boundaries[1].location)
    for i in range(len(name_out)):
        d_loc_out = [numpy.flatnonzero(data_out[i][loc,j]) for j in range(numpy.shape(data_out[i])[1])]
        d_loc_in = [numpy.flatnonzero(data_in[i][loc,j]) for j in range(numpy.shape(data_in[i])[1])]
        arr_out = [numpy.sum(data_out[i][loc[d_loc_out[j]],j]*mesh.area_sat[d_loc_out[j]])/1e-3 for j in range(numpy.shape(data_out[i])[1])]
        arr_out = [0 if numpy.isnan(x) else x for x in arr_out]
        arr_in = [numpy.sum(data_in[i][loc[d_loc_in[j]],j]*mesh.area_sat[d_loc_in[j]])/1e-3 for j in range(numpy.shape(data_in[i])[1])]
        arr_in = [0 if numpy.isnan(x) else -x for x in arr_in]
        #plt.plot(numpy.sum(data[i][loc]*numpy.repeat(mesh.volumes[loc]/(mesh.dx/2), numpy.shape(data[i])[1], axis = 1), axis = 0), label = name[i])
        time = numpy.arange(len(data_out[i][0,:]))*c.P_DT*100/1e-6
        plt.plot(time, arr_out, label = name_out[i].replace('_', '\_'))
        plt.plot(time, arr_in, label = name_in[i].replace('_', '\_'))

    plt.title(r'\textbf{Currents to/from satellite}', fontsize = 24)
    plt.ylabel(r'\textbf{Current [mA]}', fontsize = 22)
    plt.xlabel(r'\textbf{Time [$\mu$s]}', fontsize = 22)
    plt.tick_params(axis='both', which='major', labelsize=20)
    plt.grid()
    plt.legend(fontsize = 20)
    plt.show()
コード例 #8
0
def increase_number_particles(name):
    fig = plt.figure(figsize=(16,8))
    data = vtn.vtrToNumpy(mesh, vtn.loadFromResults(), name)
    for i in range(len(name)):
        arr = numpy.sum(data[i][temp]*mesh.volumes[temp][:,None], axis = 0)
        time = numpy.arange(len(arr[:-1]))*c.P_DT*10/1e-6
        plt.plot(time, arr[1:]-arr[:-1], label = name[i])
        #plt.plot(arr[1:]-arr[:-1], label = name[i])
    plt.axhline(y=3.310585e9, color = 'black', label='Photoelectron')
    plt.axhline(y=0, color = 'k')
    #plt.axhline(y=1.416000e11, color = 'red', label='electron-proton')
    plt.ylabel(r'\textbf{$\delta$ particles}', fontsize = 22)
    plt.xlabel(r'\textbf{Time [$\mu$s]}', fontsize = 22)
    plt.tick_params(axis='both', which='major', labelsize=20)
    plt.grid()
    plt.legend(fontsize = 20)
    plt.show()
コード例 #9
0
def wall_potential(name):
    fig = plt.figure(figsize=(16,8))
    data = vtn.vtrToNumpy(mesh, vtn.loadFromResults(), name)[0]
    top = numpy.unique(mesh.boundaries[1].top)
    left = numpy.unique(mesh.boundaries[1].left)
    right = numpy.unique(mesh.boundaries[1].right)
    bottom = numpy.unique(mesh.boundaries[1].bottom)
    plt.plot(numpy.arange(len(top)), data[top,-1], label = 'top')
    plt.plot(numpy.arange(len(top)), data[left,-1], label = 'left')
    plt.plot(numpy.arange(len(top)), data[right,-1], label = 'right')
    plt.plot(numpy.arange(len(top)), data[bottom,-1], label = 'bottom')
    plt.title(r'\textbf{Potential at the different borders of the satellite}', fontsize = 24)
    plt.ylabel(r'\textbf{Potential [V]}', fontsize = 22)
    plt.xlabel(r'\textbf{Borders}', fontsize = 22)
    plt.tick_params(axis='both', which='major', labelsize=20)
    plt.grid()
    plt.legend(fontsize = 20)
    plt.show()
コード例 #10
0
def debye_length_test(name):
    fig = plt.figure(figsize=(16,8))
    #Preparing data
    data = vtn.vtrToNumpy(mesh, vtn.loadFromResults(), name)
    left = c.NX*(int(c.NY/2)+1)
    cut = data[0][left:left+c.NX,-1]
    x = numpy.linspace(c.XMIN, c.XMAX, num = c.NX)
    offset = (c.XMAX-c.XMIN)/2
    dx = (c.XMAX-c.XMIN)/(c.NX-1)
    #Omitting the center
    ind = numpy.where(numpy.logical_or(x < offset-4*dx, x > offset+4*dx))

    #Debye Lenght study
    lambda_d = 1/numpy.sqrt(c.E_N*c.QE*c.QE/c.EPS_0/c.K/c.E_T+c.P_N*c.QE*c.QE/c.EPS_0/c.K/c.P_T)
    print("Theory", lambda_d)
    theory = debye_function(x-offset, 1.0, lambda_d)
    guess = (1.0, lambda_d)
    params, errors = debye_shielding_fit(x[ind]-offset, cut[ind], guess)

    plt.plot(x, theory, color = 'black', label = 'Theory')
    plt.scatter(x, cut, color = 'red', marker = '.', label = 'Simulation')
    plt.plot(x, debye_function(x-offset, *params), color = 'blue', label = 'Fit')
    plt.legend()
    plt.show()

    #Further analysis
    fig = plt.figure(figsize=(16,8))
    val = []
    err = []
    for i in range(1,10):
        ind = numpy.where(numpy.logical_or(x < offset-i*dx, x > offset+i*dx))
        guess = (1.0, lambda_d)
        params, errors = debye_shielding_fit(x[ind]-offset, cut[ind], guess)
        val.append(params[1])
        err.append(numpy.sqrt(numpy.diag(errors)[1]))
        print(params, numpy.sqrt(numpy.diag(errors)))
    plt.axhline(y=lambda_d, color = 'black')
    plt.errorbar(numpy.arange(1,10), val, yerr=err, marker = '.', linestyle = '', ecolor = 'black')
    plt.show()
コード例 #11
0
def debye_length_analysis(density, accDensity, temperature,\
        proton_density = ["Proton - Solar wind-density"], proton_accDensity = ["Proton - Solar wind-accumulated density"], proton_temperature = ["Proton - Solar wind-temperature"], n = 20):
    dictionary = {}

    data_p_density = vtn.vtrToNumpy(mesh, vtn.loadFromResults(), proton_density)
    data_p_acc = vtn.vtrToNumpy(mesh, vtn.loadFromResults(), proton_accDensity)
    data_p_density = [data_i-data_acc_i for data_i, data_acc_i in zip(data_p_density, data_p_acc)][0]
    data_p_temperature = vtn.vtrToNumpy(mesh, vtn.loadFromResults(), proton_temperature)[0]

    data_e_density = vtn.vtrToNumpy(mesh, vtn.loadFromResults(), density)
    data_e_acc = vtn.vtrToNumpy(mesh, vtn.loadFromResults(), accDensity)
    data_e_density = [data_i-data_acc_i for data_i, data_acc_i in zip(data_e_density, data_e_acc)]
    data_e_temperature = vtn.vtrToNumpy(mesh, vtn.loadFromResults(), temperature)

    #Average over the last n stored results
    ts = numpy.shape(data_p_density)[1]
    data_p_density = numpy.average(data_p_density[:,ts-n:], axis = 1)
    data_p_temperature = numpy.average(data_p_temperature[:,ts-n:], axis = 1)*c.EV_TO_K

    for i in range(len(density)):
        #Average over the last n stored results
        data_e_density_i = numpy.average(data_e_density[i][:,ts-n:], axis = 1)
        data_e_temperature_i = numpy.average(data_e_temperature[i][:,ts-n:], axis = 1)*c.EV_TO_K

        #Debye Length calcualtion
        lambda_d = debye_length((c.QE, data_e_density_i, data_e_temperature_i), (-c.QE, data_p_density, data_p_temperature))
        dictionary["Debye length - {}".format(density[i].rsplit("-", 1)[0])] = lambda_d

    #Create minimum Debye length case
    compact_l = list(dictionary.values())
    compact = reduce(lambda x, y: numpy.append(x, y[:,None], axis = 1), compact_l[1:], compact_l[0][:,None])
    compact = numpy.nanmin(compact, axis = 1)
    dictionary["Debye length - smallest"] = compact

    #Export to vtr files
    cwd = os.getcwd()
    vtkstring = os.path.join(cwd,'plotters','plots','debye_length')
    mesh.saveVTK(vtkstring, dictionary)
コード例 #12
0
    plt.gca().ticklabel_format(axis='y', style='sci')
    plt.grid()
    plt.show()


#---------------------------------------------------------------------------------------------------------------------
# Extracting data
#---------------------------------------------------------------------------------------------------------------------

data ={}
names = [\
        "Electron - Photoelectron-flux", "Electron - SEE-flux", "Electron - Solar wind-flux", "Proton - Solar wind-flux",\
        "Electron - Photoelectron-outgoing_flux", "Electron - SEE-outgoing_flux",\
        "Electron - Photoelectron-accumulated density", "Electron - SEE-accumulated density", "Electron - Solar wind-accumulated density", "Proton - Solar wind-accumulated density"\
        ]
results = vtn.vtrToNumpy(mesh, vtn.loadFromResults(), names)
for name, array in zip(names, results):
    data[name] = array

#---------------------------------------------------------------------------------------------------------------------
# Functions calls
#---------------------------------------------------------------------------------------------------------------------


#increase_number_particles(["Electron - Photoelectron-density"])
#increase_number_particles(["Electron - Photoelectron-density", "Electron - Solar wind-density", "Proton - Solar wind-density"],\
#                            [c.PHE_SPWT, c.E_SPWT, c.P_SPWT])
#extremes_density_time(["Electron - Solar wind-density", "Proton - Solar wind-density"])
#debye_length_analysis(["Electron - Photoelectron-density", "Electron - SEE-density", "Electron - Solar wind-density"],\
#                      ["Electron - Photoelectron-accumulated density", "Electron - SEE-accumulated density", "Electron - Solar wind-accumulated density"],\
#                      ["Electron - Photoelectron-temperature", "Electron - SEE-temperature", "Electron - Solar wind-temperature"])