# Calculation time for time dependent observable

Hello,
I am using trotter gate for time dependent calculations of one dimensional spin chain. I am calculating time dependent spin correlations up to final time 12, with tau=0.005 and measurement done after each 0.2 time. Initially I started with small lengths L=8,16. But time required for this calculation is very much large just for small length (almost 6-days). If I go for longer length it will take too much time comparatively. Is there other way to make calculations faster so that it will reduce calculation time.

Thank you.

What cutoff and/or maxdim are you using when you apply the gates? Is the Hamiltonian nearest-neighbor in 1D?

Yes Hamiltonian is nearest neighbor in 1D. Cutoff is 1E-10 and maxdim 300.

I see. Have you checked that the bond dimensions are staying at the maximum of 300? Or are they exceeding that maximum ?

Sorry, I made a mistake. Maxim is 100.

Bond dimensions are not exceeding maxdim. Here is some part of output.
"
Truncated to Cutoff=1.0E-10, Min_dim=1, Max_dim=100
Trunc. err=6.1E-11, States kept: dim=19
Sweep=8, HS=1, Bond=11/15
I 0 q 2E-03 E -17.8066537388
I 2 q 2E-03 E -17.8066544170
Truncated to Cutoff=1.0E-10, Min_dim=1, Max_dim=100
Trunc. err=1.3E-11, States kept: dim=17
Sweep=8, HS=1, Bond=12/15
I 0 q 2E-03 E -17.8066544169
I 2 q 3E-03 E -17.8066552039
Truncated to Cutoff=1.0E-10, Min_dim=1, Max_dim=100
Trunc. err=2.3E-11, States kept: dim=14
Sweep=8, HS=1, Bond=13/15
I 0 q 2E-03 E -17.8066552040
I 2 q 5E-03 E -17.8066583118
Truncated to Cutoff=1.0E-10, Min_dim=1, Max_dim=100
Trunc. err=5.1E-18, States kept: dim=8
Sweep=8, HS=1, Bond=14/15
I 0 q 1E-03 E -17.8066583118
I 2 q 4E-03 E -17.8066611861
Truncated to Cutoff=1.0E-10, Min_dim=1, Max_dim=100
Trunc. err=3.7E-16, States kept: dim=4
Sweep=8, HS=1, Bond=15/15
I 0 q 1E-03 E -17.8066611861
I 2 q 3E-04 E -17.8066641816
Truncated to Cutoff=1.0E-10, Min_dim=1, Max_dim=100
Trunc. err=3.6E-16, States kept: dim=2
Sweep=8, HS=2, Bond=15/15
I 0 q 3E-04 E -17.8066641816
I 2 q 2E-05 E -17.8066642157
Truncated to Cutoff=1.0E-10, Min_dim=1, Max_dim=100
Trunc. err=0.0E+00, States kept: dim=2
Sweep=8, HS=2, Bond=7/15
I 0 q 2E-03 E -17.8066769924
I 2 q 2E-03 E -17.8066776041
Truncated to Cutoff=1.0E-10, Min_dim=1, Max_dim=100
Trunc. err=8.3E-11, States kept: dim=18
Sweep=8, HS=2, Bond=6/15
I 0 q 2E-03 E -17.8066776038
I 2 q 2E-03 E -17.8066782143
Truncated to Cutoff=1.0E-10, Min_dim=1, Max_dim=100
Trunc. err=3.6E-11, States kept: dim=19
Sweep=8, HS=2, Bond=5/15
I 0 q 2E-03 E -17.8066782143
I 2 q 2E-03 E -17.8066788217
Truncated to Cutoff=1.0E-10, Min_dim=1, Max_dim=100
Trunc. err=3.8E-11, States kept: dim=18
Sweep=8, HS=2, Bond=4/15
I 0 q 2E-03 E -17.8066788213
I 2 q 2E-03 E -17.8066794606
Truncated to Cutoff=1.0E-10, Min_dim=1, Max_dim=100
Trunc. err=1.8E-11, States kept: dim=14
Sweep=8, HS=2, Bond=3/15
I 0 q 2E-03 E -17.8066794607
I 2 q 3E-03 E -17.8066803155
Truncated to Cutoff=1.0E-10, Min_dim=1, Max_dim=100
Trunc. err=3.8E-17, States kept: dim=8
Sweep=8, HS=2, Bond=2/15
I 0 q 1E-03 E -17.8066803155
I 2 q 9E-03 E -17.8067271189
Truncated to Cutoff=1.0E-10, Min_dim=1, Max_dim=100
Trunc. err=8.8E-18, States kept: dim=4
Sweep=8, HS=2, Bond=1/15
I 0 q 7E-04 E -17.8067271189
I 2 q 1E-03 E -17.8067292880
Truncated to Cutoff=1.0E-10, Min_dim=1, Max_dim=100
Trunc. err=8.6E-18, States kept: dim=2
Largest link dim during sweep 8/8 was 19
Largest truncation error: 8.43061e-11

"

What functions are you using to apply the Trotter gates? I ask because the printout looks more like that of TDVP or DMRG.

Could you please post a minimal code example? Thanks.

Here is part of my code.

``````
auto sites = SpinHalf(N,{"ConserveQNs=",false});

Real tstep=0.005;
Real ttotal=0;
Real cutoff=1E-10;

auto gates = vector<BondGate>();

auto hterm = AutoMPO(sites);

for(int b = 1; b <= N-1; ++b)
{
auto hterm =Delta*op(sites,"Sz",b)*op(sites,"Sz",b+1);
hterm += 0.5*op(sites,"S+",b)*op(sites,"S-",b+1);
hterm += 0.5*op(sites,"S-",b)*op(sites,"S+",b+1);

auto g = BondGate(sites,b,b+1,BondGate::tReal,tstep/2.,hterm);
gates.push_back(g);
}

for(int b = N-1; b >= 1; --b)
{
auto hterm = Delta*op(sites,"Sz",b)*op(sites,"Sz",b+1);
hterm += 0.5*op(sites,"S+",b)*op(sites,"S-",b+1);
hterm += 0.5*op(sites,"S-",b)*op(sites,"S+",b+1);

auto g = BondGate(sites,b,b+1,BondGate::tReal,tstep/2.,hterm);
gates.push_back(g);
}

auto ampo = AutoMPO(sites);

for(int j = 1; j < N; ++j)
{
ampo += 0.5,"S+",j,"S-",j+1;
ampo += 0.5,"S-",j,"S+",j+1;
ampo += Delta,"Sz",j,"Sz",j+1;
}

auto H = toMPO(ampo);

auto psi_i = randomMPS(sites);

auto sweeps = Sweeps(8);
sweeps.maxdim() = 10,20,30,40,100;
sweeps.cutoff() = 1E-6,1E-7,1E-8,1E-9,1E-10;
sweeps.niter() = 2;
sweeps.noise() = 0.0;

auto [E0,psi0] = dmrg(H,psi_i,sweeps);

``````
``````gateTEvol(gates,ttotal,tstep,psix1,{"Cutoff=",cutoff,"Verbose=",true});

``````
``````ttotal=ttotal+0.02;

``````

I see. So there is both a DMRG part then a call to gateTEvol. Which part is taking most of the time? How long is the list of gates you are passing to gateTEvol? Thanks.

Yes, I am using DMRG function for calculating ground state and ground state energy.
For different ttotal I am using gateTEvol function for time evolution of state. When ttotal increases time required also increases.

``````gateTEvol(gates,ttotal,tstep,psix1,{"Cutoff=",cutoff,"Verbose=",true});
``````

Also when new ttotal(ttotal=ttotal+0.02), I reset psix1 to psix1 at ttotal=0 before performing time evolution at new ttotal.
Thanks.

Here I am passing gateTEvol 600 times. i.e at each ttotal. Since I am doing calculations upto final time 12 and measurement after 0.02 time.