001package kernels; 002 003import static org.junit.Assert.*; 004 005import models.FreeModel; 006import models.IsingModel; 007 008import org.junit.Test; 009 010 011/** 012 * Unit tests for the class {@link EnergyDensityKernel}. 013 * 014 */ 015public class EnergyDensityKernelTest { 016 017 /** 018 * Test the value of the kernel at (0,0) against the known value in the free model. 019 */ 020 @Test 021 public void testKernelValue() { 022 023 EnergyDensityKernel k = new EnergyDensityKernel(new FreeModel(), 1.0, 0.0, 0, 0.1); 024 025 double val = k.kernelValue(0, 0); 026 assertEquals(1.0/2.0/Math.PI, val, 1e-10); 027 } 028 029 /** 030 * Verify the lowest eigenvalue of the energy density in the Ising model, 031 * obtained independently with an Octave program for cutoff \(R=10\), with \(n=1000\) steps. 032 */ 033 @Test 034 public void testIsingLowerEV() { 035 036 EnergyDensityKernel k = new EnergyDensityKernel(new IsingModel(), 1.0, 0.0, 0, 0.1); 037 double lowestEV = k.findSpectrum(1000, 10)[0]; 038 039 // Octave program was for mass 1 and didn't take factor 1/2 Pi into account 040 double octaveResult = -0.72944 / 2.0 / Math.PI; 041 042 assertEquals("Checking Ising model against external result", octaveResult, lowestEV, 1e-3); 043 } 044 045}