Skip to content

Commit d716dcf

Browse files
committed
fixed the Jacobi constant and added JCJacobian
1 parent 1164eb1 commit d716dcf

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

toolbox/+otp/+cr3bp/jacobiconstant.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
x = y(1:3, :);
44
v = y(4:6, :);
55

6-
d = sqrt((x(1, :) + mu).^2 + x(2, :)^2 + x(3, :)^2 + soft^2);
7-
r = sqrt((x(1, :) - 1 + mu).^2 + x(2, :).^2 + x(3, :)^2 + soft^2);
8-
6+
d = sqrt((x(1, :) + mu).^2 + x(2, :).^2 + x(3, :).^2 + soft^2);
7+
r = sqrt((x(1, :) - 1 + mu).^2 + x(2, :).^2 + x(3, :).^2 + soft^2);
98

109
U = 0.5*(x(1, :).^2 + x(2, :).^2) + (1 - mu)./d + mu./r;
1110

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
function dJdy = jacobiconstantjacobian(y, mu, soft)
2+
3+
x = y(1:3, :);
4+
v = y(4:6, :);
5+
6+
d = sqrt((x(1, :) + mu).^2 + x(2, :).^2 + x(3, :).^2 + soft^2);
7+
r = sqrt((x(1, :) - 1 + mu).^2 + x(2, :).^2 + x(3, :).^2 + soft^2);
8+
9+
dddx = (x(1, :) + mu)./d;
10+
dddy = x(2, :)./d;
11+
dddz = x(3, :)./d;
12+
drdx = (x(1, :) - 1 + mu)./r;
13+
drdy = x(2, :)./r;
14+
drdz = x(3, :)./r;
15+
16+
dUdx = x(1, :) - ((1 - mu).*dddx)./(d.^2) - (mu.*drdx)./(r.^2);
17+
dUdy = x(2, :) - ((1 - mu).*dddy)./(d.^2) - (mu.*drdy)./(r.^2);
18+
dUdz = - ((1 - mu).*dddz)./(d.^2) - (mu.*drdz)./(r.^2);
19+
20+
dJdy = [reshape(2*dUdx, 1, 1, []), ...
21+
reshape(2*dUdy, 1, 1, []), ...
22+
reshape(2*dUdz, 1, 1, []), ...
23+
reshape(-2*v(1, :), 1, 1, []), ...
24+
reshape(-2*v(2, :), 1, 1, []), ...
25+
reshape(-2*v(3, :), 1, 1, [])];
26+
27+
end

0 commit comments

Comments
 (0)