def test_latitude(): tol = 1e-5 lt = np.linspace(start=0, stop=24, num=2, endpoint=False) ds1 = ds.driftShell(local_times=lt, start_line=[6.6, 0.0, 0.0], K=0, mode='analytic_K', error_tol=tol) phi = ds1.get_phi_locations() RE = [] for key in phi: RE = ih.mag(phi[key]) lat = ih.rad_to_deg(ih.get_lat(phi[key])) print "RE: {}".format(RE) print "lat: {}".format(lat)
test_points_b.append(pv.Sphere()) test_points_b[-1].Radius = 0.05 test_points_b[-1].Center = flines[start_p].fieldLinePoints_b[( n * num_divs)] test_disp_b.append(pv.Show(test_points_b[-1], rvs)) test_disp_b[-1].DiffuseColor = [0.1, 0.1, 0.9] test_points_f.append(pv.Sphere()) test_points_f[-1].Radius = 0.05 test_points_f[-1].Center = flines[start_p].fieldLinePoints_f[( n * num_divs)] test_disp_f.append(pv.Show(test_points_f[-1], rvs)) test_disp_f[-1].DiffuseColor = [0.9, 0.1, 0.1] test_contour_list.append( ih.mag(flines[start_p].fieldLineData_f[(n * num_divs)])) contours[start_p] = test_contour_list contsphere_b[start_p] = test_points_b contsphere_f[start_p] = test_points_f min_sphr[start_p] = pv.Sphere() min_sphr[start_p].Radius = 0.06 min_sphr[start_p].Center = Bmin_loc min_sphr_disp[start_p] = pv.Show(min_sphr[start_p], rvs) min_sphr_disp[start_p].DiffuseColor = [0.0, 0.0, 0.0] Bmag_calc = pv.Calculator(Input=t96_128) Bmag_calc.ResultArrayName = 'Bmag' Bmag_calc.Function = 'mag(B)' Bmag_slice = pv.Slice(Input=Bmag_calc)
z_f = [a[2] for a in fl1.fieldLinePoints_f] x_b = [a[0] for a in fl1.fieldLinePoints_b] y_b = [a[1] for a in fl1.fieldLinePoints_b] z_b = [a[2] for a in fl1.fieldLinePoints_b] print "B(K=0): {} nT".format(fl1.get_B_mirror_for_K(K=0)) divs = 1000 calcTimes = np.linspace(0, 24, num=4, endpoint=False) ds1 = ds.driftShell(local_times=calcTimes, start_line=[2.5, 0.0, 0.0], K=0, mode='analytic_K') ideal_RE = ih.mag(ds1.field_lines[0].fieldLinePoints_f[0]) print "Ideal L*: {}".format(ideal_RE) test_grids = np.arange(start=100, stop=100, step=50, dtype=np.int) L_star = ds1.calculate_L_star(RE=1.0, lat_divs=divs, lon_divs=divs) diff = ideal_RE - L_star error = np.abs(diff / ideal_RE * 100) print "L*: {}".format(L_star) print "diff: {}".format(diff) print "% Error: {}".format(error) # mlab.plot3d(x_f, y_f, z_f) # mlab.plot3d(x_b, y_b, z_b) # # mlab.show()
plot_data = col.OrderedDict() for grid_file in grid_files: data = pv.OpenDataFile("../out/fields/{}".format(grid_file)) jobs = len(start_location) print "Looking for Drift Shell at: {} RE".format(start_location[rank]) # drift_shell = ds.driftShell(PV_dataObject=data, local_times=calcTimes, start_line=(start_location[rank],0,0), K=0, mode='location_k') drift_shell = ds.driftShell(local_times=calcTimes, start_line=(start_location[rank], 0, 0), K=0, mode='analytic_K') ideal_RE = ih.mag(drift_shell.field_lines[0].fieldLinePoints_f[0]) print "[{}] Ideal L*: {}".format(rank, ideal_RE) RE_el = 1.0 test_grids = np.arange(start=50, stop=600, step=50, dtype=np.int) # Output to file # fileName = "out/error_analysis/{}_lines/l_star_error_analysis_{}_RE_{}_tab.txt".format(lines, grid_file, start_location[rank]) fileName = "out/error_analysis/{}_lines/l_star_error_analysis_{}_RE_{}_analytic_tab.txt".format( lines, grid_file, start_location[rank]) f = open(fileName, 'w') f.write("# Error Analysis Data for RE = {}\n".format( start_location[rank])) f.write("# Author: Joshua Murphy\n")
test_disp_b = [] test_disp_f = [] for n in range(int(len(fline.fieldLinePoints_f)/10)): test_points_b.append(pv.Sphere()) test_points_b[-1].Radius = 0.20 test_points_b[-1].Center = fline.fieldLinePoints_b[(n * 10)] test_disp_b.append(pv.Show(test_points_b[-1], rv)) test_disp_b[-1].DiffuseColor = [0.1, 0.1, 0.9] test_points_f.append(pv.Sphere()) test_points_f[-1].Radius = 0.20 test_points_f[-1].Center = fline.fieldLinePoints_f[(n * 10)] test_disp_f.append(pv.Show(test_points_f[-1], rv)) test_disp_f[-1].DiffuseColor = [0.9, 0.1, 0.1] test_contour_list.append(ih.mag(fline.fieldLineData_f[(n*10)])) # min point test_points_m = pv.Sphere() test_points_m.Radius = 0.25 test_points_m.Center = fline.fieldLinePoints_b[0] test_disp_m = pv.Show(test_points_m, rv) test_disp_m.DiffuseColor = [0, 0, 0] Bmag_contour.Isosurfaces = test_contour_list contour_disp = pv.Show(Bmag_contour, rv) contour_disp.DiffuseColor = [0.0, 0.0, 0.0] rv.Background = [1.0, 1.0, 1.0]
L_Text.Text = "$L^*=$ " + str(L_100) Ldisp = pv.Show(L_Text, rvs4) Ldisp.WindowLocation = 'LowerCenter' for key in t96_K0_ds.field_lines: if t96_K0_ds.field_lines[key] is None: continue forward = pv.Show(t96_K0_ds.field_lines[key].fieldLineObj_f, rvs4) backward = pv.Show(t96_K0_ds.field_lines[key].fieldLineObj_b, rvs4) forward.DiffuseColor = [1, 0.0, 0.0] forward.LineWidth = 2.0 backward.DiffuseColor = [1, 0.0, 0.0] backward.LineWidth = 2.0 eqc = ih.mag(t96_K0_ds.field_lines[0.0].fieldLinePoints_f[0]) print "Equatorial Crossing of Drift Shell: ", eqc print "L* (500): ", L_500 print "L* (100): ", L_100 print "L* (50): ", L_50 print "L* (25): ", L_25 print "L* (10): ", L_10 print print "Error: " print "-------" print "div=10: ", (eqc - L_10) / eqc * 100, "%" print "div=25: ", (eqc - L_25) / eqc * 100, "%" print "div=50: ", (eqc - L_50) / eqc * 100, "%" print "div=100: ", (eqc - L_100) / eqc * 100, "%" print "div=500: ", (eqc - L_500) / eqc * 100, "%"