From c1b477a1b2b796617c4e345a7296a8d429d7a067 Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Sun, 26 Feb 2023 18:36:05 -0500 Subject: Update to v0.4 feature: compute the 2-point correlation function in easyeq. feature: compute the Fourier transform of the 2-point correlation function in anyeq and easyeq. feature: compute the local maximum of the 2-point correlation function and its Fourier transform. feature: compute the compressibility for anyeq. feature: allow for linear spacing of rho's. feature: print the scattering length. change: ux and uk now return real numbers. fix: error in the computation of the momentum distribution: wrong definition of delta functions. fix: various minor bugs. optimization: assign explicit types to variables. --- src/integration.jl | 50 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) (limited to 'src/integration.jl') diff --git a/src/integration.jl b/src/integration.jl index 9be4641..223d6cc 100644 --- a/src/integration.jl +++ b/src/integration.jl @@ -1,4 +1,4 @@ -## Copyright 2021 Ian Jauslin +## Copyright 2021-2023 Ian Jauslin ## ## Licensed under the Apache License, Version 2.0 (the "License"); ## you may not use this file except in compliance with the License. @@ -13,7 +13,12 @@ ## limitations under the License. # approximate \int_a^b f using Gauss-Legendre quadratures -@everywhere function integrate_legendre(f,a,b,weights) +@everywhere function integrate_legendre( + f::Function, + a::Float64, + b::Float64, + weights::Tuple{Array{Float64,1},Array{Float64,1}} +) out=0 for i in 1:length(weights[1]) out+=(b-a)/2*weights[2][i]*f((b-a)/2*weights[1][i]+(b+a)/2) @@ -21,7 +26,13 @@ return out end # \int f*g where g is sampled at the Legendre nodes -@everywhere function integrate_legendre_sampled(f,g,a,b,weights) +@everywhere function integrate_legendre_sampled( + f::Function, + g::Array{Float64,1}, + a::Float64, + b::Float64, + weights::Tuple{Array{Float64,1},Array{Float64,1}} +) out=0 for i in 1:length(weights[1]) out+=(b-a)/2*weights[2][i]*f((b-a)/2*weights[1][i]+(b+a)/2)*g[i] @@ -31,7 +42,12 @@ end # approximate \int_a^b f/sqrt((b-x)(x-a)) using Gauss-Chebyshev quadratures -@everywhere function integrate_chebyshev(f,a,b,N) +@everywhere function integrate_chebyshev( + f::Function, + a::Float64, + b::Float64, + N::Int64 +) out=0 for i in 1:N out=out+pi/N*f((b-a)/2*cos((2*i-1)/(2*N)*pi)+(b+a)/2) @@ -40,7 +56,11 @@ end end # approximate \int_0^\infty dr f(r)*exp(-a*r) using Gauss-Chebyshev quadratures -@everywhere function integrate_laguerre(f,a,weights_gL) +@everywhere function integrate_laguerre( + f::Function, + a::Float64, + weights_gL::Tuple{Array{Float64,1},Array{Float64,1}} +) out=0. for i in 1:length(weights_gL[1]) out+=1/a*f(weights_gL[1][i]/a)*weights_gL[2][i] @@ -49,10 +69,28 @@ end end # Hann window -@everywhere function hann(x,L) +@everywhere function hann( + x::Float64, + L::Float64 +) if abs(x)