From: <ha...@us...> - 2011-09-04 19:10:47
|
Revision: 16033 http://jmol.svn.sourceforge.net/jmol/?rev=16033&view=rev Author: hansonr Date: 2011-09-04 19:10:40 +0000 (Sun, 04 Sep 2011) Log Message: ----------- version=12.2.RC6_dev # bug fix: linear combination of MOs broken in 12.1.49 Modified Paths: -------------- trunk/Jmol/src/org/jmol/jvxl/readers/IsoMOReader.java trunk/Jmol/src/org/jmol/quantum/MOCalculation.java trunk/Jmol/src/org/jmol/quantum/QuantumCalculation.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties Modified: trunk/Jmol/src/org/jmol/jvxl/readers/IsoMOReader.java =================================================================== --- trunk/Jmol/src/org/jmol/jvxl/readers/IsoMOReader.java 2011-09-04 09:36:27 UTC (rev 16032) +++ trunk/Jmol/src/org/jmol/jvxl/readers/IsoMOReader.java 2011-09-04 19:10:40 UTC (rev 16033) @@ -104,6 +104,8 @@ return; coefs[j - 1] = (float[]) mos.get(j - 1).get("coefficients"); } + for (int i = params.title.length; --i >= 0;) + fixTitleLine(i, null); } isElectronDensityCalc = (coef == null && linearCombination == null && !isNci); } @@ -129,10 +131,11 @@ initializeVolumetricData(); return true; } + private void fixTitleLine(int iLine, Map<String, Object> mo) { // see Parameters.Java for defaults here. if (!fixTitleLine(iLine)) - return; + return; String line = params.title[iLine]; int pt = line.indexOf("%"); if (line.length() == 0 || pt < 0) @@ -141,21 +144,53 @@ if (line.indexOf("%F") >= 0) line = TextFormat.formatString(line, "F", params.fileName); if (line.indexOf("%I") >= 0) - line = TextFormat.formatString(line, "I", params.qm_moLinearCombination == null ? "" + params.qm_moNumber : EnumQuantumShell.getMOString(params.qm_moLinearCombination)); + line = TextFormat.formatString(line, "I", + params.qm_moLinearCombination == null ? "" + params.qm_moNumber + : EnumQuantumShell.getMOString(params.qm_moLinearCombination)); if (line.indexOf("%N") >= 0) line = TextFormat.formatString(line, "N", "" + params.qmOrbitalCount); + Float energy = null; + if (mo == null) { + // check to see if all orbitals have the same energy + for (int i = 0; i < linearCombination.length; i += 2) + if (linearCombination[i] != 0) { + mo = mos.get((int) linearCombination[i + 1] - 1); + Float e = (Float) mo.get("energy"); + if (energy == null) { + if (e == null) + break; + energy = e; + } else if (!energy.equals(e)) { + energy = null; + break; + } + } + } else { + if (mo.containsKey("energy")) + energy = (Float) mo.get("energy"); + } + if (line.indexOf("%E") >= 0) - line = TextFormat.formatString(line, "E", mo.containsKey("energy") && ++rep != 0 ? "" + mo.get("energy") : ""); + line = TextFormat.formatString(line, "E", + energy != null && ++rep != 0 ? "" + energy : ""); if (line.indexOf("%U") >= 0) - line = TextFormat.formatString(line, "U", params.moData.containsKey("energyUnits") && ++rep != 0 ? (String) params.moData.get("energyUnits") : ""); + line = TextFormat.formatString(line, "U", + energy != null && params.moData.containsKey("energyUnits") + && ++rep != 0 ? (String) params.moData.get("energyUnits") : ""); if (line.indexOf("%S") >= 0) - line = TextFormat.formatString(line, "S", mo.containsKey("symmetry") && ++rep != 0 ? "" + mo.get("symmetry") : ""); + line = TextFormat.formatString(line, "S", mo != null + && mo.containsKey("symmetry") && ++rep != 0 ? "" + mo.get("symmetry") + : ""); if (line.indexOf("%O") >= 0) - line = TextFormat.formatString(line, "O", mo.containsKey("occupancy") && ++rep != 0 ? "" + mo.get("occupancy") : ""); + line = TextFormat.formatString(line, "O", mo != null + && mo.containsKey("occupancy") && ++rep != 0 ? "" + + mo.get("occupancy") : ""); if (line.indexOf("%T") >= 0) - line = TextFormat.formatString(line, "T", mo.containsKey("type") && ++rep != 0 ? "" + mo.get("type") : ""); + line = TextFormat.formatString(line, "T", mo != null + && mo.containsKey("type") && ++rep != 0 ? "" + mo.get("type") : ""); boolean isOptional = (line.indexOf("?") == 0); - params.title[iLine] = (!isOptional ? line : rep > 0 && !line.trim().endsWith("=") ? line.substring(1) : ""); + params.title[iLine] = (!isOptional ? line : rep > 0 + && !line.trim().endsWith("=") ? line.substring(1) : ""); } private final float[] vDist = new float[3]; Modified: trunk/Jmol/src/org/jmol/quantum/MOCalculation.java =================================================================== --- trunk/Jmol/src/org/jmol/quantum/MOCalculation.java 2011-09-04 09:36:27 UTC (rev 16032) +++ trunk/Jmol/src/org/jmol/quantum/MOCalculation.java 2011-09-04 19:10:40 UTC (rev 16033) @@ -178,13 +178,24 @@ public void createCube() { setXYZBohr(points); + processPoints(); + if (doDebug || testing || isElectronDensity) + calculateElectronDensity(); + } + + double sum = -1; + + @Override + protected void processPoints() { if (linearCombination == null) { process(); } else { - double sum = 0; - for (int i = 0; i < linearCombination.length; i += 2) - sum += linearCombination[i] * linearCombination[i]; - sum = Math.sqrt(sum); + if (sum < 0) { + sum = 0; + for (int i = 0; i < linearCombination.length; i += 2) + sum += linearCombination[i] * linearCombination[i]; + sum = Math.sqrt(sum); + } if (sum == 0) return; for (int i = 0; i < linearCombination.length; i += 2) { @@ -195,8 +206,6 @@ process(); } } - if (doDebug || testing || isElectronDensity) - calculateElectronDensity(); } @Override Modified: trunk/Jmol/src/org/jmol/quantum/QuantumCalculation.java =================================================================== --- trunk/Jmol/src/org/jmol/quantum/QuantumCalculation.java 2011-09-04 09:36:27 UTC (rev 16032) +++ trunk/Jmol/src/org/jmol/quantum/QuantumCalculation.java 2011-09-04 19:10:40 UTC (rev 16033) @@ -147,11 +147,15 @@ points[0].set(pt); voxelData[0][0][0] = 0; setXYZBohr(points); - process(); + processPoints(); //System.out.println("qc pt=" + pt + " " + voxelData[0][0][0]); return voxelData[0][0][0]; } + protected void processPoints() { + process(); + } + protected void initializeOnePoint() { points = new Point3f[1]; points[0] = new Point3f(); Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2011-09-04 09:36:27 UTC (rev 16032) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2011-09-04 19:10:40 UTC (rev 16033) @@ -3,6 +3,7 @@ version=12.2.RC6_dev +# bug fix: linear combination of MOs broken in 12.1.49 # new feature: forgotten feature: load "xxxx.xxx" [ list of models to load ] # -- for example: load "cyclohexane_movie.xyz" [ 1 6 11 26 ] # new feature: set minPixelSelRadius This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |