Changeset 2742
- Timestamp:
- 01/18/2009 05:57:35 PM (1 year ago)
- Files:
-
- HadoopToys/src/edu/unl/TestLoop/TestLoop.java (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
HadoopToys/src/edu/unl/TestLoop/TestLoop.java
r2725 r2742 28 28 public static int numIteration=100; 29 29 public static List<ArrayList<String>> atoms=new ArrayList<ArrayList<String>>(); 30 public static List<ArrayList<String>> exatoms=new ArrayList<ArrayList<String>>(); 30 31 public static String x,y,z; 32 public static int exstatus; 31 33 public static String moviePath=null; //File of simulation movie in HDFS 32 34 … … 57 59 Path[] cachedFiles=new Path[0]; 58 60 int atomnumber=0; 59 mdIteration=Integer.parseInt(job.get("md.interation")); 61 // try{ 62 // String iterationstring=job.get("md.iteration"); 63 mdIteration=Integer.parseInt(job.get("md.iteration")); 64 // }catch(Exception num){ 65 // System.out.println("Error in get the parameter from JobConf:"+job.get("md.iteration")); 66 // } 60 67 FileSystem fs=null; 61 68 // FileStatus fis=new fs.FileStatus(); 62 Path movie=new Path(job.get("m ovie.path"));69 Path movie=new Path(job.get("md.moviepath")); 63 70 64 71 try{ … … 72 79 while((filecontent=fis.readLine())!=null){ 73 80 StringTokenizer token=new StringTokenizer(filecontent); 74 turnkeepper=Integer.parseInt(token.nextToken());81 // turnkeepper=Integer.parseInt(token.nextToken()); 75 82 ArrayList<String> eachline=new ArrayList<String>(); 76 83 while(token.hasMoreTokens()){ 77 84 eachline.add(token.nextToken()); 78 85 } 79 atoms.add(turnkeepper,eachline); 86 atoms.add(eachline); 87 // atoms.add((turnkeepper-1),eachline); 80 88 atomnumber++; 81 89 } … … 91 99 fs=movie.getFileSystem(job); 92 100 FSDataOutputStream fsos=fs.create(new Path(moviePath)); 93 }catch(Exception expt){ 101 OutputStream os=fsos.getWrappedStream(); 102 ObjectOutputStream oos =new ObjectOutputStream(os); 103 for(int l=0;l<atoms.size();l++){ 104 String res=null; 105 if(l==0){ 106 double stime=(double)mdIteration*TimeStep; 107 String title="Simulation Time: t= "+stime; 108 // os.write(new byte[](title)); 109 oos.writeBytes(title); 110 } 111 for(int k=0;k<5;k++){ 112 res=res+" "+((ArrayList)atoms.get(l)).get(k).toString(); 113 } 114 // os.write(new byte[](res)); 115 oos.writeBytes(res); 116 } 117 }catch(Exception expt){ 94 118 System.out.println("Error in creat the movie file"); 95 119 } … … 99 123 fs=movie.getFileSystem(job); 100 124 FSDataOutputStream fsos=fs.append(new Path(moviePath)); 125 OutputStream os=fsos.getWrappedStream(); 126 ObjectOutputStream oos =new ObjectOutputStream(os); 127 for(int l=0;l<atoms.size();l++){ 128 String res=null; 129 if(l==0){ 130 double stime=(double)mdIteration*TimeStep; 131 String title="Simulation Time: t= "+stime; 132 // os.write(new byte[](title)); 133 oos.writeBytes(title); 134 } 135 for(int k=0;k<5;k++){ 136 res=res+" "+((ArrayList)atoms.get(l)).get(k).toString(); 137 } 138 // os.write(new byte[](res)); 139 oos.writeBytes(res); 140 } 101 141 }catch(Exception expt){ 102 142 System.out.println("Error in append to the movie file"); 103 143 } 104 144 } 105 try{ 145 /* try{ 146 fs=movie.getFileSystem(job); 147 if (moviePath==null){ 148 FSDataOutputStream fsos=fs.create(new Path(moviePath)); 149 } 150 else{FSDataOutputStream fsos=fs.append(new Path(moviePath)); 151 } 106 152 OutputStream os=fsos.getWrappedStream(); 107 ObjectOutputStream oos = new ObjectOutputStream(os);153 ObjectOutputStream oos = new ObjectOutputStream(os); 108 154 109 155 for(int l=0;l<atoms.size();l++){ … … 124 170 System.out.println("Error in Writting the movie file"); 125 171 } 172 */ 126 173 } 127 174 public void mdvverlet(int keyvalue,String atomsymbol){ … … 136 183 double xvel,yvel,zvel; 137 184 double xacc,yacc,zacc; 185 int atompos; 138 186 rx=ry=rz=0; 139 187 force=0; 140 188 fsumx=fsumy=fsumz=0; 141 142 x_position=Double.parseDouble(((ArrayList)TestLoop.atoms.get(keyvalue-1)).get(2).toString()); 143 y_position=Double.parseDouble(((ArrayList)TestLoop.atoms.get(keyvalue-1)).get(3).toString()); 144 z_position=Double.parseDouble(((ArrayList)TestLoop.atoms.get(keyvalue-1)).get(4).toString()); 189 for(j=0;j<totalatom;j++){ 190 atompos=Integer.parseInt(((ArrayList)TestLoop.atoms.get(j)).get(0).toString()); 191 if(atompos==keyvalue){ 192 keyvalue=j; 193 break; 194 } 195 } 196 x_position=Double.parseDouble(((ArrayList)TestLoop.atoms.get(keyvalue)).get(2).toString()); 197 y_position=Double.parseDouble(((ArrayList)TestLoop.atoms.get(keyvalue)).get(3).toString()); 198 z_position=Double.parseDouble(((ArrayList)TestLoop.atoms.get(keyvalue)).get(4).toString()); 145 199 146 200 // Read information of the atom which will interact with the selected one 147 201 for(j=1;j<totalatom+1;j++){ 148 if(keyvalue ==j){202 if(keyvalue+1==j){ 149 203 x_force[j]=(double)0.0; 150 204 y_force[j]=(double)0.0; … … 214 268 z_acc=fsumz/mass; 215 269 //get the old velocity 216 xvel=Double.parseDouble(((ArrayList)atoms.get(keyvalue -1)).get(5).toString());217 yvel=Double.parseDouble(((ArrayList)atoms.get(keyvalue -1)).get(6).toString());218 zvel=Double.parseDouble(((ArrayList)atoms.get(keyvalue -1)).get(7).toString());270 xvel=Double.parseDouble(((ArrayList)atoms.get(keyvalue)).get(5).toString()); 271 yvel=Double.parseDouble(((ArrayList)atoms.get(keyvalue)).get(6).toString()); 272 zvel=Double.parseDouble(((ArrayList)atoms.get(keyvalue)).get(7).toString()); 219 273 //get the old acceleration 220 xacc=Double.parseDouble(((ArrayList)atoms.get(keyvalue -1)).get(8).toString());221 yacc=Double.parseDouble(((ArrayList)atoms.get(keyvalue -1)).get(9).toString());222 zacc=Double.parseDouble(((ArrayList)atoms.get(keyvalue -1)).get(10).toString());274 xacc=Double.parseDouble(((ArrayList)atoms.get(keyvalue)).get(8).toString()); 275 yacc=Double.parseDouble(((ArrayList)atoms.get(keyvalue)).get(9).toString()); 276 zacc=Double.parseDouble(((ArrayList)atoms.get(keyvalue)).get(10).toString()); 223 277 //get the new velocity 224 278 x_vel=(double) (xvel+TimeStep*(x_acc+xacc)/2.0);
