Skip to content

Commit

Permalink
Merge branch 'master' into doc-writing
Browse files Browse the repository at this point in the history
  • Loading branch information
tfmlaX authored Dec 17, 2024
2 parents ddd22b6 + 278ae98 commit 67886f4
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 12 deletions.
133 changes: 133 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion docs/src/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -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](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).
16 changes: 10 additions & 6 deletions examples/bath-observables.jl
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,
);
Expand Down Expand Up @@ -115,7 +118,6 @@ correlations_cdag = [
]

bath_occup_phys = physical_occup(cdagcdag_average[:,:,T], cc_average[:,:,T], omeg, bath_occup[:,:,T], β, N)

#--------------------
# Analytical results
#--------------------
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion examples/correlatedenvironment.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 14 additions & 3 deletions src/mpsBasics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

"""
Expand Down
6 changes: 6 additions & 0 deletions src/tensorOps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 67886f4

Please sign in to comment.