Mercurial > repos > public > sbplib
annotate +scheme/Schrodinger2d.m @ 718:71aa5828cbbf feature/utux2D
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Sat, 03 Mar 2018 16:18:33 -0800 |
parents | |
children | b3f8fb9cefd2 |
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 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
31 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
32 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
|
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 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
35 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
36 methods |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
37 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
38 function obj = Schrodinger2d(g ,order, a, opSet) |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
39 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
|
40 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
|
41 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
|
42 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
43 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
|
44 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
45 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
|
46 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
|
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 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
|
49 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
|
50 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
|
51 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
|
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 % 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
|
54 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
|
55 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
|
56 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
|
57 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
58 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
59 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
|
60 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
|
61 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
|
62 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
|
63 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
|
64 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
|
65 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
|
66 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
|
67 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
|
68 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
69 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
|
70 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
|
71 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
|
72 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
|
73 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
|
74 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
|
75 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
|
76 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
|
77 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
|
78 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
|
79 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
80 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
81 % 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
|
82 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
|
83 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
|
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 %====== 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 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
|
93 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
94 % D1 |
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.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
|
96 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
|
97 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
98 % 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
|
99 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
|
100 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
|
101 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
|
102 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
|
103 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
104 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
|
105 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
|
106 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
|
107 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
|
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 % D2 |
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.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
|
111 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
|
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 % Quadratures |
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.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
|
115 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
|
116 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
|
117 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
|
118 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
|
119 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
120 % 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
|
121 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
|
122 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
|
123 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
|
124 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
|
125 end |
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.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
|
127 %=========================================% |
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 % Misc. |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
130 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
|
131 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
|
132 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
|
133 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
|
134 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
|
135 obj.a = a; |
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 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
138 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
139 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
140 % 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
|
141 % 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
|
142 % 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
|
143 % 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
|
144 % 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
|
145 % 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
|
146 % 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
|
147 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
|
148 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
|
149 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
|
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 % 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
|
152 % 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
|
153 % 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
|
154 % 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
|
155 [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
|
156 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
|
157 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
|
158 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
|
159 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
|
160 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
|
161 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
|
162 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
|
163 end |
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 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
|
166 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
|
167 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
|
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 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
|
170 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
171 % 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
|
172 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
|
173 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
|
174 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
|
175 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
176 % 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
|
177 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
|
178 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
|
179 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
|
180 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
181 % 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
|
182 otherwise |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
183 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
|
184 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
185 end |
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 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
|
188 % 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
|
189 % v denotes the solution in the neighbour domain |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
190 error('Interface not implemented'); |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
191 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
192 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
193 % 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
|
194 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
|
195 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
196 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
|
197 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
|
198 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
|
199 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
|
200 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
|
201 otherwise |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
202 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
|
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 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
|
206 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
|
207 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
|
208 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
|
209 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
|
210 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
211 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
212 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
213 % 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
|
214 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
|
215 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
216 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
|
217 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
|
218 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
|
219 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
|
220 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
|
221 otherwise |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
222 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
|
223 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
224 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
225 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
|
226 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
|
227 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
|
228 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
|
229 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
|
230 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
|
231 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
|
232 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
233 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
|
234 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
|
235 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
|
236 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
|
237 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
|
238 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
|
239 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
240 otherwise |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
241 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
|
242 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
243 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
244 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
245 |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
246 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
|
247 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
|
248 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
249 end |
71aa5828cbbf
Add Schrödinger scheme for 2d single block. Will develop to multiblock with interpolation.
Martin Almquist <malmquist@stanford.edu>
parents:
diff
changeset
|
250 end |