def copy_mpp(args): out = outdir_path_helper(args.out) df = read_xcsv(args.jv, read_csv_kwargs=dict(index_col=0))[0] df.index.name = 'index' df['P'] = -df.j_tot_nc * df.V df = df[df.concentration_factor > 0] df_mpp = df.sort_values('P', ascending=False).drop_duplicates(CASE_KEYS) df_jsc = df[df.V.abs() < 1e-10].drop_duplicates(CASE_KEYS) # df1 = df1.sort_values('index') df1 = pd.concat([df_mpp, df_jsc]) for index, row in df1.iterrows(): filename = row['filename'] base = osp.dirname(filename) for oldname in [ filename, filename.rpartition('.plot_meta.yaml')[0] + '.csv.0', osp.join(base, 'submit.yaml') ]: newname = osp.join(out, oldname) mkdirp(osp.dirname(newname)) print(oldname, newname) shutil.copyfile(oldname, newname) to_xcsv(df_mpp, out + "JV_mpp.csv") to_xcsv(df1, out + "JV_mpp_and_jsc.csv")
def plot_jv_old(args): savefig = args.matplotlib_savefig out = outdir_path_helper(args.out) df = read_xcsv(args.jv)[0] df = df[df['IB_sigma_ci'] == 1e-12] mus = list(df['IB_mobility'].unique()) mus.sort(key=float) fig, ax = plt.subplots() j_min = 0 for mu in mus: df2 = df[((df['IB_mobility'] == mu) & (df['concentration_factor'] == 1e3))] j = df2['j_tot_nc'] / df2['concentration_factor'] j_min = min(j_min, j.min()) ax.plot(df2['V'], j, label=r"$\mu={}$".format(mu), marker='.') ax.set_xlabel(r'applied bias ($\mathrm{V}$)') ax.set_ylabel(r'$J_{\mathrm{tot}} / X$ ($\mathrm{mA/cm^2}$)') #ax.set_ylim([j_min*1.05, 0]) ax.set_ylim([-55, -48]) ax.legend() fig.tight_layout() savefig(fig, out + 'JV mus')
def plot_detail_j(args): savefig = args.matplotlib_savefig out = outdir_path_helper(args.out) spdir = args.spatial_input_dir SILLY = args.silly jv = read_xcsv(args.jv_mpp)[0] fig = plt.figure(figsize=(4.8, 6.4), dpi=100) gs0 = GridSpec(ncols=1, nrows=2, figure=fig, left=0.18, right=0.95, top=0.97, bottom=0.10, wspace=0.00, hspace=0.25, height_ratios=[1, 1]) ax0 = fig.add_subplot(gs0[0, 0]) ax1 = fig.add_subplot(gs0[1, 0]) sigma_ci_to_ls = { 2e-13: 'solid', 1e-12: 'dashed', } mu_to_color = {0.001: COLOR['blue'], 30.0: COLOR['red']} jv1 = jv.query("(IB_sigma_ci == 2e-13) &" "(IB_mobility == 100.0)") assert len(jv1.index) == 1 df = common_load_spatial_data(spdir, jv1['filename'].iloc[0]) df_add_drift_diffusion_terms(df) ax = ax0 plot_detail_j_subplot( locals(), ax=ax0, concentration_factor=jv1['concentration_factor'].iloc[0]) ax = ax1 jv["j_IB_max_abs"] = jv["filename"].apply( partial(extract_max_abs_IB_current, spdir)) for sigma_ci in [2e-13, 1e-12]: jv1 = jv[jv.IB_sigma_ci == sigma_ci] jv1 = jv1.sort_values("IB_mobility") ax.plot(jv1.IB_mobility, jv1.j_IB_max_abs / jv1.concentration_factor, color='black', label=SIGMA_CI_TO_LABEL[sigma_ci], linestyle=SIGMA_CI_TO_LS[sigma_ci], marker=SIGMA_CI_TO_MARKER[sigma_ci]) ax.set_ylim([0, 10.3]) ax.set_xlabel(r'IB mobility ($\mathrm{cm^2/V/s}$)') ax.set_ylabel(r'$\max(|j_{I}| / X)$ ($\mathrm{cm^2/V/s}$)') ax.set_xscale('log') ax.legend() to_xcsv(jv, out + "marti02_final_Jdd_maxIB.csv") savefig(fig, out + 'marti02_final_Jdd')
def plot_fs(args): savefig = args.matplotlib_savefig out = outdir_path_helper(args.out) spdir = args.spatial_input_dir SILLY = args.silly jv = read_xcsv(args.jv_mpp)[0] fig = plt.figure(figsize=(4.8, 3.6), dpi=100) gs0 = GridSpec(ncols=1, nrows=1, figure=fig, left=0.18, right=0.95, top=0.97, bottom=0.16, wspace=0.00, hspace=0.00, height_ratios=[1]) ax0 = fig.add_subplot(gs0[0, 0]) sigma_ci_to_ls = { 2e-13: 'solid', 1e-12: 'dashed', } mu_to_color = {0.001: COLOR['blue'], 30.0: COLOR['red']} ax = ax0 for sigma_ci in [2e-13, 1e-12]: jv1 = jv[jv.IB_sigma_ci == sigma_ci] jv1 = jv1.sort_values('IB_mobility', ascending=False) # if not SILLY: # jv1 = jv1[jv1.IB_mobility.isin([0.001, 30])] ls = sigma_ci_to_ls[sigma_ci] # position doesn't matter, will be manually adjusted in inkscape ax.text( 0.07, 0.93, SIGMA_CI_TO_LABEL[sigma_ci], horizontalalignment='left', verticalalignment='top', transform=ax.transAxes, # fontsize='small' ) for index, row in jv1.iterrows(): try: color = mu_to_color[row['IB_mobility']] except KeyError: continue df = common_load_spatial_data(spdir, row['filename']) df = extract_IB_region_only(df) df = df[df.x.between(200, 1000)] # Jacob request; was (250, 1000) ax.plot(df['x'], df['f_IB'], color=color, linestyle=ls, label='_nolegend_') if sigma_ci == 2e-13: mu_label = (r'$\mu_{{I}} = {:.7g}' '\;\mathrm{{cm^2/V/s}}$'.format( row['IB_mobility'])) ax.plot([], [], label=mu_label, color=color) # ax.plot([], [], linestyle=ls, color='black', # label=SIGMA_CI_TO_LABEL[sigma_ci]) if not SILLY: ax.legend() ax.set_ylabel(r'IB filling fraction') ax.set_xlim([200, 1000]) ax.set_ylim([0.23, 0.56]) ax.set_xlabel(r"position ($\mathrm{nm}$)") savefig(fig, out + 'marti02_final_f_IB')
def plot_bands(args): savefig = args.matplotlib_savefig out = outdir_path_helper(args.out) spdir = args.spatial_input_dir # python3 -m ecd_thesis2018.marti2002_plot plot-bands --usetex --out out.marti2002_plot/ --jv out.marti2002_plot_datafiles/JV_mpp_and_jsc.csv --spatial-input-dir out.marti2002_plot_datafiles/ # thesis2018=d0332dc0382ea2b5cd609c931e7b7970c218bd29 # simudo=682f18db136c86b6342e6fbbd2ff7a4df3ea67c1 jv = read_xcsv(args.jv)[0] jv = jv[jv.V.abs() < 1e-10] # short circuit fig = plt.figure(figsize=(4.8, 2.6), dpi=100) gs0 = GridSpec(ncols=1, nrows=1, figure=fig, left=0.14, right=0.95, top=0.97, bottom=0.22, wspace=0.00, hspace=0.00, height_ratios=[1]) ax0 = fig.add_subplot(gs0[0, 0]) jv1 = jv[(jv.IB_sigma_ci == 1e-12) & (jv['IB_mobility'] == 10.0)] (_, row), = list(jv1.iterrows()) df = common_load_spatial_data(spdir, row['filename']) print(row['filename']) df_mask_IB(df) XS = 1e-3 ax = ax0 for band_name, band in BANDS.items(): ax.plot(df['x'] * XS, df['Ephi_' + band_name], label='_nolegend_', color=band['color'], alpha=0.5) ax.text(0.5, 0.5, r"$\mathcal{{E}}_{}$".format(band['sym']), color='black') # as my soul for band_name, band in BANDS.items(): ax.plot(df['x'] * XS, df['qfl_' + band_name], label='$w_{{{}}}$'.format(band['sym']), color=band['color'], linestyle='dashed') ax.text(0.5, 0.5, "$w_{}$".format(band['sym']), color=band['color']) # print(df['qfl_VB']) ax.set_xlabel(r'position ($\mathrm{\mu m}$)') ax.set_ylabel(r'Energy ($\mathrm{eV}$)') ax.set_xlim(np.array([0 - 10, (df['x'].max() + 10)]) * XS) ax.set_ylim([-1.63, 1.76]) # ax.legend() # fig.tight_layout() savefig(fig, out + 'marti02_final_bands')
def plot_jv(args): savefig = args.matplotlib_savefig out = outdir_path_helper(args.out) df = read_xcsv(args.jv)[0] fig = plt.figure(figsize=(4.8, 6.4), dpi=100) gs0 = GridSpec(ncols=1, nrows=2, figure=fig, left=0.2, right=0.95, top=0.97, bottom=0.1, wspace=0.00, hspace=0.25, height_ratios=[1, 1]) ax0 = fig.add_subplot(gs0[0, 0]) ax1 = fig.add_subplot(gs0[1, 0]) def _ll(ax, *args, **kwargs): ax.plot([], [], *args, **kwargs) sigma_ci_to_ls = SIGMA_CI_TO_LS sigma_ci_to_label = SIGMA_CI_TO_LABEL ax = ax0 for sigma_ci, mu in itertools.product([2e-13, 1e-12], [0.001, 300.0]): df1 = df[(df.IB_mobility == mu) & (df.IB_sigma_ci == sigma_ci) & (df.concentration_factor > 0)] color = COLOR['red' if mu == 300.0 else 'blue'] ls = sigma_ci_to_ls[sigma_ci] j = df1['j_tot_nc'] / df1['concentration_factor'] ax.plot(df1.V, j, color=color, linestyle=ls, label='_nolegend_' # label="${}$ ${}$".format(sigma_ci, mu) ) # by Jacob's request # _ll(ax, color='black', linestyle='solid', # label=sigma_ci_to_label[2e-13]) # _ll(ax, color='black', linestyle='dotted', # label=sigma_ci_to_label[1e-12]) _ll(ax, color=COLOR['red'], label=r'$\mu_{I} = 300\;\mathrm{cm^2/V/s}$') _ll(ax, color=COLOR['blue'], label=r'$\mu_{I} = 0.001\;\mathrm{cm^2/V/s}$') ax.set_ylim([-55, -48.5]) ax.set_xlim([0, 1.35]) ax.legend() ax.set_xlabel(r'applied bias ($\mathrm{V}$)') ax.set_ylabel(r'$J_{\mathrm{tot}} / X$ ($\mathrm{mA/cm^2}$)') ax = ax1 df1 = df[(df.V == 0.0) & (df.concentration_factor > 0)] # mus = list(sorted(df['IB_mobility'].unique())) for sigma_ci in [2e-13, 1e-12]: df2 = df1[df1['IB_sigma_ci'] == sigma_ci] df2 = df2.sort_values('IB_mobility') j = df2['j_tot_nc'] / df2['concentration_factor'] ls = sigma_ci_to_ls[sigma_ci] ax.plot(df2.IB_mobility, j, linestyle=ls, color='black', label=sigma_ci_to_label[sigma_ci], marker=SIGMA_CI_TO_MARKER[sigma_ci]) # ax.set_xlim([1e-3, 300]) ax.set_ylim([-54.5, -53]) ax.set_xscale('log') ax.legend() ax.yaxis.set_major_locator(MultipleLocator(0.5)) ax.set_xlabel(r'IB mobility ($\mathrm{cm^2/V/s}$)') ax.set_ylabel(r'$J_{SC} / X$ ($\mathrm{mA/cm^2}$)') savefig(fig, out + 'marti02_final_JVs')