// Path: src/org/opensourcephysics/stp/util/Rdf.java
// public class Rdf {
//   public double bin = 0.1;
//   public double[] x, y;
//   public double Lx, Ly;
//   public double rmax;
//   public int N, nbins;
//   public boolean pbc = true;
//   public int ncorr = 0;
//   double[] gr;
//   public double[] rx, ngr; // normalized gr
// 
//   /**
//    * Constructor Rdf
//    */
//   public Rdf() {}
// 
//   /**
//    * Constructor Rdf
//    * @param lx
//    * @param ly
//    */
//   public Rdf(double lx, double ly) {
//     initialize(lx, ly, 0.1);
//   }
// 
//   public void initialize(double lx, double ly, double _bin) {
//     Lx = lx;
//     Ly = ly;
//     rmax = (Lx>Ly)
//            ? 0.5*Lx
//            : 0.5*Ly;
//     bin = _bin;
//     nbins = (int) Math.ceil(rmax/bin);
//     gr = new double[nbins];
//     ngr = new double[nbins];
//     rx = new double[nbins];
//     for(int i = 0; i<nbins; i++) {
//       rx[i] = i*bin;
//       gr[i] = 0.0;
//     }
//   }
// 
//   public void reset() {
//     for(int i = 0; i<nbins; i++) {
//       rx[i] = i*bin;
//       gr[i] = 0.0;
//     }
//     ncorr = 0;
//   }
// 
//   public void append(double[] x, double[] y) {
//     N = x.length;
//     ncorr++;
//     for(int i = 0; i<N; i++) {
//       for(int j = i+1; j<N; j++) {
//         double dx = x[i]-x[j];
//         double dy = y[i]-y[j];
//         if(pbc) {
//           dx = separation(dx, Lx);
//           dy = separation(dy, Ly);
//         }
//         double dr = dx*dx+dy*dy;
//         dr = Math.sqrt(dr);
//         int nbin = (int) ((dr+0.0000001)/bin);
//         if(nbin<nbins) {
//           //if(nbin == 9)System.out.println(dr);
//           gr[nbin]++;
//         }
//       }
//     }
//   }
// 
//   public void normalize() {
//     double area;
//     double pi = Math.PI;
//     int i = 0;
//     int imax = (int) (rmax/bin);
//     double rho = N/Lx/Ly;
//     double norm = 0.5*rho*ncorr*N;
//     while(i<imax) {
//       double r = i*bin;
//       area = pi*((r+bin)*(r+bin)-r*r);
//       area *= norm;
//       ngr[i] = gr[i]/area;
//       i++;
//     }
//   }
// 
//   public void setBinSize(double _bin) {
//     bin = _bin;
//     nbins = (int) (rmax/bin)+1;
//   }
// 
//   public void setPbc(boolean p) {
//     pbc = p;
//   }
// 
//   public double separation(double dx, double lx) {
//     if(dx>0.5*lx) {
//       return dx-lx;
//     }
//     if(dx<-0.5*lx) {
//       return dx+lx;
//     }
//     return dx;
//   }
// 
// }


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowListener;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import org.opensourcephysics.controls.*;
import org.opensourcephysics.display.DrawingPanel;
import org.opensourcephysics.display.GUIUtils;
import org.opensourcephysics.display.OSPFrame;
import org.opensourcephysics.display.OSPRuntime;
import org.opensourcephysics.frames.*;
import org.opensourcephysics.stp.util.Rdf;
/*

 * Open Source Physics software is free software as described near the bottom of this code file.

 *

 * For additional information and documentation on Open Source Physics please see:

 * <http://www.opensourcephysics.org/>

 */

package org.opensourcephysics.stp.lj;

/**
 * LJfluidApp simulates a two-dimensional system of interacting particles
 * via the Lennard-Jones potential.
 *
 * @author Jan Tobochnik, Wolfgang Christian, Harvey Gould
 * @version 1.0 revised 03/28/05, 3/29/05, 8/14/08
 */
public class LJfluidApp extends AbstractSimulation {
  LJfluid md = new LJfluid();
  PlotFrame pressureData = new PlotFrame("time", "PA/NkT", "Mean pressure");
  PlotFrame temperatureData = new PlotFrame("time", "temperature", "Temperature");
  HistogramFrame xVelocityHistogram = new HistogramFrame("vx", "H(vx)", "Velocity histogram");
  DisplayFrame displayFrame= new DisplayFrame("x", "y", "Lennard-Jones system");
  DrawingPanel displayPanel;
  PlotFrame grFrame = new PlotFrame("r", "g(r)", "Radial distribution function");
// Path: src/org/opensourcephysics/stp/util/Rdf.java
// public class Rdf {
//   public double bin = 0.1;
//   public double[] x, y;
//   public double Lx, Ly;
//   public double rmax;
//   public int N, nbins;
//   public boolean pbc = true;
//   public int ncorr = 0;
//   double[] gr;
//   public double[] rx, ngr; // normalized gr
// 
//   /**
//    * Constructor Rdf
//    */
//   public Rdf() {}
// 
//   /**
//    * Constructor Rdf
//    * @param lx
//    * @param ly
//    */
//   public Rdf(double lx, double ly) {
//     initialize(lx, ly, 0.1);
//   }
// 
//   public void initialize(double lx, double ly, double _bin) {
//     Lx = lx;
//     Ly = ly;
//     rmax = (Lx>Ly)
//            ? 0.5*Lx
//            : 0.5*Ly;
//     bin = _bin;
//     nbins = (int) Math.ceil(rmax/bin);
//     gr = new double[nbins];
//     ngr = new double[nbins];
//     rx = new double[nbins];
//     for(int i = 0; i<nbins; i++) {
//       rx[i] = i*bin;
//       gr[i] = 0.0;
//     }
//   }
// 
//   public void reset() {
//     for(int i = 0; i<nbins; i++) {
//       rx[i] = i*bin;
//       gr[i] = 0.0;
//     }
//     ncorr = 0;
//   }
// 
//   public void append(double[] x, double[] y) {
//     N = x.length;
//     ncorr++;
//     for(int i = 0; i<N; i++) {
//       for(int j = i+1; j<N; j++) {
//         double dx = x[i]-x[j];
//         double dy = y[i]-y[j];
//         if(pbc) {
//           dx = separation(dx, Lx);
//           dy = separation(dy, Ly);
//         }
//         double dr = dx*dx+dy*dy;
//         dr = Math.sqrt(dr);
//         int nbin = (int) ((dr+0.0000001)/bin);
//         if(nbin<nbins) {
//           //if(nbin == 9)System.out.println(dr);
//           gr[nbin]++;
//         }
//       }
//     }
//   }
// 
//   public void normalize() {
//     double area;
//     double pi = Math.PI;
//     int i = 0;
//     int imax = (int) (rmax/bin);
//     double rho = N/Lx/Ly;
//     double norm = 0.5*rho*ncorr*N;
//     while(i<imax) {
//       double r = i*bin;
//       area = pi*((r+bin)*(r+bin)-r*r);
//       area *= norm;
//       ngr[i] = gr[i]/area;
//       i++;
//     }
//   }
// 
//   public void setBinSize(double _bin) {
//     bin = _bin;
//     nbins = (int) (rmax/bin)+1;
//   }
// 
//   public void setPbc(boolean p) {
//     pbc = p;
//   }
// 
//   public double separation(double dx, double lx) {
//     if(dx>0.5*lx) {
//       return dx-lx;
//     }
//     if(dx<-0.5*lx) {
//       return dx+lx;
//     }
//     return dx;
//   }
// 
// }


// Path: src/org/opensourcephysics/stp/lj/LJfluidApp.java
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowListener;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import org.opensourcephysics.controls.*;
import org.opensourcephysics.display.DrawingPanel;
import org.opensourcephysics.display.GUIUtils;
import org.opensourcephysics.display.OSPFrame;
import org.opensourcephysics.display.OSPRuntime;
import org.opensourcephysics.frames.*;
import org.opensourcephysics.stp.util.Rdf;

/*

 * Open Source Physics software is free software as described near the bottom of this code file.

 *

 * For additional information and documentation on Open Source Physics please see:

 * <http://www.opensourcephysics.org/>

 */

package org.opensourcephysics.stp.lj;

/**
 * LJfluidApp simulates a two-dimensional system of interacting particles
 * via the Lennard-Jones potential.
 *
 * @author Jan Tobochnik, Wolfgang Christian, Harvey Gould
 * @version 1.0 revised 03/28/05, 3/29/05, 8/14/08
 */
public class LJfluidApp extends AbstractSimulation {
  LJfluid md = new LJfluid();
  PlotFrame pressureData = new PlotFrame("time", "PA/NkT", "Mean pressure");
  PlotFrame temperatureData = new PlotFrame("time", "temperature", "Temperature");
  HistogramFrame xVelocityHistogram = new HistogramFrame("vx", "H(vx)", "Velocity histogram");
  DisplayFrame displayFrame= new DisplayFrame("x", "y", "Lennard-Jones system");
  DrawingPanel displayPanel;
  PlotFrame grFrame = new PlotFrame("r", "g(r)", "Radial distribution function");
  Rdf gr = new Rdf();