Skip to content

Commit 165c7ef

Browse files
authored
added full and reduced Krylov methods
1 parent 6aa98e1 commit 165c7ef

File tree

1 file changed

+75
-5
lines changed

1 file changed

+75
-5
lines changed

scikit_tt/solvers/ode.py

+75-5
Original file line numberDiff line numberDiff line change
@@ -1167,8 +1167,6 @@ def tdvp(operator: 'TT', initial_value: 'TT', step_size: float, number_of_steps:
11671167
return solution
11681168

11691169

1170-
1171-
11721170
def __update_core_tdvp(i: int, micro_op: np.ndarray, solution: 'TT', step_size: float, direction: str):
11731171
"""
11741172
Update TT core for TDVP.
@@ -1270,10 +1268,82 @@ def __update_core_tdvp(i: int, micro_op: np.ndarray, solution: 'TT', step_size:
12701268
solution.cores[i] = expm_multiply(-1j*step_size*0.5*micro_op, solution.cores[i].flatten())
12711269
solution.cores[i] = solution.cores[i].reshape(r1, n, 1, r2)
12721270

1273-
1274-
def krylov(operator: 'TT', initial_value: 'TT', dimension: int, step_size: float, threshold: float=1e-12, max_rank: int=50, normalize: int=0) -> 'TT':
1271+
1272+
def krylov_reduced(operator: 'TT', initial_value: 'TT', dimension: int, step_size: float, threshold: float=1e-12, max_rank: int=50, normalize: int=0) -> 'TT':
1273+
"""
1274+
Krylov method with reduced orthonormalization, see [1]_.
1275+
1276+
Parameters
1277+
----------
1278+
operator : TT
1279+
TT operator
1280+
1281+
initial_value : TT
1282+
initial value for ODE
1283+
1284+
dimension: int
1285+
dimension of Krylov subspace, must be larger than 1
1286+
1287+
step_size: float
1288+
step size
1289+
1290+
threshold : float, optional
1291+
threshold for reduced SVD decompositions, default is 1e-12
1292+
1293+
max_rank : int, optional
1294+
maximum rank of the solution, default is 50
1295+
1296+
normalize : {0, 1, 2}, optional
1297+
no normalization if 0, otherwise the solution is normalized in terms of Manhattan or Euclidean norm in each step
1298+
1299+
1300+
Returns
1301+
-------
1302+
TT
1303+
approximated solution of the Schrödinger equation
1304+
1305+
References
1306+
----------
1307+
..[1] S. Paeckel, T. Köhler, A. Swoboda, S. R. Manmana, U. Schollwöck,
1308+
C. Hubig, "Time-evolution methods for matrix-product states".
1309+
Annals of Physics, 411, 167998, 2019
1310+
"""
1311+
1312+
# construct Krylov subspace basis and effective H
1313+
T = np.zeros([dimension, dimension], dtype=complex)
1314+
krylov_tensors = [initial_value]
1315+
w_tmp = operator@krylov_tensors[-1]
1316+
alpha = (w_tmp.transpose(conjugate=True)@krylov_tensors[-1])
1317+
T[0,0] = alpha
1318+
w_tmp = w_tmp - alpha*krylov_tensors[-1]
1319+
w_tmp = w_tmp.ortho(threshold=threshold, max_rank=2*max_rank)
1320+
for i in range(1,dimension):
1321+
beta = w_tmp.norm()
1322+
T[i,i-1] = beta
1323+
T[i-1,i] = beta
1324+
krylov_tensors.append((1/beta)*w_tmp)
1325+
w_tmp = operator@krylov_tensors[-1]
1326+
alpha = (w_tmp.transpose(conjugate=True)@krylov_tensors[-1])
1327+
T[i,i] = alpha
1328+
w_tmp = w_tmp - alpha*krylov_tensors[-1] - beta*krylov_tensors[-2]
1329+
w_tmp = w_tmp.ortho(threshold=threshold, max_rank=2*max_rank)
1330+
1331+
# compute time-evolved state
1332+
w_tmp = np.zeros([dimension], dtype=complex)
1333+
w_tmp[0] = 1
1334+
w_tmp = expm_multiply(-1j*T*step_size, w_tmp)
1335+
solution = w_tmp[0]*krylov_tensors[0]
1336+
for j in range(1,dimension):
1337+
solution = solution + w_tmp[j]*krylov_tensors[j]
1338+
solution = solution.ortho(threshold=threshold, max_rank=max_rank)
1339+
if normalize > 0:
1340+
solution = (1 / solution.norm(p=normalize)) * solution
1341+
return solution
1342+
1343+
1344+
def krylov_full(operator: 'TT', initial_value: 'TT', dimension: int, step_size: float, threshold: float=1e-12, max_rank: int=50, normalize: int=0) -> 'TT':
12751345
"""
1276-
Krylov method, see [1]_.
1346+
Krylov method with full orthonormalization, see [1]_.
12771347
12781348
Parameters
12791349
----------

0 commit comments

Comments
 (0)