Created
September 28, 2015 20:05
-
-
Save leelasd/25ec255539335c61938d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################ | |
def Sim_Anneal(ps,const): | |
T=8.00 | |
delta = 0.05 | |
nmoves=10 | |
while (T > 5e-2): | |
accept=0 | |
reject=0 | |
Beta=(1.0/T) | |
for i in range(0,nmoves): | |
old_ene = Goodness_of_Fit(ps) | |
pick=randint(0,len(ps)-1) | |
old = ps[pick] | |
ps[pick] = old*(1+randrange(-1,2,2)*delta)*const[pick] | |
new_ene = Goodness_of_Fit(ps) | |
boltz = exp(-(new_ene-old_ene) *Beta) | |
charge = np.sum([ps[3*i] for i in range(len(ps)/3)]) | |
# if (boltz>uniform(0,1) or new_ene < old_ene): | |
# if ( new_ene < old_ene and abs(charge) < 1e-3): | |
if ( new_ene < old_ene): | |
accept=accept+1 | |
else: | |
reject=reject+1 | |
ps[pick]=old | |
new_ene = Goodness_of_Fit(ps) | |
print("TOTAL= %5d ACCEPTED= %5d REJECTED= %5d" %(nmoves,accept,reject)) | |
print("T = %5.5f and Chisq = %5.5f and Charge =%3.3f" %(T,new_ene,charge)) | |
T=T*0.9 | |
return new_ene,ps | |
fene,fpars=Sim_Anneal(INP_pars,DEL_List) | |
print len(fpars) | |
################################################ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment