use if False instead of commenting out code

This commit is contained in:
Jan Petykiewicz 2023-05-23 12:52:17 -07:00
parent 2a9e482e44
commit 98c973743f

View File

@ -554,7 +554,7 @@ def eigsolve(
prev_E = 0.0 prev_E = 0.0
d_scale = 1.0 d_scale = 1.0
prev_traceGtKG = 0.0 prev_traceGtKG = 0.0
#prev_theta = 0.5 prev_theta = 0.5
D = numpy.zeros(shape=y_shape, dtype=complex) D = numpy.zeros(shape=y_shape, dtype=complex)
Z: NDArray[numpy.complex128] Z: NDArray[numpy.complex128]
@ -674,7 +674,7 @@ def eigsolve(
trace = _rtrace_AtB(R, Qi) trace = _rtrace_AtB(R, Qi)
return numpy.abs(trace) return numpy.abs(trace)
''' if False:
def trace_deriv(theta): def trace_deriv(theta):
Qi = Qi_func(theta) Qi = Qi_func(theta)
c2 = numpy.cos(2 * theta) c2 = numpy.cos(2 * theta)
@ -705,8 +705,18 @@ def eigsolve(
theta = -abs(prev_theta) * numpy.sign(dE) theta = -abs(prev_theta) * numpy.sign(dE)
# theta, new_E, new_dE = linmin(theta, E, dE, 0.1, min(tolerance, 1e-6), 1e-14, 0, -numpy.sign(dE) * K_PI, trace_func) # theta, new_E, new_dE = linmin(theta, E, dE, 0.1, min(tolerance, 1e-6), 1e-14, 0, -numpy.sign(dE) * K_PI, trace_func)
theta, n, _, new_E, _, _new_dE = scipy.optimize.line_search(trace_func, trace_deriv, xk=theta, pk=numpy.ones((1,1)), gfk=dE, old_fval=E, c1=min(tolerance, 1e-6), c2=0.1, amax=pi) theta, n, _, new_E, _, _new_dE = scipy.optimize.line_search(
''' trace_func,
trace_deriv,
xk=theta,
pk=numpy.ones((1, 1)),
gfk=dE,
old_fval=E,
c1=min(tolerance, 1e-6),
c2=0.1,
amax=pi,
)
result = scipy.optimize.minimize_scalar(trace_func, bounds=(0, pi), tol=tolerance) result = scipy.optimize.minimize_scalar(trace_func, bounds=(0, pi), tol=tolerance)
new_E = result.fun new_E = result.fun
theta = result.x theta = result.x
@ -716,7 +726,7 @@ def eigsolve(
Z *= numpy.cos(theta) Z *= numpy.cos(theta)
Z += D * numpy.sin(theta) Z += D * numpy.sin(theta)
#prev_theta = theta prev_theta = theta
prev_E = E prev_E = E
if callback: if callback: