Skip to content

Instantly share code, notes, and snippets.

@Hugo-Diaz-N
Created October 19, 2018 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hugo-Diaz-N/0168c2c90c4e8e19c3694636069b2e24 to your computer and use it in GitHub Desktop.
Save Hugo-Diaz-N/0168c2c90c4e8e19c3694636069b2e24 to your computer and use it in GitHub Desktop.
Movement particle on a sphere surface under a force F
% Problem: find u s.t.
% \frac{d}{dt}{\bf u}(t)+\alpha {\bf u}(t)\times \frac{d}{dt}{\bf u}(t)&={\bf u}(t)\times {\bf F}(t)
% initial position u_0=0.5*\sqrt(2)(0 1 1)^t
F=[0 0 10]'; % constant case
u0=0.5*sqrt(2)*[0 1 1]';
a=0.1; % alpha in the PDE
b=(1/(1+a*a*norm(u0,2)^2));
f=@(t,u) b*(cross(u,F)-a*(F'*u)*u+a*norm(u)^2*F);
[t,w]=ode23s(f,[0,10],u0);
w=w';
x1 = w(1,:);
x2 = w(2,:);
x3 = w(3,:);
hold on
sphere(40)
plot3(x1,x2,x3,'-sk','LineWidth',2)
view(-90,90)
figure
plot(t,x1,'-.r',t,x2,'-.b',t,x3,'-.k','LineWidth',2)
w=w.^2; w=sqrt(sum(w));
figure
plot(t,w,'.-k')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment