Skip to content

Commit 24b91eb

Browse files
authored
Merge pull request #93 from numericalEFT/remove_triqs
move TRIQS interface to an independent package NEFTInterface.jl
2 parents a67d608 + 84a8310 commit 24b91eb

18 files changed

+8
-1846
lines changed

.github/workflows/CI.yml

+1-9
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ jobs:
1414
test:
1515
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
1616
runs-on: ${{ matrix.os }}
17-
env:
18-
JULIA_PYTHONCALL_EXE: "/usr/bin/python3"
19-
# test for PythonCall needs python, solution from https://github.com/cjdoris/PythonCall.jl/issues/120
2017
strategy:
2118
fail-fast: false
2219
matrix:
@@ -25,10 +22,9 @@ jobs:
2522
- "nightly"
2623
os:
2724
- ubuntu-latest
28-
# python-version: ["3.7"]
2925
arch:
3026
- x64
31-
# - x86
27+
- x86
3228
steps:
3329
- uses: actions/checkout@v2
3430
- uses: julia-actions/setup-julia@v1
@@ -46,10 +42,6 @@ jobs:
4642
${{ runner.os }}-test-
4743
${{ runner.os }}-
4844
- uses: julia-actions/julia-buildpkg@v1
49-
- name: Install triqs
50-
run: sudo apt-get update && sudo apt-get install -y software-properties-common apt-transport-https curl && source /etc/lsb-release && curl -L https://users.flatironinstitute.org/~ccq/triqs3/$DISTRIB_CODENAME/public.gpg | sudo apt-key add - && sudo add-apt-repository "deb https://users.flatironinstitute.org/~ccq/triqs3/$DISTRIB_CODENAME/ /" && sudo apt-get update && sudo apt-get install -y triqs
51-
- name: Check triqs
52-
run: python3 -c "import triqs.version; print(triqs.version.version)"
5345
- uses: julia-actions/julia-runtest@v1
5446
- uses: julia-actions/julia-processcoverage@v1
5547
- uses: codecov/codecov-action@v2

Project.toml

+1-7
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,17 @@ version = "0.2.0"
77
BrillouinZoneMeshes = "9f696214-9961-49f3-89a2-cb1ea204eb6e"
88
CompositeGrids = "b5136c89-beeb-4521-9139-60d2cac8be56"
99
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
10-
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
11-
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
1210
Lehmann = "95bf888a-8996-4655-9f35-1c0506bdfefe"
1311
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1412
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
15-
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
1613
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1714
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1815

1916
[compat]
17+
BrillouinZoneMeshes = "0.1"
2018
CompositeGrids = "0.1"
21-
FileIO = "1"
22-
JLD2 = "0.4"
2319
Lehmann = "0.2"
2420
StaticArrays = "1"
25-
BrillouinZoneMeshes = "0.1"
26-
PythonCall = "0.9"
2721
julia = "1.6, 1.7, 1.8"
2822

2923
[extras]

README.md

+1-128
Original file line numberDiff line numberDiff line change
@@ -130,131 +130,4 @@ The imaginary-time Green's function after the Fourier transform shoud be consist
130130

131131
TRIQS (Toolbox for Research on Interacting Quantum Systems) is a scientific project providing a set of C++ and Python libraries for the study of interacting quantum systems. We provide a direct interface to convert TRIQS objects, such as the temporal meshes, the Brillouin zone meshes, and the multi-dimensional (blocked) Green's functions, to the equivalent objects in our package. It would help TRIQS users to make use of our package without worrying about the different internal data structures.
132132

133-
We rely on the package [`PythonCall.jl`](https://github.com/cjdoris/PythonCall.jl) to interface with the python language. You need to install TRIQS package from the python environment that `PythonCall` calls. We recommand you to check the sections [`Configuration`](https://cjdoris.github.io/PythonCall.jl/stable/pythoncall/#pythoncall-config) and [`Installing Python Package`](https://cjdoris.github.io/PythonCall.jl/stable/pythoncall/#python-deps) in the `PythonCall` documentation.
134-
135-
### Example 5: Load Triqs Temporal Mesh
136-
First we show how to import an imaginary-time mesh from TRIQS.
137-
```julia
138-
using PythonCall, GreenFunc
139-
gf = pyimport("triqs.gf")
140-
np = pyimport("numpy")
141-
142-
mt = gf.MeshImTime(beta=1.0, S="Fermion", n_max=3)
143-
mjt = from_triqs(mt)
144-
for (i, x) in enumerate([p for p in mt.values()])
145-
@assert mjt[i] pyconvert(Float64, x) # make sure mjt is what we want
146-
end
147-
148-
```
149-
- With the `PythonCall` package, one can import python packages with `pyimport` and directly exert python code in Julia. Here we import the Green's function module `triqs.gf` and generate a uniform imaginary-time mesh with `MeshImTime`. The user has to specify the inverse temperature, whether the particle is fermion or boson, and the number of grid points.
150-
151-
- Once a TRIQS object is prepared, one can simply convert it to an equivalent object in our package with `from_triqs`. The object can be a mesh, a Green's function, or a block Green's function. In this example, the TRIQS imaginary time grid is converted to an identical `ImTime` grid.
152-
153-
### Example 6: Load Triqs BrillouinZone
154-
155-
In this example, we show how the Brillouin zone mesh from TRIQS can be converted to a UniformMesh from the `BrillouinZoneMeshes` package and clarify the convention we adopted to convert a Python data structure to its Julia counterpart.
156-
157-
```julia
158-
using PythonCall, GreenFunc
159-
160-
# construct triqs Brillouin zone mesh
161-
lat = pyimport("triqs.lattice")
162-
gf = pyimport("triqs.gf")
163-
BL = lat.BravaisLattice(units=((2, 0, 0), (1, sqrt(3), 0)))
164-
BZ = lat.BrillouinZone(BL)
165-
nk = 4
166-
mk = gf.MeshBrillouinZone(BZ, nk)
167-
168-
# load Triqs mesh and construct
169-
mkj = from_triqs(mk)
170-
171-
for p in mk
172-
pval = pyconvert(Array, p.value)
173-
# notice that TRIQS always return a 3D point, even for 2D case(where z is always 0)
174-
# notice also that Julia index starts from 1 while Python from 0
175-
# points of the same linear index has the same value
176-
ilin = pyconvert(Int, p.linear_index) + 1
177-
@assert pval[1:2] mkj[ilin]
178-
# points with the same linear index corresponds to REVERSED cartesian index
179-
inds = pyconvert(Array, p.index)[1:2] .+ 1
180-
@assert pval[1:2] mkj[reverse(inds)...]
181-
end
182-
```
183-
184-
- Julia uses column-major layout for multi-dimensional array similar as Fortran and matlab, whereas python uses row-major layout. The converted Julias Brillouin zone mesh wll be indexed differently from that in TRIQS.
185-
- We adopted the convention so that the grid point and linear index are consistent with TRIQS counterparts, while the orders of Cartesian index
186-
and lattice vector are reversed.
187-
- Here's a table of 2D converted mesh v.s. the Triqs counterpart:
188-
189-
| Object | TRIQS | GreenFunc.jl |
190-
| --------------- | ----------------- | -------------- |
191-
| Linear index | mk[i]=(x, y, 0) | mkj[i]= (x, y) |
192-
| Cartesian index | mk[i,j]=(x, y, 0) | mkj[j,i]=(x,y) |
193-
| Lattice vector | (a1, a2) | (a2, a1) |
194-
195-
### Example 7: Load Triqs Greens function of a Hubbard Lattice
196-
197-
A TRIQS Green's function is defined on a set of meshes of continuous variables, together with the discrete inner states specified by the `target_shape`. The structure is immediately representable by `MeshArray`. In the following example, we reimplement the example 3 to first show how to generate a TRIQS Green's function of a Hubbard lattice within Julia, then convert the TRIQS Green's function to a julia `MeshArray` object. The Green's function is given by $G(q, \omega_n) = \frac{1}{i\omega_n - \epsilon_q}$ with $\epsilon_q = -2t(\cos(q_x)+\cos(q_y))$.
198-
199-
```julia
200-
using PythonCall, GreenFunc
201-
202-
np = pyimport("numpy")
203-
lat = pyimport("triqs.lattice")
204-
gf = pyimport("triqs.gf")
205-
206-
BL = lat.BravaisLattice(units=((2, 0, 0), (1, sqrt(3), 0))) # testing with a triangular lattice so that exchanged index makes a difference
207-
BZ = lat.BrillouinZone(BL)
208-
nk = 20
209-
mk = gf.MeshBrillouinZone(BZ, nk)
210-
miw = gf.MeshImFreq(beta=1.0, S="Fermion", n_max=100)
211-
mprod = gf.MeshProduct(mk, miw)
212-
213-
G_w = gf.GfImFreq(mesh=miw, target_shape=[1, 1]) #G_w.data.shape will be [201, 1, 1]
214-
G_k_w = gf.GfImFreq(mesh=mprod, target_shape = [2, 3] ) #target_shape = [2, 3] --> innerstate = [3, 2]
215-
216-
# Due to different cartesian index convention in Julia and Python, the data g_k_w[n, m, iw, ik] corresponds to G_k_w.data[ik-1, iw-1, m-1, n-1])
217-
218-
t = 1.0
219-
for (ik, k) in enumerate(G_k_w.mesh[0])
220-
G_w << gf.inverse(gf.iOmega_n - 2 * t * (np.cos(k[0]) + np.cos(k[1])))
221-
G_k_w.data[ik-1, pyslice(0, nk^2), pyslice(0, G_k_w.target_shape[0]) , pyslice(0,G_k_w.target_shape[1])] = G_w.data[pyslice(0, nk^2), pyslice(0, G_w.target_shape[0]) , pyslice(0,G_w.target_shape[1])] #pyslice = :
222-
end
223-
224-
g_k_w = from_triqs(G_k_w)
225-
226-
#alternatively, you can use the MeshArray constructor to convert TRIQS Green's function to a MeshArray
227-
g_k_w2 = MeshArray(G_k_w)
228-
@assert g_k_w2 g_k_w
229-
230-
#Use the << operator to import python data into an existing MeshArray
231-
g_k_w2 << G_k_w
232-
@assert g_k_w2 g_k_w
233-
234-
```
235-
- When converting a TRIQS Green's function into a `MeshArray` julia object, the `MeshProduct` from TRIQS is decomposed into separate meshes and converted to the corresponding Julia meshes. The `MeshArray` stores the meshes as a tuple object, not as a `MeshProduct`.
236-
- The `target_shape` in TRIQS Green's function is converted to a tuple of `UnitRange{Int64}` objects that represents the discrete degrees of freedom. Data slicing with `:` is not available in `PythonCall`. One needs to use `pyslice` instead.
237-
- As explained in Example 6, the cartesian index order of data has to be inversed during the conversion.
238-
- We support three different interfaces for the conversion of TRIQS Green's function. One can construct a new MeshArray with `from_triqs` or `MeshArray` constructor. One can also load TRIQS Green's function into an existing `MeshArray` with the `<<` operator.
239-
240-
### Example 8: Load Triqs block Greens function
241-
242-
The block Greens function in TRIQS can be converted to a dictionary of `MeshArray` objects in julia.
243-
244-
```julia
245-
using PythonCall, GreenFunc
246-
247-
gf = pyimport("triqs.gf")
248-
np = pyimport("numpy")
249-
mt = gf.MeshImTime(beta=1.0, S="Fermion", n_max=3)
250-
lj = pyconvert(Int, @py len(mt))
251-
G_t = gf.GfImTime(mesh=mt, target_shape=[2,3]) #target_shape = [2, 3] --> innerstate = [3, 2]
252-
G_w = gf.GfImTime(mesh=mt, target_shape=[2,3]) #target_shape = [2, 3] --> innerstate = [3, 2]
253-
254-
blockG = gf.BlockGf(name_list=["1", "2"], block_list=[G_t, G_w], make_copies=false)
255-
256-
jblockG = from_triqs(blockG)
257-
#The converted block Green's function is a dictionary of MeshArray corresponding to TRIQS block Green's function. The mapping between them is: jblockG["name"][i1, i2, t] = blockG["name"].data[t-1, i2-1, i1-1]
258-
259-
```
260-
133+
The interface is provided by an independent package [`NEFTInterface.jl`](https://github.com/numericalEFT/NEFTInterface.jl). We provide several examples of interfacing TRIQS and `GreenFunc.jl` in the [`NEFTInterface.jl` README](https://github.com/numericalEFT/NEFTInterface.jl).

docs/Manifest.toml

-97
This file was deleted.

docs/make.jl

+3-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ DocMeta.setdocmeta!(GreenFunc, :DocTestSetup, :(using GreenFunc); recursive=true
55

66
makedocs(;
77
modules=[GreenFunc],
8-
authors="Tao Wang, Xiansheng Cai",
9-
repo="https://github.com/fsxbhyy/GreenFunc.jl/blob/{commit}{path}#{line}",
8+
authors="Kun Chen, Tao Wang, Xiansheng Cai, PengCheng Hou, and Zhiyi Li",
9+
repo="https://github.com/numericaleft/GreenFunc.jl/blob/{commit}{path}#{line}",
1010
sitename="GreenFunc.jl",
1111
format=Documenter.HTML(;
1212
prettyurls=get(ENV, "CI", "false") == "true",
13-
canonical="https://fsxbhyy.github.io/GreenFunc.jl",
13+
canonical="https://numericaleft.github.io/GreenFunc.jl",
1414
assets=String[]
1515
),
1616
pages=[
@@ -19,8 +19,6 @@ makedocs(;
1919
"GreenFunc" => "lib/greenfunc.md",
2020
"MeshArrays" => "lib/mesharrays.md",
2121
"MeshGrids" => "lib/meshgrids.md",
22-
"Triqs" => "lib/triqs.md",
23-
"Deprecated" => "lib/deprecated.md",
2422
]
2523
]
2624
)

0 commit comments

Comments
 (0)