| 1 | |
|---|
| 2 | |
|---|
| 3 | import java.awt.*; |
|---|
| 4 | |
|---|
| 5 | public class PlotSpecial extends Panel { |
|---|
| 6 | private Plot dRhoPlot; public PlotPanel pp; |
|---|
| 7 | public double deltarho, dmax, curvelocities[]={0,0,0,0,0,0,0,0,0,0}; |
|---|
| 8 | private int points[]={0,0,0,0,0,0,0,0,0,0}; |
|---|
| 9 | boolean curveExists[]={true,false,false,false,false,false,false,false,false, |
|---|
| 10 | false}; |
|---|
| 11 | |
|---|
| 12 | public void init() { |
|---|
| 13 | setLayout(new BorderLayout()); |
|---|
| 14 | |
|---|
| 15 | dRhoPlot=new Plot(); add("Center",dRhoPlot); dRhoPlot.init(); |
|---|
| 16 | dRhoPlot.setTitle("Velocity Contours"); dRhoPlot.setGrid(true); |
|---|
| 17 | dRhoPlot.setNumSets(10); dRhoPlot.setMarksStyle("none"); |
|---|
| 18 | dRhoPlot.setXLabel("Sphere Density"); dRhoPlot.setYLabel("Diameter"); |
|---|
| 19 | |
|---|
| 20 | dRhoPlot.addPoint(0,pp.rho,0,false); dRhoPlot.addPoint(0,pp.rho,dmax,true); |
|---|
| 21 | } |
|---|
| 22 | |
|---|
| 23 | private void _drawPlot(int curvenum, double u) { |
|---|
| 24 | if(curvenum<1||curvenum>9) return; |
|---|
| 25 | if(curveExists[curvenum]) { |
|---|
| 26 | for(int i=0;i<points[curvenum];i++) |
|---|
| 27 | dRhoPlot.erasePoint(curvenum,0); |
|---|
| 28 | points[curvenum]=0; } |
|---|
| 29 | |
|---|
| 30 | curvelocities[curvenum]=u; |
|---|
| 31 | double rhomin=pp.rho+u*u*u*pp.rho*pp.rho/800000/pp.mu/pp.g; |
|---|
| 32 | double rhomax=pp.rho+deltarho; |
|---|
| 33 | if(rhomin-pp.rho<=deltarho) { |
|---|
| 34 | if(rhomax-pp.rho>deltarho) rhomax=pp.rho+deltarho; |
|---|
| 35 | boolean first=false; for(int i=0; i<=100; i++) { |
|---|
| 36 | double newrho=rhomin+i*Math.abs(rhomax-rhomin)/100.; |
|---|
| 37 | double Re=pp.dc.rerat(pp.dc.free(newrho,u)); |
|---|
| 38 | if(Re>0&&(Re*=pp.mu/pp.rho/u)<=dmax) { |
|---|
| 39 | dRhoPlot.addPoint(curvenum,newrho,Re,first); |
|---|
| 40 | points[curvenum]++; first=true; }}} |
|---|
| 41 | |
|---|
| 42 | rhomax=pp.rho-u*u*u*pp.rho*pp.rho/800000/pp.mu/pp.g; |
|---|
| 43 | rhomin=Math.max(pp.rho-deltarho,0); |
|---|
| 44 | if(pp.rho-rhomax<=deltarho && rhomax>0) { |
|---|
| 45 | boolean first=false; for(int i=0; i<=100; i++) { |
|---|
| 46 | double newrho=rhomin+i*Math.abs(rhomax-rhomin)/100.; |
|---|
| 47 | double Re=pp.dc.rerat(pp.dc.free(newrho,u)); |
|---|
| 48 | if(Re>0&&(Re*=pp.mu/pp.rho/u)<=dmax) { |
|---|
| 49 | dRhoPlot.addPoint(curvenum,newrho,Re,first); |
|---|
| 50 | points[curvenum]++; first=true; }}} |
|---|
| 51 | |
|---|
| 52 | dRhoPlot.setXRange(Math.max(pp.rho-deltarho,0), pp.rho+deltarho); |
|---|
| 53 | dRhoPlot.setYRange(0,dmax); |
|---|
| 54 | curveExists[curvenum]=true; } |
|---|
| 55 | |
|---|
| 56 | public void drawPlot(int curvenum, double u) { |
|---|
| 57 | _drawPlot(curvenum, u); dRhoPlot.drawPlot(true); } |
|---|
| 58 | |
|---|
| 59 | public void redoAllPlots() { |
|---|
| 60 | dRhoPlot.erasePoint(0,0); dRhoPlot.erasePoint(0,0); |
|---|
| 61 | dRhoPlot.addPoint(0,pp.rho,0,false); dRhoPlot.addPoint(0,pp.rho,dmax,true); |
|---|
| 62 | for(int i=1; i<10; i++) |
|---|
| 63 | if(curveExists[i]) _drawPlot(i, curvelocities[i]); |
|---|
| 64 | dRhoPlot.drawPlot(true); } |
|---|
| 65 | |
|---|
| 66 | public void changedRho(double newdRho) { |
|---|
| 67 | deltarho=newdRho; redoAllPlots(); } |
|---|
| 68 | |
|---|
| 69 | public void changeDmax(double newDmax) { |
|---|
| 70 | dmax=newDmax; redoAllPlots(); } |
|---|
| 71 | |
|---|
| 72 | public PlotSpecial(PlotPanel fff) { |
|---|
| 73 | pp=fff; deltarho=Math.abs(pp.rho_p-pp.rho); |
|---|
| 74 | dmax=100000*pp.mu/pp.rho/pp.u; } |
|---|
| 75 | |
|---|
| 76 | public void paint(Graphics g) { dRhoPlot.paint(g); }} |
|---|