Anterior

Procedimientos numéricos

Sistema de ecuaciones diferenciales

Resolver el sistema de ecuaciones diferenciales

d 2 x d τ 2 =1 3 2 x ( x 2 +1 ) 5/2 i di dτ =αi+ 3β 2 x ( x 2 +1 ) 5/2 dx dτ

por procedimientos numéricos con las condiciones iniciales: en el instante τ=0, la posición inicial del imán es x0, y parte del reposo, su velocidad inicial dx/dτ=0, la intensidad inicial en la espira i0=0.

public abstract class RungeKutta {
    double h;
    public RungeKutta(double h){
      this.h=h;
    }
    void setPaso(double dt){
      this.h=dt;
    }
    public void resolver(Estado e){
//variables auxiliares
	    double k1, k2, k3, k4;
	    double l1, l2, l3, l4;
	    double m1, m2, m3, m4;
//estado inicial
	    double x=e.x;
	    double y=e.y;
	    double vx=e.vx;
	    double t=e.t;

		    k1=h*vx;
		    l1=h*f(x, y, vx, t);
		    m1=h*g(x, y, vx, t);

		    k2=h*(vx+l1/2);
		    l2=h*f(x+k1/2, y+m1/2, vx+l1/2, t+h/2);
		    m2=h*g(x+k1/2, y+m1/2, vx+l1/2, t+h/2);

		    k3=h*(vx+l2/2);
		    l3=h*f(x+k2/2, y+m2/2, vx+l2/2,  t+h/2);
		    m3=h*g(x+k2/2, y+m2/2, vx+l2/2,  t+h/2);

		    k4=h*(vx+l3);
		    l4=h*f(x+k3, y+m3, vx+l3,  t+h);
		    m4=h*g(x+k3, y+m3, vx+l3,  t+h);

		    x+=(k1+2*k2+2*k3+k4)/6;
		    vx+=(l1+2*l2+2*l3+l4)/6;
		    y+=(m1+2*m2+2*m3+m4)/6;
        t+=h;
	  
//estado final
	    e.x=x;
	    e.y=y;
	    e.vx=vx;
	    e.t=t;
    }
    abstract public double f(double x, double y, double vx,  double t);
    abstract public double g(double x, double y, double vx,  double t);
	}

 

public class Sistema extends RungeKutta{
    double alfa; 
    double beta;
    public Sistema(double alfa, double beta,  double h){
      super(h);
      this.alfa=alfa;
      this.beta=beta;
    }
    public double f(double x, double y, double vx, double t){
         double temp=-1-3*x*y/(2*(1+x*x)*(1+x*x)*Math.sqrt(1+x*x));
         return temp;
    }
    public double g(double x, double y, double vx,  double t){
         double temp=-alfa*y+3*beta*x*vx/(2*(1+x*x)*(1+x*x)*Math.sqrt(1+x*x));
         return temp;
    }
}

 

public class Estado {
    public double t;
    public double x;
    public double y;
    public double vx;
    public Estado(double t, double x, double y, double vx) {
        this.t=t;
        this.x=x;
        this.y=y;
        this.vx=vx;
    }
}

Se establece el estado incial

Estado estado=new Estado(0.0, x0, 0.0, 0.0);

Se crea un objeto de la clase derivada

 Sistema sis=new Sistema(alfa, beta, 0.025);

Se llama a la función resolver que determina el estado del sistema en el instante t+h conocido el estado en el instante t

sis.resolver(estado);Anterior