From e35b03873e35974b7584bc1377d9b59133c730dc Mon Sep 17 00:00:00 2001 From: Nhertl Date: Wed, 18 Sep 2024 11:46:52 +0100 Subject: [PATCH 1/3] Insert of coupling_rescale in wide_band_bath_discretisation.jl Introduction of the keyword 'coupling_rescale' in 'fillbathcouplings!' and 'setcoupling!' --- src/diabatic/wide_band_bath_discretisation.jl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/diabatic/wide_band_bath_discretisation.jl b/src/diabatic/wide_band_bath_discretisation.jl index 85bb5a8..093861b 100644 --- a/src/diabatic/wide_band_bath_discretisation.jl +++ b/src/diabatic/wide_band_bath_discretisation.jl @@ -8,19 +8,19 @@ function fillbathstates!(out::Hermitian, bath::WideBandBathDiscretisation) copy!(diagonal, bath.bathstates) end -function fillbathcoupling!(out::Hermitian, coupling::Real, bath::WideBandBathDiscretisation) +function fillbathcoupling!(out::Hermitian, coupling::Real, bath::WideBandBathDiscretisation, coupling_rescale) first_column = @view out.data[2:end, 1] - setcoupling!(first_column, bath.bathcoupling, coupling) + setcoupling!(first_column, bath.bathcoupling, coupling, coupling_rescale) first_row = @view out.data[1, 2:end] copy!(first_row, first_column) end -function setcoupling!(out::AbstractVector, bathcoupling::AbstractVector, coupling::Real) - out .= bathcoupling .* coupling +function setcoupling!(out::AbstractVector, bathcoupling::AbstractVector, coupling::Real, coupling_rescale) + out .= bathcoupling .* coupling .* coupling_rescale end -function setcoupling!(out::AbstractVector, bathcoupling::Real, coupling::Real) - fill!(out, bathcoupling * coupling) +function setcoupling!(out::AbstractVector, bathcoupling::Real, coupling::Real, coupling_rescale) + fill!(out, bathcoupling * coupling .* coupling_rescale) end """ From cec450f8040eeac5cfafeec3f41cbb363343edd3 Mon Sep 17 00:00:00 2001 From: Nhertl Date: Wed, 18 Sep 2024 13:11:07 +0100 Subject: [PATCH 2/3] Introduced 'coupling_rescale' keyword in anderson_holstein.jl Introduction of 'coupling_rescale' keyword in the struct 'AndersonHolstein' as well as optional keyword in the function AndersonHolstein with the default value 1.0 --- src/diabatic/anderson_holstein.jl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/diabatic/anderson_holstein.jl b/src/diabatic/anderson_holstein.jl index 183e863..a72a604 100644 --- a/src/diabatic/anderson_holstein.jl +++ b/src/diabatic/anderson_holstein.jl @@ -5,13 +5,14 @@ struct AndersonHolstein{M<:DiabaticModel,B,D,T} <: LargeDiabaticModel tmp_derivative::Base.RefValue{D} fermi_level::T nelectrons::Int + coupling_rescale::Real end -function AndersonHolstein(model, bath; fermi_level=0.0) +function AndersonHolstein(model, bath; fermi_level=0.0, coupling_rescale=1.0) tmp_derivative = Ref(NQCModels.zero_derivative(model, zeros(1,1))) fermi_level = austrip(fermi_level) nelectrons = count(x -> x <= fermi_level, bath.bathstates) - return AndersonHolstein(model, bath, tmp_derivative, fermi_level, nelectrons) + return AndersonHolstein(model, bath, tmp_derivative, fermi_level, nelectrons, coupling_rescale) end NQCModels.nstates(model::AndersonHolstein) = NQCModels.nstates(model.bath) + 1 @@ -23,7 +24,7 @@ function NQCModels.potential!(model::AndersonHolstein, V::Hermitian, r::Abstract Vsystem = NQCModels.potential(model.model, r) V[1,1] = Vsystem[2,2] - Vsystem[1,1] fillbathstates!(V, model.bath) - fillbathcoupling!(V, Vsystem[2,1], model.bath) + fillbathcoupling!(V, Vsystem[2,1], model.bath, model.coupling_rescale) return V end @@ -32,7 +33,7 @@ function NQCModels.derivative!(model::AndersonHolstein, D::AbstractMatrix{<:Herm for I in eachindex(Dsystem, D) D[I][1,1] = Dsystem[I][2,2] - Dsystem[I][1,1] - fillbathcoupling!(D[I], Dsystem[I][2,1], model.bath) + fillbathcoupling!(D[I], Dsystem[I][2,1], model.bath, model.coupling_rescale) end return D From 93ac3cd516dd8493afc4bd500a1be3a29f75ff3f Mon Sep 17 00:00:00 2001 From: Nhertl Date: Wed, 18 Sep 2024 18:54:35 +0100 Subject: [PATCH 3/3] coupling_rescale introduced Introduction of the keyword 'coupling_rescale' into fillbathcouplings! --- test/wide_band_bath_discretisations.jl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/wide_band_bath_discretisations.jl b/test/wide_band_bath_discretisations.jl index 1b0388f..992019d 100644 --- a/test/wide_band_bath_discretisations.jl +++ b/test/wide_band_bath_discretisations.jl @@ -8,10 +8,11 @@ using LinearAlgebra: Hermitian, diagind bath = NQCModels.TrapezoidalRule(50, -10, 10) n = NQCModels.nstates(bath) out = Hermitian(zeros(n+1, n+1)) + coupling_rescale = 1.0 NQCModels.DiabaticModels.fillbathstates!(out, bath) @test all(out[diagind(out)[2:end]] .== bath.bathstates) - NQCModels.DiabaticModels.fillbathcoupling!(out, 1.0, bath) + NQCModels.DiabaticModels.fillbathcoupling!(out, 1.0, bath, coupling_rescale) @test all(isapprox.(out[1,2:end], 1.0 / sqrt(50/20))) @test all(isapprox.(out[2:end,1], 1.0 / sqrt(50/20))) end @@ -21,9 +22,10 @@ end n = NQCModels.nstates(bath) out = Hermitian(zeros(n+1, n+1)) + coupling_rescale = 1.0 NQCModels.DiabaticModels.fillbathstates!(out, bath) - NQCModels.DiabaticModels.fillbathcoupling!(out, 1.0, bath) + NQCModels.DiabaticModels.fillbathcoupling!(out, 1.0, bath, coupling_rescale) end @testset "ReferenceGaussLegendre" begin @@ -31,9 +33,10 @@ end n = NQCModels.nstates(bath) out = Hermitian(zeros(n+1, n+1)) + coupling_rescale = 1.0 NQCModels.DiabaticModels.fillbathstates!(out, bath) - NQCModels.DiabaticModels.fillbathcoupling!(out, 1.0, bath) + NQCModels.DiabaticModels.fillbathcoupling!(out, 1.0, bath, coupling_rescale) end @testset "FullGaussLegendre" begin @@ -41,7 +44,8 @@ end n = NQCModels.nstates(bath) out = Hermitian(zeros(n+1, n+1)) + coupling_rescale = 1.0 NQCModels.DiabaticModels.fillbathstates!(out, bath) - NQCModels.DiabaticModels.fillbathcoupling!(out, 1.0, bath) + NQCModels.DiabaticModels.fillbathcoupling!(out, 1.0, bath, coupling_rescale) end