Revision: 18416 http://sourceforge.net/p/jmol/code/18416 Author: hansonr Date: 2013-07-04 07:22:02 +0000 (Thu, 04 Jul 2013) Log Message: ----------- adds preliminary org.jmol.quantum.NMRCalculation and nmr_data.txt (from _documents/nmr_data.xls) and org.jmol.api.JmolNMRInterface
Modified Paths: -------------- trunk/Jmol/src/org/jmol/viewer/Viewer.java Added Paths: ----------- trunk/Jmol/src/org/jmol/api/JmolNMRInterface.java trunk/Jmol/src/org/jmol/quantum/NMRCalculation.java trunk/Jmol/src/org/jmol/quantum/nmr_data.txt Added: trunk/Jmol/src/org/jmol/api/JmolNMRInterface.java =================================================================== --- trunk/Jmol/src/org/jmol/api/JmolNMRInterface.java (rev 0) +++ trunk/Jmol/src/org/jmol/api/JmolNMRInterface.java 2013-07-04 07:22:02 UTC (rev 18416) @@ -0,0 +1,16 @@ +package org.jmol.api; + +public interface JmolNMRInterface { + + /** + * Get magnetogyricRatio (gamma/10^7 rad s^-1 T^-1) and quadrupoleMoment (Q/fm^2) + * for a given isotope or for the default isotope of an element. + * + * @param isoSym may be an element symbol (H, F) or an isotope_symbol (1H, 19F) + * @return [g, Q] + */ + public float[] getIsotopeData(String isoSym); + +} + + Added: trunk/Jmol/src/org/jmol/quantum/NMRCalculation.java =================================================================== --- trunk/Jmol/src/org/jmol/quantum/NMRCalculation.java (rev 0) +++ trunk/Jmol/src/org/jmol/quantum/NMRCalculation.java 2013-07-04 07:22:02 UTC (rev 18416) @@ -0,0 +1,129 @@ +/* $RCSfile$ + * $Author: hansonr $ + * $Date: 2006-05-13 19:17:06 -0500 (Sat, 13 May 2006) $ + * $Revision: 5114 $ + * + * Copyright (C) 2003-2005 Miguel, Jmol Development, www.jmol.org + * + * Contact: jmol-develop...@lists.sf.net + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.jmol.quantum; + +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.InputStream; +import java.net.URL; +import java.util.Hashtable; +import java.util.Map; + +import org.jmol.api.JmolNMRInterface; +import org.jmol.io.JmolBinary; +import org.jmol.util.Escape; +import org.jmol.util.Logger; +import org.jmol.util.Parser; + + +/* + * + * Bob Hanson hans...@stolaf.edu 7/4/2013 + * + */ + +/* + * NOTE -- THIS CLASS IS INSTANTIATED USING Interface.getOptionInterface + * NOT DIRECTLY -- FOR MODULARIZATION. NEVER USE THE CONSTRUCTOR DIRECTLY! + * + */ + +public class NMRCalculation implements JmolNMRInterface { + + public NMRCalculation() { + getData(); + } + + /** + * isotopeData keyed by nnnSym, for example: 1H, 19F, etc.; + * and also by element name itself: H, F, etc., for default + */ + private Map<String, float[]> isotopeData; + + private final static String resource = "org/jmol/quantum/nmr_data.txt"; + + /** + * Get magnetogyricRatio (gamma/10^7 rad s^-1 T^-1) and quadrupoleMoment (Q/10^-2 fm^2) + * for a given isotope or for the default isotope of an element. + * + * @param isoSym may be an element symbol (H, F) or an isotope_symbol (1H, 19F) + * @return [g, Q] + */ + public float[] getIsotopeData(String isoSym) { + return isotopeData.get(isoSym); + } + + private void getData() { + BufferedReader br = null; + boolean debugging = Logger.debugging; + try { + InputStream is; + URL url = null; + if ((url = this.getClass().getResource("nmr_data.txt")) == null) { + Logger.error("Couldn't find file: " + resource); + return; + } + is = (InputStream) url.getContent(); + br = JmolBinary.getBufferedReader(new BufferedInputStream(is), null); + String line; + // "#extracted by Simone Sturniolo from ROBIN K. HARRIS, EDWIN D. BECKER, SONIA M. CABRAL DE MENEZES, ROBIN GOODFELLOW, AND PIERRE GRANGER, Pure Appl. Chem., Vol. 73, No. 11, pp. 1795–1818, 2001. NMR NOMENCLATURE. NUCLEAR SPIN PROPERTIES AND CONVENTIONS FOR CHEMICAL SHIFTS (IUPAC Recommendations 2001)" + // #element atomNo isotopeDef isotope1 G1 Q1 isotope2 G2 Q2 isotope3 G3 Q3 + // H 1 1 1 26.7522128 0 2 4.10662791 0.00286 3 28.5349779 0 + isotopeData = new Hashtable<String, float[]>(); + while ((line = br.readLine()) != null) { + if (debugging) + Logger.info(line); + if (line.indexOf("#") >= 0) + continue; + String[] tokens = Parser.getTokens(line); + String name = tokens[0]; + String defaultIso = tokens[2] + name; + if (debugging) + Logger.info(name + " default isotope " + defaultIso); + for (int i = 3; i < tokens.length; i += 3) { + String isoname = tokens[i] + name; + float[] dataGQ = new float[] { Float.parseFloat(tokens[i + 1]), + Float.parseFloat(tokens[i + 2]) }; + if (debugging) + Logger.info(isoname + " " + Escape.eAF(dataGQ)); + isotopeData.put(isoname, dataGQ); + } + float[] defdata = isotopeData.get(defaultIso); + if (defdata == null) { + Logger.error("Cannot find default NMR data in nmr_data.txt for " + defaultIso); + throw new NullPointerException(); + } + isotopeData.put(name, defdata); + } + br.close(); + } catch (Exception e) { + Logger.error("Exception " + e.toString() + " reading " + resource); + try { + br.close(); + } catch (Exception ee) { + // ignore + } + } + } +} Added: trunk/Jmol/src/org/jmol/quantum/nmr_data.txt =================================================================== --- trunk/Jmol/src/org/jmol/quantum/nmr_data.txt (rev 0) +++ trunk/Jmol/src/org/jmol/quantum/nmr_data.txt 2013-07-04 07:22:02 UTC (rev 18416) @@ -0,0 +1,83 @@ +#extracted by Simone Sturniolo from ROBIN K. HARRIS, EDWIN D. BECKER, SONIA M. CABRAL DE MENEZES, ROBIN GOODFELLOW, AND PIERRE GRANGER, Pure Appl. Chem., Vol. 73, No. 11, pp. 1795\x961818, 2001. NMR NOMENCLATURE. NUCLEAR SPIN PROPERTIES AND CONVENTIONS FOR CHEMICAL SHIFTS (IUPAC Recommendations 2001) +#element atomNo isotopeDef isotope1 G1 Q1 isotope2 G2 Q2 isotope3 G3 Q3 +H 1 1 1 26.7522128 0 2 4.10662791 0.00286 3 28.5349779 0 +He 2 3 3 -20.3801587 0 +Li 3 7 6 3.9371709 -0.000808 7 10.3977013 -0.0401 +Be 4 9 9 -3.759666 0.05288 +B 5 11 10 2.8746786 0.08459 11 8.5847044 0.04059 +C 6 13 13 6.728284 0 +N 7 14 14 1.9337792 0.02044 15 -2.71261804 0 +O 8 17 17 -3.62808 -0.02558 +F 9 19 19 25.18148 -0.0942 +Ne 10 21 21 -2.11308 0.10155 +Na 11 23 23 7.0808493 0.104 +Mg 12 25 25 -1.63887 0.1994 +Al 13 27 27 6.9762715 0.1466 +Si 14 29 29 -5.319 0 +P 15 31 31 10.8394 0 +S 16 33 33 2.055685 -0.0678 +Cl 17 35 35 2.624198 -0.08165 37 2.184368 -0.06435 +K 19 39 40 -1.5542854 -0.073 41 0.68606808 0.0711 39 1.2500608 0.0585 +Ca 20 43 43 -1.803069 -0.0408 +Sc 21 45 45 6.5087973 -0.22 +Ti 22 49 49 -1.51095 0.247 47 -1.5105 0.302 +V 23 51 50 2.670649 0.21 51 7.0455117 -0.052 +Cr 24 53 53 -1.5152 -0.15 +Mn 25 55 55 6.6452546 0.33 +Fe 26 57 57 0.8680624 0.16 +Co 27 59 59 6.332 0.42 +Ni 28 61 61 -2.3948 0.162 +Cu 29 65 65 7.60435 -0.204 63 7.111789 -0.22 +Zn 30 67 67 1.676688 0.15 +Ga 31 71 69 6.438855 0.171 71 8.181171 0.107 +Ge 32 73 73 -0.9360303 -0.196 +As 33 75 75 4.596163 0.314 +Se 34 77 77 5.1253857 0.76 +Br 35 81 81 7.249776 0.262 79 6.725616 0.313 +Kr 36 83 83 -1.0331 0.259 +Rb 37 87 85 2.592705 0.276 87 8.7864 0.1335 +Sr 38 87 87 -1.1639376 0.305 +Y 39 89 89 -1.3162791 0 +Zr 40 91 91 -2.49743 -0.176 +Nb 41 93 93 6.5674 -0.32 +Mo 42 95 97 -1.788 0.255 95 1.751 -0.022 +Ru 44 99 99 -1.229 0.079 +Tc 43 99 99 6.046 -0.129 +Rh 45 103 103 -0.8468 0 +Pd 46 105 105 -1.23 0.66 +Ag 47 109 107 -1.0889181 0 109 -1.2518634 0 +Cd 48 113 113 -5.9609155 0 111 -5.6983131 0 +In 49 115 113 5.8845 0.759 115 5.8972 0.77 +Sn 50 119 115 -8.8013 0 117 -9.58879 0 119 -10.0317 -0.132 +Sb 51 121 121 6.4435 -0.543 123 3.4892 -0.692 +Te 52 125 123 -7.059098 0 125 -8.5108404 0 +I 53 127 127 5.389573 -0.696 +Xe 54 129 129 -7.452103 0 131 2.209076 -0.114 +Cs 55 133 133 3.5332539 -0.00343 +Ba 56 137 137 2.99295 0.245 135 2.6755 0.16 +La 57 139 138 3.557239 0.45 139 3.8083318 0.2 +Pr 59 141 141 8.1907 -0.0589 +Nd 60 145 145 -0.898 -0.33 143 -1.457 -0.63 +Sm 62 147 147 -1.115 -0.259 149 -0.9192 0.075 +Eu 63 153 153 2.9369 2.412 151 6.651 0.903 +Gd 64 155 155 -0.82132 1.27 157 -1.0769 1.35 +Tb 65 159 159 6.431 1.432 +Dy 66 161 161 -0.9201 2.507 163 1.289 2.648 +Ho 67 165 165 5.71 3.58 +Er 68 167 167 -0.77157 3.565 +Tm 69 169 169 -2.218 -1.2 +Yb 70 171 171 4.7288 0 173 -1.3025 2.8 +Lu 71 176 176 2.1684 4.97 175 3.0552 3.49 +Hf 72 179 177 1.086 3.365 179 -6.82E-08 3.793 +Ta 73 181 181 3.2438 3.17 +W 74 183 183 1.1282403 0 +Re 75 187 185 6.1057 2.18 187 6.1682 2.07 +Os 76 187 187 0.6192895 0 189 2.10713 0.856 +Ir 77 193 193 0.5227 0.751 191 0.4812 0.816 +Pt 78 195 195 5.8385 0 +Au 79 197 197 0.47306 0.547 +Hg 80 199 201 -1.788769 0.387 199 4.8457916 0 +Tl 81 205 203 15.5393338 0 205 15.6921808 0 +Pb 82 207 207 5.58046 0 +Bi 83 209 209 4.375 -0.516 +U 92 235 235 -0.52 4.936 Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2013-07-04 07:21:44 UTC (rev 18415) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2013-07-04 07:22:02 UTC (rev 18416) @@ -49,6 +49,7 @@ import org.jmol.modelset.ModelCollection.StateScript; import org.jmol.adapter.smarter.SmarterJmolAdapter; +import org.jmol.api.JmolNMRInterface; import org.jmol.api.JmolPopupInterface; import org.jmol.api.ApiPlatform; import org.jmol.api.AtomIndexIterator; @@ -10065,6 +10066,9 @@ return modelSet.getBsBranches(dihedralList); } + public Map<Object, Object> chainMap = new Hashtable<Object, Object>(); + public JmolList<String> chainList = new JmolList<String>(); + /** * Create a unique integer for any chain string. * Note that if there are any chains that are more than @@ -10095,17 +10099,14 @@ return (String) chainMap.get(Integer.valueOf(id)); } - public Map<Object, Object> chainMap = new Hashtable<Object, Object>(); - public JmolList<String> chainList = new JmolList<String>(); - public Boolean getScriptQueueInfo() { return (scriptManager != null && scriptManager.isQueueProcessing() ? Boolean.TRUE : Boolean.FALSE); } -// public float[] getQuadricForTensor(Tensor tensor, P3 center) { -// Object[] data = new Object[] { tensor, center, null }; -// shapeManager.loadShape(JC.SHAPE_ELLIPSOIDS); -// shapeManager.getShapePropertyData(JC.SHAPE_ELLIPSOIDS, "quadric", data); -// return (float[]) data[2]; -// } + private JmolNMRInterface nmrCalculation; + + public JmolNMRInterface getNMRCalculation() { + return (nmrCalculation == null ? (nmrCalculation = (JmolNMRInterface) Interface + .getOptionInterface("quantum.NMRCalculation")) : nmrCalculation); + } } 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