Skip to content

Commit

Permalink
Rename var_parms -> extende_feynmanvw; other refactor / clean.
Browse files Browse the repository at this point in the history
  • Loading branch information
jarvist committed Nov 29, 2022
1 parent e18f990 commit 53b350f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/FeynmanTheory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ function feynmanvw(α, β; v=3.0, w=3.0) # v, w defaults
Δv = v - w # defines a constraint, so that v>w
initial = [Δv + 0.01, w]

# Tthermal action
# Thermal action
f(x) = F(x[1] + x[2], x[2], β, α)

# Use Optim to optimise v and w to minimise enthalpy.
Expand Down
8 changes: 4 additions & 4 deletions src/MobilityTheories.jl
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ function make_polaron(ϵ_optic, ϵ_static, phonon_freq, m_eff, T::Float64, Ω::F
betas = [T == 0.0 ? Inf64 : ħ * ω[j] / (kB * T) * 1e12 for j in eachindex(ω)]

# Calculate variational parameters for each temperature from multiple phonon frequencies.
params = T == 0.0 ? var_params(α; v=v_guess, w=v_guess, ω=ω, N=N_params) : var_params(α, betas; v=v_guess, w=w_guess, ω=ω, N=N_params)
params = T == 0.0 ? extended_feynmanvw(α; v=v_guess, w=v_guess, ω=ω, N=N_params) : extended_feynmanvw(α, betas; v=v_guess, w=w_guess, ω=ω, N=N_params)

# Separate tuples of variational parameters into a list of 'v' and 'w' parameters for each temperature.
v_params = params[1]
Expand Down Expand Up @@ -426,7 +426,7 @@ end
v_guess, w_guess, E_guess = params[i-1]
end

params[i] = Trange[i] == 0.0 ? var_params(α; v=v_guess, w=w_guess, ω=ω, N=N_params) : var_params(α, @view(betas[i, :]); v=v_guess, w=w_guess, ω=ω, N=N_params)
params[i] = Trange[i] == 0.0 ? extended_feynmanvw(α; v=v_guess, w=w_guess, ω=ω, N=N_params) : extended_feynmanvw(α, @view(betas[i, :]); v=v_guess, w=w_guess, ω=ω, N=N_params)

@fastmath @inbounds @simd for j in 1:N_params
v_params[i, j] = params[i][1][j]
Expand Down Expand Up @@ -470,7 +470,7 @@ function make_polaron(α::Float64, T::Float64, Ω::Float64; ω=1.0, v_guess = 5.
beta = T == 0.0 ? Inf64 : ω / T

# Calculate variational parameters for each alpha parameter and temperature. Returns a Matrix of tuples.
params = T == 0.0 ? var_params(α; v=v_guess, w=w_guess, ω=ω, N=N_params) : var_params(α, beta; v=v_guess, w=w_guess, ω=ω, N=N_params)
params = T == 0.0 ? extended_feynmanvw(α; v=v_guess, w=w_guess, ω=ω, N=N_params) : extended_feynmanvw(α, beta; v=v_guess, w=w_guess, ω=ω, N=N_params)

# Separate tuples of variational parameters into a Matrices of 'v' and 'w' parameters for each alpha parameter and temperature.
v_param = params[1]
Expand Down Expand Up @@ -538,7 +538,7 @@ end

@fastmath @inbounds @simd for i in eachindex(αrange)

params[i, j] = Trange[j] == 0.0 ? var_params(αrange[i]; v=v_guess, w=w_guess, ω=ω, N=N_params) : var_params(αrange[i], betas[j]; v=v_guess, w=w_guess, ω=ω, N=N_params)
params[i, j] = Trange[j] == 0.0 ? extended_feynmanvw(αrange[i]; v=v_guess, w=w_guess, ω=ω, N=N_params) : extended_feynmanvw(αrange[i], betas[j]; v=v_guess, w=w_guess, ω=ω, N=N_params)

for k in 1:N_params
v_params[i, j, k] = params[i, j][1][k]
Expand Down
2 changes: 1 addition & 1 deletion src/MultipleBranches.jl
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ Minimises the multiple phonon mode free energy function for a set of vₚ and w
See also [`multi_F`](@ref), [`feynmanvw`](@ref).
"""
function var_params...; v = 0.0, w = 0.0, ω = 1.0, N = 1, show_trace = false) # N number of v and w params
function extended_feynmanvw...; v = 0.0, w = 0.0, ω = 1.0, N = 1, show_trace = false) # N number of v and w params

if N != length(v) != length(w)
return error("The number of variational parameters v & w must be equal to N.")
Expand Down
2 changes: 1 addition & 1 deletion src/PolaronMobility.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export frohlichalpha, feynmanvw, F, polaronmobility, savepolaron
export HellwarthBScheme, HellwarthAScheme
export polaron_memory_function # Polaron memory functions
export optical_absorption # Polaron optical absorption
export ϵ_ionic_mode, multi_frohlichalpha, var_params, multi_F, polaron_mobility, polaron_complex_impedence, polaron_complex_conductivity
export ϵ_ionic_mode, multi_frohlichalpha, extended_feynmanvw, multi_F, polaron_mobility, polaron_complex_impedence, polaron_complex_conductivity
export frohlichPartial, IRtoDielectric, IRtoalpha, DielectricFromIRmode
export Hellwarth1999mobilityRHS
export make_polaron, save_polaron, load_polaron, combine_polarons
Expand Down
4 changes: 2 additions & 2 deletions test/MultiplePhonons.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@

# Variations

v_0, w_0 = var_params(α; v=0.0, w=0.0, ω=ω) # Athermal
v_0, w_0 = extended_feynmanvw(α; v=0.0, w=0.0, ω=ω) # Athermal

β = [i .* ħ / (kB * 300) * 1e12 for i in ω]
v, w = var_params(α, β; v=0.0, w=0.0, ω=ω) # Thermal
v, w = extended_feynmanvw(α, β; v=0.0, w=0.0, ω=ω) # Thermal

@testset "Multiple mode variations" begin

Expand Down

0 comments on commit 53b350f

Please sign in to comment.