import java.applet.Applet; import java.awt.event.*; import java.awt.*; public class XtraEnergy { /**All these routines are used in our program to make sure that our Energy Estimator works propertly. They just serve as sanity checks. **/ /**This routine computes the partial energy, in which only certain bonds are turned on. **/ public static double energy(double e,Vector[] V,int[][] on) { double total=0; for(int i=0;i<5;++i) { for(int j=i+1;j<5;++j) { if(on[i][j]==1) total=total+Energy.interaction(e,V[i],V[j]); } } return(total); } /**This routine gets thergy of a planar configuration, with certain of the bonds turned off/on, as specified by the numbers in the array on.**/ public static double energy(double e,Complex[] z,int[][] on) { Vector[] V=new Vector[5]; for(int i=0;i<4;++i) V[i]=Stereo.inverseStereo(z[i]); V[4]=new Vector(0,0,1); return(energy(e,V,on)); } /**This routine gets the list of interactions between the vertices of box1 and the center of box2**/ public static double[] getEnergyVertices(double e,Box BB1,Box BB2) { Box B1=new Box(BB1); Box B2=new Box(BB2); B1.type=0; double[] d=new double[4]; Vector[] V1=B1.toVectors(); Vector V2=new Vector(0,0,1); if(B2.type!=2) V2=Stereo.inverseStereo(B2.z); for(int i=0;id[i]) x=d[i]; } return(x); } /**For the second box we just use the center point. First we compute a convex average of the energies of the vertices. Then we compare this to a convex average of the energie of a suitably chosen interior point.**/ public static double discrepancy0(double E,Box B1,Box B2,double a,double b) { double[] d=getEnergyVertices(E,B1,B2); double d1=a*d[3]+(1-a)*d[0]; double d2=a*d[2]+(1-a)*d[1]; double d3=b*d2+(1-b)*d1; //weighted average of verticex energies Vector V1=XtraBox.getPoint(B1,a,b); Vector V2=B2.getCenter(); double d4=Energy.interaction(E,V1,V2); //actual interaction energy return(d3-d4); } }