From 8bc4ab04fdd13b8a91a0a02aacfdf5310088e6fa Mon Sep 17 00:00:00 2001 From: imppresser <503731351@qq.com> Date: Wed, 8 Dec 2021 17:23:10 +0800 Subject: [PATCH] Update trotter.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1维海森堡哈密顿量构建,周期性边界的相互作用系数由1更改为interaction_strength[interaction_idx] --- paddle_quantum/trotter.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/paddle_quantum/trotter.py b/paddle_quantum/trotter.py index 2220d78..39bb51d 100644 --- a/paddle_quantum/trotter.py +++ b/paddle_quantum/trotter.py @@ -588,13 +588,14 @@ def get_1d_heisenberg_hamiltonian( # add interactions on (0, n) for closed periodic boundary condition if periodic_boundary_condition: boundary_sites = [0, length - 1] - for interaction in interactions: + for interaction_idx in range(len(interactions)): term_str = '' + interaction = interactions[interaction_idx] for idx_word in range(len(interaction)): term_str += interaction[idx_word] + str(boundary_sites[idx_word]) if idx_word != len(interaction) - 1: term_str += ', ' - pauli_str.append([1, term_str]) + pauli_str.append([interaction_strength[interaction_idx], term_str]) # add magnetic field, if h_z is a single value, then add a uniform field on each site if isinstance(h_z, np.ndarray) or isinstance(h_z, list) or isinstance(h_z, tuple):