// Pogram to read the last occupancy level from the EVALUES file adn create the OCCEXC file, it also prints the energy and level. // The files EVALUES and SUMMARY must be present in the directory // // example usage: java create_occexc hole_state particle_state hole_spin particle_spin // // hole_state must be zero or negative // particle state must be zero or positive // spin is either 1 or 2 // // Luis Basurto, Sept. 2012 // import java.io.*; import java.util.Scanner; public class create_occexc{ static double eqv=27.2116; static String List1[]=new String[11]; static FileInputStream fstream; static DataInputStream in; static Scanner scan; public static void main(String args[]){ double[] energy,occ; int level; int[]rep,deg,spin; String filename; int i=0; int hole_state=0,particle_state=0; int hole_spin=0,particle_spin=0; int spins[] = {0,0}; double last_energy=0.0; try{ if(args.length != 4){ System.out.println("Need to input hole_state particle_state hole_spin particle_spin. Example: java create_occexc -2 3 1 2"); return; } File file1= new File("EVALUES"); if(!file1.exists()){ System.out.println("Error: File EVALUES not found"); return; } File file2= new File("SUMMARY"); if(!file2.exists()){ System.out.println("Error: File SUMMARY not found"); return; } filename="EVALUES"; try{ hole_state = Integer.parseInt(args[0]); }catch(NumberFormatException e){ System.out.println("Error in first argument: "+e.getMessage()+" must be integer"); return; } try{ particle_state = Integer.parseInt(args[1]); }catch(NumberFormatException e){ System.out.println("Error in second argument: "+e.getMessage()+" must be integer"); return; } try{ hole_spin = Integer.parseInt(args[2]); }catch(NumberFormatException e){ System.out.println("Error in third argument: "+e.getMessage()+" must be integer"); return; } try{ particle_spin = Integer.parseInt(args[3]); }catch(NumberFormatException e){ System.out.println("Error in fourth argument: "+e.getMessage()+" must be integer"); return; } last_energy = get_energy(); double fermi = get_fermi(filename); int states = count_states(filename); System.out.println("States:"+states); rep = new int[states]; deg = new int[states]; spin = new int[states]; energy = new double[states]; occ = new double[states]; fstream = new FileInputStream(filename); in = new DataInputStream(fstream); scan = new Scanner(in); String temp= new String(); temp=scan.next(); while(temp.compareTo("OCCUPANCIES:")!=0) temp=scan.next(); while(scan.hasNext()){ read_line(); // 1 REP: 1 DEG: 1 SPIN: 1 ENERGY: -345.602 OCC: 1.00000 try{ rep[i]=Integer.parseInt(List1[2]); }catch(NumberFormatException e){ System.out.println("Error: "+e.getMessage()+" Assuming zero"); rep[i]=0; } try{ deg[i]=Integer.parseInt(List1[4]); }catch(NumberFormatException e){ System.out.println("Error: "+e.getMessage()+" Assuming zero"); deg[i]=0; } try{ spin[i]=Integer.parseInt(List1[6]); }catch(NumberFormatException e){ System.out.println("Error: "+e.getMessage()+" Assuming zero"); spin[i]=0; } try{ energy[i]=Double.parseDouble(List1[8]); }catch(NumberFormatException e){ System.out.println("Error: "+e.getMessage()+" Assuming zero"); energy[i]=0.0; } try{ occ[i]=Double.parseDouble(List1[10]); }catch(NumberFormatException e){ System.out.println("Error: "+e.getMessage()+" Assuming zero"); occ[i]=0.0; } i++; } i=0; fstream.close(); in.close(); while((energy[i]-fermi)<=0.00001){ if(spin[i]==1) spins[0]++; else spins[1]++; i++; } level=i; double gap=energy[level]-energy[level-1]; System.out.println("Gap:"+gap+" au"); System.out.println("Gap:"+(gap*eqv)+" eV"); System.out.println("State:"+(level-1)+" eHOMO:"+energy[level-1]+" OCC:"+occ[level-1]); System.out.println("State:"+level+" eLUMO:"+energy[level]+" OCC:"+occ[level]); if(occ[level]>0&&occ[level]<1.0) System.out.println("Warning: Metallic system!"); }catch(IOException e){ System.err.println("Error: "+e.getMessage()); } // Create File OCCEXC // Introductory stuff try{ FileWriter Outfile = new FileWriter("OCCEXC"); PrintWriter out = new PrintWriter(Outfile); out.println("1"); out.println(""+last_energy); if(hole_spin==1) out.println(""+hole_spin+" "+(spins[0]+hole_state)+" Hole Spin, hole state"); else out.println(""+hole_spin+" "+(spins[1]+hole_state)+" Hole Spin, hole state"); if(particle_spin==1) out.println(""+particle_spin+" "+(spins[0]+1+particle_state)+" Particle Spin, particle state"); else out.println(""+particle_spin+" "+(spins[1]+1+particle_state)+" Particle Spin, particle state"); // Print states in the "before" moving the electron out.println(""+spins[0]); for(i=0;i