From 13494df20b6312ba0116f4d709d7154b80496ae5 Mon Sep 17 00:00:00 2001 From: Nuwan Yapa Date: Thu, 25 Apr 2024 11:32:52 -0400 Subject: [PATCH] Different subdivisions for mesh segment --- B2R_comparison.jl | 4 ++-- EC_test.ipynb | 4 ++-- p_space.jl | 8 ++++---- p_space_test.ipynb | 4 ++-- simple_berggren.ipynb | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/B2R_comparison.jl b/B2R_comparison.jl index 3b12791..1447510 100644 --- a/B2R_comparison.jl +++ b/B2R_comparison.jl @@ -1,8 +1,8 @@ using Plots, LinearAlgebra include("p_space.jl") -berggren_mesh = get_mesh((0, 0.4 - 0.15im, 0.8, 6), 128) -csm_mesh = get_mesh((0, 8 - 3im), 512) +berggren_mesh = get_mesh([0, 0.4 - 0.15im, 0.8, 6], [128, 128, 128]) +csm_mesh = get_mesh([0, 8 - 3im], [512]) for mesh in (berggren_mesh, csm_mesh) p, w = mesh diff --git a/EC_test.ipynb b/EC_test.ipynb index 32f5be4..105ae00 100644 --- a/EC_test.ipynb +++ b/EC_test.ipynb @@ -16,8 +16,8 @@ "metadata": {}, "outputs": [], "source": [ - "vertices = (0, 0.4 - 0.15im, 0.8, 6)\n", - "subdivisions = 128\n", + "vertices = [0, 0.4 - 0.15im, 0.8, 6]\n", + "subdivisions = [128, 128, 128]\n", "p, w = get_mesh(vertices, subdivisions)\n", "mesh_E = p.*p ./ (2*0.5)\n", "\n", diff --git a/p_space.jl b/p_space.jl index 8363fee..1ad9704 100644 --- a/p_space.jl +++ b/p_space.jl @@ -13,11 +13,11 @@ function gausslegendre_shifted(a, b, n) return (p, w) end -function get_mesh(vertices, subdivisions) +function get_mesh(vertices::Vector, subdivs::Vector) p = Vector{ComplexF64}() w = Vector{ComplexF64}() - for (a, b) in zip(vertices, vertices[2:end]) - p_new, w_new = gausslegendre_shifted(a, b, subdivisions) + for (a, b, subdiv) in zip(vertices, vertices[2:end], subdivs) + p_new, w_new = gausslegendre_shifted(a, b, subdiv) append!(p, p_new) append!(w, w_new) end @@ -46,7 +46,7 @@ function identify_pole_i(p, evals, μ=0.5) end function quick_pole_E(V_pq, μ=0.5; cs_angle=0.4, cutoff=8.0, meshpoints=256) - p, w = get_mesh([0, cutoff * exp(-1im * cs_angle)], meshpoints) + p, w = get_mesh([0, cutoff * exp(-1im * cs_angle)], [meshpoints]) evals = eigvals(get_H_matrix(V_pq, p, w, μ)) return evals[identify_pole_i(p, evals, μ)] end \ No newline at end of file diff --git a/p_space_test.ipynb b/p_space_test.ipynb index 7ede478..636c06e 100644 --- a/p_space_test.ipynb +++ b/p_space_test.ipynb @@ -16,8 +16,8 @@ "metadata": {}, "outputs": [], "source": [ - "vertices = (0, 1 - 0.5im, 2, 6)\n", - "subdivisions = 64\n", + "vertices = [0, 1 - 0.5im, 2, 6]\n", + "subdivisions = [64, 64, 64]\n", "p, w = get_mesh(vertices, subdivisions)\n", "\n", "scatter(real.(p), imag.(p))" diff --git a/simple_berggren.ipynb b/simple_berggren.ipynb index 0608ce5..576b36f 100644 --- a/simple_berggren.ipynb +++ b/simple_berggren.ipynb @@ -16,8 +16,8 @@ "metadata": {}, "outputs": [], "source": [ - "vertices = (0, 0.5 - 0.3im, 1, 6)\n", - "subdivisions = 64\n", + "vertices = [0, 0.5 - 0.3im, 1, 6]\n", + "subdivisions = [64, 64, 64]\n", "p, w = get_mesh(vertices, subdivisions)\n", "\n", "# resonance example from my thesis\n",