From 41635785f02f31a310336987554a4724bce2336c Mon Sep 17 00:00:00 2001 From: xtalax Date: Thu, 7 Nov 2024 19:17:57 +0000 Subject: [PATCH] fix complex bcs --- .gitignore | 2 ++ src/make_pdesys_compatible.jl | 29 +++++++++++++++++++++-------- src/parse_boundaries.jl | 1 + 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 29126e4..81955e6 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,5 @@ docs/site/ # committed for packages, but should be committed for applications that require a static # environment. Manifest.toml + +.vscode/ \ No newline at end of file diff --git a/src/make_pdesys_compatible.jl b/src/make_pdesys_compatible.jl index 18e8a54..f37b338 100644 --- a/src/make_pdesys_compatible.jl +++ b/src/make_pdesys_compatible.jl @@ -67,16 +67,30 @@ function split_complex_eq(eq, redvmaps, imdvmaps) end end +struct ComplexEq + reeq1 + imeq1 + reeq2 + imeq2 +end + function split_complex_bc(eq, redvmaps, imdvmaps) - eq = split_complex(eq) - if eq isa Vector + eq = eq isa Pair ? eq : split_complex(eq) + if eq isa Vector eq1 = eq[1] - eq2 = eq[2] + eq2 = eq[2] + reeq1 = substitute(eq1.lhs, redvmaps) ~ substitute(eq1.rhs, redvmaps) + imeq2 = substitute(eq2.lhs, imdvmaps) ~ substitute(eq2.rhs, imdvmaps) + reeq2 = substitute(eq2.lhs, redvmaps) ~ substitute(eq2.rhs, redvmaps) + imeq1 = substitute(eq1.lhs, imdvmaps) ~ substitute(eq1.rhs, imdvmaps) + return [reeq1.lhs - imeq2.lhs ~ reeq1.rhs - imeq2.rhs , reeq2.lhs + imeq1.lhs ~ reeq2.rhs + imeq1.rhs] + elseif eq isa Pair + rhs = split_complex(unwrap(eq.second)) + eq1 = substitute(eq.first, redvmaps) ~ rhs[1] + eq2 = substitute(eq.first, imdvmaps) ~ rhs[2] + else eq1 = substitute(eq1.lhs, redvmaps) ~ substitute(eq1.rhs, redvmaps) eq2 = substitute(eq2.lhs, imdvmaps) ~ substitute(eq2.rhs, imdvmaps) - else - eq1 = substitute(eq.lhs, redvmaps) ~ substitute(eq.rhs, redvmaps) - eq2 = substitute(eq.lhs, imdvmaps) ~ substitute(eq.rhs, imdvmaps) end return [eq1, eq2] end @@ -122,8 +136,7 @@ function handle_complex(pdesys) imdv = imdvmaps[operation(dv)](arguments(dv)...) [redv, imdv] end - #eqs = substitute.(eqs, [false => 0.0]) - #@show eqs + pdesys = PDESystem(eqs, bcs, pdesys.domain, pdesys.ivs, dvs, pdesys.ps, name = pdesys.name) return pdesys, dvmaps else diff --git a/src/parse_boundaries.jl b/src/parse_boundaries.jl index 77024fc..64c2897 100644 --- a/src/parse_boundaries.jl +++ b/src/parse_boundaries.jl @@ -151,6 +151,7 @@ function generate_boundary_matching_rules(v, orders) return (lower, upper) end + """ Creates a map of boundaries for each variable to be used later when discretizing the boundary condition equations """