Skip to content

Commit 33b7f02

Browse files
Correct CUSP initial conditions
1 parent 7d3973f commit 33b7f02

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

src/+otp/+cusp/+presets/Canonical.m

+11-19
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,24 @@
66
methods
77
function obj = Canonical(varargin)
88
p = inputParser;
9-
p.addParameter('Size', 32, @isscalar);
9+
p.addParameter('Size', 32);
1010
p.addParameter('epsilon', 1e-4);
1111
p.addParameter('sigma', 1/144);
12-
1312
p.parse(varargin{:});
14-
15-
s = p.Results;
16-
17-
n = s.Size;
13+
opts = p.Results;
1814

1915
params = otp.cusp.CUSPParameters;
20-
params.Size = n;
21-
params.Epsilon = s.epsilon;
22-
params.Sigma = s.sigma;
23-
24-
xs = linspace(0, 1, n + 1)';
25-
26-
% The last point is the same as the first, so we will ignore it.
27-
xs = xs(1:(end-1));
28-
29-
y0 = zeros(n, 1);
30-
a0 = -2*cos(2*pi*xs);
31-
b0 = -2*cos(2*pi*xs);
16+
params.Size = opts.Size;
17+
params.Epsilon = opts.epsilon;
18+
params.Sigma = opts.sigma;
19+
20+
ang = 2 * pi / opts.Size * (1:opts.Size).';
21+
y0 = zeros(opts.Size, 1);
22+
a0 = -2*cos(ang);
23+
b0 = 2*sin(ang);
3224

3325
u0 = [y0; a0; b0];
34-
tspan = [0 1.1];
26+
tspan = [0; 1.1];
3527

3628
obj = [email protected](tspan, u0, params);
3729
end

0 commit comments

Comments
 (0)