Gauss-Legendre added
This commit is contained in:
parent
cdf6a3c722
commit
3a9f30e4f5
|
|
@ -1,5 +1,6 @@
|
|||
[deps]
|
||||
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
|
||||
FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838"
|
||||
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
|
||||
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
|
||||
PolyLog = "85e3b03c-9856-11eb-0374-4dc1f8670e7f"
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ function optimized_dirac_potentials(p::Bool, s::system)
|
|||
@. f1s = M - s.Φ0 - s.W0 - (p - 0.5) * 2 * s.B0 - p * s.A0
|
||||
@. f2s = -M + s.Φ0 - s.W0 - (p - 0.5) * 2 * s.B0 - p * s.A0
|
||||
|
||||
f1 = linear_interpolation(s.r_mesh.r, f1s)
|
||||
f2 = linear_interpolation(s.r_mesh.r, f2s)
|
||||
f1 = linear_interpolation(s.r_mesh.r, f1s, extrapolation_bc = Flat())
|
||||
f2 = linear_interpolation(s.r_mesh.r, f2s, extrapolation_bc = Flat())
|
||||
|
||||
return (f1, f2)
|
||||
end
|
||||
|
|
|
|||
18
system.jl
18
system.jl
|
|
@ -1,3 +1,5 @@
|
|||
using FastGaussQuadrature
|
||||
|
||||
"Tabulates a nucleon spectrum (protons or neutrons) containing κ and occupancy"
|
||||
struct spectrum
|
||||
κ::Vector{Int}
|
||||
|
|
@ -22,6 +24,15 @@ function uniform_mesh(r_max::Float64, divs::Int)::mesh
|
|||
return mesh(r_max, r, w)
|
||||
end
|
||||
|
||||
"Create a Gauss-Legendre mesh"
|
||||
function gauleg_mesh(r_max::Float64, n::Int)::mesh
|
||||
a, b = (0.0, r_max)
|
||||
nodes, weights = gausslegendre(n)
|
||||
transformed_nodes = (b - a) / 2 .* nodes .+ (b + a) / 2
|
||||
transformed_weights = (b - a) / 2 .* weights
|
||||
return mesh(r_max, transformed_nodes, transformed_weights)
|
||||
end
|
||||
|
||||
"Defines a nuclear system containing relevant parameters and meson/nucleon densities"
|
||||
mutable struct system
|
||||
Z::Int
|
||||
|
|
@ -42,11 +53,14 @@ mutable struct system
|
|||
ρ_sn::Vector{Float64}
|
||||
ρ_vn::Vector{Float64}
|
||||
|
||||
"Initialize an unsolved system"
|
||||
system(Z, N, r_max, divs) = new(Z, N, uniform_mesh(r_max, divs), unfilled_spectrum(), unfilled_spectrum(), [zeros(1 + divs) for _ in 1:8]...)
|
||||
"Initialize an unsolved system with a uniform r-mesh"
|
||||
system(Z::Int, N::Int, r_max::Float64, divs::Int) = new(Z, N, uniform_mesh(r_max, divs), unfilled_spectrum(), unfilled_spectrum(), [zeros(1 + divs) for _ in 1:8]...)
|
||||
|
||||
"Dummy struct to define the mesh"
|
||||
system(r_max, divs) = system(0, 0, r_max, divs)
|
||||
|
||||
"Initialize an unsolved system with a Gauss-Legendre r-mesh"
|
||||
system(Z::Int, N::Int, mesh_size::Int, r_max::Float64) = new(Z, N, gauleg_mesh(r_max, mesh_size), unfilled_spectrum(), unfilled_spectrum(), [zeros(mesh_size) for _ in 1:8]...)
|
||||
end
|
||||
|
||||
"Get mass number of nucleus"
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ include("../NuclearRMF.jl")
|
|||
Z = 82
|
||||
N = 126
|
||||
r_max = 20.0
|
||||
divs = 400
|
||||
mesh_points = 400
|
||||
|
||||
s = system(Z, N, r_max, divs)
|
||||
s = system(Z, N, mesh_points, r_max)
|
||||
|
||||
solve_system!(s; monitor_plot=true)
|
||||
|
|
|
|||
Loading…
Reference in New Issue