Definition at line 129 of file numerov_solve.py. 00129 : 00130 results=[] 00131 if state_separation_estimate is None: 00132 state_separation_estimate=ground_state_estimate 00133 #prime the bookkeeping to guess where next state lies and make it point to ground_state_estimate 00134 e0, e1= ground_state_estimate-2*state_separation_estimate, ground_state_estimate-state_separation_estimate 00135 for i in range(levels): 00136 if trace: print '***', i, e0, e1 00137 delta_e=(e1-e0)/subdivide 00138 if i & 1: 00139 parity=-1 00140 else: 00141 parity=1 00142 try: 00143 firstguess=e1+(e1-e0)*0.5 #1/2 to next estimated level 00144 psi, slope=single_well_numerov_match(V0-firstguess, dx, parity) #initial slope 00145 for s in range(1,10*subdivide): 00146 00147 e_test=firstguess+delta_e 00148 psi, test_slope=single_well_numerov_match(V0-e_test, dx, parity) #initial slope 00149 if trace: 00150 print "%4d %4d %8.2e %8.2e %8.2e %8.2e" % (i, s, firstguess, slope, e_test, test_slope) 00151 if test_slope==0.0 or test_slope*slope < 0.0: #got a sign change 00152 break 00153 if s==(10*subdivide-1): 00154 assert 0,"No root found" #bail out completely 00155 firstguess=e_test 00156 slope=test_slope 00157 e_n, psi_n=single_well_numerov_solve(V0, dx, parity, e1+(s-1)*delta_e, e_test) #must bracket root 00158 results.append((i,e_n, psi_n)) 00159 e0, e1=e1, e_n #use last two energies to estimate search size 00160 except: 00161 print sys.exc_value 00162 break #stop if we can't find a level! 00163 return results 00164 00165 if __name__=='__main__':
|