jarvist / PolaronMobility.jl
Showing 2 of 3 files from the diff.
Newly tracked file
src/Types.jl changed.
Other files ignored by Codecov

@@ -546,7 +546,7 @@
 546 546 547 547 `See also [`multi_F`](@ref), [`feynmanvw`](@ref).` 548 548 `"""` 549 - `function var_params(α, β; v = 0.0, w = 0.0, ω = 1.0, N = 1, show_trace = false) # N number of v and w params` 549 + `function var_params(α...; v = 0.0, w = 0.0, ω = 1.0, N = 1, show_trace = false) # N number of v and w params` 550 550 551 551 ` if N != length(v) != length(w)` 552 552 ` return error("The number of variational parameters v & w must be equal to N.")`
@@ -566,7 +566,7 @@
 566 566 ` upper = fill(Inf64, 2 * N)` 567 567 568 568 ` # The multiple phonon mode free energy function to minimise.` 569 - ` f(x) = multi_F([x[2 * n - 1] for n in 1:N] .+ [x[2 * n] for n in 1:N], [x[2 * n] for n in 1:N], α, β; ω = ω)` 569 + ` f(x) = multi_F([x[2 * n - 1] for n in 1:N] .+ [x[2 * n] for n in 1:N], [x[2 * n] for n in 1:N], α...; ω = ω)` 570 570 571 571 ` # Use Optim to optimise the free energy function w.r.t the set of v and w parameters.` 572 572 ` solution = Optim.optimize(`
@@ -594,66 +594,4 @@
 594 594 ` return (Δv .+ w, w, energy)` 595 595 `end` 596 596 597 - `"""` 598 - ` var_params(α; v = 0.0, w = 0.0, ω = 1.0, N = 1, show_trace = false, verbose = false)` 599 - 600 - `Minimises the multiple phonon mode free energy function for a set of vₚ and wₚ variational parameters at zero-temperature. Similar to `var_params(α, β)` but with `β = Inf`.` 601 - 602 - `# Arguments` 603 - `- `α::Vector{Float64}`: is the partial dielectric electron-phonon coupling parameter for the 'jth' phonon mode. ` 604 - `- `v::Float64, w::Float64`: determines if the function should start with a random initial set of variational parameters (v, w = 0.0) or a given set of variational parameter values.` 605 - `- `ω::Union{Float64, Vector{Float64}}`: phonon mode frequencies (2π THz). Predefined as `ω = 1.0` for a single mode in polaron units.` 606 - `- `N::Integer`: specifies the number of variational parameter pairs, v_p and w_p, to use in minimising the free energy.` 607 - `- `show_trace::Bool`: shows the optimsation trace from `Optim.jl`.` 608 - `- `verbose`: is used by `make_polaron()` to specify whether or not to print. Ignore.` 609 - 610 - `See also [`multi_F`](@ref), [`feynmanvw`](@ref), [`var_param`](@ref).` 611 - `"""` 612 - `function var_params(α; v = 0.0, w = 0.0, ω = 1.0, N = 1, show_trace = false) # N number of v and w params` 613 - ` ` 614 - ` if N != length(v) != length(w)` 615 - ` return error("The number of variational parameters v & w must be equal to N.")` 616 - ` end` 617 - 618 - ` # Use a random set of N initial v and w values.` 619 - ` if v == 0.0 || w == 0.0` 620 - ` # Intial guess for v and w parameters.` 621 - ` initial = [x for x in 1.0:(2.0*N)] # initial guess around 4 and ≥ 1.` 622 - ` else` 623 - ` Δv = v .- w` 624 - ` initial = vcat(Δv .+ 1e-5, w)` 625 - ` end` 626 - 627 - ` # Limits of the optimisation.` 628 - ` lower = fill(0.0, 2 * N)` 629 - ` upper = fill(100.0, 2 * N)` 630 - 631 - ` # The multiple phonon mode free energy function to minimise.` 632 - ` f(x) = multi_F([x[2 * n - 1] for n in 1:N] .+ [x[2 * n] for n in 1:N], [x[2 * n] for n in 1:N], α; ω = ω)` 633 - 634 - ` # Use Optim to optimise the free energy function w.r.t the set of v and w parameters.` 635 - ` solution = Optim.optimize(` 636 - ` Optim.OnceDifferentiable(f, initial; autodiff=:forward),` 637 - ` lower,` 638 - ` upper,` 639 - ` initial,` 640 - ` Fminbox(BFGS()),` 641 - ` Optim.Options(show_trace = show_trace), # Set time limit for asymptotic convergence if needed.` 642 - ` )` 643 - 644 - ` # Extract the v and w parameters that minimised the free energy.` 645 - ` var_params = Optim.minimizer(solution)` 646 - ` energy = Optim.minimum(solution)` 647 - 648 - ` # Separate the v and w parameters into one-dimensional arrays (vectors).` 649 - ` Δv = [var_params[2*n-1] for n in 1:N]` 650 - ` w = [var_params[2*n] for n in 1:N]` 651 - 652 - ` if Optim.converged(solution) == false` 653 - ` @warn "Failed to converge T = 0 K variational solution. v = \$(Δv .+ w), w = \$w."` 654 - ` end` 655 - 656 - ` # Return the variational parameters that minimised the free energy.` 657 - ` return (Δv .+ w, w, energy)` 658 - `end` 659 597

@@ -11,9 +11,11 @@
 11 11 `"Boltzmann's constant, (kgm²K⁻¹)."` 12 12 `const Boltzmann = const kB = 1.380649e-23` 13 13 `"Permittivity of free space, (C²N⁻¹m⁻²)."` 14 - `const ε_0 = 8.85418682e-12` 14 + `const ε_0 = ϵ_0 = 8.85418682e-12` 15 15 `"Speed of light, (ms⁻¹)."` 16 16 `const c = 299792458` 17 + `"Atomic mass unit, (kg)"` 18 + `const amu = 1.660_539_066_60e-27` 17 19 18 20 `# Structures` 19 21
Files Coverage
src 59.48%
Project Totals (9 files) 59.48%