Skip to content

Commit

Permalink
fix complex bcs
Browse files Browse the repository at this point in the history
  • Loading branch information
xtalax committed Nov 7, 2024
1 parent 154ff3f commit 4163578
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ docs/site/
# committed for packages, but should be committed for applications that require a static
# environment.
Manifest.toml

.vscode/
29 changes: 21 additions & 8 deletions src/make_pdesys_compatible.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/parse_boundaries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down

0 comments on commit 4163578

Please sign in to comment.