Mercurial > repos > public > sbplib
comparison +scheme/Schrodinger.m @ 426:29944ea7674b feature/quantumTriangles
Updated the Shrodinger scheme to the new operator syntax
author | Ylva Rydin <ylva.rydin@telia.com> |
---|---|
date | Wed, 25 Jan 2017 17:14:17 +0100 |
parents | 446d67a49cd8 |
children | a39fe3bcbd95 |
comparison
equal
deleted
inserted
replaced
378:18525f1bb941 | 426:29944ea7674b |
---|---|
21 | 21 |
22 methods | 22 methods |
23 % Solving SE in the form u_t = i*u_xx -i*V; | 23 % Solving SE in the form u_t = i*u_xx -i*V; |
24 function obj = Schrodinger(m,xlim,order,V) | 24 function obj = Schrodinger(m,xlim,order,V) |
25 default_arg('V',0); | 25 default_arg('V',0); |
26 | 26 ops = sbp.D2Standard(m,xlim,order); |
27 [x, h] = util.get_grid(xlim{:},m); | 27 |
28 | 28 obj.x=ops.x; |
29 ops = sbp.Ordinary(m,h,order); | 29 obj.h=ops.h; |
30 | 30 obj.D2 = ops.D2; |
31 obj.D2 = sparse(ops.derivatives.D2); | 31 obj.H = ops.H; |
32 obj.H = sparse(ops.norms.H); | 32 obj.Hi = ops.HI; |
33 obj.Hi = sparse(ops.norms.HI); | 33 obj.M = ops.M; |
34 obj.M = sparse(ops.norms.M); | 34 obj.e_l = ops.e_l; |
35 obj.e_l = sparse(ops.boundary.e_1); | 35 obj.e_r = ops.e_r; |
36 obj.e_r = sparse(ops.boundary.e_m); | 36 obj.d1_l = ops.d1_l; |
37 obj.d1_l = sparse(ops.boundary.S_1); | 37 obj.d1_r = ops.d1_r; |
38 obj.d1_r = sparse(ops.boundary.S_m); | |
39 | 38 |
40 | 39 |
41 if isa(V,'function_handle') | 40 if isa(V,'function_handle') |
42 V_vec = V(x); | 41 V_vec = V(obj.x); |
43 else | 42 else |
44 V_vec = x*0 + V; | 43 V_vec = obj.x*0 + V; |
45 end | 44 end |
46 | 45 |
47 V_mat = spdiags(V_vec,0,m,m); | 46 V_mat = spdiags(V_vec,0,m,m); |
48 | 47 |
49 obj.D = 1i * obj.D2 - 1i * V_mat; | 48 obj.D = 1i * obj.D2 - 1i * V_mat; |
50 | 49 |
51 obj.m = m; | 50 obj.m = m; |
52 obj.h = h; | |
53 obj.order = order; | 51 obj.order = order; |
54 | |
55 obj.x = x; | |
56 end | 52 end |
57 | 53 |
58 | 54 |
59 % Closure functions return the opertors applied to the own doamin to close the boundary | 55 % Closure functions return the opertors applied to the own doamin to close the boundary |
60 % Penalty functions return the opertors to force the solution. In the case of an interface it returns the operator applied to the other doamin. | 56 % Penalty functions return the opertors to force the solution. In the case of an interface it returns the operator applied to the other doamin. |