Revision: 18615 http://sourceforge.net/p/jmol/code/18615 Author: hansonr Date: 2013-08-22 05:32:34 +0000 (Thu, 22 Aug 2013) Log Message: ----------- NMRCalculation simplification of code
Modified Paths: -------------- trunk/Jmol/src/org/jmol/api/JmolNMRInterface.java trunk/Jmol/src/org/jmol/modelset/Measurement.java trunk/Jmol/src/org/jmol/quantum/NMRCalculation.java Modified: trunk/Jmol/src/org/jmol/api/JmolNMRInterface.java =================================================================== --- trunk/Jmol/src/org/jmol/api/JmolNMRInterface.java 2013-08-22 05:13:37 UTC (rev 18614) +++ trunk/Jmol/src/org/jmol/api/JmolNMRInterface.java 2013-08-22 05:32:34 UTC (rev 18615) @@ -28,13 +28,14 @@ * If t is null, then a1, a2, and type are used to find the appropriate * tensor. * + * @param isIso * @param a1 * @param a2 * @param type * @param t * @return 0 if not found */ - public float getJCouplingHz(Atom a1, Atom a2, String type, Tensor t); + public float getIsoOrAnisoHz(boolean isIso, Atom a1, Atom a2, String type, Tensor t); /** * Modified: trunk/Jmol/src/org/jmol/modelset/Measurement.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/Measurement.java 2013-08-22 05:13:37 UTC (rev 18614) +++ trunk/Jmol/src/org/jmol/modelset/Measurement.java 2013-08-22 05:32:34 UTC (rev 18615) @@ -313,7 +313,7 @@ / (a1.getVanderwaalsRadiusFloat(viewer, EnumVdw.AUTO) + a2.getVanderwaalsRadiusFloat(viewer, EnumVdw.AUTO)) : isDC ? viewer.getNMRCalculation().getDipolarConstantHz(a1, a2) - : viewer.getNMRCalculation().getJCouplingHz(a1, a2, units, + : viewer.getNMRCalculation().getIsoOrAnisoHz(true, a1, a2, units, null)); isValid = !Float.isNaN(dist); if (isPercent) Modified: trunk/Jmol/src/org/jmol/quantum/NMRCalculation.java =================================================================== --- trunk/Jmol/src/org/jmol/quantum/NMRCalculation.java 2013-08-22 05:13:37 UTC (rev 18614) +++ trunk/Jmol/src/org/jmol/quantum/NMRCalculation.java 2013-08-22 05:32:34 UTC (rev 18615) @@ -196,6 +196,10 @@ } public float getJCouplingHz(Atom a1, Atom a2, String type, Tensor isc) { + return getIsoOrAnisoHz(true, a1, a2, type, isc); + } + + public float getIsoOrAnisoHz(boolean isIso, Atom a1, Atom a2, String type, Tensor isc) { if (isc == null) { type = getISCtype(a1, type); if (type == null || a1.modelIndex != a2.modelIndex) @@ -212,29 +216,9 @@ a2 = viewer.modelSet.atoms[isc.atomIndex2]; } return (float) (getIsotopeData(a1, MAGNETOGYRIC_RATIO) - * getIsotopeData(a2, MAGNETOGYRIC_RATIO) * isc.getIso() * J_FACTOR); + * getIsotopeData(a2, MAGNETOGYRIC_RATIO) * (isIso ? isc.isotropy() : isc.anisotropy()) * J_FACTOR); } - public float getAnisoHz(Atom a1, Atom a2, String type, Tensor isc) { - if (isc == null) { - type = getISCtype(a1, type); - if (type == null || a1.modelIndex != a2.modelIndex) - return 0; - BS bs = new BS(); - bs.set(a1.index); - bs.set(a2.index); - JmolList<Tensor> list = getInteractionTensorList(type, bs); - if (list.size() == 0) - return Float.NaN; - isc = list.get(0); - } else { - a1 = viewer.modelSet.atoms[isc.atomIndex1]; - a2 = viewer.modelSet.atoms[isc.atomIndex2]; - } - return (float) (getIsotopeData(a1, MAGNETOGYRIC_RATIO) - * getIsotopeData(a2, MAGNETOGYRIC_RATIO) * isc.getAnisotropy() * J_FACTOR); - } - @SuppressWarnings("unchecked") private String getISCtype(Atom a1, String type) { JmolList<Tensor> tensors = (JmolList<Tensor>) viewer.getModelAuxiliaryInfoValue(a1.modelIndex, "interactionTensors"); @@ -386,7 +370,7 @@ public float getMagneticShielding(Atom atom) { Tensor t = viewer.modelSet.getAtomTensor(atom.index, "ms"); - return (t == null ? Float.NaN : t.getIso()); + return (t == null ? Float.NaN : t.isotropy()); } private Map<String, Float> shiftRefsPPM = new Hashtable<String, Float>(); @@ -440,8 +424,8 @@ list1 = new JmolList<Object>(); list1.addLast(Integer.valueOf(t.atomIndex1)); list1.addLast(Integer.valueOf(t.atomIndex2)); - list1.addLast(isEta? Float.valueOf(getAnisoHz(null, null, null, t)) : isJ ? Float.valueOf(getJCouplingHz(null, null, null, t)) - : t.getInfo(infoType)); + list1.addLast(isEta || isJ ? Float.valueOf(getIsoOrAnisoHz(isJ, null, + null, null, t)) : t.getInfo(infoType)); data.addLast(list1); } if (tensorType != null) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Introducing Performance Central, a new site from SourceForge and AppDynamics. Performance Central is your source for news, insights, analysis and resources for efficient Application Performance Management. Visit us today! http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk _______________________________________________ Jmol-commits mailing list Jmol-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-commits