annotate +scheme/Schrodinger2d.m @ 719:b3f8fb9cefd2 feature/utux2D

Add interpolation to Schrödinger 2D scheme.
author Martin Almquist <malmquist@stanford.edu>
date Sun, 11 Mar 2018 21:39:49 -0700
parents 71aa5828cbbf
children f4595f14d696
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'))
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
49
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
50 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
51 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
52
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
53 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
54 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
55 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
56 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
57
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
58 % 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
59 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
60 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
61 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
62 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
63
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
64 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
65 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
66 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
67 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
68 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
69 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
70 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
71 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
72 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
73
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
74 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
75 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
76 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
77 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
78 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
79 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
80 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
81 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
82 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
83 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
84 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
85
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
86 % 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
87 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
88 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
89 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
90
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
91 %====== 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
92 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
93 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
94 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
95 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
96 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
97 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
98
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
99 % D1
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{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
101 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
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 % 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
104 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
105 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
106 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
107 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
108
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.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
110 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
111 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
112 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
113
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
114 % D2
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.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
116 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
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 % Quadratures
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.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
120 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
121 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
122 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
123 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
124
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
125 % 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
126 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
127 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
128 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
129 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
130 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
131 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
132 %=========================================%
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 % Misc.
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.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
136 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
137 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
138 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
139 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
140 obj.a = a;
719
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
141 obj.e_w = obj.e_l{1};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
142 obj.e_e = obj.e_r{1};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
143 obj.e_s = obj.e_l{2};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
144 obj.e_n = obj.e_r{2};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
145 obj.d_w = obj.d1_l{1};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
146 obj.d_e = obj.d1_r{1};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
147 obj.d_s = obj.d1_l{2};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
148 obj.d_n = obj.d1_r{2};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
149 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
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
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
166 % 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
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};
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
181 a = obj.a;
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'}
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
187 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
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'}
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
192 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
193 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
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
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
201 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
202 % 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
203 % 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
204 % Get neighbour boundary operator
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
205
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
206 [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
207 [coord, n] = get_boundary_number(obj, boundary);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
208 switch n_nei
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
209 case 1
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
210 % North or east boundary
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
211 e_neighbour = neighbour_scheme.e_r;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
212 d_neighbour = neighbour_scheme.d1_r;
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 % South or west boundary
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
215 e_neighbour = neighbour_scheme.e_l;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
216 d_neighbour = neighbour_scheme.d1_l;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
217 end
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
218
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
219 e_neighbour = e_neighbour{coord_nei};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
220 d_neighbour = d_neighbour{coord_nei};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
221 H_gamma = obj.H_boundary{coord};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
222 Hi = obj.Hi;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
223 a = obj.a;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
224
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
225 switch coord_nei
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
226 case 1
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
227 m_neighbour = neighbour_scheme.m(2);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
228 case 2
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
229 m_neighbour = neighbour_scheme.m(1);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
230 end
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 switch coord
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
233 case 1
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
234 m = obj.m(2);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
235 case 2
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
236 m = obj.m(1);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
237 end
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
238
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
239 switch n
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
240 case 1
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
241 % North or east boundary
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
242 e = obj.e_r;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
243 d = obj.d1_r;
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 % South or west boundary
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
246 e = obj.e_l;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
247 d = obj.d1_l;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
248 end
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
249 e = e{coord};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
250 d = d{coord};
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
251
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
252 Hi = obj.Hi;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
253 sigma = -n*1i*a/2;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
254 tau = -n*(1i*a)'/2;
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 grid_ratio = m/m_neighbour;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
257 if grid_ratio ~= 1
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
258
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
259 [ms, index] = sort([m, m_neighbour]);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
260 orders = [obj.order, neighbour_scheme.order];
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
261 orders = orders(index);
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 switch obj.interpolation_type
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
264 case 'MC'
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
265 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
266 if grid_ratio < 1
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
267 I_neighbour2local_e = interpOpSet.IF2C;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
268 I_neighbour2local_d = interpOpSet.IF2C;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
269 I_local2neighbour_e = interpOpSet.IC2F;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
270 I_local2neighbour_d = interpOpSet.IC2F;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
271 elseif grid_ratio > 1
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
272 I_neighbour2local_e = interpOpSet.IC2F;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
273 I_neighbour2local_d = interpOpSet.IC2F;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
274 I_local2neighbour_e = interpOpSet.IF2C;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
275 I_local2neighbour_d = interpOpSet.IF2C;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
276 end
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
277 case 'AWW'
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
278 %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
279 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
280 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
281 if grid_ratio < 1
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
282 % Local is coarser than neighbour
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
283 I_neighbour2local_e = interpOpSetF2C.IF2C;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
284 I_neighbour2local_d = interpOpSetC2F.IF2C;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
285 I_local2neighbour_e = interpOpSetC2F.IC2F;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
286 I_local2neighbour_d = interpOpSetF2C.IC2F;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
287 elseif grid_ratio > 1
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
288 % Local is finer than neighbour
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
289 I_neighbour2local_e = interpOpSetC2F.IC2F;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
290 I_neighbour2local_d = interpOpSetF2C.IC2F;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
291 I_local2neighbour_e = interpOpSetF2C.IF2C;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
292 I_local2neighbour_d = interpOpSetC2F.IF2C;
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
293 end
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
294 otherwise
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
295 error(['Interpolation type ' obj.interpolation_type ...
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
296 ' is not available.' ]);
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
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
299 else
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
300 % No interpolation required
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
301 I_neighbour2local_e = speye(m,m);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
302 I_neighbour2local_d = speye(m,m);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
303 I_local2neighbour_e = speye(m,m);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
304 I_local2neighbour_d = speye(m,m);
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
305 end
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
306
b3f8fb9cefd2 Add interpolation to Schrödinger 2D scheme.
Martin Almquist <malmquist@stanford.edu>
parents: 718
diff changeset
307 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
308 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
309 -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
310
718
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
311 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
312
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
313 % 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
314 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
315
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
316 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
317 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
318 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
319 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
320 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
321 otherwise
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
322 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
323 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
324
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
325 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
326 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
327 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
328 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
329 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
330 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
331 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
332
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
333 % 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
334 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
335
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
336 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
337 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
338 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
339 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
340 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
341 otherwise
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
342 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
343 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
344
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
345 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
346 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
347 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
348 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
349 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
350 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
351 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
352 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
353 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
354 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
355 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
356 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
357 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
358 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
359 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
360 otherwise
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
361 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
362 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
363
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
364 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
365
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
366 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
367 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
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 end
71aa5828cbbf Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
370 end