From 7c274d0e53ae360f7798663761ede15bc3fa8007 Mon Sep 17 00:00:00 2001 From: Angela Riva <62027430+angelariva@users.noreply.github.com> Date: Mon, 25 Nov 2024 18:54:56 +0100 Subject: [PATCH 1/8] Update bath-observables.jl --- examples/bath-observables.jl | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/examples/bath-observables.jl b/examples/bath-observables.jl index 2bec03f..b0bf265 100644 --- a/examples/bath-observables.jl +++ b/examples/bath-observables.jl @@ -1,6 +1,6 @@ using MPSDynamics, Plots, LaTeXStrings, QuadGK, LinearAlgebra, Interpolations, Revise -import MPSDynamics: measuremodes, measurecorrs, mpsembed!, eigenchain, physical_occup +import MPSDynamics: measuremodes, measurecorrs, mpsembed!, eigenchain, physical_occup, bath_occup_phys const ∞ = Inf @@ -22,10 +22,10 @@ s = 1 # ohmicity # Simulation parameters #----------------------- -method = :TDVP1 # time-evolution method -conv = 3 # bond dimension for the TDVP1 +method = :TDVP2 # time-evolution method +conv = 0.001 # Allowed SVD singular value truncation dt = 0.5 # time step -tfinal = 50.0 # simulation time +tfinal = 60.0 # simulation time #---------------------------- # Ohmic spectral density @@ -35,7 +35,8 @@ if β == ∞ cpars = chaincoeffs_ohmic(N, α, s; ωc=ωc) # chain parameters, i.e. on-site energies ϵ_i, hopping energies t_i, and system-chain coupling c_0 else cpars = chaincoeffs_finiteT(N, β; α=α, s=s, J=nothing, ωc=ωc, mc=4, mp=0, AB=nothing, iq=1, idelta=2, procedure=:Lanczos, Mmax=5000, save=false) # chain parameters, i.e. on-site energies ϵ_i, hopping energies t_i, and system-chain coupling c_0 - #=#If cpars is stored in "../ChainOhmT/ohmicT" + #= + #If cpars is stored in "../ChainOhmT/ohmicT" curdir = @__DIR__ dir_chaincoeff = abspath(joinpath(curdir, "../ChainOhmT/ohmicT")) cpars = readchaincoeffs("$dir_chaincoeff/chaincoeffs.h5", N, α, s, β) # chain parameters, i.e. on-site energies ϵ_i, hopping energies t_i, and system-chain coupling c_0 @@ -81,6 +82,8 @@ A, dat = runsim(dt, tfinal, A, H, prec=1E-4; convparams = conv, reduceddensity = true, verbose = false, + savebonddims = true, + Dlim = 100, save = false, plot = true, ); @@ -115,7 +118,6 @@ correlations_cdag = [ ] bath_occup_phys = physical_occup(cdagcdag_average[:,:,T], cc_average[:,:,T], omeg, bath_occup[:,:,T], β, N) - #-------------------- # Analytical results #-------------------- @@ -166,6 +168,8 @@ p3 = heatmap(omeg, omeg, abs.(real.(correlations_cdag[:,:,T]) .+ im*imag.(correl Mhalf = Int(length(omeg)*0.5)+1 M = length(omeg) + + p4 = plot(omeg[Mhalf:M], bath_occup_phys, lw=4, xlabel=L"\omega", ylabel=L"\langle n^b_\omega \rangle", title="Mode occupation in the physical bath") From 7f95a238a558881772f604a853a03eb97b33fe85 Mon Sep 17 00:00:00 2001 From: Thibaut Lacroix <57836508+tfmlaX@users.noreply.github.com> Date: Tue, 26 Nov 2024 16:05:56 +0100 Subject: [PATCH 2/8] Create CODE_OF_CONDUCT.md --- CODE_OF_CONDUCT.md | 133 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..1a127a3 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,133 @@ + +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official email address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +shareloqs_ @ _framagroupes.org. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations From c613d27de5cfe993ff345ff6a986c10e2de067bd Mon Sep 17 00:00:00 2001 From: Thibaut Lacroix <57836508+tfmlaX@users.noreply.github.com> Date: Tue, 26 Nov 2024 16:20:13 +0100 Subject: [PATCH 3/8] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 733ba4e..a09f7e1 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ [![J. Chem. Phys.](https://img.shields.io/badge/J.%20Chem.%20Phys.%20-%2010.1063%2F5.0223107%20-%20navy)](https://doi.org/10.1063/5.0223107) [![ArXiv](https://img.shields.io/badge/arXiv-2406.07052-B31B1B.svg)](https://arxiv.org/abs/2406.07052) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.11400776.svg)](https://doi.org/10.5281/zenodo.11400776) [![license](https://img.shields.io/badge/License-GPL_3.0-orange.svg)](https://github.com/shareloqs/MPSDynamics/blob/master/LICENSE) [![documentation workflow](https://github.com/shareloqs/MPSDynamics/actions/workflows/docs.yml/badge.svg)](https://shareloqs.github.io/MPSDynamics/) +[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md) This package is intended to provide an easy to use interface for performing tensor network simulations on Matrix Product @@ -240,7 +241,7 @@ Contributions are welcome! Don't hesitate to contact us if you * have a suggestion on how to improve the code and/or documentation; * would like to get involved in writing code and/or documentation. -Feel free to open an [issue](https://github.com/shareloqs/MPSDynamics/issues) on Github :) +Feel free to open an [issue](https://github.com/shareloqs/MPSDynamics/issues) on Github. You will find guidelines in the [Contributing](CONTRIBUTING.md) file :) # References From a9d3bd7dad15afc26a7a1c98759dff047d6be334 Mon Sep 17 00:00:00 2001 From: Thibaut Lacroix <57836508+tfmlaX@users.noreply.github.com> Date: Fri, 29 Nov 2024 16:30:28 +0100 Subject: [PATCH 4/8] Add links to contibuting and code of conduct --- docs/src/dev.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/src/dev.md b/docs/src/dev.md index 1fdf2a1..245664f 100644 --- a/docs/src/dev.md +++ b/docs/src/dev.md @@ -12,4 +12,6 @@ Contributions are welcome! Don't hesitate to contact us if you * have a suggestion on how to improve the code and/or documentation; * would like to get involved in writing code and/or documentation. -You can contact us by raising an [issue on Github](https://github.com/shareloqs/MPSDynamics/issues), or by writing to one of the developers. +You can contact us by raising an [issue on Github](https://github.com/shareloqs/MPSDynamics/issues), by writing to one of the developers or at shareloqs_@_framagroupes.org. + +We have [contribution guidelines](../../CONTRIBUTING.md) and a community [code of conduct](../../CODE_OF_CONDUCT.md). From 048d0a970f784ff15fef70e7151a36aeda87ca12 Mon Sep 17 00:00:00 2001 From: Thibaut Lacroix <57836508+tfmlaX@users.noreply.github.com> Date: Fri, 29 Nov 2024 16:37:48 +0100 Subject: [PATCH 5/8] Fix links --- docs/src/dev.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/dev.md b/docs/src/dev.md index 245664f..5519562 100644 --- a/docs/src/dev.md +++ b/docs/src/dev.md @@ -14,4 +14,4 @@ Contributions are welcome! Don't hesitate to contact us if you You can contact us by raising an [issue on Github](https://github.com/shareloqs/MPSDynamics/issues), by writing to one of the developers or at shareloqs_@_framagroupes.org. -We have [contribution guidelines](../../CONTRIBUTING.md) and a community [code of conduct](../../CODE_OF_CONDUCT.md). +We have [contribution guidelines](https://github.com/shareloqs/MPSDynamics/blob/master/CONTRIBUTING.md) and a community [code of conduct](https://github.com/shareloqs/MPSDynamics/blob/master/CODE_OF_CONDUCT.md). From 13648ea2c562d6cec3860adde0feecb2d238e291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brieuc=20Le=20D=C3=A9?= Date: Fri, 29 Nov 2024 19:47:16 +0100 Subject: [PATCH 6/8] Fix correlated example --- examples/correlatedenvironment.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/correlatedenvironment.jl b/examples/correlatedenvironment.jl index 3ba95c2..0d3f4ce 100644 --- a/examples/correlatedenvironment.jl +++ b/examples/correlatedenvironment.jl @@ -77,7 +77,7 @@ eps = [1e-3] # projection error threshol for DTDVP # MPO and initial state MPS #--------------------------- -Hs = multisitempo(N, E, J, As) # system Hamiltonian +Hs = MPSDynamics.multisitempo(N, E, J, As) # system Hamiltonian Hc = correlatedenvironmentmpo(R, M, d; chainparams=cpars, fnamecc=fnamecc, s=s, α=α, ωc=ωc, c_phonon=c, β=β) # environment Hamiltonian From c4a4bf26487dd7283ac9ceafa2fa9c057b1db964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brieuc=20Le=20D=C3=A9?= Date: Sat, 7 Dec 2024 12:27:14 +0100 Subject: [PATCH 7/8] add rhoABstar methods --- src/tensorOps.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/tensorOps.jl b/src/tensorOps.jl index 7206956..1b8c1fd 100644 --- a/src/tensorOps.jl +++ b/src/tensorOps.jl @@ -46,6 +46,12 @@ end function rhoAAstar(ρ::Array{T1,2}, A::Array{T2,3}) where {T1,T2} return @tensoropt ρO[a,b] := ρ[a0,b0] * conj(A[a0,a,s]) * A[b0,b,s] end +function rhoABstar(ρ::Array{T1,2}, A::Array{T2,2}, B::Array{T3,2}) where {T1,T2,T3} + @tensoropt ρO = tensorscalar(ρ[a0,b0] * conj(B[a0,s]) * A[b0,s]) +end +function rhoABstar(ρ::Array{T1,2}, A::Array{T2,3}, B::Array{T3,3}) where {T1,T2,T3} + return @tensoropt ρO[a,b] := ρ[a0,b0] * conj(B[a0,a,s]) * A[b0,b,s] +end function rhoAAstar(ρ::Array{T1,2}, A::Array{T2,4}, indir::Int, outdir::Int) where {T1,T2} indir==1 && outdir==2 && return @tensoropt ρO[a,b] := ρ[a0,b0] * conj(A[a0,a,c0,s]) * A[b0,b,c0,s] From 278ae98039167643dbc076463a9c279d74644cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brieuc=20Le=20D=C3=A9?= Date: Mon, 16 Dec 2024 11:23:59 +0100 Subject: [PATCH 8/8] Add compat in Project and applympo SDV extension --- Project.toml | 22 ++++++++++++++++++++-- src/mpsBasics.jl | 17 ++++++++++++++--- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Project.toml b/Project.toml index 8769cc2..c2df4ad 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,7 @@ name = "MPSDynamics" uuid = "8fc8f346-e1eb-498f-94db-02ffe92d8134" -authors = ["angus-dunnett ", "Thibaut Lacroix "] +authors = ["Angus Dunnett", "Thibaut Lacroix", "Brieuc Le Dé", "Angela Riva"] +maintainers = ["ShareLOQS "] version = "1.1.0" [deps] @@ -25,6 +26,23 @@ SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2" [compat] +Dates = "1.1.0 - 1.11" +DelimitedFiles = "1.1.0 - 1.9" +Distributed = "1.1.0 - 1.11" +GraphRecipes = "0.4, 0.5" +HDF5 = "0.17.2" ITensors = "0.6" +Interpolations = "0.11, 0.15" +JLD = "0.13.5" +Jacobi = "0.7.0" +KrylovKit = "0.8.3" +LinearAlgebra = "1.0.0 - 1.11" +Logging = "1.5.0 - 1.11" +Plots = "1.35.0 - 1.40" +Preferences = "1.0.0 - 1.4" +Printf = "1.0.0 - 1.11" +QuadGK = "2.0.0 - 2.11" +Random = "1.0.0 - 1.11" +SpecialFunctions = "2.4.0" TensorOperations = "4.0.7" -julia = "1.7" +julia = "1.7 - 1.11" diff --git a/src/mpsBasics.jl b/src/mpsBasics.jl index 4d8bee6..57b10ed 100644 --- a/src/mpsBasics.jl +++ b/src/mpsBasics.jl @@ -540,12 +540,12 @@ Apply an operator O on the MPS A. O is acting on only one site ::Int. The result apply1siteoperator!(A, O, site::Int) = apply1siteoperator!(A, O, [site]) """ - applympo!(A, H) + applympo!(A, H; SVD=false, kwargs...) -Apply an MPO H on the MPS A. H must have the same number of site than A. The resulting MPS A is the MPS modified by the MPO H. +Apply an MPO H on the MPS A. H must have the same number of site than A. The resulting MPS A is the MPS modified by the MPO H. The argument SVD can be set to true if one wants the MPS to recover the same dimensions after having applied the MPO H. Further parameters for the SVD truncation can be added with the kwargs. """ -function applympo!(A, H) +function applympo!(A, H ; SVD=false, kwargs...) N = length(H) N == length(A) || throw(ArgumentError("MPO has $N site while MPS has $(length(A)) sites")) for i=1:N @@ -554,6 +554,17 @@ function applympo!(A, H) @tensor X[a',a,b',b,s] := H[i][a',b',s,s'] * A[i][a,b,s'] A[i] = reshape(X, Al*Hl, Ar*Hr, d) end + if SVD + for i in 2:N + Dl, Dr, d = size(A[i-1]) + U, S, Vt = svdtrunc(reshape(permutedims(A[i-1], [1,3,2]), Dl*d, Dr); kwargs...) + Dnew = size(S,1) + A[i-1] = permutedims(reshape(U, Dl, d, Dnew), [1,3,2]) + R = Diagonal(S)*Vt + @tensor AC[:] := R[-1,1] * A[i][1,-2,-3] + A[i] = AC + end + end end """