annotate +scheme/Schrodinger2d.m @ 743:f4595f14d696 feature/utux2D

Change schemes to work for special coefficients.
author Martin Almquist <malmquist@stanford.edu>
date Mon, 21 May 2018 23:11:34 -0700
parents b3f8fb9cefd2
children 459eeb99130f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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,
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
4 % in the Schrödinger equation way (i.e., the discretization matrix is not necessarily
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)
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
6 % u_t = a*i*Laplace u
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
718
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
33
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
719
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
36 interpolation_type % MC or AWW
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
37
718
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
38 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
39
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
40 methods
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
41
719
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
42 function obj = Schrodinger2d(g ,order, a, opSet, interpolation_type)
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
43 default_arg('interpolation_type','AWW');
718
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
44 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
45 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
46 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
47
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
48 assert(isa(g, 'grid.Cartesian'))
743
f4595f14d696 Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents: 719
diff changeset
49 if isa(a, 'function_handle')
f4595f14d696 Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents: 719
diff changeset
50 a = grid.evalOn(g, a);
f4595f14d696 Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents: 719
diff changeset
51 a = spdiag(a);
f4595f14d696 Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents: 719
diff changeset
52 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
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 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
55 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
56
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
57 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
58 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
59 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
60 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
61
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
62 % 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
63 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
64 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
65 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
66 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
67
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
68 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
69 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
70 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
71 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
72 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
73 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
74 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
75 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
76 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
77
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
78 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
79 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
80 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
81 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
82 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
83 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
84 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
85 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
86 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
87 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
88 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
89
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
90 % 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
91 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
92 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
93 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
94
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
95 %====== 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
96 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
97 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
98 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
99 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
100 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
101 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
102
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
103 % D1
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
104 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
105 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
106
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
107 % 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
108 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
109 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
110 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
111 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
112
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_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
114 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
115 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
116 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
117
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
118 % D2
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
119 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
120 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
121
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
122 % Quadratures
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 = 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
124 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
125 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
126 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
127 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
128
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
129 % 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
130 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
131 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
132 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
133 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
134 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
135 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
136 %=========================================%
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
137
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
138 % Misc.
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.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
140 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
141 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
142 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
143 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
144 obj.a = a;
719
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
145 obj.e_w = obj.e_l{1};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
146 obj.e_e = obj.e_r{1};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
147 obj.e_s = obj.e_l{2};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
148 obj.e_n = obj.e_r{2};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
149 obj.d_w = obj.d1_l{1};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
150 obj.d_e = obj.d1_r{1};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
151 obj.d_s = obj.d1_l{2};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
152 obj.d_n = obj.d1_r{2};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
153 obj.interpolation_type = interpolation_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
154
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
155 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
156
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
157
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
158 % 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
159 % 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
160 % 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
161 % 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
162 % 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
163 % 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
164 % 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
165 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
166 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
167 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
168
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 is the coordinate direction of 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
170 % nj: outward unit normal component.
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
171 % 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
172 % 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
173 [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
174 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
175 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
176 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
177 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
178 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
179 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
180 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
181 end
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 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
184 H_gamma = obj.H_boundary{j};
743
f4595f14d696 Change schemes to work for special coefficients.
Martin Almquist <malmquist@stanford.edu>
parents: 719
diff changeset
185 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
186
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
187 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
188
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
189 % 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
190 case {'D','d','dirichlet','Dirichlet'}
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
191 closure = nj*Hi*d{j}*a*1i*H_gamma*(e{j}' );
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
192 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
193
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
194 % 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
195 case {'N','n','neumann','Neumann'}
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
196 closure = -nj*Hi*e{j}*a*1i*H_gamma*(d{j}' );
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
197 penalty = nj*Hi*e{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
198
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
199 % 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
200 otherwise
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
201 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
202 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
203 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
204
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
205 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary)
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
206 % 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
207 % 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
208 % Get neighbour boundary operator
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
209
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
210 [coord_nei, n_nei] = get_boundary_number(obj, neighbour_boundary);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
211 [coord, n] = get_boundary_number(obj, boundary);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
212 switch n_nei
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
213 case 1
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
214 % North or east boundary
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
215 e_neighbour = neighbour_scheme.e_r;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
216 d_neighbour = neighbour_scheme.d1_r;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
217 case -1
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
218 % South or west boundary
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
219 e_neighbour = neighbour_scheme.e_l;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
220 d_neighbour = neighbour_scheme.d1_l;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
221 end
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
222
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
223 e_neighbour = e_neighbour{coord_nei};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
224 d_neighbour = d_neighbour{coord_nei};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
225 H_gamma = obj.H_boundary{coord};
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
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
229 switch coord_nei
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
230 case 1
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
231 m_neighbour = neighbour_scheme.m(2);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
232 case 2
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
233 m_neighbour = neighbour_scheme.m(1);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
234 end
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
235
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
236 switch coord
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
237 case 1
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
238 m = obj.m(2);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
239 case 2
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
240 m = obj.m(1);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
241 end
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
242
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
243 switch n
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
244 case 1
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
245 % North or east boundary
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
246 e = obj.e_r;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
247 d = obj.d1_r;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
248 case -1
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
249 % South or west boundary
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
250 e = obj.e_l;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
251 d = obj.d1_l;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
252 end
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
253 e = e{coord};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
254 d = d{coord};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
255
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
256 Hi = obj.Hi;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
257 sigma = -n*1i*a/2;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
258 tau = -n*(1i*a)'/2;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
259
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
260 grid_ratio = m/m_neighbour;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
261 if grid_ratio ~= 1
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
262
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
263 [ms, index] = sort([m, m_neighbour]);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
264 orders = [obj.order, neighbour_scheme.order];
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
265 orders = orders(index);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
266
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
267 switch obj.interpolation_type
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
268 case 'MC'
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
269 interpOpSet = sbp.InterpMC(ms(1),ms(2),orders(1),orders(2));
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
270 if grid_ratio < 1
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
271 I_neighbour2local_e = interpOpSet.IF2C;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
272 I_neighbour2local_d = interpOpSet.IF2C;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
273 I_local2neighbour_e = interpOpSet.IC2F;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
274 I_local2neighbour_d = interpOpSet.IC2F;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
275 elseif grid_ratio > 1
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
276 I_neighbour2local_e = interpOpSet.IC2F;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
277 I_neighbour2local_d = interpOpSet.IC2F;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
278 I_local2neighbour_e = interpOpSet.IF2C;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
279 I_local2neighbour_d = interpOpSet.IF2C;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
280 end
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
281 case 'AWW'
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
282 %String 'C2F' indicates that ICF2 is more accurate.
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
283 interpOpSetF2C = sbp.InterpAWW(ms(1),ms(2),orders(1),orders(2),'F2C');
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
284 interpOpSetC2F = sbp.InterpAWW(ms(1),ms(2),orders(1),orders(2),'C2F');
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
285 if grid_ratio < 1
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
286 % Local is coarser than neighbour
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
287 I_neighbour2local_e = interpOpSetF2C.IF2C;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
288 I_neighbour2local_d = interpOpSetC2F.IF2C;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
289 I_local2neighbour_e = interpOpSetC2F.IC2F;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
290 I_local2neighbour_d = interpOpSetF2C.IC2F;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
291 elseif grid_ratio > 1
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
292 % Local is finer than neighbour
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
293 I_neighbour2local_e = interpOpSetC2F.IC2F;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
294 I_neighbour2local_d = interpOpSetF2C.IC2F;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
295 I_local2neighbour_e = interpOpSetF2C.IF2C;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
296 I_local2neighbour_d = interpOpSetC2F.IF2C;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
297 end
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
298 otherwise
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
299 error(['Interpolation type ' obj.interpolation_type ...
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
300 ' is not available.' ]);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
301 end
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
302
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
303 else
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
304 % No interpolation required
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
305 I_neighbour2local_e = speye(m,m);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
306 I_neighbour2local_d = speye(m,m);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
307 I_local2neighbour_e = speye(m,m);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
308 I_local2neighbour_d = speye(m,m);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
309 end
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
310
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
311 closure = tau*Hi*d*H_gamma*e' + sigma*Hi*e*H_gamma*d';
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
312 penalty = -tau*Hi*d*H_gamma*I_neighbour2local_e*e_neighbour' ...
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
313 -sigma*Hi*e*H_gamma*I_neighbour2local_d*d_neighbour';
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
314
718
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
315 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
316
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
317 % 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
318 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
319
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
320 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
321 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
322 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
323 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
324 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
325 otherwise
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
326 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
327 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
328
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
329 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
330 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
331 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
332 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
333 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
334 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
335 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
336
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
337 % 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
338 function [return_op] = get_boundary_operator(obj, op, boundary)
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
339
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
340 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
341 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
342 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
343 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
344 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
345 otherwise
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
346 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
347 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
348
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
349 switch op
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
350 case 'e'
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
351 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
352 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
353 return_op = obj.e_l{j};
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
354 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
355 return_op = obj.e_r{j};
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
356 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
357 case 'd'
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
358 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
359 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
360 return_op = obj.d1_l{j};
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
361 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
362 return_op = obj.d1_r{j};
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
363 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
364 otherwise
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
365 error(['No such operator: operator = ' op]);
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
366 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
367
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
368 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
369
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
370 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
371 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
372 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
373 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
374 end