# cutoff and bond dimensions

**URL:** <https://itensor.discourse.group/t/cutoff-and-bond-dimensions/272>\
**Category:** DMRG and Numerical Methods\
**Created:** [July 20, 2022, 12:15pm UTC](https://itensor.discourse.group/t/cutoff-and-bond-dimensions/272 "2022-07-20T12:15:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![paban.patra](https://avatars.discourse-cdn.com/v4/letter/p/58956e/32.png) [@paban.patra](https://itensor.discourse.group/u/paban.patra)\
**Post date:** [July 20, 2022, 12:15pm UTC](https://itensor.discourse.group/t/cutoff-and-bond-dimensions/272/1 "2022-07-20T12:15:15Z")

</div>

Hello,

I am using ITensor in Julia language to calculate the ground state properties of a two-leg ladder model.  
My questions are as follows

1. Generally, we write cut off in this way

![Bond_dimension](https://global.discourse-cdn.com/free1/uploads/itensor/original/1X/a80253014704f96716e43a3bdd58a8b2d4e7ae5f.png)

But how to write different cutoff for different bond dimension, e.g cutoff= 10^{-9} for 60 bond dimension and cutoff= 10^{-10} for 200 bond dimensions?  
Similarly how to write different cutoffs for different sweeps?

2)I want to plot a graph of energy vs maxim bond dimension, Is there any way to save these data, or I have to do it by giving the values manually?

Thanks

---

<div class="post-metadata">

**Author:** ![miles](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/miles/32/6_2.png) [@miles](https://itensor.discourse.group/u/miles)\
**Post date:** [July 20, 2022, 7:01pm UTC](https://itensor.discourse.group/t/cutoff-and-bond-dimensions/272/2 "2022-07-20T19:01:28Z")

</div>

Good question - you can do something similar in the `cutoff!` function as in the `maxdim!` function, which is to provide a comma-separated list of cutoff values for each sweep. So like

```auto
cutoff!(1E-9,1E-9,1E-10,1E-12)

```

which would use 1E-9 for the first two sweeps, then 1E-10 for the third sweep, then 1E-12 for the fourth and all remaining sweeps.

---

<div class="post-metadata">

**Author:** ![paban.patra](https://avatars.discourse-cdn.com/v4/letter/p/58956e/32.png) [@paban.patra](https://itensor.discourse.group/u/paban.patra)\
**Post date:** [August 1, 2022, 2:47pm UTC](https://itensor.discourse.group/t/cutoff-and-bond-dimensions/272/3 "2022-08-01T14:47:51Z")

</div>

Thanks for the answer,

But let’s say I have to give 100 maxim bond dimensions for 50 sweeps. So, other than writing it 50 times is there any other way to do it?  
the same question goes for the cutoff also.

---

<div class="post-metadata">

**Author:** ![miles](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/miles/32/6_2.png) [@miles](https://itensor.discourse.group/u/miles)\
**Post date:** [August 1, 2022, 3:43pm UTC](https://itensor.discourse.group/t/cutoff-and-bond-dimensions/272/4 "2022-08-01T15:43:49Z")

</div>

It’s a good question. Fortunately we have a new `dmrg` interface that is already working, but we have just not publicized it enough. It’s a good reminder for us to start switching the examples to use this new interface and putting it into the documentation.

Here is a simple example of this new interface:

```auto
  # Plan to do 5 DMRG sweeps:
  nsweeps = 5
  maxdim = [10,20,100,100,200]
  cutoff = [1E-11]

  # Run the DMRG algorithm, returning energy and optimized MPS
  energy, psi = dmrg(H, psi0; nsweeps, maxdim, cutoff)

```

where you can see that there is now no `Sweeps` object and the parameters such as nsweeps, maxdim, and cutoff (there is also optionally mindim and noise) can be passed as just arrays.

With either interface, if one of the arrays is shorter than the number of sweeps, all remaining sweeps will use the last value in the array. So `cutoff = [1E-8, 1E-11]` would do 1E-8 for the first sweep, then 1E-11 for the second and all remaining sweeps.

Finally, in terms of how this addresses your question, you can use “array comprehension” tools and other base library features in Julia to easily make arrays. So if you want an array with the entry “50” repeating 100 times you can do:

```auto
maxdim = fill(50,100)

```

and of course you can do more complicated things like `maxdim = [f(n) for n=1:nsweeps]` for any function `f` you like.

---

<div class="post-metadata">

**Author:** ![paban.patra](https://avatars.discourse-cdn.com/v4/letter/p/58956e/32.png) [@paban.patra](https://itensor.discourse.group/u/paban.patra)\
**Post date:** [August 1, 2022, 7:16pm UTC](https://itensor.discourse.group/t/cutoff-and-bond-dimensions/272/5 "2022-08-01T19:16:05Z")

</div>

Thanks for the quick reply. However, when I put this in the code it shows the following error

 ![Screenshot from 2022-08-02 00-37-13](https://global.discourse-cdn.com/free1/uploads/itensor/original/1X/0782ed9bf089febcf8e0aab8c3cdbddf55ea62df.png)

Can you tell me how to fix it?

---

<div class="post-metadata">

**Author:** ![miles](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/miles/32/6_2.png) [@miles](https://itensor.discourse.group/u/miles)\
**Post date:** [August 1, 2022, 7:31pm UTC](https://itensor.discourse.group/t/cutoff-and-bond-dimensions/272/6 "2022-08-01T19:31:20Z")

</div>

Hm I don’t get that kind of error when I try similar code. Could you please post a more complete example code that reproduces this error message?

---

<div class="post-metadata">

**Author:** ![paban.patra](https://avatars.discourse-cdn.com/v4/letter/p/58956e/32.png) [@paban.patra](https://itensor.discourse.group/u/paban.patra)\
**Post date:** [August 2, 2022, 3:27pm UTC](https://itensor.discourse.group/t/cutoff-and-bond-dimensions/272/7 "2022-08-02T15:27:22Z")

</div>

I am able to run it now.

Thanks for quick responses.
