Simulation des Hängependels
|
package opti;
import java.awt.*;
public class Antrieb extends Simulationsmodell
{
public Antrieb()
{
super(2); //Zwei Simulationsgleichungen
}
public double[] berechneRechteSeite(double[] yalt, double t)
{
double m = 1.0;
double r = 0.5;
double d = 0.05;
double g = 9.81;
double J = 0.25*m*(0.5*d)*(0.5*d)+(1.0/12.0)*m*(2.0*r)*(2.0*r);
double FA = 0.0;
f[0] = yalt[1];
f[1] = - (( m*r*g )/(J+m*r*r))*Math.sin(yalt[0]) + ((2.0*r)/(J+m*r*r))*Math.cos(yalt[0])*FA;
return f;
}
}
Code 0-1: Antrieb.java (Hängependel als Modell eingefügt)
package opti;
public class TestAntrieb
{
public static void main(String[] args)
{
Antrieb antrieb = new Antrieb();
RungeKuttaIntegrator rungekuttaintegrator = new RungeKuttaIntegrator();
rungekuttaintegrator.add(antrieb);
double dt = 0.005;
double t = 0.0;
double[] y;
double[] yalt = {0.25*Math.PI,0.0};
for(int i=0;i<1000;i++)
{
System.out.println(t+" "+yalt[0]);
y = rungekuttaintegrator.zeitschritt(yalt,t,dt);
yalt[0] = y[0];
yalt[1] = y[1];
t+=dt;
}
}
}
Code 0-2: TestAntrieb.java (Simuliert testweise das Hängependel)
simhaenge.zip - Testweise Simulation des Hängependels.
Bild 0-1: Simulationsergebnis.