|
| 1 | +# Copyright 2020 The TEMPO Collaboration |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +""" |
| 15 | +Tests for the time_evovling_mpo.backends.tensor_network modules. |
| 16 | +""" |
| 17 | +import sys |
| 18 | +sys.path.insert(0,'.') |
| 19 | + |
| 20 | +import pytest |
| 21 | +import numpy as np |
| 22 | + |
| 23 | +import oqupy |
| 24 | + |
| 25 | +# ----------------------------------------------------------------------------- |
| 26 | +# -- Test F: Test Lindblad dissipation for PT-TEBD --------------------------- |
| 27 | + |
| 28 | +# --- Parameters -------------------------------------------------------------- |
| 29 | + |
| 30 | +# -- time steps -- |
| 31 | +dt = 0.1 |
| 32 | +num_steps = 10 |
| 33 | + |
| 34 | +# -- bath -- |
| 35 | +alpha = 0.3 |
| 36 | +omega_cutoff = 3.0 |
| 37 | +temperature = 0.8 |
| 38 | +pt_dkmax = 10 |
| 39 | +pt_epsrel = 1.0e-6 |
| 40 | + |
| 41 | +# -- chain -- |
| 42 | +N = 5 |
| 43 | +Omega = 1.0 |
| 44 | +eta = 0.3 |
| 45 | +Delta = 1.2 |
| 46 | +h = np.array( |
| 47 | + [[1.0, 0.0, 0.0], |
| 48 | + [2.0, 0.0, 0.0], |
| 49 | + [3.0, 0.0, 0.0], |
| 50 | + [4.0, 0.0, 0.0], |
| 51 | + [5.0, 0.0, 0.0]]) * np.pi / 10 |
| 52 | +J = np.array([[Delta, 1.0+eta, 1.0-eta]]*(N-1)) |
| 53 | +up_dm = oqupy.operators.spin_dm("z+") |
| 54 | +down_dm = oqupy.operators.spin_dm("z-") |
| 55 | +tebd_order = 2 |
| 56 | +tebd_epsrel = 1.0e-7 |
| 57 | + |
| 58 | + |
| 59 | +def test_pt_tebd_site_dissipation_H1(): |
| 60 | + # -- initial state -- |
| 61 | + initial_augmented_mps = oqupy.AugmentedMPS([up_dm, down_dm, down_dm]) |
| 62 | + |
| 63 | + # -- add single site dissipation -- |
| 64 | + system_chain = oqupy.SystemChain(hilbert_space_dimensions=[2,2,2]) |
| 65 | + # lowering operator on site 0: |
| 66 | + system_chain.add_site_dissipation(0,[[0,0],[1,0]]) |
| 67 | + # identity cross raising operator on sites 1 and 2: |
| 68 | + system_chain.add_nn_dissipation(1,np.identity(2),[[0,1],[0,0]]) |
| 69 | + |
| 70 | + # -- PT-TEBD parameters -- |
| 71 | + pt_tebd_params = oqupy.PtTebdParameters( |
| 72 | + dt=dt, |
| 73 | + order=tebd_order, |
| 74 | + epsrel=tebd_epsrel) |
| 75 | + |
| 76 | + num_steps = int(1.0/pt_tebd_params.dt) |
| 77 | + |
| 78 | + pt_tebd = oqupy.PtTebd( |
| 79 | + initial_augmented_mps=initial_augmented_mps, |
| 80 | + system_chain=system_chain, |
| 81 | + process_tensors=[None]*3, |
| 82 | + parameters=pt_tebd_params, |
| 83 | + dynamics_sites=[0,1,2], |
| 84 | + chain_control=None) |
| 85 | + |
| 86 | + r = pt_tebd.compute(num_steps, progress_type="silent") |
| 87 | + |
| 88 | + np.testing.assert_almost_equal( |
| 89 | + r['dynamics'][0].states[-1], |
| 90 | + [[np.exp(-1),0],[0,1-np.exp(-1)]], |
| 91 | + decimal=4) |
| 92 | + np.testing.assert_almost_equal( |
| 93 | + r['dynamics'][1].states[-1], |
| 94 | + [[0,0],[0,1]], |
| 95 | + decimal=4) |
| 96 | + np.testing.assert_almost_equal( |
| 97 | + r['dynamics'][2].states[-1], |
| 98 | + [[1-np.exp(-1),0],[0,np.exp(-1)]], |
| 99 | + decimal=4) |
| 100 | + |
| 101 | +# ----------------------------------------------------------------------------- |
0 commit comments