Revision: 18383
          http://sourceforge.net/p/jmol/code/18383
Author:   hansonr
Date:     2013-07-01 08:08:21 +0000 (Mon, 01 Jul 2013)
Log Message:
-----------
___JmolVersion="13.1.19_dev_2013.07.01"

new feature: {xxx}.tensor(type,what)
  -- type = "temp", "ms", "efg", etc.
  -- what = "eigenvalues", "eigenvectors", "asymmetric", "symmetric", "type", 
and "indices"
  -- returns a list of data
  

Modified Paths:
--------------
    trunk/Jmol/src/org/jmol/modelset/AtomCollection.java
    trunk/Jmol/src/org/jmol/modelset/ModelCollection.java
    trunk/Jmol/src/org/jmol/modelset/ModelSet.java
    trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java
    trunk/Jmol/src/org/jmol/script/T.java
    trunk/Jmol/src/org/jmol/util/Tensor.java
    trunk/Jmol/src/org/jmol/viewer/Jmol.properties

Modified: trunk/Jmol/src/org/jmol/modelset/AtomCollection.java
===================================================================
--- trunk/Jmol/src/org/jmol/modelset/AtomCollection.java        2013-06-30 
07:21:27 UTC (rev 18382)
+++ trunk/Jmol/src/org/jmol/modelset/AtomCollection.java        2013-07-01 
08:08:21 UTC (rev 18383)
@@ -250,6 +250,17 @@
     return (i < 0 || atomTensorList == null || i >= atomTensorList.length ? 
null
         : atomTensorList[i]);
   }
+  
+  public Tensor getAtomTensor(int i, String type) {
+    Tensor[] tensors = getAtomTensorList(i);
+    if (tensors == null || type == null)
+      return null;
+    type = type.toLowerCase();
+    for (int j = 0; j < tensors.length; j++)
+      if (tensors[j] != null && type.equals(tensors[j].type))
+        return tensors[j];
+    return null;
+  }
 
   protected void setAtomTensors(int atomIndex, JmolList<Tensor> list) {
     if (list == null || list.size() == 0)

Modified: trunk/Jmol/src/org/jmol/modelset/ModelCollection.java
===================================================================
--- trunk/Jmol/src/org/jmol/modelset/ModelCollection.java       2013-06-30 
07:21:27 UTC (rev 18382)
+++ trunk/Jmol/src/org/jmol/modelset/ModelCollection.java       2013-07-01 
08:08:21 UTC (rev 18383)
@@ -3419,5 +3419,24 @@
     return ilist;
   }
 
+  @SuppressWarnings("unchecked")
+  public JmolList<Tensor> getInteractionTensorList(String type, BS bs) {
+    type = type.toLowerCase();
+    BS bsModels = getModelBitSet(bs, false);
+    JmolList<Tensor> list = new JmolList<Tensor>();
+    for (int i = bsModels.nextSetBit(0); i >= 0; i = bsModels.nextSetBit(i + 
1)) {
+      JmolList<Tensor> tensors = (JmolList<Tensor>) 
getModelAuxiliaryInfoValue(i, "interactionTensors");
+      if (tensors == null)
+        continue;
+      int n = tensors.size();
+      for (int j = 0; j < n; j++) {
+        Tensor t = tensors.get(j);
+        if (t.type.equals(type))
+          list.addLast(t);
+      }      
+    }
+    return list;
+  }
 
+
 }

Modified: trunk/Jmol/src/org/jmol/modelset/ModelSet.java
===================================================================
--- trunk/Jmol/src/org/jmol/modelset/ModelSet.java      2013-06-30 07:21:27 UTC 
(rev 18382)
+++ trunk/Jmol/src/org/jmol/modelset/ModelSet.java      2013-07-01 08:08:21 UTC 
(rev 18383)
@@ -37,7 +37,6 @@
 import org.jmol.util.P4;
 import org.jmol.util.Quaternion;
 import org.jmol.util.SB;
-import org.jmol.util.Tensor;
 import org.jmol.util.Tuple3f;
 import org.jmol.util.V3;
 

Modified: trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java
===================================================================
--- trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java     2013-06-30 
07:21:27 UTC (rev 18382)
+++ trunk/Jmol/src/org/jmol/script/ScriptMathProcessor.java     2013-07-01 
08:08:21 UTC (rev 18383)
@@ -61,6 +61,7 @@
 import org.jmol.util.P4;
 import org.jmol.util.Quaternion;
 import org.jmol.util.SB;
+import org.jmol.util.Tensor;
 import org.jmol.util.TextFormat;
 import org.jmol.util.Tuple3f;
 import org.jmol.util.V3;
@@ -821,6 +822,8 @@
       return evaluateSymop(args, op.tok == T.propselector);
 //    case Token.volume:
   //    return evaluateVolume(args);
+    case T.tensor:
+      return evaluateTensor(args);
     case T.within:
       return evaluateWithin(args);
     case T.contact:
@@ -831,6 +834,28 @@
     return false;
   }
 
+  private boolean evaluateTensor(SV[] args) throws ScriptException {
+    // {*}.tensor("efg","eigenvalues")
+    // T.tensor is set to allow exactly 2 parameters
+    // change that in T.java to adjust
+    BS bs = SV.getBitSet(getX(), false);
+    String tensorType = SV.sValue(args[0]).toLowerCase();
+    String infoType = ";" + SV.sValue(args[1]).toLowerCase() + ".";
+    JmolList<Object> data = new JmolList<Object>();
+    if (tensorType.equals("isc")) {
+      JmolList<Tensor> list = viewer.modelSet.getInteractionTensorList("isc",
+          bs);
+      int n = (list == null ? 0 : list.size());
+      for (int i = 0; i < n; i++)
+        data.addLast((list.get(i).getInfo(infoType)));
+    }
+    for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) {
+      Tensor t = viewer.modelSet.getAtomTensor(i, tensorType);
+      data.addLast(t == null ? null : t.getInfo(infoType));
+    }
+    return addXList(data);
+  }
+
   private boolean evaluateCache(SV[] args) {
     if (args.length > 0)
       return false;

Modified: trunk/Jmol/src/org/jmol/script/T.java
===================================================================
--- trunk/Jmol/src/org/jmol/script/T.java       2013-06-30 07:21:27 UTC (rev 
18382)
+++ trunk/Jmol/src/org/jmol/script/T.java       2013-07-01 08:08:21 UTC (rev 
18383)
@@ -745,8 +745,8 @@
   
   public final static int add          = 1 | 2 << 9 | mathfunc | mathproperty;
   public final static int distance     = 2 | 2 << 9 | mathfunc | mathproperty;
-  final static int find         = 4 | 3 << 9 | mathfunc | mathproperty;
   final static int replace      = 3 | 2 << 9 | mathfunc | mathproperty;
+  final static int tensor       = 4 | 2 << 9 | mathfunc | mathproperty;
 
   // xxx(a,b,c)
   
@@ -759,6 +759,7 @@
   
   final static int bin          = 1 | 3 << 9 | mathfunc | mathproperty;
   public final static int symop = 2 | 3 << 9 | mathfunc | mathproperty | 
intproperty; 
+  final static int find         = 3 | 3 << 9 | mathfunc | mathproperty;
 
   // anything beyond 3 are set "unlimited"
 
@@ -1978,6 +1979,7 @@
       "sxyz",            T.t(screenxyz),
       "temperature",     T.t(temperature),
       "relativeTemperature", null,
+      "tensor",          T.t(tensor),
       "theta",           T.t(theta),
       "thisModel",       T.t(thismodel),
       "ticks",           T.t(ticks),

Modified: trunk/Jmol/src/org/jmol/util/Tensor.java
===================================================================
--- trunk/Jmol/src/org/jmol/util/Tensor.java    2013-06-30 07:21:27 UTC (rev 
18382)
+++ trunk/Jmol/src/org/jmol/util/Tensor.java    2013-07-01 08:08:21 UTC (rev 
18383)
@@ -108,6 +108,56 @@
   public int atomIndex1 = -1;
   public int atomIndex2 = -1;
 
+  /**
+   * returns an object of the specified type, including 
+   * "eigenvalues", "eigenvectors", "asymmetric", "symmetric", "type", and 
"indices"
+   * 
+   * @param infoType
+   * @return Object or null
+   */
+  public Object getInfo(String infoType) {
+    if (infoType.charAt(0) != ';')
+      infoType = ";" + infoType + ".";
+    switch ((";............."
+           + ";eigenvalues.."
+           + ";eigenvectors."
+           + ";asymmetric..."
+           + ";symmetric...."
+           + ";type........."
+           + ";indices......").indexOf(infoType)) {
+    case 14:
+      return eigenValues;
+    case 28:
+      P3[] list = new P3[3];
+      for (int i = 0; i < 3; i++)
+        list[i] = P3.newP(eigenVectors[i]);
+      return list;
+    case 42:
+      if (asymTensor == null)
+        return null;
+      float[][] a = new float[3][3];
+      for (int i = 0; i < 3; i++)
+        for (int j = 0; j < 3; j++)
+          a[i][j] = (float) asymTensor[i][j];
+      return a;
+    case 56:
+      if (symTensor == null)
+        return null;
+      float[][] b = new float[3][3];
+      for (int i = 0; i < 3; i++)
+        for (int j = 0; j < 3; j++)
+          b[i][j] = (float) symTensor[i][j];
+      return b;
+    case 70:
+      return type;
+    case 84:
+      return new int[] {modelIndex, atomIndex1, atomIndex2};
+    default:
+      return null;
+    }
+  }
+
+
   public static Tensor copyTensor(Tensor t0) {
     Tensor t = new Tensor();
     t.setType(t0.type);
@@ -227,7 +277,7 @@
         || Math.abs(t.eigenVectors[1].dot(t.eigenVectors[2])) > 0.0001f 
         || Math.abs(t.eigenVectors[2].dot(t.eigenVectors[0])) > 0.0001f)
       return null;
-    sort(t.eigenVectors, t.eigenValues);
+    sortAndNormalize(t.eigenVectors, t.eigenValues);
     return t.setType("other");
   }
 
@@ -252,7 +302,7 @@
     mat[0][2] = mat[2][0] = coefs[4] / 2; //XZ
     mat[1][2] = mat[2][1] = coefs[5] / 2; //YZ
     Eigen.getUnitVectors(mat, t.eigenVectors, t.eigenValues);
-    sort(t.eigenVectors, t.eigenValues);
+    sortAndNormalize(t.eigenVectors, t.eigenValues);
     t.typeFactor = TEMPERATURE_FACTOR;
     return t.setType("temp");
   }
@@ -304,7 +354,7 @@
     t.eigenVectors = vectors;
     for (int i = 0; i < 3; i++)
       t.eigenVectors[i].normalize();
-    sort(t.eigenVectors, t.eigenValues);
+    sortAndNormalize(t.eigenVectors, t.eigenValues);
     t.setType(type);
     t.eigenSignMask = (t.eigenValues[0] >= 0 ? 1 : 0)
         + (t.eigenValues[1] >= 0 ? 2 : 0) + (t.eigenValues[2] >= 0 ? 4 : 0);
@@ -363,12 +413,11 @@
    * 
    * |sigma_3 - sigma_iso| >= |sigma_1 - sigma_iso| >= |sigma_2 - sigma_iso|
    * 
-   * and normalize the eigenVectors
    * 
    * @param eigenVectors
    * @param eigenValues
    */
-  private static void sort(V3[] eigenVectors, float[] eigenValues) {
+  private static void sortAndNormalize(V3[] eigenVectors, float[] eigenValues) 
{
     // first sorted 3 2 1, then 1 and 2 are switched using the sortOrder above.
     Object[][] o = new Object[][] {
         new Object[] { eigenVectors[0], Float.valueOf(eigenValues[0]) },

Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2013-06-30 07:21:27 UTC 
(rev 18382)
+++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2013-07-01 08:08:21 UTC 
(rev 18383)
@@ -9,8 +9,13 @@
 #  The quotes above look odd for a parameter file, but they are 
 #  important for the JavaScript version of Jmol.
 
-___JmolVersion="13.1.19_dev_2013.06.29"
+___JmolVersion="13.1.19_dev_2013.07.01"
 
+new feature: {xxx}.tensor(type,what)
+  -- type = "temp", "ms", "efg", etc.
+  -- what = "eigenvalues", "eigenvectors", "asymmetric", "symmetric", "type", 
and "indices"
+  -- returns a list of data
+  
 new feature: SET ECHO POINT {atom or point} 
   -- allows 2D and 3D echos to have 
   -- needs a bit of adjustment, as it only works when x is not within range of 
echo itself (same with labels)

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Jmol-commits mailing list
Jmol-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-commits

Reply via email to