diff --git a/README.md b/README.md index 892246f..b575c40 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,10 @@ Neural-Network representations of mixed quantum states and to find the Steady- State of dissipative Quantum Systems with variational Montecarlo schemes. +This code has been developed while working on [Variational neural network ansatz for steady states in open quantum systems](https://arxiv.org/abs/1902.10104) + ## Installation -To Install `NeuralQuantum.jl`, please run the following commands to install all +To Install `NeuralQuantum.jl`, run the following commands to install all dependencies: ``` using Pkg @@ -13,15 +15,14 @@ pkg"add https://github.com/PhilipVinc/QuantumLattices.jl" pkg"add https://github.com/PhilipVinc/ValueHistoriesLogger.jl" pkg"add https://github.com/PhilipVinc/NeuralQuantum.jl" ``` -If you are wondering what all those packages are for, here's an explanation: +Those packages are needed for the following reasons: - `QuantumLattices` is a custom package that allows defining new types of operators on a lattice. It's not needed natively but it is usefull to define hamiltonians on a lattice. - - `Optimisers`, a custom version of the still unreleased `FluxML/Optimisers.jl`, with features that are not yet released in the original branch. - `ValueHistoriesLogger` custom logger for logging arbitrary values ## Example ``` # Load dependencies -using NeuralQuantum, QuantumLattices, Optimisers +using NeuralQuantum, QuantumLattices using Printf, ValueHistoriesLogger, Logging, ValueHistories # Select the numerical precision diff --git a/src/States/NAryState.jl b/src/States/NAryState.jl index 0701d0c..5d75c27 100644 --- a/src/States/NAryState.jl +++ b/src/States/NAryState.jl @@ -109,6 +109,20 @@ IntegerToState(n_sites, loc_dim, val, T::Type{<:Number}) = end arr end + +# --- Indexing function for local spaces used in operators +local_index(s::NAryState, i::T) where {T<:Integer} = + T(s.σ[i])+1 + +function local_index(s::NAryState{T,Nb}, is::Vector{T2}) where {T,Nb,T2<:Integer} + idx = 0 + for (i, j)=enumerate(reverse(is)) + idx += T2(s.σ[i]) * Nb^(j-1) + end + return idx + 1 +end +# -- end + # -------------- Base.show extension for nice printing -------------- # Base.show(io::IO, ::MIME"text/plain", bs::NAryState) = print(io, "NAryState(",bs.n,") : ", String(bs.σ,false), " = ", bs.i_σ)