package rk3; public class RkApp3 { public static void main(String[] args) { double h=0.01; //paso //Situación inicial double x0=1.5; //posición inicial double v0=10.0; //velocidad inicial Estado es=new Estado(0.0, x0, v0); double t=2.0; //resolver la e. d. hasta este instante double w=2.0; //frecuencia propia oscilaciones libres double g=0.5; //cte de amortiguamiento //oscilaciones libres System.out.println("Oscilaciones libres"); Oscilador os=new Oscilador(w); os.resolver(t, es, h); System.out.println("posición aprox. "+es.x); System.out.println("velocidad aprox. "+es.v); // valor exacto double fi=Math.atan(w*x0/v0); double A=x0/Math.sin(fi); double x=A*Math.sin(w*t+fi); double v=A*w*Math.cos(w*t+fi); System.out.println("posición exacta "+x); System.out.println("velocidad exacta "+v); //oscilaciones amortiguadas System.out.println("Oscilaciones amortiguadas"); es=new Estado(0.0, x0, v0); new Amortiguado(g, w).resolver(t, es, h); System.out.println("posición aprox. "+es.x); System.out.println("velocidad aprox. "+es.v); // valor exacto double w1=Math.sqrt(w*w-g*g); fi=Math.atan(w1*x0/(v0+g*x0)); A=x0/Math.sin(fi); x=A*Math.exp(-g*t)*Math.sin(w1*t+fi); System.out.println("posición exacta "+x); v=A*Math.exp(-g*t)*(-g*Math.sin(w1*t+fi)+w1*Math.cos(w1*t+fi)); System.out.println("velocidad exacta "+v); try { //espera la pulsación de una tecla y luego RETORNO System.in.read(); }catch (Exception ex) { } } }