Anterior

Procedimiento numérico

Ecuación diferencial de segundo orden y sistema de dos ecuaciones diferenciales de segundo orden

d 2 θ d t 2 = m g r 0 cos θ I O

Se resuelve la ecuación diferencial por procedimientos numéricos con las siguientes condiciones iniciales: En el instante t=0, θ=0, dθ/dt=0.

Se termina la primera etapa del movimiento en el instante t1 cuando la tabla forma un ángulo θ1 por debajo de la horizontal

d 2 θ d t 2 = 12 r L 2 + 12 r 2 ( g cos θ 2 d r d t d θ d t ) d 2 r d t 2 = g sin θ + r ( d θ d t ) 2 μ k L 2 L 2 + 12 r 2 ( g cos θ 2 d r d t d θ d t )

Resolvemos este sistema de ecuaciones diferenciales por procedimientos numéricos, con las siguientes condiciones iniciales: en el instante t=t1, r=r0, dr/dt=0, y

θ 1 = arctan ( μ s L 2 L 2 + 36 r 0 2 ) ( d θ d t ) 1 = 24 g r 0 L 2 + 12 r 0 2 sin θ 1

Concluye esta etapa cuando el valor fuerza normal N

N = m L 2 12 r d 2 θ d t 2

es nulo.

public abstract class State {
	double t;
	double x;
	double vx;
public State(double t, double x, double vx) {
	this.t=t;
	this.x=x;
	this.vx=vx;
}
}
public class Estado extends State{
public Estado(double t, double x, double vx) {
	super(t, x, vx);
}
}
public class Estado1 extends State{
	double y;
	double vy;
public Estado1(double t, double x, double y, double vx, double vy) {
	super(t, x, vx);
	this.y=y;
	this.vy=vy;
}
}
public interface RK {
abstract public void resolver(State e);
}
      
public abstract class RungeKutta implements RK{
	double h;
public RungeKutta(double h){
	this.h=h;
}
public void resolver(State e){
//variables auxiliares
	double k1, k2, k3, k4;
	double l1, l2, l3, l4;
	double q1, q2, q3, q4;
	double m1, m2, m3, m4;
//condiciones iniciales
	double x=e.x;
	double v=e.vx;
	double t=e.t;

	k1=h*v;
	l1=h*f(x, v, t);
	k2=h*(v+l1/2);
	l2=h*f(x+k1/2, v+l1/2, t+h/2);
	k3=h*(v+l2/2);
	l3=h*f(x+k2/2, v+l2/2, t+h/2);
	k4=h*(v+l3);
	l4=h*f(x+k3, v+l3, t+h);
//nuevo estado del sistema
	x+=(k1+2*k2+2*k3+k4)/6;
	v+=(l1+2*l2+2*l3+l4)/6;
//cambia el estado de la partícula
	e.x=x;
	e.vx=v;
	e.t=t+h;
}
abstract public double f(double x, double v, double t);
}
public abstract class RungeKutta1 implements RK{
	double h;
public RungeKutta1(double h){
	this.h=h;
}
public void resolver(State e){
//variables auxiliares
	double k1, k2, k3, k4;
	double l1, l2, l3, l4;
	double q1, q2, q3, q4;
	double m1, m2, m3, m4;
//estado inicial
	double x=e.x;
	double y=((Estado1)e).y;
	double vx=e.vx;
	double vy=((Estado1)e).vy;
	double t=e.t;

	k1=h*vx;
	l1=h*f(x, y, vx, vy, t);
	q1=h*vy;
	m1=h*g(x, y, vx, vy, t);
	k2=h*(vx+l1/2);
	l2=h*f(x+k1/2, y+q1/2, vx+l1/2, vy+m1/2, t+h/2);
	q2=h*(vy+m1/2);
	m2=h*g(x+k1/2, y+q1/2, vx+l1/2, vy+m1/2, t+h/2);
	k3=h*(vx+l2/2);
	l3=h*f(x+k2/2, y+q2/2, vx+l2/2, vy+m2/2, t+h/2);
	q3=h*(vy+m2/2);
	m3=h*g(x+k2/2, y+q2/2, vx+l2/2, vy+m2/2, t+h/2);
	k4=h*(vx+l3);
	l4=h*f(x+k3, y+q3, vx+l3, vy+m3, t+h);
	q4=h*(vy+m3);
	m4=h*g(x+k3, y+q3, vx+l3, vy+m3, t+h);

	x+=(k1+2*k2+2*k3+k4)/6;
	vx+=(l1+2*l2+2*l3+l4)/6;
	y+=(q1+2*q2+2*q3+q4)/6;
	vy+=(m1+2*m2+2*m3+m4)/6;
	t+=h;

//estado final
	e.x=x;
	((Estado1)e).y=y;
	e.vx=vx;
	((Estado1)e).vy=vy;
	e.t=t;
}
abstract public double f(double x, double y, double vx, double vy, double t);
abstract public double g(double x, double y, double vx, double vy, double t);
}
      
public class Sistema extends RungeKutta{
    final double  lonVarilla=0.102;
    double radio;
    public Sistema(double radio, double h){
      super(h);
      this.radio=radio;
     }
    public double f(double x, double v, double t){ 
      double y=9.8*12*radio*Math.cos(x)/(lonVarilla*lonVarilla+12*radio*radio);
      return y;
    }
}
      
public class Sistema1 extends RungeKutta1{
    final double  lonVarilla=0.102;
    double mu;
    public Sistema1(double mu, double h){
      super(h);
      this.mu=mu;
    }
public double f(double x, double y, double vx, double vy, double t){
      double z=(12*y/(lonVarilla*lonVarilla+12*y*y))*(9.8*Math.cos(x)-2*vx*vy);
      return z;
}
public double g(double x, double y, double vx, double vy, double t){
    double z=9.8*Math.sin(x)-(mu*lonVarilla*lonVarilla/
(lonVarilla*lonVarilla+12*y*y))*(9.8*Math.cos(x)-2*vx*vy)+y*vx*vx; return z; } public double fuerza_Y(double x, double y, double vx, double vy){ double temp=lonVarilla*lonVarilla*f(x, y, vx, vy, 0.0)/(12*y); return temp; } }
public class MiCanvas extends Canvas {
//parámetros
    final double lonVarilla=0.102;   // 10.2 cm
 //intervalo de tiempo
    final double dt=0.0005;
    double radio=0.55/100;
    double angCritico;
    double mu;
    double x0, y0, v0x, v0y;
    double angulo;
    double t;
    double y, x;
 //objeto sistema
   RK sistema;
   State estado=new Estado(0.0, 0.0, 0.0);
   Polygon barra=new Polygon();
   int tipo=1;

 void setNuevo(double mu, double radio){
    this.radio=radio;
    this.mu=mu;
    tipo=1;
    estado=new Estado(0.0, 0.0, 0.0);
    sistema=new Sistema(radio, dt);
    angCritico=Math.atan(mu/(1+36*radio*radio/(lonVarilla*lonVarilla)));
    t=0.0;
 }

 void mover(){
     switch(tipo){
        case 1:
            sistema.resolver(estado);
            if(estado.x>angCritico){
                  double wCritica=Math.sqrt(24*9.8*radio*Math.sin(angCritico)
/(lonVarilla*lonVarilla+12*radio*radio)); estado=new Estado1(estado.t, angCritico, radio, wCritica, 0.0); sistema=new Sistema1(mu, dt); tipo=2; } break; case 2: sistema.resolver((Estado1)estado); double normal=((Sistema1)sistema).fuerza_Y
(estado.x, ((Estado1)estado).y, estado.vx, ((Estado1)estado).vy); if(normal<=0.0){ v0x=((Estado1)estado).vy*Math.cos(estado.x)-
estado.vx*((Estado1)estado).y*Math.sin(estado.x); v0y=((Estado1)estado).vy*Math.sin(estado.x)+
estado.vx*((Estado1)estado).y*Math.sin(estado.x); x=x0=((Estado1)estado).y*Math.cos(estado.x); y=y0=((Estado1)estado).y*Math.sin(estado.x); t=0.0; angulo=estado.x; tipo=3; //cae } break; case 3: angulo=estado.x+estado.vx*t; x=x0+v0x*t; y=y0+v0y*t+4.9*t*t; if(y>0.2) parent.hilo.putMsg(Hilo.PAUSE); t+=dt; break; default: break; } }
Anterior