package odend; import Jama.*; /** * ODE describing a mathematical pendulum with friction,<br> * driven by a harmonically varying force */ public class PendelErzwODE extends ODE { protected double lambda = 5.0/10.0; // friction coefficient protected double A = 12.0/10.0; // amplitude protected double omega = 6667.0/10000.0; // frequency /** * construct from given initial conditions phi(t0), phi'(t0) */ public PendelErzwODE(double phi0, double phidot0, double t0) { super(new Matrix(2,1), t0); x0.set(0,0, phi0); x0.set(1,0, phidot0); } /** * r.h.s. giving the forced damped pendulum */ public Matrix f(Matrix x, double t) { Matrix result = new Matrix(2,1); result.set(0,0, x.get(1,0)); // x(0)' = x(1) = v result.set(1,0, -lambda * x.get(1,0) - Math.sin(x.get(0,0)) + A * Math.cos(omega * t)); return result; } /** * set the amplitude of the external force */ public void setA(double A) { this.A = A; } /** * set the friction coefficient of the pendulum */ public void setLambda(double lambda) { this.lambda = lambda; } /** * set the angular frequency of the external force */ public void setOmega(double omega) { this.omega = omega; } }