From: <ha...@us...> - 2013-08-14 10:38:05
|
Revision: 18564 http://sourceforge.net/p/jmol/code/18564 Author: hansonr Date: 2013-08-14 10:38:00 +0000 (Wed, 14 Aug 2013) Log Message: ----------- incommensurate work -- M50/40 file reading Modified Paths: -------------- trunk/Jmol/src/org/jmol/adapter/readers/cif/CifReader.java trunk/Jmol/src/org/jmol/adapter/readers/cif/ModulationReader.java trunk/Jmol/src/org/jmol/adapter/readers/xtal/JanaReader.java trunk/Jmol/src/org/jmol/render/RepaintManager.java trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java trunk/Jmol/src/org/jmol/util/Modulation.java trunk/Jmol/src/org/jmol/util/ModulationSet.java trunk/Jmol/src/org/jmol/viewer/AnimationManager.java Modified: trunk/Jmol/src/org/jmol/adapter/readers/cif/CifReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/cif/CifReader.java 2013-08-14 02:43:07 UTC (rev 18563) +++ trunk/Jmol/src/org/jmol/adapter/readers/cif/CifReader.java 2013-08-14 10:38:00 UTC (rev 18564) @@ -218,7 +218,7 @@ } else if (key.startsWith("_chemical_formula_sum") || key.equals("_chem_comp_formula")) { processChemicalInfo("formula"); } else if (key.equals("_cell_modulation_dimension") && !modAverage) { - setModDim(data); + setModDim(parseIntStr(data)); } else if (key.startsWith("_cell_")) { processCellParameter(); } else if (key.startsWith("_symmetry_space_group_name_H-M") Modified: trunk/Jmol/src/org/jmol/adapter/readers/cif/ModulationReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/cif/ModulationReader.java 2013-08-14 02:43:07 UTC (rev 18563) +++ trunk/Jmol/src/org/jmol/adapter/readers/cif/ModulationReader.java 2013-08-14 10:38:00 UTC (rev 18564) @@ -68,7 +68,10 @@ protected boolean modVib; protected String modAxes; protected boolean modAverage; + protected String modType; protected boolean checkSpecial = true; + protected boolean modDebug; + protected int modDim; protected boolean incommensurate; protected Atom[] atoms; @@ -83,7 +86,9 @@ protected void initializeMod() throws Exception { + modDebug = checkFilterKey("MODDEBUG"); modAxes = getFilter("MODAXES="); + modType = getFilter("MODTYPE="); //ODU modVib = checkFilterKey("MODVIB"); // then use MODULATION ON to see modulation modAverage = checkFilterKey("MODAVE"); if (!modVib && !modAverage) @@ -93,10 +98,10 @@ allowRotations = !checkFilterKey("NOSYM"); } - protected void setModDim(String token) { - modDim = parseIntStr(token); + protected void setModDim(int ndim) { if (modAverage) return; + modDim = ndim; if (modDim > 1) { // not ready for dim=2 appendLoadNote("Too high modulation dimension (" + modDim + ") -- reading average structure"); @@ -114,9 +119,19 @@ } protected void addModulation(Map<String, P3> map, String id, P3 pt, int iModel) { + if (modType != null) + switch (id.charAt(0)) { + case 'O': + case 'D': + case 'U': + if (modType.indexOf(id.charAt(0)) < 0) + return; + break; + } if (map == null) map = htModulation; - id += "@" + (iModel >= 0 ? iModel : atomSetCollection.getCurrentAtomSetIndex()); + id += "@" + + (iModel >= 0 ? iModel : atomSetCollection.getCurrentAtomSetIndex()); Logger.info("Adding " + id + " " + pt); map.put(id, pt); } @@ -128,7 +143,11 @@ protected void setModulation() { if (!incommensurate || htModulation == null) return; + if (modDebug) + Logger.debugging = Logger.debuggingHigh = false; setModulationForStructure(atomSetCollection.getCurrentAtomSetIndex()); + if (modDebug) + Logger.debugging = Logger.debuggingHigh = true; } private String suffix; @@ -255,7 +274,6 @@ atomSetCollection.setAtomSetAtomProperty("modt", sb.toString(), -1); htAtomMods = null; } - private String checkKey(String key) { int pt_ = key.indexOf(suffix); return (pt_ < 0 ? null : key.substring(0, pt_)); @@ -285,53 +303,62 @@ if (iop < 0) iop = 0; // now set to - int mdim = 0; // just the first row -- assuming d=1 here - + int mdim = 0; // just the first row -- assuming d=1 here + //if (a.index == 40) - //Logger.debuggingHigh = Logger.debugging = true; + //Logger.debuggingHigh = Logger.debugging = true; if (Logger.debuggingHigh) - Logger.debug("setModulation: i=" + a.index + " " + a.atomName + " xyz=" + a + " occ=" + a.occupancy); + Logger.debug("setModulation: i=" + a.index + " " + a.atomName + " xyz=" + + a + " occ=" + a.occupancy); if (iop != iopLast) { symmetry.getMod456Row(iop, mdim, f4); //System.out.println("mdim=" + mdim + " op=" + (iop + 1) + " " + symmetry.getSpaceGroupOperation(iop) + " " + symmetry.getSpaceGroupXyz(iop, false)); iopLast = iop; rot = new Matrix3f(); - epsilon = f4[0]; //symmetry.getModParam(iop, 0); - delta = f4[3] - modT; //symmetry.getModParam(iop, 1); + epsilon = f4[0]; //symmetry.getModParam(iop, 0); + delta = f4[3] - modT; //symmetry.getModParam(iop, 1); } symmetry.getSpaceGroupOperation(iop).getRotationScale(rot); if (Logger.debugging) { - Logger.debug("setModulation iop = " + iop + " " + symmetry.getSpaceGroupXyz(iop, false) + " " + a.bsSymmetry); + Logger.debug("setModulation iop = " + iop + " " + + symmetry.getSpaceGroupXyz(iop, false) + " " + a.bsSymmetry); } ModulationSet ms = new ModulationSet(a.index + " " + a.atomName, list); a.vib = ms; ms.epsilon = epsilon; ms.delta = delta; ms.r = P3.newP(a); + ms.v0 = a.occupancy / 100f; ms.rot = rot; ms.calculate(); - if (ms.v < 0.5f) { + if (modVib && !Float.isNaN(ms.v0)) { + a.occupancy = (int) ((ms.v0 + ms.v) * 100); + } else if (ms.v < 0.5f) { a.occupancy = 0; - if (bsAtoms != null) - bsAtoms.clear(a.index); + bsAtoms.clear(a.index); + } else if (ms.v >= 0.5f) { + a.occupancy = 100; } if (ms.htValues != null) { // Uiso or Uij. We add the displacements, create the tensor, then rotate it, // replacing the tensor already present for that atom. if (Logger.debuggingHigh) { Logger.debug("setModulation Uij(initial)=" + Escape.eAF(a.anisoBorU)); - Logger.debug("setModulation tensor=" + Escape.e(a.tensors.get(0).getInfo("all"))); + Logger.debug("setModulation tensor=" + + Escape.e(a.tensors.get(0).getInfo("all"))); } - for (Entry<String, Float>e : ms.htValues.entrySet()) + for (Entry<String, Float> e : ms.htValues.entrySet()) addUStr(a, e.getKey(), e.getValue().floatValue()); - + if (a.tensors != null) a.tensors.get(0).isUnmodulated = true; - Tensor t = atomSetCollection.addRotatedTensor(a, symmetry.getTensor(a.anisoBorU), iop, false); + Tensor t = atomSetCollection.addRotatedTensor(a, symmetry + .getTensor(a.anisoBorU), iop, false); t.isModulated = true; if (Logger.debuggingHigh) { - Logger.debug("setModulation Uij(final)=" + Escape.eAF(a.anisoBorU) + "\n"); + Logger.debug("setModulation Uij(final)=" + Escape.eAF(a.anisoBorU) + + "\n"); Logger.debug("setModulation tensor=" + a.tensors.get(0).getInfo("all")); } } @@ -345,10 +372,10 @@ sb.append(((int) t) + "\n"); } // displace the atom and reverse the vector only if not filter "MODVIB" -// if (!modVib) { - // a.add(ms); + // if (!modVib) { + // a.add(ms); // ms.setModT(true, Integer.MAX_VALUE); - // } + // } symmetry.toCartesian(ms, true); //System.out.println("a.vib(xyz)=" + a.vib); } Modified: trunk/Jmol/src/org/jmol/adapter/readers/xtal/JanaReader.java =================================================================== --- trunk/Jmol/src/org/jmol/adapter/readers/xtal/JanaReader.java 2013-08-14 02:43:07 UTC (rev 18563) +++ trunk/Jmol/src/org/jmol/adapter/readers/xtal/JanaReader.java 2013-08-14 10:38:00 UTC (rev 18564) @@ -132,7 +132,7 @@ } private void ndim() { - setModDim(line.substring(line.length() - 1)); + setModDim(parseIntStr(getTokens()[1]) - 3); } private int qicount; @@ -253,17 +253,23 @@ P3 pt; if (nOcc > 0 && !haveCrenel) r.readLine(); //"1.00000" + int wv = 0; + float a1, a2; for (int j = 0; j < nOcc; j++) { if (haveCrenel) { float[][] data = readM40FloatLines(2, 1, r); - float w = data[0][0]; - float c = data[1][0]; - id = "O_0#0" + label; - pt = P3.new3(c, w, 0); - addModulation(null, id, pt, -1); + a1 = data[0][0]; + a2 = data[1][0]; } else { - addSinCos(j, "O_", label, r); + wv = j + 1; + readM40Floats(r); + a1 = floats[1]; + a2 = floats[0]; } + id = "O_" + wv + "#0" + label; + pt = P3.new3(a1, a2, 0); + if (a1 != 0 || a2 != 0) + addModulation(null, id, pt, -1); } // read displacement data Modified: trunk/Jmol/src/org/jmol/render/RepaintManager.java =================================================================== --- trunk/Jmol/src/org/jmol/render/RepaintManager.java 2013-08-14 02:43:07 UTC (rev 18563) +++ trunk/Jmol/src/org/jmol/render/RepaintManager.java 2013-08-14 10:38:00 UTC (rev 18564) @@ -106,10 +106,8 @@ if (repaintPending) return false; repaintPending = true; - if (holdRepaint == 0) { - //System.out.println("RM refresh() " + (test++)); + if (holdRepaint == 0) repaintNow(why); - } return true; } Modified: trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java =================================================================== --- trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2013-08-14 02:43:07 UTC (rev 18563) +++ trunk/Jmol/src/org/jmol/script/ScriptEvaluator.java 2013-08-14 10:38:00 UTC (rev 18564) @@ -308,7 +308,7 @@ } if (haveError || !isJS || !allowJSThreads) { viewer.setTainted(true); - viewer.popHoldRepaint("executeCommands" + " " + scriptLevel); + viewer.popHoldRepaint("executeCommands" + " " + (scriptLevel > 0 ? JC.REPAINT_IGNORE : "")); } timeEndExecution = System.currentTimeMillis(); if (errorMessage == null && executionStopped) Modified: trunk/Jmol/src/org/jmol/util/Modulation.java =================================================================== --- trunk/Jmol/src/org/jmol/util/Modulation.java 2013-08-14 02:43:07 UTC (rev 18563) +++ trunk/Jmol/src/org/jmol/util/Modulation.java 2013-08-14 10:38:00 UTC (rev 18564) @@ -61,8 +61,9 @@ case TYPE_DISP_FOURIER: case TYPE_OCC_FOURIER: case TYPE_U_FOURIER: - a1 = params.x; - a2 = params.y; + a1 = params.x; // cos + a2 = params.y; // sin + //System.out.println("ccos=" + a1 + " csin=" + a2); break; case TYPE_DISP_SAWTOOTH: case TYPE_OCC_CRENEL: @@ -135,7 +136,7 @@ if (a2 != 0) v += a2 * Math.sin(theta); if (Logger.debuggingHigh) - Logger.debug("MOD v " + v + " a1 a2 " + a1 + " " + a2 + " / " + theta + " " + ms.t); + Logger.debug("MOD v=" + v + " a1,a2=" + a1 + " " + a2 + " / theta=" + theta + " id=" + ms.id); break; case TYPE_OCC_CRENEL: @@ -147,6 +148,7 @@ x4 -= Math.floor(x4); ms.v = (range(x4) ? 1 : 0); + ms.v0 = Float.NaN; // don't add this in //System.out.println("MOD " + ms.r + " " + ms.delta + " " + ms.epsilon + " " + ms.id + " " + ms.v + " l=" + left + " x=" + x4 + " r=" + right); return; case TYPE_DISP_SAWTOOTH: Modified: trunk/Jmol/src/org/jmol/util/ModulationSet.java =================================================================== --- trunk/Jmol/src/org/jmol/util/ModulationSet.java 2013-08-14 02:43:07 UTC (rev 18563) +++ trunk/Jmol/src/org/jmol/util/ModulationSet.java 2013-08-14 10:38:00 UTC (rev 18564) @@ -18,6 +18,7 @@ public float delta; public P3 r; public Matrix3f rot; + public float v0; public float v = Float.NaN; public int t; public Map<String, Float> htValues; Modified: trunk/Jmol/src/org/jmol/viewer/AnimationManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/AnimationManager.java 2013-08-14 02:43:07 UTC (rev 18563) +++ trunk/Jmol/src/org/jmol/viewer/AnimationManager.java 2013-08-14 10:38:00 UTC (rev 18564) @@ -53,23 +53,28 @@ public int lastFrameDelayMs; public void setAnimationOn(boolean animationOn) { + if (animationOn == this.animationOn) + return; + if (!animationOn || !viewer.haveModelSet() || viewer.isHeadless()) { stopThread(false); return; } if (!viewer.getSpinOn()) - viewer.refresh(3, "Viewer:setAnimationOn"); + viewer.refresh(3, "Anim:setAnimationOn"); setAnimationRange(-1, -1); resumeAnimation(); } public void stopThread(boolean isPaused) { + boolean stopped = false; if (animationThread != null) { animationThread.interrupt(); animationThread = null; + stopped = true; } animationPaused = isPaused; - if (!viewer.getSpinOn()) + if (stopped && !viewer.getSpinOn()) viewer.refresh(3, "Viewer:setAnimationOff"); animation(false); stopModulationThread(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |