Skip to content

Commit

Permalink
Merge pull request #115 from SotaYoshida/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
SotaYoshida authored Mar 4, 2024
2 parents 7035c0b + b8bcc38 commit 0dfd2a1
Show file tree
Hide file tree
Showing 47 changed files with 2,272 additions and 504 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ jobs:
arch: x64
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
env:
JULIA_NUM_THREADS: 2
if: ${{ matrix.payload == 'serial' }}
continue-on-error: ${{ matrix.version == 'nightly' }}
- name: "Run tests"
run: |
julia --project -e 'import Pkg; Pkg.test()'
build:
runs-on: ubuntu-latest
strategy:
Expand Down
41 changes: 7 additions & 34 deletions .github/workflows/CI_pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ jobs:
arch: x64
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
env:
JULIA_NUM_THREADS: 2
if: ${{ matrix.payload == 'serial' }}
continue-on-error: ${{ matrix.version == 'nightly' }}
- name: "Run tests"
run: |
julia --project -e 'import Pkg; Pkg.test()'
# env:
# JULIA_NUM_THREADS: 2
# if: ${{ matrix.payload == 'serial' }}
# continue-on-error: ${{ matrix.version == 'nightly' }}
build:
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -63,35 +65,6 @@ jobs:
export PATH=$PATH:/home/runner/.julia/bin
mpiexecjl -n 4 julia --depwarn=yes --project=@. ./test/mpirun_test.jl
# build2:
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# include:
# - {version: '1.8', os: ubuntu-latest}
# name: Run sample_script.jl
# steps:
# - uses: actions/checkout@v2
# with:
# fetch-depth: 0
# - uses: julia-actions/setup-julia@v1
# with:
# version: ${{ matrix.version }}
# arch: x64
# - uses: julia-actions/cache@v1
# - uses: julia-actions/julia-buildpkg@v1
# - run: |
# git_hash=$(git rev-parse --short "$GITHUB_SHA")
# echo git_hash $git_hash
# echo running on branch ${GITHUB_REF##*/}
# echo git_hash:[$git_hash] > ./example/log_sample_script.txt
# julia --project="@." -t 4 ./example/sample_script.jl >> ./example/log_sample_script.txt
# git add example/log_sample_script.txt
# - name: commit changed logfile
# uses: stefanzweifel/[email protected]
# with:
# commit_message: Update log_sample_script.txt
docs:
name: Documentation
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ src/.DS_Store
docs/.DS_Store

# potential files and Omega generated through IMSRG flows
*.snt
*.snt.bin
tbme*.snt
tbme*.snt.bin
/snts
/flowOmega
logfile.dat
Expand Down
32 changes: 32 additions & 0 deletions .gitignore~
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Files generated by invoking Julia with --code-coverage
*.jl.cov
*.jl.*.cov

# Files generated by invoking Julia with --track-allocation
*.jl.mem

# System-specific files and directories generated by the BinaryProvider and BinDeps packages
# They contain absolute paths specific to the host computer, and so should not be committed
deps/deps.jl
deps/build.log
deps/downloads/
deps/usr/
deps/src/

# Build artifacts for creating documentation generated by the Documenter package
docs/build/
docs/site/

# Mac
.DS_Store
src/.DS_Store
docs/.DS_Store

# potential files and Omega generated through IMSRG flows
*.snt
*.snt.bin
/snts
/flowOmega
logfile.dat
*/logfile.dat

8 changes: 4 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NuclearToolkit"
uuid = "89bb3bae-bcec-43ae-87b7-9dd181dc6334"
authors = ["SotaYoshida <[email protected]> and contributors"]
version = "0.4.0"
version = "0.4.1"

[deps]
Arpack = "7d9fca2a-8960-54d3-9f78-7d1dccf2cb97"
Expand Down Expand Up @@ -32,9 +32,9 @@ WignerSymbols = "9f57e263-0b3d-5e2e-b1be-24f2bb48858b"
[compat]
Arpack = "0.5"
AssociatedLegendrePolynomials = "1"
CodecZlib="0.7"
CodecZlib = "0.7"
Combinatorics = "1"
DocStringExtensions="0.9"
DocStringExtensions = "0.9"
FLoops = "0.2"
Glob = "1"
HDF5 = "0.16, 0.17"
Expand All @@ -44,8 +44,8 @@ LatinHypercubeSampling = "1.8"
MKL = "0.6"
MPI = "0.19, 0.20"
Measures = "0.3"
Plots = "1"
Parsers = "2.8"
Plots = "1"
SpecialFunctions = "2"
Statistics = "1"
StatsBase = "0.33, 0.34"
Expand Down
2 changes: 2 additions & 0 deletions example/log_sample_script.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
option in optional_parameters.jl will be used.
--- chiEFTparameters used ---
n_mesh = 50
pmax_fm = 5.0
Expand Down Expand Up @@ -31,6 +32,7 @@ size of dWS (jmax 9 lmax 40 e2max 8 Nnmax 20):
# of sp states 15
# of channels 2bstate 55 #TBME = 34320
E(2H): bare = -2.224578 srg = -2.224578 Diff.1.484e-10
option in optional_parameters.jl will be used.
size of dWS (jmax 9 lmax 40 e2max 8 Nnmax 20):
dtri 4.46 MB dcgm0 1.11 MB d6j_int 1.11 MB d6j_lj 0.28 MB
d9j_lsj 1.76 MB dictHOB 0.44 MB
Expand Down
10 changes: 6 additions & 4 deletions src/IMSRG.jl/emulator_imsrg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,13 @@ function check_stationarity(z, z_k, z_pred, Atilde, itnum=1000)
end

"""
function extrapolate_DMD(x_start, U_r, Atilde, s_pred, fn_exact, s_end, ds, nuc, inttype, emax, oupdir)
function extrapolate_DMD(x_start, U_r, Atilde, s_pred, fn_exact, s_end, ds, nuc, inttype, emax, oupdir; verbose=false)
Function to perform the DMD extrapolation.
The time evolution (IMSRG flow) of original data `x` is approximated by the time evolution of
`z` in the latent space, and then the approximated data `x'` is written to a HDF5 file.
"""
function extrapolate_DMD(x_start, U_r, Atilde, s_pred, fn_exact, s_end, ds, nuc, inttype, emax, oupdir)
function extrapolate_DMD(x_start, U_r, Atilde, s_pred, fn_exact, s_end, ds, nuc, inttype, emax, oupdir; verbose=false)
@assert length(s_pred) == length(fn_exact) "s_pred and fn_exact must have the same length"
if length(s_pred) > 0
r = size(U_r)[2]
Expand Down Expand Up @@ -377,7 +377,9 @@ function extrapolate_DMD(x_start, U_r, Atilde, s_pred, fn_exact, s_end, ds, nuc,
end
write_dmdvec_hdf5(x_pred,s,E_imsrg,nuc,inttype,emax,oupdir)
end
check_stationarity(z1_r, z_k, z_new, Atilde)
if verbose
check_stationarity(z1_r, z_k, z_new, Atilde)
end
end
return nothing
end
Expand All @@ -387,7 +389,7 @@ function write_dmdvec_hdf5(vec_in,s,E_imsrg,nuc,inttype,emax,oupdir)
vec[1] = s
vec[2] = E_imsrg
vec[3:end] .= vec_in
fname = oupdir*"omega_dmdvec_$(inttype)_e$(emax)_$(nuc)_s"*strip(@sprintf("%6.2f",s))*".h5"
fname = oupdir*"omega_dmdvec"*ifelse(inttype=="","","_"*inttype)*"_e$(emax)_$(nuc)_s"*strip(@sprintf("%6.2f",s))*".h5"
io = h5open(fname,"w")
write(io,"vec",vec)
close(io)
Expand Down
37 changes: 22 additions & 15 deletions src/IMSRG.jl/imsrg_util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
- `restart_from_files`: files to be read for restart 1st one is for IMSRG and 2nd one is for VSIMSRG
"""
function imsrg_main(binfo::basedat,Chan1b::chan1b,Chan2bD::chan2bD,HFobj::HamiltonianNormalOrdered,dictsnt,dWS,valencespace,Operators,MatOp,to;
delete_Ops=false,core_generator_type="atan",valence_generator_type="shell-model-atan",fn_params="optional_parameters.jl",debugmode=0,Hsample=false,restart_from_files=String[])
delete_Ops=false,core_generator_type="atan",valence_generator_type="shell-model-atan",fn_params="optional_parameters.jl",debugmode=0,Hsample=0,restart_from_files=String[])
if binfo.nuc.corenuc == "" && vsIMSRG; println("core (hole) for VS-IMSRG is not specified."); return nothing;end
dictMono = deepcopy(dictsnt.dictMonopole)
vsIMSRG = ifelse(valencespace!=[]&&valencespace!="",true,false)
Expand All @@ -36,6 +36,8 @@ function imsrg_main(binfo::basedat,Chan1b::chan1b,Chan2bD::chan2bD,HFobj::Hamilt
if length(restart_from_files) >= 1; IMSRGobj.smax = IMSRGobj.dsmax;end
d6j_defbyrun = Dict{UInt64,Float64}()
IMSRGflow(binfo,HFobj,IMSRGobj,PandyaObj,Chan1b,Chan2bD,dictMono,d6j_defbyrun,core_generator_type,valence_generator_type,to;debugmode=debugmode,Hsample=Hsample,restart_from_files=restart_from_files)
IMSRGobj.ExpectationValues["E0"] = IMSRGobj.H.zerobody[1]

if vsIMSRG && length(restart_from_files) == 0
IMSRGflow(binfo,HFobj,IMSRGobj,PandyaObj,Chan1b,Chan2bD,dictMono,d6j_defbyrun,core_generator_type,valence_generator_type,to;valenceflow=true,Hsample=Hsample)
effOps = flow_Operators(binfo,HFobj,IMSRGobj,PandyaObj,Chan1b,Chan2bD,dWS,d6j_defbyrun,dictMono,Operators,MatOp,restart_from_files,to)
Expand All @@ -54,7 +56,7 @@ function imsrg_main(binfo::basedat,Chan1b::chan1b,Chan2bD::chan2bD,HFobj::Hamilt
else
flow_Operators(binfo,HFobj,IMSRGobj,PandyaObj,Chan1b,Chan2bD,dWS,d6j_defbyrun,dictMono,Operators,MatOp,restart_from_files,to)
end

if length(restart_from_files) >= 1
if binfo.nuc.cZ != binfo.nuc.Z || binfo.nuc.cN != binfo.nuc.N
println("normal ordering...")
Expand All @@ -72,7 +74,7 @@ function imsrg_main(binfo::basedat,Chan1b::chan1b,Chan2bD::chan2bD,HFobj::Hamilt
end
#write_vs_snt(binfo,HFobj,IMSRGobj,Operators,Chan1b,Chan2bD,valencespace)
end
if !delete_Ops
if delete_Ops
pid = getpid()
for f in glob("flowOmega/Omega_$(pid)*.bin")
rm(f)
Expand Down Expand Up @@ -650,7 +652,7 @@ function sort_d6j_lj(d6j)
end

function IMSRGflow(binfo::basedat,HFobj::HamiltonianNormalOrdered,IMSRGobj::IMSRGobject,PandyaObj::PandyaObject,Chan1b::chan1b,Chan2bD,dictMono,d6j_lj,
core_generator,valence_generator,to;valenceflow=false,debugmode=0,maxstep=2000,Hsample=false,num_Hsample=50,modsample=4,
core_generator,valence_generator,to;valenceflow=false,debugmode=0,maxstep=2000,Hsample=0,
restart_from_files=String[])
Chan2b = Chan2bD.Chan2b
ncomm = IMSRGobj.Ncomm
Expand Down Expand Up @@ -730,10 +732,13 @@ function IMSRGflow(binfo::basedat,HFobj::HamiltonianNormalOrdered,IMSRGobj::IMSR
func_Eta(HFobj,IMSRGobj,Chan2b,dictMono,norms)

# remnant for IMSRG-Net sampling
#if Hsample && ( ( 15.0 <= s <= 20.00 || s == 30.0 || s == 50.0 ) || valenceflow) #(istep <=10 && valenceflow)
if Hsample && ( ( s <= 20.00 || s == 30.0 || s == 50.0 ) || valenceflow) #(istep <=10 && valenceflow)
Nested = deepcopy(IMSRGobj.Omega)
gather_omega_sofar_write(Hsample,istep, s, fvec, Omega, nOmega, tmpOp, binfo, Chan1b, Chan2bD, HFobj, IMSRGobj, dictMono, d6j_lj, PandyaObj,to,dict_idx_op_to_flatvec, dict_idx_flatvec_to_op,dict_if_idx_for_hdf5)
if Hsample > 0
cond_1 = Hsample == 1 && ( (s <= 20.00 || s == 30.0 || s == 50.0 ) || valenceflow) # for DMD
cond_2 = Hsample == 2 && ( (15.0 <= s <= 20.00 || s == 30.0 || s == 50.0 ) || valenceflow) # for IMSRG-Net
if cond_1 || cond_2
Nested = deepcopy(IMSRGobj.Omega)
gather_omega_sofar_write(Hsample,istep, s, fvec, Omega, nOmega, tmpOp, binfo, Chan1b, Chan2bD, HFobj, IMSRGobj, dictMono, d6j_lj, PandyaObj,to,dict_idx_op_to_flatvec, dict_idx_flatvec_to_op,dict_if_idx_for_hdf5)
end
end

print_flowstatus(istep,s,ncomm,norms,IMSRGobj,Chan2b)
Expand Down Expand Up @@ -797,12 +802,11 @@ function normHs(Hs::Operator)
return sqrt(norm(Hs.onebody[1],2)^2 + norm(Hs.onebody[2],2)^2 + norm2b^2)
end

function gather_omega_sofar_write(Hsample::Bool, istep, s, fvec, oOmega, nOmega, tmpOp, binfo, Chan1b, Chan2bD,
function gather_omega_sofar_write(Hsample, istep, s, fvec, oOmega, nOmega, tmpOp, binfo, Chan1b, Chan2bD,
HFobj, IMSRGobj, dictMono, d6j_lj, PandyaObj,to,
dict_idx_op_to_flatvec, dict_idx_flatvec_to_op,dict_if_idx_for_hdf5;debug_mode=true)
if !Hsample; return nothing;end
if Hsample==0; return nothing;end
magnusmethod = IMSRGobj.magnusmethod
#splitting = ifelse((magnusmethod!="" && magnusmethod!="split"),true,false)
splitting = ifelse((magnusmethod!="" && magnusmethod!="split"),false,true)
fvec .*= 0.0
ncom = zeros(Int64,3)
Expand All @@ -828,8 +832,10 @@ function gather_omega_sofar_write(Hsample::Bool, istep, s, fvec, oOmega, nOmega,
end
get_fvec_from_Op!(s, fvec, tildeO, dict_idx_op_to_flatvec, dict_idx_flatvec_to_op)
write_fvec_hdf5(binfo,fvec,dict_if_idx_for_hdf5,s,IMSRGobj.H.zerobody[1];label="omega")
get_fvec_from_Op!(s, fvec, IMSRGobj.eta, dict_idx_op_to_flatvec, dict_idx_flatvec_to_op)
write_fvec_hdf5(binfo,fvec,dict_if_idx_for_hdf5,s,IMSRGobj.H.zerobody[1];label="eta")
if Hsample == 2
get_fvec_from_Op!(s, fvec, IMSRGobj.eta, dict_idx_op_to_flatvec, dict_idx_flatvec_to_op)
write_fvec_hdf5(binfo,fvec,dict_if_idx_for_hdf5,s,IMSRGobj.H.zerobody[1];label="eta")
end
return nothing
end

Expand Down Expand Up @@ -1049,7 +1055,7 @@ Constructor for IMSRGobject
- `n_written_omega::Int` # of written Omega by splitting to solve IMSRGflow
- `Ncomm::Vector{Int}` # of commutator evaluated during IMSRG flow
"""
function init_IMSRGobject(HFobj,filename;smax=500.0,dsmax=1.0,maxnormOmega=0.25,eta_criterion=1.e-6,denominatorDelta=0.0)
function init_IMSRGobject(HFobj,filename;smax=500.0,dsmax=0.5,maxnormOmega=0.25,eta_criterion=1.e-6,denominatorDelta=0.0)
tf = isfile(filename)
ds = min(dsmax,1.0)
s = [0.0,ds]
Expand All @@ -1064,7 +1070,8 @@ function init_IMSRGobject(HFobj,filename;smax=500.0,dsmax=1.0,maxnormOmega=0.25,
n_written_omega = [0]
Ncomm =[0]
magnusmethod = ""
IMSRGobj = IMSRGobject(H0,Hs,s,smax,dsmax,maxnormOmega,magnusmethod,eta,Omega,eta_criterion,denominatorDelta,n_written_omega,Ncomm)
ExpectationValues = Dict{String,Float64}()
IMSRGobj = IMSRGobject(H0,Hs,s,smax,dsmax,maxnormOmega,magnusmethod,eta,Omega,eta_criterion,denominatorDelta,n_written_omega,Ncomm,ExpectationValues)
if !tf
println("Since $filename is not found, the default parameters will be used.")
return IMSRGobj
Expand Down
2 changes: 1 addition & 1 deletion src/NuclearToolkit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ include("chiEFTint/nn_sampling.jl")
include("chiEFTint/read_me3j.jl")
export make_chiEFTint
export nn_IMSRG_sampling
export test_me3j
export test3NF

### NuclData.jl
include("NuclData.jl/amedata.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/ShellModel/betadecay.jl
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ function eval_bFF_files(fns,qfactors::quenching_factors,parent,daughter,Qvals;ve
fFF = f_0 + f_1 + f_2
thalf = K/fFF
logft = log10(fis[2]*thalf)
if false #verbose
if verbose
println("Energy $tkey Ex.",@sprintf("%8.3f",tkey-daughter.Egs)," J2",@sprintf("%4i",J2),ffobj.prty)
println("M0s,M0t,M0s'", @sprintf("%12.4e", ffobj.M0rs),@sprintf("%12.4e", ffobj.M0sp),@sprintf("%12.4e", ffobj.M0rsd))
println("x, u, xi'y ", @sprintf("%12.4e", x),@sprintf("%12.4e", u),@sprintf("%12.4e", xidy))
Expand Down
Loading

0 comments on commit 0dfd2a1

Please sign in to comment.