Mercurial > repos > public > sbplib
annotate +scheme/Schrodinger2d.m @ 1316:bd8e607768ce feature/poroelastic
Add interfaceForcing method in multiblock.DiffOp to facilitate mms forcing
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Sun, 26 Jul 2020 20:05:10 -0700 |
parents | 3dd7f87c9a1b |
children | 78db023a7fe3 |
rev | line source |
---|---|
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
1 classdef Schrodinger2d < scheme.Scheme |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
2 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
3 % Discretizes the Laplacian with constant coefficent, |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
743
diff
changeset
|
4 % in the Schrödinger equation way (i.e., the discretization matrix is not necessarily |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
5 % definite) |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
743
diff
changeset
|
6 % u_t = a*i*Laplace u |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
7 % opSet should be cell array of opSets, one per dimension. This |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
8 % is useful if we have periodic BC in one direction. |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
9 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
10 properties |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
11 m % Number of points in each direction, possibly a vector |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
12 h % Grid spacing |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
13 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
14 grid |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
15 dim |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
16 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
17 order % Order of accuracy for the approximation |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
18 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
19 % Diagonal matrix for variable coefficients |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
20 a % Constant coefficient |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
21 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
22 D % Total operator |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
23 D1 % First derivatives |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
24 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
25 % Second derivatives |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
26 D2 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
27 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
28 H, Hi % Inner products |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
29 e_l, e_r |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
30 d1_l, d1_r % Normal derivatives at the boundary |
719
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
31 e_w, e_e, e_s, e_n |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
32 d_w, d_e, d_s, d_n |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
743
diff
changeset
|
33 |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
34 H_boundary % Boundary inner products |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
35 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
36 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
37 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
38 methods |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
39 |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
40 function obj = Schrodinger2d(g ,order, a, opSet) |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
41 default_arg('opSet',{@sbp.D2Variable, @sbp.D2Variable}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
42 default_arg('a',1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
43 dim = 2; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
44 |
948
3dd7f87c9a1b
Use assertType(...) instead of assert(isa(...))
Jonatan Werpers <jonatan@werpers.com>
parents:
941
diff
changeset
|
45 assertType(g, 'grid.Cartesian'); |
743
f4595f14d696
Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents:
719
diff
changeset
|
46 if isa(a, 'function_handle') |
f4595f14d696
Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents:
719
diff
changeset
|
47 a = grid.evalOn(g, a); |
f4595f14d696
Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents:
719
diff
changeset
|
48 a = spdiag(a); |
f4595f14d696
Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents:
719
diff
changeset
|
49 end |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
50 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
51 m = g.size(); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
52 m_tot = g.N(); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
53 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
54 h = g.scaling(); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
55 xlim = {g.x{1}(1), g.x{1}(end)}; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
56 ylim = {g.x{2}(1), g.x{2}(end)}; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
57 lim = {xlim, ylim}; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
58 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
59 % 1D operators |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
60 ops = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
61 for i = 1:dim |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
62 ops{i} = opSet{i}(m(i), lim{i}, order); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
63 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
64 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
65 I = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
66 D1 = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
67 D2 = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
68 H = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
69 Hi = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
70 e_l = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
71 e_r = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
72 d1_l = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
73 d1_r = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
74 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
75 for i = 1:dim |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
76 I{i} = speye(m(i)); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
77 D1{i} = ops{i}.D1; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
78 D2{i} = ops{i}.D2; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
79 H{i} = ops{i}.H; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
80 Hi{i} = ops{i}.HI; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
81 e_l{i} = ops{i}.e_l; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
82 e_r{i} = ops{i}.e_r; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
83 d1_l{i} = ops{i}.d1_l; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
84 d1_r{i} = ops{i}.d1_r; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
85 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
86 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
87 % Constant coeff D2 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
88 for i = 1:dim |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
89 D2{i} = D2{i}(ones(m(i),1)); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
90 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
91 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
92 %====== Assemble full operators ======== |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
93 obj.D1 = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
94 obj.D2 = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
95 obj.e_l = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
96 obj.e_r = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
97 obj.d1_l = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
98 obj.d1_r = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
99 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
100 % D1 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
101 obj.D1{1} = kron(D1{1},I{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
102 obj.D1{2} = kron(I{1},D1{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
103 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
104 % Boundary operators |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
105 obj.e_l{1} = kron(e_l{1},I{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
106 obj.e_l{2} = kron(I{1},e_l{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
107 obj.e_r{1} = kron(e_r{1},I{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
108 obj.e_r{2} = kron(I{1},e_r{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
109 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
110 obj.d1_l{1} = kron(d1_l{1},I{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
111 obj.d1_l{2} = kron(I{1},d1_l{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
112 obj.d1_r{1} = kron(d1_r{1},I{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
113 obj.d1_r{2} = kron(I{1},d1_r{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
114 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
115 % D2 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
116 obj.D2{1} = kron(D2{1},I{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
117 obj.D2{2} = kron(I{1},D2{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
118 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
119 % Quadratures |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
120 obj.H = kron(H{1},H{2}); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
121 obj.Hi = inv(obj.H); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
122 obj.H_boundary = cell(dim,1); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
123 obj.H_boundary{1} = H{2}; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
124 obj.H_boundary{2} = H{1}; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
125 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
126 % Differentiation matrix D (without SAT) |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
127 D2 = obj.D2; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
128 D = sparse(m_tot,m_tot); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
129 for j = 1:dim |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
130 D = D + a*1i*D2{j}; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
131 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
132 obj.D = D; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
133 %=========================================% |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
134 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
135 % Misc. |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
136 obj.m = m; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
137 obj.h = h; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
138 obj.order = order; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
139 obj.grid = g; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
140 obj.dim = dim; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
141 obj.a = a; |
719
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
142 obj.e_w = obj.e_l{1}; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
143 obj.e_e = obj.e_r{1}; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
144 obj.e_s = obj.e_l{2}; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
145 obj.e_n = obj.e_r{2}; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
146 obj.d_w = obj.d1_l{1}; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
147 obj.d_e = obj.d1_r{1}; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
148 obj.d_s = obj.d1_l{2}; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
149 obj.d_n = obj.d1_r{2}; |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
150 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
151 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
152 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
153 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
154 % Closure functions return the operators applied to the own domain to close the boundary |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
155 % Penalty functions return the operators to force the solution. In the case of an interface it returns the operator applied to the other doamin. |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
156 % boundary is a string specifying the boundary e.g. 'l','r' or 'e','w','n','s'. |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
157 % type is a string specifying the type of boundary condition. |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
158 % data is a function returning the data that should be applied at the boundary. |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
159 % neighbour_scheme is an instance of Scheme that should be interfaced to. |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
160 % neighbour_boundary is a string specifying which boundary to interface to. |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
161 function [closure, penalty] = boundary_condition(obj, boundary, type, parameter) |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
162 default_arg('type','Neumann'); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
163 default_arg('parameter', []); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
164 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
165 % j is the coordinate direction of the boundary |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
743
diff
changeset
|
166 % nj: outward unit normal component. |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
167 % nj = -1 for west, south, bottom boundaries |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
168 % nj = 1 for east, north, top boundaries |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
169 [j, nj] = obj.get_boundary_number(boundary); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
170 switch nj |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
171 case 1 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
172 e = obj.e_r; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
173 d = obj.d1_r; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
174 case -1 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
175 e = obj.e_l; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
176 d = obj.d1_l; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
177 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
178 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
179 Hi = obj.Hi; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
180 H_gamma = obj.H_boundary{j}; |
743
f4595f14d696
Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents:
719
diff
changeset
|
181 a = e{j}'*obj.a*e{j}; |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
182 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
183 switch type |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
184 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
185 % Dirichlet boundary condition |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
186 case {'D','d','dirichlet','Dirichlet'} |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
743
diff
changeset
|
187 closure = nj*Hi*d{j}*a*1i*H_gamma*(e{j}' ); |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
188 penalty = -nj*Hi*d{j}*a*1i*H_gamma; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
189 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
190 % Free boundary condition |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
191 case {'N','n','neumann','Neumann'} |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
743
diff
changeset
|
192 closure = -nj*Hi*e{j}*a*1i*H_gamma*(d{j}' ); |
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
743
diff
changeset
|
193 penalty = nj*Hi*e{j}*a*1i*H_gamma; |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
194 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
195 % Unknown boundary condition |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
196 otherwise |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
197 error('No such boundary condition: type = %s',type); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
198 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
199 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
200 |
939
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
201 % type Struct that specifies the interface coupling. |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
202 % Fields: |
939
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
203 % -- interpolation: type of interpolation, default 'none' |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
204 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary,type) |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
205 |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
206 defaultType.interpolation = 'none'; |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
207 default_struct('type', defaultType); |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
208 |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
209 switch type.interpolation |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
210 case {'none', ''} |
940
31186559236d
Add forgotten type argument in call to interfaceStandard in Schrodinger2d and LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
939
diff
changeset
|
211 [closure, penalty] = interfaceStandard(obj,boundary,neighbour_scheme,neighbour_boundary,type); |
939
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
212 case {'op','OP'} |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
213 [closure, penalty] = interfaceNonConforming(obj,boundary,neighbour_scheme,neighbour_boundary,type); |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
214 otherwise |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
215 error('Unknown type of interpolation: %s ', type.interpolation); |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
216 end |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
217 end |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
218 |
939
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
219 function [closure, penalty] = interfaceStandard(obj,boundary,neighbour_scheme,neighbour_boundary,type) |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
220 % u denotes the solution in the own domain |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
221 % v denotes the solution in the neighbour domain |
719
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
222 |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
223 % Get boundary operators |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
224 [e_neighbour, d_neighbour] = neighbour_scheme.get_boundary_ops(neighbour_boundary); |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
225 [e, d, H_gamma] = obj.get_boundary_ops(boundary); |
719
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
226 Hi = obj.Hi; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
227 a = obj.a; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
228 |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
229 % Get outward unit normal component |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
230 [~, n] = obj.get_boundary_number(boundary); |
719
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
231 |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
232 Hi = obj.Hi; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
233 sigma = -n*1i*a/2; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
234 tau = -n*(1i*a)'/2; |
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
235 |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
236 closure = tau*Hi*d*H_gamma*e' + sigma*Hi*e*H_gamma*d'; |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
237 penalty = -tau*Hi*d*H_gamma*e_neighbour' ... |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
238 -sigma*Hi*e*H_gamma*d_neighbour'; |
719
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
239 |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
240 end |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
241 |
939
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
242 function [closure, penalty] = interfaceNonConforming(obj,boundary,neighbour_scheme,neighbour_boundary,type) |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
243 |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
244 % User can request special interpolation operators by specifying type.interpOpSet |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
245 default_field(type, 'interpOpSet', @sbp.InterpOpsOP); |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
246 interpOpSet = type.interpOpSet; |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
247 |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
248 % u denotes the solution in the own domain |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
249 % v denotes the solution in the neighbour domain |
939
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
250 [e_v, d_v] = neighbour_scheme.get_boundary_ops(neighbour_boundary); |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
251 [e_u, d_u, H_gamma] = obj.get_boundary_ops(boundary); |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
252 Hi = obj.Hi; |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
253 a = obj.a; |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
254 |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
255 % Get outward unit normal component |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
256 [~, n] = obj.get_boundary_number(boundary); |
719
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
257 |
939
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
258 % Find the number of grid points along the interface |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
259 m_u = size(e_u, 2); |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
260 m_v = size(e_v, 2); |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
261 |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
262 % Build interpolation operators |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
263 intOps = interpOpSet(m_u, m_v, obj.order, neighbour_scheme.order); |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
264 Iu2v = intOps.Iu2v; |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
265 Iv2u = intOps.Iv2u; |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
266 |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
267 sigma = -n*1i*a/2; |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
268 tau = -n*(1i*a)'/2; |
719
b3f8fb9cefd2
Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents:
718
diff
changeset
|
269 |
939
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
270 closure = tau*Hi*d_u*H_gamma*e_u' + sigma*Hi*e_u*H_gamma*d_u'; |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
271 penalty = -tau*Hi*d_u*H_gamma*Iv2u.good*e_v' ... |
46f5dc61d90b
Update Schrodinger2d to work with new interface types, similar to LaplCurv.
Martin Almquist <malmquist@stanford.edu>
parents:
912
diff
changeset
|
272 -sigma*Hi*e_u*H_gamma*Iv2u.bad*d_v'; |
905
459eeb99130f
Include type as (optional) input parameter in the interface method of all schemes.
Martin Almquist <malmquist@stanford.edu>
parents:
743
diff
changeset
|
273 |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
274 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
275 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
276 % Returns the coordinate number and outward normal component for the boundary specified by the string boundary. |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
277 function [j, nj] = get_boundary_number(obj, boundary) |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
278 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
279 switch boundary |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
280 case {'w','W','west','West', 'e', 'E', 'east', 'East'} |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
281 j = 1; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
282 case {'s','S','south','South', 'n', 'N', 'north', 'North'} |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
283 j = 2; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
284 otherwise |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
285 error('No such boundary: boundary = %s',boundary); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
286 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
287 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
288 switch boundary |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
289 case {'w','W','west','West','s','S','south','South'} |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
290 nj = -1; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
291 case {'e', 'E', 'east', 'East','n', 'N', 'north', 'North'} |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
292 nj = 1; |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
293 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
294 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
295 |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
296 % Returns the boundary ops and sign for the boundary specified by the string boundary. |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
297 % The right boundary is considered the positive boundary |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
298 function [e, d, H_b] = get_boundary_ops(obj, boundary) |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
299 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
300 switch boundary |
912
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
301 case 'w' |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
302 e = obj.e_w; |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
303 d = obj.d_w; |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
304 H_b = obj.H_boundary{1}; |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
305 case 'e' |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
306 e = obj.e_e; |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
307 d = obj.d_e; |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
308 H_b = obj.H_boundary{1}; |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
309 case 's' |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
310 e = obj.e_s; |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
311 d = obj.d_s; |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
312 H_b = obj.H_boundary{2}; |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
313 case 'n' |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
314 e = obj.e_n; |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
315 d = obj.d_n; |
1cdf5ead2a16
Refactor interface method for Schrodinger2d
Martin Almquist <malmquist@stanford.edu>
parents:
910
diff
changeset
|
316 H_b = obj.H_boundary{2}; |
718
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
317 otherwise |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
318 error('No such boundary: boundary = %s',boundary); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
319 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
320 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
321 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
322 function N = size(obj) |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
323 N = prod(obj.m); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
324 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
325 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
326 end |