import ChaosDemos.*; import java.awt.*; import java.util.*; //******************************************************************** /** * TimeSeris Diagnostics for Odes
* @version 24 October 1997 * @author Michael Cross */ //******************************************************************** public class OdesMaxMap extends OdesDiagnostics { /** time for ghost */ double ghostTime=10.; /** number of iterations for ghost */ int ghostLength; /** updated number of points in plot */ int nplot; /** index of first data curve */ int ncurve1; /** updated number of points in plot of second curve */ int nplot1; /** copy of x */ double[] xp={0.,0.,0.,0.}; /** true if Poincare plane has been crossed */ boolean crossed=true; /** true if first data point */ boolean firstDataPoint=true; /** variable for Poincare section */ int secVar=3; /** value for Poincare section */ double sec=20.; /** last x[xecVar] for Poincare section calculation */ double zHold; /** vasiables for return map */ double z1,z2; /** last time */ double tp; /** input marker size */ double marker=1.; /** marker size */ double markerScale=0; /** type of marker (see marker.txt) */ int markerType; String[] XTitleArray={"","X{^ max}_n","Y{^ max}_n","Z{^ max}_n"}; String[] YTitleArray={"","X{^ max}_n+1","Y{^ max}_n+1","Z{^ max}_n+1"}; //****************************************************************** /** * @param inParent parent class * @see Map1D */ //****************************************************************** public OdesMaxMap(Odes inParent) { super(inParent); allowDrag=true; } //******************************************************************** /** * Updates parameters from the text controls in parent class */ //******************************************************************** public void updateParameters() { super.updateParameters(); setAxesRange=false; ghostLength=(int)(parent.ghostTime/dtp); secVar=parent.variables.parseTextField(4,secVar,1,3); marker=parent.variables.parseTextField(6,marker, true); if(plot_x==0 || plot_x==plot_y || plot_x+plot_y+secVar !=6) { plot_x=mod(secVar+1,3)+1; plot_y=mod(plot_x+1,3)+1; parent.parameters.setText(5,String.valueOf(plot_x)); parent.parameters.setText(6,String.valueOf(plot_y)); } if(marker<=0.01){ markerType=7; markerScale=1.; } else { markerType=1; markerScale=marker; } parent.graph.setXAxisTitle(XTitleArray[secVar]); parent.graph.setYAxisTitle(YTitleArray[secVar]); } //********************************************************************* /** * Restarts */ //********************************************************************* public boolean restart() { double data[] = new double[2*ghostLength]; double data1[] = new double[4]; int i,j; double xSave[] = new double[nVariables]; double tSave; t=0.; if(runTrans) { if(!eliminateTransient()) return false; runTrans=false; parent.status.setText(""); } err=0.; System.arraycopy(x,0,xp,0,nVariables); z1=z2=x[secVar]; tp=t; if(setAxesRange) { data1[0]=xmin; data1[1]=ymin; data1[2]=xmax; data1[3]=ymax; ncurve = parent.graph.addCurve(data1,2,Color.black,0,7,1); } if(ghostLength>0) { for(i=0;i 0) ncurve = parent.graph.addCurve(data,nplot, parent.transientColor,0,markerType,markerScale); for(i=0;i 0) { parent.graph.paintAll=false; // Don't paint while updating data parent.graph.appendToCurve(moredata,1,ncurve1); parent.graph.paintAll=true; parent.graph.clearAll=false; parent.graph.repaint(); // graph.paint(graph.getGraphics()); } errp=parent.solver.err[plot_x]+parent.solver.err[plot_y]; if(errp>err) err=errp; if(parent.showTime) parent.status.setText(" Time ="+(float)t); return true; } //********************************************************************** /** * Sets default values of parameters depending on plot type */ //********************************************************************** public void setDefaults() { parent.variables.show(4); parent.variables.hide(5); parent.variables.show(6); parent.variables.setText(4,"3"); parent.variables.setLabelText(4,"Variable"); parent.variables.setText(6,"1."); parent.variables.setLabelText(6,"PlotMark"); parent.topRightPanel.validate(); } //********************************************************************** /** * Shifts x to 0shift) { x=x-shift; } while (x<0.) { x=x+shift; } return x; } //********************************************************************** private int mod(int x, int shift) { while (x>=shift) { x=x-shift; } while (x<0) { x=x+shift; } return x; } //********************************************************************** /** * Sets delay for movie iteration */ //********************************************************************** public void setDelay(int inDelay) { delay=inDelay; dt=dtp/((double) delay); ntrans=(int) (trans/dtp); ghostLength=(int) (parent.ghostTime/dtp); } //********************************************************************** /** * process data * @param x variable * @param data for plotting * @param nplot number of points indata * @return nplot new number of points in data */ //********************************************************************** int process(double x[], double[] data, int nplot) { double z,zmax; if(wrapX) x[1]=mod(x[1],wrapXValue); if(wrapY) x[2]=mod(x[2],wrapYValue); if(wrapZ) x[3]=mod(x[3],wrapZValue); int j=2*nplot; z=x[secVar]; if(z1>z2 && z1>z) { zmax=0.5*(-0.25*z2*z2-0.25*z*z-4.*z1*z1+0.5*z2*z+2*z2*z1+2*z1*z)/ (z2-2*z1+z); if(firstDataPoint) { if(checkXRange(zmax)) { zHold=zmax; firstDataPoint=false; } } else{ if(checkYRange(zmax)) { data[j]=zHold; j++; data[j]=zmax; nplot++; } if(checkXRange(zmax)) zHold=zmax; else firstDataPoint=true; } } z2=z1; z1=z; return nplot; } //********************************************************************** /** * Checks if point within plot range * @param x x-coordinate of point * @param y y-coordinate of point * @return true if within range */ //********************************************************************** private boolean checkRange(double x,double y) { if(!setAxesRange) return true; if(x>xmin && xymin && yxmin && xymin && y