[Scilab-users] ode with algebraic constraint
Rafael Guerra
jrafaelbguerra at hotmail.com
Sat Aug 11 02:24:25 CEST 2018
Hi Jens,
I have got the particle moving on the sphere by writing the total acceleration as a sum of a centripetal component and a tangential component:
// START OF CODE
// Particle motion on a sphere using cartesian coordinates
function dz=EoM(t, z, m, f)//z=[x; y; z; vx; vy; vz] (6 x 1)
dz(1:3)= z(4:6);
nz = norm(z(1:3));
u = z(1:3)/nz;
fc= m*norm(z(4:6))^2/nz; // centripetal force
Ft= f - (f'*u)*u; // tangential force
dz(4:6)= -fc*u/m + Ft/m;
endfunction
R=2; // sphere radius
r0 = [0; 0; R]; // initial position
v0 = [-1; 3; 0]; // must be tangent to the sphere at r0
z0=[r0;v0];
t0=0;
dt=0.05;
tmax = 50;
t=dt:dt:tmax;
m = 1; // mass
f= [-1;1;0.5]; // external force
z = ode(z0,t0,t,EoM)
clf;
scatter3(z(1,:),z(2,:),z(3,:))
gca().axes_reverse = ["on", "off", "off"];
isoview on
// END OF CODE
Let me know if you see any flaw in the physics.
Regards,
Rafael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20180811/92e4e860/attachment.htm>
More information about the users
mailing list