-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenergyequation.m
134 lines (121 loc) · 3.41 KB
/
energyequation.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
% ENERGY EQUATION IN NON-DIMENSIONAL 3 BODY PROBLEM
% CHNAGE IN ENERGY with mu
clear;close all;
syms x y z vx vy vz mu;
fps = 20;
figure(1)
r1 = sqrt((x+mu)^2+y^2+z^2);
r2 = sqrt((x-(1-mu))^2+y^2+z^2);
U = 1/2*(x^2+y^2)+(1-mu)/r1+mu/r2;
gradU = gradient(U);
Ux = gradU(1);Uy = gradU(2);Uz = gradU(3);
KE = 1/2*((vx-y)^2+(vy+x)^2+vz^2);
E = U+KE;
% Estationary = subs(E,[vx,vy,vz],[0,0,0]);
%
%
% dEdt = Ux*y-Uy*x+Uz/2;
% dEdt = subs(dEdt,z,0);
% dEdt = dEdt-z;
% Estationary = subs(Estationary,z,0);
% Estationary = Estationary-z;
% mu_step = 0.01;
% muN = 0:mu_step:1;
% filename = 'EanddEdtforPCR3BP.gif';
%
%
% for i = 1:length(muN)
%
%
% dEdtN = subs(dEdt,mu,muN(i));
% EstationaryN = subs(Estationary,mu,muN(i));
%
% %colororder(jet(101))
% hold off;
% scatter([-muN(i),1-muN(i)],[0,0],'r','filled','DisplayName','Masses');hold on;
% xlabel('x(ND)');
% ylabel('y(ND)');
% txt = sprintf('dE/dt for mu = %.2f and z = 0',muN(i));
% title(txt);
% fimplicit3(dEdtN,[-2,2,-2,2,-50,50],'MeshDensity',100,'EdgeColor','none');hold on
% colormap(jet);
% line([1/2-muN(i) 1/2-muN(i)], [-2 2],'color','k','LineStyle','--');
% line([-2 2],[0 0],'color','k','LineStyle','--');
%
% colorbar('Ticks',[-50 0 50],'TickLabels',{'-50', '0','50'});
%
%
% frame = getframe(gcf);
% im = frame2im(frame);
% [imind,cm] = rgb2ind(im,256);
% if i == 1
% imwrite(imind,cm,filename,'gif', 'Loopcount',inf);
% else
% imwrite(imind,cm,filename,'gif','WriteMode','append','DelayTime',1/fps);
% end
% end
%% VARIATION IN Z
% dEdt = Ux*y-Uy*x+Uz/2;
% dEdt = subs(dEdt,mu,0.01215);
%
% z_step = 0.01;
% muEM = 0.01215;
% zN = -0.5:z_step:0.5;
% filename = 'dEdtforCR3BPmuEM.gif';
%
% for i = 1:length(zN)
%
%
% dEdtN = subs(dEdt,z,zN(i));
% dEdtN = dEdtN-z;
% hold off;
% scatter3([-muEM,1-muEM],[0,0],[0,0],'r','filled','DisplayName','Masses');hold on;
% xlabel('x(ND)');
% ylabel('y(ND)');
% txt = sprintf('dE/dt for mu = 0.01215 and z = %.2f',zN(i));
% title(txt);
% fimplicit3(dEdtN,[-2,2,-2,2,-50,50],'MeshDensity',100,'EdgeColor','none');hold on
% colormap(jet);
% line([1/2-muEM 1/2-muEM], [-2 2],'color','k','LineStyle','--');
% line([-2 2],[0 0],'color','k','LineStyle','--');
% caxis([-10 10])
% colorbar;
%
%
% frame = getframe(gcf);
% im = frame2im(frame);
% [imind,cm] = rgb2ind(im,256);
% if i == 1
% imwrite(imind,cm,filename,'gif', 'Loopcount',inf);
% else
% imwrite(imind,cm,filename,'gif','WriteMode','append','DelayTime',1/fps);
% end
% end
%% FIND dEdT isosurface
dEdt = Ux*y-Uy*x+Uz/2;
dEdt = subs(dEdt,mu,0.01215);
z_step = 0.1;
muEM = 0.01215;
EN = -10:z_step:10;
filename = 'dEdtforCR3BPmuEM.gif';
for i = 1:length(EN)
%dEdtN = subs(dEdt,z,zN(i));
%dEdtN = dEdtN-z;
hold off;
scatter3([-muEM,1-muEM],[0,0],[0,0],'r','filled','DisplayName','Masses');hold on;
xlabel('x(ND)');
ylabel('y(ND)');
txt = sprintf('dE/dt for mu = 0.01215 and dEdt = %.2f',EN(i));
title(txt);
fimplicit3(dEdt-EN(i),[-2,2,-2,2,-50,50],'MeshDensity',100,'EdgeColor','none','FaceColor','green');hold on
line([1/2-muEM 1/2-muEM], [-2 2],'color','k','LineStyle','--');
line([-2 2],[0 0],'color','k','LineStyle','--');
frame = getframe(gcf);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
if i == 1
imwrite(imind,cm,filename,'gif', 'Loopcount',inf);
else
imwrite(imind,cm,filename,'gif','WriteMode','append','DelayTime',1/fps);
end
end