workpath = './' allfile = os.listdir(workpath) for files in allfile: filepath = "./" + files if os.path.isdir(filepath): material = files.split('_')[2] # get material name by split dir name effmass_path = filepath + "/02_calc_q_ZPR/q1/mode0" data = inputs.DataAims(effmass_path) segments = extrema.generate_segments(settings, data) outputs.plot_segments(data, settings, segments) table = outputs.make_table(segments, which_values) outputs.print_terminal_table(table) # file.write(segment) # file.write('\n') cbm_index = segments[-1].band # calculate effective mass at Gamma Point # in order to specify the k-position of effmass(such as Gamma point), we need to set argument 'bk' # such as bk=[[4, 0],[4, 100],[4, 200]] at 'extrema.generate_segments()' # Here I write a loop to generate this bk array vbm_index = cbm_index - 1 k_point = 0 # Gamma-point seg_position = [] # array of one single segment e.g. [4, 0] all_segs = [] # array of all segments e.g. [[4, 0],[4, 100],[4, 200]] for i in range(3):
def test_plot_segments(data_object, settings_object, segment_object): fig, ax = outputs.plot_segments(data_object, settings_object, [segment_object]) assert type(fig) == matplotlib.figure.Figure
def cli(): print("Welcome to effmass 2.0.0 \U0001F388") ignore, seedname, fermi_level = None, None, None random_int = randint(10000, 99999) DFT_code = questionary.select( "Which DFT code have you used to generate the bandstructure?", choices=['Vasp', 'FHI-aims', 'Castep']).ask() pathname = questionary.path( "What's the path to your {} output files?".format(DFT_code), default="./", only_directories=True).ask() if DFT_code == 'Vasp': ignore = questionary.text( "How many k-points should I ignore at the start of the file? (useful for hybrid calculations)", default="0").ask() if DFT_code == 'Castep': seedname = questionary.text( "What's the seedname of your Castep files? (e.g. Si.bands and Si.castep have the seedname Si)", ).ask() fermi_level = questionary.text( "I will infer the position of the CBM and VBM from the calculated Fermi level." + " If you know this value to be incorrect, please input a more accurate value:", ).ask() extrema_search_depth = questionary.text( "How far (in eV) from the CBM (VBM) would you like me to search for minima (maxima)?", default="0.05").ask() energy_range = questionary.text( "What would you like the energy range (in eV) of each segment to be?", default="0.5").ask() which_values = questionary.checkbox( "Which values would you like me to calculate?", choices=[ questionary.Choice("parabolic m* (least squares)", checked=True), questionary.Choice("parabolic m* (finite difference)", checked=True) ]).ask() # need to select oe save_plot = questionary.confirm( "Would you like me to save a plot of the band segments?", default=True, auto_enter=False).ask() save_summary = questionary.confirm( "Would you like me to save a summary file?", default=True, auto_enter=False).ask() settings = inputs.Settings( extrema_search_depth=float(extrema_search_depth), energy_range=float(energy_range)) print("Reading in data...") if DFT_code == "Vasp": data = inputs.DataVasp(pathname + "/OUTCAR", pathname + "/PROCAR", ignore=int(ignore)) elif DFT_code == "FHI-aims": data = inputs.DataAims(pathname) else: data = inputs.DataCastep(pathname + "/", seedname) if fermi_level: data.fermi_level = fermi_level data.find_cbm_vbm() print("Finding extrema...") print("Generating segments...") segments = extrema.generate_segments(settings, data) print("Calculating effective masses...") table = outputs.make_table(segments, which_values) outputs.print_terminal_table(table) if save_plot: print("Plotting segments...") outputs.plot_segments(data, settings, segments, savefig=True, random_int=random_int) print("Plot of segments saved to effmass_{}.png".format(random_int)) if save_summary: print("Writing summary file...") outputs.print_summary_file(random_int, DFT_code, pathname, ignore, seedname, fermi_level, extrema_search_depth, energy_range, table) print("Summary file saved as effmass_{}.txt".format(random_int))
from effmass import inputs, analysis, extrema, outputs, dos, ev_to_hartree #random_int= randint(10000,99999) random_int = 'VBCB' file=open("effmass_data.txt",'a') settings = inputs.Settings(extrema_search_depth=0.03, energy_range=0.3) which_values = ["parabolic m* (least squares)","parabolic m* (finite difference)"] data = inputs.DataAims("./mode0") #use .format() can add variable in string segments = extrema.generate_segments(settings,data) outputs.plot_segments(data,settings,segments) table=outputs.make_table(segments,which_values) outputs.print_terminal_table(table) file.write(table.get_string()) file.write('\n') #print(segments[-1].band) cbm_index = segments[-1].band ''' Here I use band index to determine CBM and VBM. Band index stored in function: segments.band Here I choose the last band in segment (e.i. segments[-1]), it's index should be CBM Then I write the loop below to select VBM and CBM from all segments. 'cbm_index - 1' is obviously VBM '''