# Excited State DMRG with saving to disk

**URL:** <https://itensor.discourse.group/t/excited-state-dmrg-with-saving-to-disk/1460>\
**Category:** ITensor Julia Questions\
**Tags:** julia, dmrg\
**Created:** [February 2, 2024, 2:37am UTC](https://itensor.discourse.group/t/excited-state-dmrg-with-saving-to-disk/1460 "2024-02-02T02:37:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cfengno1](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@cfengno1](https://itensor.discourse.group/u/cfengno1)\
**Post date:** [February 2, 2024, 2:37am UTC](https://itensor.discourse.group/t/excited-state-dmrg-with-saving-to-disk/1460/1 "2024-02-02T02:37:10Z")

</div>

Hi there,

I am trying to target the 1st excited state through

**energy,psi = dmrg(H,[psi0],psix,sweeps; write\_when\_maxdim\_exceeds=500)**

However, I got the following error message:

**ERROR: LoadError: MethodError: no method matching disk(::ProjMPO\_MPS; path=“/scratch/feng/tmp”)  
Closest candidates are:  
disk(::SerializedElementArrays.SerializedElementArray; kw…) at ~/.julia/packages/SerializedElementArrays/cdFxy/src/SerializedElementArrays.jl:153  
disk(::AbstractArray; kw…) at ~/.julia/packages/SerializedElementArrays/cdFxy/src/SerializedElementArrays.jl:151  
disk(::ITensors.AbstractSum; disk\_kwargs…) at ~/.julia/dev/ITensors/src/mps/projmposum.jl:110  
…  
Stacktrace:  
[1] dmrg(PH::ProjMPO\_MPS, psi0::MPS, sweeps::Sweeps; kwargs::Base.Pairs{Symbol, Any, NTuple{6, Symbol}, NamedTuple{(:start\_disk, :write\_when\_maxdim\_exceeds, :write\_step, :eigsolve\_tol, :eigsolve\_krylovdim, :weight), Tuple{Bool, Int64, String, Float64, Int64, Int64}}})  
@ ITensors ~/.julia/dev/ITensors/src/mps/dmrg.jl:225  
[2] dmrg(H::MPO, Ms::Vector{MPS}, psi0::MPS, sweeps::Sweeps; kwargs::Base.Pairs{Symbol, Any, NTuple{6, Symbol}, NamedTuple{(:start\_disk, :write\_when\_maxdim\_exceeds, :write\_step, :eigsolve\_tol, :eigsolve\_krylovdim, :weight), Tuple{Bool, Int64, String, Float64, Int64, Int64}}})  
@ ITensors ~/.julia/dev/ITensors/src/mps/dmrg.jl:55**

It seems that disk() cannot treat ProjMPO\_MPS type object. Can you help?

Best,  
Simon

---

<div class="post-metadata">

**Author:** ![mtfishman](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/mtfishman/32/11_2.png) [@mtfishman](https://itensor.discourse.group/u/mtfishman)\
**Post date:** [February 2, 2024, 12:41pm UTC](https://itensor.discourse.group/t/excited-state-dmrg-with-saving-to-disk/1460/2 "2024-02-02T12:41:30Z")

</div>

Thanks for the report, that will be simple to fix.

---

<div class="post-metadata">

**Author:** ![cfengno1](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@cfengno1](https://itensor.discourse.group/u/cfengno1)\
**Post date:** [February 2, 2024, 4:02pm UTC](https://itensor.discourse.group/t/excited-state-dmrg-with-saving-to-disk/1460/3 "2024-02-02T16:02:26Z")

</div>

Hi Matthew,

Thanks for the reply. Can you explain how?

Best,  
Simon

---

<div class="post-metadata">

**Author:** ![mtfishman](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/mtfishman/32/11_2.png) [@mtfishman](https://itensor.discourse.group/u/mtfishman)\
**Post date:** [February 2, 2024, 4:14pm UTC](https://itensor.discourse.group/t/excited-state-dmrg-with-saving-to-disk/1460/4 "2024-02-02T16:14:50Z")

</div>

If you want something working for yourself, you could look at the design of `DiskProjMPO`: [ITensors.jl/src/mps/diskprojmpo.jl at main · ITensor/ITensors.jl · GitHub](https://github.com/ITensor/ITensors.jl/blob/main/src/mps/diskprojmpo.jl).

The conceptually simplest strategy would be to make a `DiskProjMPS` type, based on combining the design of `DiskProjMPO` and `ProjMPS` ([ITensors.jl/src/mps/projmps.jl at main · ITensor/ITensors.jl · GitHub](https://github.com/ITensor/ITensors.jl/blob/main/src/mps/projmps.jl)). Then you could create a `DiskProjMPO_MPS` similar to the `ProjMPO_MPS` type ([ITensors.jl/src/mps/projmpo\_mps.jl at main · ITensor/ITensors.jl · GitHub](https://github.com/ITensor/ITensors.jl/blob/main/src/mps/projmpo_mps.jl)).

If I were to do it myself, I think I would do a bigger rewrite of those types to share more code across the projected MPO/MPS types types that are stored in memory and on disk, so for example redesign `ProjMPO`, `ProjMPS`, and `ProjMPO_MPS` to be parametrized types that either can be fully in memory or partially on disk depending on what objects they are storing. I may go ahead and do that but if you want something done faster for yourself, you could take the strategy I outlined above.

---

<div class="post-metadata">

**Author:** ![mtfishman](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/mtfishman/32/11_2.png) [@mtfishman](https://itensor.discourse.group/u/mtfishman)\
**Post date:** [February 6, 2024, 1:27am UTC](https://itensor.discourse.group/t/excited-state-dmrg-with-saving-to-disk/1460/5 "2024-02-06T01:27:54Z")

</div>

An update that @miles will be looking into implementing this.

---

<div class="post-metadata">

**Author:** ![cfengno1](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@cfengno1](https://itensor.discourse.group/u/cfengno1)\
**Post date:** [February 6, 2024, 11:50pm UTC](https://itensor.discourse.group/t/excited-state-dmrg-with-saving-to-disk/1460/6 "2024-02-06T23:50:51Z")

</div>

Sounds great! Thank you!
