/** * Constructs OscillatorsMode with the given mode and number of particles. * * <p>The particle separation is one in this model. * * @param mode int * @param N int */ OscillatorsMode(int mode, int N) { amplitude = Math.sqrt(2.0 / (N + 1)); omega = 2 * Math.sqrt(OMEGA_SQUARED) * Math.abs(Math.sin(mode * Math.PI / N / 2)); wavenumber = Math.PI * mode / (N + 1); functionDrawer = new FunctionDrawer(this); functionDrawer.initialize(0, N + 1, 300, false); // draws the initial displacement functionDrawer.color = Color.LIGHT_GRAY; }
/** * Creates an AffineMatrix representing a rotation about the origin by some angle around the given * axis. * * @param theta double * @param axis double[] * @return AffineMatrix */ public static Affine3DMatrix Rotation(double theta, double[] axis) { Affine3DMatrix at = new Affine3DMatrix(null); double[][] atMatrix = at.matrix; double norm = Math.sqrt(axis[0] * axis[0] + axis[1] * axis[1] + axis[2] * axis[2]); double x = axis[0] / norm, y = axis[1] / norm, z = axis[2] / norm; double c = Math.cos(theta), s = Math.sin(theta); double t = 1 - c; // matrix elements not listed are zero atMatrix[0][0] = t * x * x + c; atMatrix[0][1] = t * x * y - s * z; atMatrix[0][2] = t * x * y + s * y; atMatrix[1][0] = t * x * y + s * z; atMatrix[1][1] = t * y * y + c; atMatrix[1][2] = t * y * z - s * x; atMatrix[2][0] = t * x * z - s * y; atMatrix[2][1] = t * y * z + s * x; atMatrix[2][2] = t * z * z + c; atMatrix[3][3] = 1; return at; }
/** * Evaluates the displacement for an oscillator at postion x * * @param x postion along chain * @return the displacement */ public double evaluate(double x) { return amplitude * Math.sin(x * wavenumber); }
public double cosh(double x) { double ex, mex; ex = Math.exp(x); mex = 1 / ex; return (ex + mex) / 2; }
public double tanh(double x) { double ex, mex; ex = Math.exp(x); mex = 1 / ex; return (ex - mex) / (ex + mex); }
public double freeenergy(double x) { return 0.5 * Jq * x * x - 1.0 / beta * Math.log(2 * cosh(beta * (Jq * x + b))); }