def spawn(dets_p, dets_c, key_p, spawn_map, tau, update_spawn_map_flag): """Spawning of all parents on the determinant indexed by key_p.""" # Spawning. p_sign = (dets_p[key_p].value > 0) p_u_num = abs(dets_p[key_p].value) count = 0 for count in range(p_u_num): # Single or double excitation. rand_val = random.random() if rand_val < ctrl_panel.single_prob: # Single excitation. orbs_p, key_c, sign, p_gen, orbs_diff = key_ops.single_excite(key_p) p_sing_or_doub = ctrl_panel.single_prob else: # Double excitation. orbs_p, key_c, sign, p_gen, orbs_diff = key_ops.double_excite(key_p) p_sing_or_doub = 1 - ctrl_panel.single_prob mat_element = integrals.sandwich(orbs_p, orbs_diff) if not sign: # Accounts for a possible negative sign from permuting the spawned determinant. mat_element = -mat_element prob = tau * mat_element / p_gen / p_sing_or_doub # Gets the sign of children. if prob < 0: c_sign = p_sign prob = -prob else: c_sign = not p_sign c_num = int(prob) # At least we have c_num children. prob_frac = prob - c_num rand_val = random.random() if rand_val < prob_frac: # One more child. c_num += 1 if c_num != 0: # Add c_num children to the list. if not c_sign: c_num = -c_num if key_c in dets_c: dets_c[key_c].value += c_num if dets_c[key_c].value == 0: del dets_c[key_c] else: dets_c[key_c].flag = dets_p[key_p].flag else: dets_c[key_c] = det.Det(c_num, dets_p[key_p].flag) if update_spawn_map_flag: key_index_p = ctrl_panel.key_list.index(key_p) spawn_map[key_index_p][ctrl_panel.key_list.index(key_c)] += abs(c_num)
def spawn(dets_p, dets_c, key_p, tau): """Spawning of all parents on the determinant indexed by $key_p$.""" # Spawning. p_sign = (dets_p[key_p].value > 0) p_u_num = abs(dets_p[key_p].value) count = 0 for count in range(p_u_num): # Single or double excitation. rand_val = random.random() if rand_val < gl_consts.single_prob: # Single excitation. orbs_p, key_c, sign, p_gen, orbs_diff = key_ops.single_excite(key_p) p_sing_or_doub = gl_consts.single_prob else: # Double excitation. orbs_p, key_c, sign, p_gen, orbs_diff = key_ops.double_excite(key_p) p_sing_or_doub = 1 - gl_consts.single_prob mat_element = black_box.sandwich(orbs_p, orbs_diff) if not sign: # Accounts for a possible negative sign from permuting the spawned determinant. mat_element = -mat_element prob = tau * mat_element / p_gen / p_sing_or_doub # Gets the sign of children. if prob < 0: c_sign = p_sign prob = -prob else: c_sign = not p_sign c_num = int(prob) # At least we have $c_num$ children. prob_frac = prob - c_num rand_val = random.random() if rand_val < prob_frac: # One more child. c_num += 1 if c_num != 0: # Add $c_num$ children to the list. if not c_sign: c_num = -c_num if key_c in dets_c: dets_c[key_c].value += c_num if dets_c[key_c].value == 0: del dets_c[key_c] else: dets_c[key_c].flag = dets_p[key_p].flag else: dets_c[key_c] = det.Det(c_num, dets_p[key_p].flag)