Changeset 2742

Show
Ignore:
Timestamp:
01/18/2009 05:57:35 PM (1 year ago)
Author:
airbots
Message:

Movie file test and exchange arraylist added

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • HadoopToys/src/edu/unl/TestLoop/TestLoop.java

    r2725 r2742  
    2828        public static int numIteration=100;                  
    2929        public static List<ArrayList<String>> atoms=new ArrayList<ArrayList<String>>(); 
     30        public static List<ArrayList<String>> exatoms=new ArrayList<ArrayList<String>>(); 
    3031        public static String x,y,z; 
     32        public static int exstatus; 
    3133        public static String moviePath=null;             //File of simulation movie in HDFS 
    3234 
     
    5759        Path[] cachedFiles=new Path[0]; 
    5860        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//      } 
    6067        FileSystem fs=null; 
    6168//      FileStatus fis=new fs.FileStatus(); 
    62         Path movie=new Path(job.get("movie.path")); 
     69        Path movie=new Path(job.get("md.moviepath")); 
    6370  
    6471        try{ 
     
    7279                while((filecontent=fis.readLine())!=null){ 
    7380                    StringTokenizer token=new StringTokenizer(filecontent); 
    74                   turnkeepper=Integer.parseInt(token.nextToken()); 
     81//                turnkeepper=Integer.parseInt(token.nextToken()); 
    7582                    ArrayList<String> eachline=new ArrayList<String>(); 
    7683                    while(token.hasMoreTokens()){ 
    7784                        eachline.add(token.nextToken()); 
    7885                    } 
    79                     atoms.add(turnkeepper,eachline); 
     86                    atoms.add(eachline); 
     87//                  atoms.add((turnkeepper-1),eachline); 
    8088                    atomnumber++; 
    8189                } 
     
    9199                fs=movie.getFileSystem(job); 
    92100                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){ 
    94118                System.out.println("Error in creat the movie file"); 
    95119                } 
     
    99123                fs=movie.getFileSystem(job); 
    100124                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            } 
    101141            }catch(Exception expt){ 
    102142                System.out.println("Error in append to the movie file"); 
    103143                } 
    104144        } 
    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        } 
    106152            OutputStream os=fsos.getWrappedStream(); 
    107            ObjectOutputStream oos = new ObjectOutputStream(os); 
     153            ObjectOutputStream oos = new ObjectOutputStream(os); 
    108154            
    109155            for(int l=0;l<atoms.size();l++){ 
     
    124170                System.out.println("Error in Writting the movie file"); 
    125171        } 
     172*/ 
    126173} 
    127174        public void mdvverlet(int keyvalue,String atomsymbol){ 
     
    136183                double xvel,yvel,zvel; 
    137184                double xacc,yacc,zacc; 
     185                int atompos; 
    138186                rx=ry=rz=0; 
    139187                force=0; 
    140188                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()); 
    145199         
    146200//      Read information of the atom which will interact with the selected one           
    147201                for(j=1;j<totalatom+1;j++){ 
    148                         if(keyvalue==j){ 
     202                        if(keyvalue+1==j){ 
    149203                                x_force[j]=(double)0.0; 
    150204                                y_force[j]=(double)0.0; 
     
    214268                z_acc=fsumz/mass; 
    215269                //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()); 
    219273                //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()); 
    223277                //get the new velocity 
    224278                x_vel=(double) (xvel+TimeStep*(x_acc+xacc)/2.0);