def get_text(cid): return TB.make("snd-value(text(<str>))", "Hello World, my first ToolBus tool in Python!\n")
ALL['stats'] = {'pre':'allplanes_','filee':'.stats'} ALL['qMDDmet'] = ['coMDD','CS','MDD','FT'] # ['coMDD','CS','MDD','FT'] ############## Normal ################# load_data = True #True False None save_data = True # True False BBL = {} BBL.update(ALL) BBL['desc'] = {'name':'bbl-f75-p33','comp_to':'FT','CS_niter':10,'NITER':50,'random_seed':'y'} BBL['path'] = os.path.join(dn,'data','bblM_20130104_pH6_5C_0Murea_normal','analysis_FT','int_corr_ft_method_all_awk_full') #BBL['path'] = os.path.join('/','home','tlinnet','kte','t1rho','bblM_20130104_pH6_5C_0Murea_normal','analysis_FT','int_corr_ft_method_all_awk_full') logout = os.path.join(outdir,"%s.log"%(BBL['desc']['name'])) tlog=logging.FileHandler(logout); tlog.setFormatter(logformatter); logger.addHandler(tlog); logger.setLevel(logging.INFO) if load_data==False: TB.getstat(BBL,BBL['qMDDmet']) TB.getser(BBL,BBL['qMDDmet']) #TB.plotstats([BBL],BBL['qMDDmet']) TB.sortInt(BBL,BBL['qMDDmet']) #l = range(2,10,2); BBL['NIarr']['CS'] = l[::-1]; BBL['NIarr']['MDD'] = l[::-1]; BBL['NIarr']['FT'] = l[::-1] TB.getdecay(BBL,BBL['qMDDmet']) #TB.plotdecays([BBL],BBL['qMDDmet'],peaks=[3],fss=range(0,5,5)) TB.getrates(BBL,BBL['qMDDmet']) #TB.plotrates([BBL],BBL['qMDDmet'], peaks=[1,2,3,4]) psel = [3, 5, 6, 7, 8, 9, 11, 14, 15, 16, 18, 19, 21, 23, 24, 26, 27, 28, 30, 31, 32, 33] TB.getglobfit(BBL,BBL['qMDDmet'],psel) #TB.plot_kEX([BBL],BBL['qMDDmet']) TB.get_glob_props(BBL,BBL['qMDDmet']) #TB.plot_glob_props([BBL],['coMDD','CS'])
# hello.py -- hello tool in Python import TB import sys import __main__ # Don't forget this one! def rec_terminate(cid, A): sys.exit(0) def get_text(cid): return TB.make("snd-value(text(<str>))", "Hello World, my first ToolBus tool in Python!\n") cid = TB.parseArgs(sys.argv, __main__) TB.connect(cid) TB.eventloop()
def mag_corr_loop(U_array, J_array, dJ_array, jobdef, jobdef_file, model, temp_modelfile, orb_type, number_decimals): """ Function mag_corr_loop is designed to run over the U, J and dJ values to fill up the mag_corr dictionary. INPUTS TYPE DESCRIPTION U_array nparray All the U values in a numpy array. J_array nparray All the J values in a numpy array. dJ_array nparray All the dJ values in a numpy array. jobdef dict The dictionary that defines the tight binding job to be run. jobdef_file str The name of the jobdef file. model dict The dictionary that contains the model system for the tight binding job to be run. temp_modelfile str The name of the model file. orb_type str On-site orbital symmetry. either s, p or d. number_decimals int The number of decimal places to report values of U, J and dJ. OUTPUTS TYPE DESCRIPTION SuccessFlag bool If all the tight binding simulations are successful then this is returned as True, if any are not successful the loop is exited and this is returned as False. mag_corr dict A dictionary containing value of the magnetic correlation at each value of U, J and dJ. """ # initialise the mag_corr dictionary mag_corr = {} SuccessFlag = True for U in U_array: for J in J_array: print "U = ", U, "\t J = ", J for dJ in dJ_array: # if J > U: # mag_corr[U, J, dJ] = 0.0 # else: model['species'][0]["U"] = round(U, number_decimals) if orb_type == "p": model['species'][0]["I"] = round(J, number_decimals) elif orb_type == "d": model['species'][0]["I"] = round(J, number_decimals) model['species'][0]["dJ"] = round(dJ, number_decimals) # write out the new modelfile with open(temp_modelfile, 'w') as f: commentjson.dump(model, f, sort_keys=True, indent=4, separators=(',', ': ')) try: SCFflag, mag_corr[round(U, number_decimals), round(J, number_decimals), round(dJ, number_decimals)] = TB.main() # if we end up with a linear algebra error then we can re-run with a different optimisation scheme. except numpy.linalg.linalg.LinAlgError: # store original optimisation routine choice old_routine = jobdef['optimisation_routine'] if old_routine == 1: # then set it to routine 2 jobdef['optimisation_routine'] = 2 else: # then set it to routine 1 jobdef['optimisation_routine'] = 1 # write jobdef back to file with open(jobdef_file, 'w') as f: commentjson.dump(jobdef, f, sort_keys=True, indent=4, separators=(',', ': ')) # and run again print("SCF did not converge. Re-running simulation with different optimisation routine. ") SCFflag, mag_corr[round(U, number_decimals), round(J, number_decimals), round(dJ, number_decimals)] = TB.main() # reset optimisation routine jobdef['optimisation_routine'] = old_routine # write jobdef back to file with open(jobdef_file, 'w') as f: commentjson.dump(jobdef, f, sort_keys=True, indent=4, separators=(',', ': ')) # If the SCF has converged then we can trust the result if SCFflag == True: pass # If the SCF flag is False and this was an SCF calculation then rerun elif jobdef["scf_on"] == 1: # Use a smaller value of A (divide by 10) jobdef["A"] = jobdef["A"]/10.0 # Increase number of steps by a factor of 10 jobdef["scf_max_loops"] = int(jobdef["scf_max_loops"]*10) # write jobdef back to file with open(jobdef_file, 'w') as f: commentjson.dump(jobdef, f, sort_keys=True, indent=4, separators=(',', ': ')) # and run again print("SCF did not converge. Re-running simulation with smaller mixing value. ") SCFflag, mag_corr[round(U, number_decimals), round(J, number_decimals), round(dJ, number_decimals)] = TB.main() # Re-set the jobdef variables: jobdef["A"] = jobdef["A"]*10.0 jobdef["scf_max_loops"] = int(jobdef["scf_max_loops"]/10) with open(jobdef_file, 'w') as f: commentjson.dump(jobdef, f, sort_keys=True, indent=4, separators=(',', ': ')) # If that still hasn't worked, exit gracefully... if SCFflag == False: SuccessFlag = False print "SCF did not converge for U = ", round(U, number_decimals), "; J = ", round(J, number_decimals), "; dJ = ", round(dJ, number_decimals) print "Exiting." return SuccessFlag, mag_corr return SuccessFlag, mag_corr
from scipy import * from scipy import integrate import TB W=2.0 rom=201 nom=6000 T=0.01 t = 1. tp = 0. e0 = 0. mu = 0. nk = 300 ndos = 101 SL = TB.square_lattice(nk,mu,hopping=(t,tp,e0)) SL.Create_irr_klist() SL.Fourier_Transform() SL.Compute_eigvals() ommesh, DOS = TB.Compute_DOS(ndos,SL.eigvals,SL.wklist) iom=(2*arange(nom)+1)*pi*T Delta=zeros(nom,dtype=complex) for i in range(nom): denom=iom[i]**2+(mu-ommesh)**2 Del_re=DOS*(mu-ommesh)/denom Del_im=DOS*iom[i]/denom Delta[i]=integrate.simps(Del_re,ommesh)-1j*integrate.simps(Del_im,ommesh) with open('Delta.inp', 'w') as f: