我的版本信息
julia> versioninfo()
Julia Version 1.6.7
Commit 3b76b25b64 (2022-07-19 15:11 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: AMD Ryzen 5 2600 Six-Core Processor
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.0.1 (ORCJIT, znver1)
Environment:
JULIA_NUM_THREADS = 8
JULIA_PKG_SERVER = https://mirrors.bfsu.edu.cn/julia/static
然后是我这里在REPL中赋值给s
,是能够用isnan
判断的
julia> s=NaN
NaN
julia> isnan(s)
true
我提供下我测试的代码:
computername = ENV["COMPUTERNAME"]
if computername == "家里电脑"
push!(LOAD_PATH, "E:/Documents/JuliaProgram/MyModules/")
elseif computername == "宿舍电脑"
push!(LOAD_PATH, "F:/Documents/JuliaProgramme/MyModules")
elseif computername=="DESKTOP-FDIN0I7"
push!(LOAD_PATH, "D:/Documents/Julia/MyModules")
elseif computername=="TINA"
push!(LOAD_PATH, "D:/JuliaProgramme/MyModules")
end
using DoubleRFs, CSV, DataFrames, Interpolations, BenchmarkTools, Plots
function getWakeFunction(wakepath::String)
df=CSV.read(wakepath, DataFrame)
LinearInterpolation(df[!,"z"],1e12*df[!,"wakez"])
end
function main()
funwakez = getWakeFunction("./wakezlin.csv")
σz = 0.00252
Nb = 5e-9/1.6e-19
v1 = 116.66328e6
v2 = 0.0
r = v2/v1
ϕs = 2.8155729
ϕ2s = 0.0
h1 = 216820
h = 3
ηp = 1.429249e-5
σδ = 3.836791e-4
Δz = 0.01σz
centerenergy = 45.5e9
circum=9.9635e4
Σ = 0.5
χ = 0.01
denerr = 1e-12
gr()
# 全程不变的量
zvec = collect(-Σ:Δz:Σ)
potenVecCavity = getPotenCavity(zvec, ϕs, ϕ2s, v1, r, h1, h, circum, centerenergy)
zR, criPotential = DoubleRFs.getRBound(zvec, potenVecCavity, ϕs, ϕ2s, v1, r, h1, h, circum, centerenergy, σz) # 头部粒子存在与否的边界,及该点临界potential
zL = DoubleRFs.getLBound(zvec, potenVecCavity, criPotential, σz)
# 由于右侧(头部)不会受到尾场影响,因此只需要求一次右侧z和临界的Hamiltonian即可。
# 左侧(尾部)则为了保险起见每次更新。
ρvec=DoubleRFs.getDistFromPotential(zvec, potenVecCavity, zL, zR, ηp, σδ) # 计算初始密度分布
# gr()
# plt1 = plot(zvec, potenVecCavity, label="Cavity Potential")
# plot!(plt1, zvec, getPotenWake(zvec, ρvec, funwakez, Nb, Δz, centerenergy, circum), label="")
# xlims!(plt1, -0.04, 0.04)
# ylims!(plt1, -1e-11, 1e-10)
# display(plt1)
plt=plot(zvec, ρvec, label="")
title!(plt, "χ="*string(χ))
xlims!(plt, -0.015, 0.015)
# 第一次迭代
ρvecpre = ρvec
println("第1次调用")
ρvecnow = DoubleRFs.getρVecNow(ρvec, zvec, potenVecCavity, funwakez, zR, criPotential, Nb, centerenergy, circum, ηp, σδ, σz, Δz)
ρvec = (1-χ).*ρvecpre .+ χ.*ρvecnow # 这是利用默认权重χ, 直接迭代的分布, 下一行则是相应的初始判据
cri = DoubleRFs.convergecriterion(ρvec, ρvecpre, zvec, χ, zL, zR)
# 开始循环迭代
while χ >= 0.001
ρvecpre = ρvec
println("第2次调用")
ρvecnow = DoubleRFs.getρVecNow(ρvec, zvec, potenVecCavity, funwakez, zR, criPotential, Nb, centerenergy, circum, ηp, σδ, σz, Δz)
# 找到合适的χ,使分布收敛
suc = false
while suc == false
ρvec = (1-χ).*ρvecpre .+ χ.*ρvecnow
tmpcri = DoubleRFs.convergecriterion(ρvec, ρvecpre, zvec, χ, zL, zR)
if tmpcri < cri # 找到的χ能否让判据收敛
suc = true
cri = tmpcri
println("χ=", χ, ", criterion=", cri)
elseif χ <= 0.001 # 如果χ过小,则不用再寻找合适的χ了
break
else
χ = χ*0.99
end
end
end
# zvec, ρvec
plot!(plt, zvec, ρvec, label="")
display(plt)
nothing
end
main()
而这里的DoubleRFs
库,被我上传到了Github,大佬可以下载下来像我一样push!
调用。
这次遇到的问题函数是./src/Voltage.jl
文件中的getWakeVoltage
的第一个方法。
我测试通过的代码和记录也被我放在./test/
中的TestVoltage.jl
和TestVoltage.md
中。