From bc078749edd672ba1a873991b74463351a06cf27 Mon Sep 17 00:00:00 2001 From: cometscome Date: Tue, 8 Oct 2024 12:13:33 +0900 Subject: [PATCH] JLD2 format is added --- Project.toml | 2 +- README.md | 51 ++++++++++++++++++++++++++++++++++++++++++++++ src/Gaugefields.jl | 1 + src/output/io.jl | 2 +- 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 2278474..8c77001 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Gaugefields" uuid = "a461e10c-0d91-493e-bc41-027b226eee91" authors = ["Akio Tomiya, Yuki Nagai and contributors"] -version = "0.2.8" +version = "0.2.9" [deps] CLIME_jll = "3c6ae550-c37b-5556-a07e-d40b4910cf1c" diff --git a/README.md b/README.md index f0abcf9..536b801 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,57 @@ filename = "testconf.txt" save_textdata(U,filename) ``` +## JLD2 format +Gaugefields.jl also supports [JLD2 format](https://github.com/JuliaIO/JLD2.jl). + +### File save and loading + +```julia +function main() +using Gaugefields + +function savingexample() + NX = 4 + NY = 4 + NZ = 4 + NT = 4 + NC = 3 + Nwing = 0 + Dim = 4 + + U = Initialize_Gaugefields(NC, Nwing, NX, NY, NZ, NT, condition="hot") + temp1 = similar(U[1]) + temp2 = similar(U[1]) + + comb = 6 + factor = 1 / (comb * U[1].NV * U[1].NC) + @time plaq_t = calculate_Plaquette(U, temp1, temp2) * factor + println("plaq_t = $plaq_t") + + + filename = "test.jld2" + saveU(filename, U) +end + +function loadingexample() + filename = "test.jld2" + U = loadU(filename) + + temp1 = similar(U[1]) + temp2 = similar(U[1]) + + comb = 6 + factor = 1 / (comb * U[1].NV * U[1].NC) + @time plaq_t = calculate_Plaquette(U, temp1, temp2) * factor + println("plaq_t = $plaq_t") +end + +savingexample() +loadingexample() +``` + + + ## Z(Nc) 2-form gauge fields SU(N) gauge fields possess Z(N) center symmetry, diff --git a/src/Gaugefields.jl b/src/Gaugefields.jl index 4f779b4..d5e6a07 100644 --- a/src/Gaugefields.jl +++ b/src/Gaugefields.jl @@ -242,6 +242,7 @@ export overrelaxation! export AbstractGaugefields, Traceless_antihermitian export write_to_numpyarray, map_U_sequential! export load_binarydata! +export loadU, saveU diff --git a/src/output/io.jl b/src/output/io.jl index 6098064..b24e8c7 100644 --- a/src/output/io.jl +++ b/src/output/io.jl @@ -1,6 +1,6 @@ module IOmodule using JLD2 -import ..AbstractGaugefields_module: AbstractGaugefields +import ..AbstractGaugefields_module: AbstractGaugefields, IdentityGauges #using ..Gaugefields #import ..Gaugefields:GaugeFields,SU2GaugeFields,SU3GaugeFields,SUNGaugeFields #import Main.LatticeQCD.Gaugefields:GaugeFields