From: <ha...@us...> - 2007-04-06 13:19:28
|
Revision: 7334 http://svn.sourceforge.net/jmol/?rev=7334&view=rev Author: hansonr Date: 2007-04-06 06:19:26 -0700 (Fri, 06 Apr 2007) Log Message: ----------- 11.1.28 MO improvements, MOPAC graphf improvements You can now pre-set the mo characteristics with, for example: mo nofill mesh then later use mo 5 mo 6 These are file defaults, not global defaults. Modified Paths: -------------- trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java trunk/Jmol/src/org/jmol/adapter/smarter/MopacGraphfReader.java trunk/Jmol/src/org/jmol/util/Parser.java trunk/Jmol/src/org/jmol/viewer/MolecularOrbital.java Modified: trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java 2007-04-06 04:39:52 UTC (rev 7333) +++ trunk/Jmol/src/org/jmol/adapter/smarter/AtomSetCollectionReader.java 2007-04-06 13:19:26 UTC (rev 7334) @@ -104,10 +104,8 @@ return Parser.getTokens(line); } - static float[] getTokensFloat(String s, int n) { - float[] f = new float[n]; - Parser.parseFloatArray(getTokens(s), f); - return f; + static void getTokensFloat(String s, float[] f, int n) { + Parser.parseFloatArray(getTokens(s), f, n); } static String[] getTokens(String s) { @@ -177,7 +175,6 @@ return Parser.parseTrimmed(s, iStart, iEnd); } - // load options: boolean doApplySymmetry; Modified: trunk/Jmol/src/org/jmol/adapter/smarter/MopacGraphfReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/smarter/MopacGraphfReader.java 2007-04-06 04:39:52 UTC (rev 7333) +++ trunk/Jmol/src/org/jmol/adapter/smarter/MopacGraphfReader.java 2007-04-06 13:19:26 UTC (rev 7334) @@ -118,8 +118,9 @@ nOrbitals = 0; Vector intinfo = new Vector(); Vector floatinfo = new Vector(); + float[] values = new float[3]; for (int iAtom = 0; iAtom < atomCount; iAtom++) { - float[] values = getTokensFloat(readLine(), 3); + getTokensFloat(readLine(), values, 3); int[] idata; int atomicNumber = atomicNumbers[iAtom]; float fdata[]; @@ -221,8 +222,11 @@ } void readMOs() throws Exception { - //(5 data per line, 15 characters per datum, FORTRAN format: 5d15.8) + // read mo coefficients + + // (5 data per line, 15 characters per datum, FORTRAN format: 5d15.8) + float[][] list = new float[nOrbitals][nOrbitals]; for (int iMo = 0; iMo < nOrbitals; iMo++) { int n = -1; @@ -232,35 +236,17 @@ list[iMo][i] = parseFloat(line.substring(n * 15, (n + 1) * 15)); } } -/* - System.out.println("MO file coordinates: "); - for (int i = 0; i < nOrbitals; i++) { - System.out.print((i + 1) + ": "); - for (int j = 0; j < nOrbitals; j++) - System.out.print(" " + list[i][j]); - System.out.println(); - } -*/ + // read lower triangle of symmetric inverse sqrt matrix and multiply float[][] invMatrix = new float[nOrbitals][nOrbitals]; for (int iMo = 0; iMo < nOrbitals; iMo++) { int n = -1; for (int i = 0; i < iMo + 1; i++) { if ((n = (n + 1) % 5) == 0) readLine(); - String s = line.substring(n * 15, (n + 1) * 15); - float value = parseFloat(s); - invMatrix[iMo][i] = invMatrix[i][iMo] = value; + invMatrix[iMo][i] = invMatrix[i][iMo] = parseFloat(line.substring( + n * 15, (n + 1) * 15)); } } -/* - System.out.println("inversionMatrix: "); - for (int i = 0; i < nOrbitals; i++) { - System.out.print((i + 1) + ": "); - for (int j = 0; j < nOrbitals; j++) - System.out.print(" " + invMatrix[i][j]); - System.out.println(); - } -*/ float[][] list2 = new float[nOrbitals][nOrbitals]; for (int i = 0; i < nOrbitals; i++) for (int j = 0; j < nOrbitals; j++) { @@ -269,22 +255,27 @@ if (Math.abs(list2[i][j]) < 1e-10) list2[i][j] = 0; } + /* + System.out.println("MO coefficients: "); + for (int i = 0; i < nOrbitals; i++) { + System.out.print((i + 1) + ": "); + for (int j = 0; j < nOrbitals; j++) + System.out.print(" " + list2[i][j]); + System.out.println(); + } + */ + // read MO energies and occupancies, and fill "coefficients" element + float[] values = new float[2]; for (int iMo = 0; iMo < nOrbitals; iMo++) { Hashtable mo = new Hashtable(); + getTokensFloat(readLine(), values, 2); + mo.put("energy", new Float(values[0])); + mo.put("occupancy", new Integer((int) values[1])); mo.put("coefficients", list2[iMo]); orbitals.add(mo); } moData.put("mos", orbitals); atomSetCollection.setAtomSetAuxiliaryInfo("moData", moData); -/* - System.out.println("MO coefficients: "); - for (int i = 0; i < nOrbitals; i++) { - System.out.print((i + 1) + ": "); - for (int j = 0; j < nOrbitals; j++) - System.out.print(" " + list2[i][j]); - System.out.println(); - } -*/ } } Modified: trunk/Jmol/src/org/jmol/util/Parser.java =================================================================== --- trunk/Jmol/src/org/jmol/util/Parser.java 2007-04-06 04:39:52 UTC (rev 7333) +++ trunk/Jmol/src/org/jmol/util/Parser.java 2007-04-06 13:19:26 UTC (rev 7334) @@ -66,10 +66,21 @@ * @param data the array to fill */ public static void parseFloatArray(String[] tokens, float[] data) { - for (int i = Math.min(data.length, tokens.length); --i>=0;) - data[i] = Parser.parseFloat(tokens[i]); + parseFloatArray(tokens, data, data.length); } + /** + * parses a string array for floats. Returns NaN for nonfloats or missing data. + * + * @param tokens the strings to parse + * @param data the array to fill + * @param nData the number of elements + */ + public static void parseFloatArray(String[] tokens, float[] data, int nData) { + for (int i = nData; --i >= 0;) + data[i] = (i >= tokens.length ? Float.NaN : Parser.parseFloat(tokens[i])); + } + public static float parseFloat(String str) { return parseFloat(str, new int[] {0}); } Modified: trunk/Jmol/src/org/jmol/viewer/MolecularOrbital.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/MolecularOrbital.java 2007-04-06 04:39:52 UTC (rev 7333) +++ trunk/Jmol/src/org/jmol/viewer/MolecularOrbital.java 2007-04-06 13:19:26 UTC (rev 7334) @@ -52,6 +52,10 @@ Integer moColorPos = null; Integer moColorNeg = null; boolean moIsPositiveOnly = false; + boolean moFill = true; + boolean moMesh = false; + boolean moDots = false; + boolean moFrontOnly = true; String moTitleFormat = null; boolean moDebug; int myColorPt; @@ -163,6 +167,26 @@ thisModel.put("moTranslucency", value); //pass through } + + if ("dots" == propertyName) { + moDots = (value == Boolean.TRUE); + //pass through + } + if ("mesh" == propertyName) { + moMesh = (value == Boolean.TRUE); + //pass through + } + + if ("frontOnly" == propertyName) { + moFrontOnly = (value == Boolean.TRUE); + //pass through + } + + if ("fill" == propertyName) { + moFill = (value == Boolean.TRUE); + //pass through + } + if ("delete" == propertyName) { htModels.remove(strID); //pass through @@ -266,6 +290,11 @@ super.setProperty("translucenctLevel", moTranslucentLevel, null); if (moTranslucency != null) super.setProperty("translucency", moTranslucency, null); + super.setProperty("fill", moFill ? Boolean.TRUE: Boolean.FALSE, null); + super.setProperty("mesh", moMesh ? Boolean.TRUE: Boolean.FALSE, null); + super.setProperty("dots", moDots ? Boolean.TRUE: Boolean.FALSE, null); + super.setProperty("frontOnly", moFrontOnly ? Boolean.TRUE: Boolean.FALSE, null); + thisModel.put("mesh", currentMesh); return; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |